babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286
  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. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. 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);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * 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;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets 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. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * 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).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * 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.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * 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.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets 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. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets 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. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * 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.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets 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. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * 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).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets 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. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets 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. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * 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.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets 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. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * 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).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets 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. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets 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. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * 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.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets 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. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * 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).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets 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. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets 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. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * 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.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Define the current target of the camera as an object or a position.
  8662. */
  8663. lockedTarget: any;
  8664. /** @hidden */
  8665. _currentTarget: Vector3;
  8666. /** @hidden */
  8667. _initialFocalDistance: number;
  8668. /** @hidden */
  8669. _viewMatrix: Matrix;
  8670. /** @hidden */
  8671. _camMatrix: Matrix;
  8672. /** @hidden */
  8673. _cameraTransformMatrix: Matrix;
  8674. /** @hidden */
  8675. _cameraRotationMatrix: Matrix;
  8676. /** @hidden */
  8677. _referencePoint: Vector3;
  8678. /** @hidden */
  8679. _transformedReferencePoint: Vector3;
  8680. protected _globalCurrentTarget: Vector3;
  8681. protected _globalCurrentUpVector: Vector3;
  8682. /** @hidden */
  8683. _reset: () => void;
  8684. private _defaultUp;
  8685. /**
  8686. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8687. * This is the base of the follow, arc rotate cameras and Free camera
  8688. * @see http://doc.babylonjs.com/features/cameras
  8689. * @param name Defines the name of the camera in the scene
  8690. * @param position Defines the start position of the camera in the scene
  8691. * @param scene Defines the scene the camera belongs to
  8692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8693. */
  8694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8695. /**
  8696. * Gets the position in front of the camera at a given distance.
  8697. * @param distance The distance from the camera we want the position to be
  8698. * @returns the position
  8699. */
  8700. getFrontPosition(distance: number): Vector3;
  8701. /** @hidden */
  8702. _getLockedTargetPosition(): Nullable<Vector3>;
  8703. private _storedPosition;
  8704. private _storedRotation;
  8705. private _storedRotationQuaternion;
  8706. /**
  8707. * Store current camera state of the camera (fov, position, rotation, etc..)
  8708. * @returns the camera
  8709. */
  8710. storeState(): Camera;
  8711. /**
  8712. * Restored camera state. You must call storeState() first
  8713. * @returns whether it was successful or not
  8714. * @hidden
  8715. */
  8716. _restoreStateValues(): boolean;
  8717. /** @hidden */
  8718. _initCache(): void;
  8719. /** @hidden */
  8720. _updateCache(ignoreParentClass?: boolean): void;
  8721. /** @hidden */
  8722. _isSynchronizedViewMatrix(): boolean;
  8723. /** @hidden */
  8724. _computeLocalCameraSpeed(): number;
  8725. /**
  8726. * Defines the target the camera should look at.
  8727. * @param target Defines the new target as a Vector or a mesh
  8728. */
  8729. setTarget(target: Vector3): void;
  8730. /**
  8731. * Return the current target position of the camera. This value is expressed in local space.
  8732. * @returns the target position
  8733. */
  8734. getTarget(): Vector3;
  8735. /** @hidden */
  8736. _decideIfNeedsToMove(): boolean;
  8737. /** @hidden */
  8738. _updatePosition(): void;
  8739. /** @hidden */
  8740. _checkInputs(): void;
  8741. protected _updateCameraRotationMatrix(): void;
  8742. /**
  8743. * 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)
  8744. * @returns the current camera
  8745. */
  8746. private _rotateUpVectorWithCameraRotationMatrix;
  8747. private _cachedRotationZ;
  8748. private _cachedQuaternionRotationZ;
  8749. /** @hidden */
  8750. _getViewMatrix(): Matrix;
  8751. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8752. /**
  8753. * @hidden
  8754. */
  8755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8756. /**
  8757. * @hidden
  8758. */
  8759. _updateRigCameras(): void;
  8760. private _getRigCamPositionAndTarget;
  8761. /**
  8762. * Gets the current object class name.
  8763. * @return the class name
  8764. */
  8765. getClassName(): string;
  8766. }
  8767. }
  8768. declare module "babylonjs/Events/keyboardEvents" {
  8769. /**
  8770. * Gather the list of keyboard event types as constants.
  8771. */
  8772. export class KeyboardEventTypes {
  8773. /**
  8774. * The keydown event is fired when a key becomes active (pressed).
  8775. */
  8776. static readonly KEYDOWN: number;
  8777. /**
  8778. * The keyup event is fired when a key has been released.
  8779. */
  8780. static readonly KEYUP: number;
  8781. }
  8782. /**
  8783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8784. */
  8785. export class KeyboardInfo {
  8786. /**
  8787. * Defines the type of event (KeyboardEventTypes)
  8788. */
  8789. type: number;
  8790. /**
  8791. * Defines the related dom event
  8792. */
  8793. event: KeyboardEvent;
  8794. /**
  8795. * Instantiates a new keyboard info.
  8796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8797. * @param type Defines the type of event (KeyboardEventTypes)
  8798. * @param event Defines the related dom event
  8799. */
  8800. constructor(
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number,
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent);
  8809. }
  8810. /**
  8811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8813. */
  8814. export class KeyboardInfoPre extends KeyboardInfo {
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number;
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent;
  8823. /**
  8824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8825. */
  8826. skipOnPointerObservable: boolean;
  8827. /**
  8828. * Instantiates a new keyboard pre info.
  8829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8830. * @param type Defines the type of event (KeyboardEventTypes)
  8831. * @param event Defines the related dom event
  8832. */
  8833. constructor(
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number,
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent);
  8842. }
  8843. }
  8844. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8845. import { Nullable } from "babylonjs/types";
  8846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8848. /**
  8849. * Manage the keyboard inputs to control the movement of a free camera.
  8850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8851. */
  8852. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8853. /**
  8854. * Defines the camera the input is attached to.
  8855. */
  8856. camera: FreeCamera;
  8857. /**
  8858. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8859. */
  8860. keysUp: number[];
  8861. /**
  8862. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8863. */
  8864. keysDown: number[];
  8865. /**
  8866. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8867. */
  8868. keysLeft: number[];
  8869. /**
  8870. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8871. */
  8872. keysRight: number[];
  8873. private _keys;
  8874. private _onCanvasBlurObserver;
  8875. private _onKeyboardObserver;
  8876. private _engine;
  8877. private _scene;
  8878. /**
  8879. * Attach the input controls to a specific dom element to get the input from.
  8880. * @param element Defines the element the controls should be listened from
  8881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8882. */
  8883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8884. /**
  8885. * Detach the current controls from the specified dom element.
  8886. * @param element Defines the element to stop listening the inputs from
  8887. */
  8888. detachControl(element: Nullable<HTMLElement>): void;
  8889. /**
  8890. * Update the current camera state depending on the inputs that have been used this frame.
  8891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8892. */
  8893. checkInputs(): void;
  8894. /**
  8895. * Gets the class name of the current intput.
  8896. * @returns the class name
  8897. */
  8898. getClassName(): string;
  8899. /** @hidden */
  8900. _onLostFocus(): void;
  8901. /**
  8902. * Get the friendly name associated with the input class.
  8903. * @returns the input friendly name
  8904. */
  8905. getSimpleName(): string;
  8906. }
  8907. }
  8908. declare module "babylonjs/Lights/shadowLight" {
  8909. import { Camera } from "babylonjs/Cameras/camera";
  8910. import { Scene } from "babylonjs/scene";
  8911. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8913. import { Light } from "babylonjs/Lights/light";
  8914. /**
  8915. * Interface describing all the common properties and methods a shadow light needs to implement.
  8916. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8917. * as well as binding the different shadow properties to the effects.
  8918. */
  8919. export interface IShadowLight extends Light {
  8920. /**
  8921. * The light id in the scene (used in scene.findLighById for instance)
  8922. */
  8923. id: string;
  8924. /**
  8925. * The position the shdow will be casted from.
  8926. */
  8927. position: Vector3;
  8928. /**
  8929. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8930. */
  8931. direction: Vector3;
  8932. /**
  8933. * The transformed position. Position of the light in world space taking parenting in account.
  8934. */
  8935. transformedPosition: Vector3;
  8936. /**
  8937. * The transformed direction. Direction of the light in world space taking parenting in account.
  8938. */
  8939. transformedDirection: Vector3;
  8940. /**
  8941. * The friendly name of the light in the scene.
  8942. */
  8943. name: string;
  8944. /**
  8945. * Defines the shadow projection clipping minimum z value.
  8946. */
  8947. shadowMinZ: number;
  8948. /**
  8949. * Defines the shadow projection clipping maximum z value.
  8950. */
  8951. shadowMaxZ: number;
  8952. /**
  8953. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8954. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8955. */
  8956. computeTransformedInformation(): boolean;
  8957. /**
  8958. * Gets the scene the light belongs to.
  8959. * @returns The scene
  8960. */
  8961. getScene(): Scene;
  8962. /**
  8963. * Callback defining a custom Projection Matrix Builder.
  8964. * This can be used to override the default projection matrix computation.
  8965. */
  8966. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8967. /**
  8968. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8969. * @param matrix The materix to updated with the projection information
  8970. * @param viewMatrix The transform matrix of the light
  8971. * @param renderList The list of mesh to render in the map
  8972. * @returns The current light
  8973. */
  8974. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8975. /**
  8976. * Gets the current depth scale used in ESM.
  8977. * @returns The scale
  8978. */
  8979. getDepthScale(): number;
  8980. /**
  8981. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8982. * @returns true if a cube texture needs to be use
  8983. */
  8984. needCube(): boolean;
  8985. /**
  8986. * Detects if the projection matrix requires to be recomputed this frame.
  8987. * @returns true if it requires to be recomputed otherwise, false.
  8988. */
  8989. needProjectionMatrixCompute(): boolean;
  8990. /**
  8991. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8992. */
  8993. forceProjectionMatrixCompute(): void;
  8994. /**
  8995. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8996. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8997. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8998. */
  8999. getShadowDirection(faceIndex?: number): Vector3;
  9000. /**
  9001. * Gets the minZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the min for
  9003. * @returns the depth min z
  9004. */
  9005. getDepthMinZ(activeCamera: Camera): number;
  9006. /**
  9007. * Gets the maxZ used for shadow according to both the scene and the light.
  9008. * @param activeCamera The camera we are returning the max for
  9009. * @returns the depth max z
  9010. */
  9011. getDepthMaxZ(activeCamera: Camera): number;
  9012. }
  9013. /**
  9014. * Base implementation IShadowLight
  9015. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9016. */
  9017. export abstract class ShadowLight extends Light implements IShadowLight {
  9018. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9019. protected _position: Vector3;
  9020. protected _setPosition(value: Vector3): void;
  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. get position(): Vector3;
  9026. /**
  9027. * Sets the position the shadow will be casted from. Also use as the light position for both
  9028. * point and spot lights.
  9029. */
  9030. set position(value: Vector3);
  9031. protected _direction: Vector3;
  9032. protected _setDirection(value: Vector3): void;
  9033. /**
  9034. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9035. * Also use as the light direction on spot and directional lights.
  9036. */
  9037. get direction(): Vector3;
  9038. /**
  9039. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9040. * Also use as the light direction on spot and directional lights.
  9041. */
  9042. set direction(value: Vector3);
  9043. protected _shadowMinZ: number;
  9044. /**
  9045. * Gets the shadow projection clipping minimum z value.
  9046. */
  9047. get shadowMinZ(): number;
  9048. /**
  9049. * Sets the shadow projection clipping minimum z value.
  9050. */
  9051. set shadowMinZ(value: number);
  9052. protected _shadowMaxZ: number;
  9053. /**
  9054. * Sets the shadow projection clipping maximum z value.
  9055. */
  9056. get shadowMaxZ(): number;
  9057. /**
  9058. * Gets the shadow projection clipping maximum z value.
  9059. */
  9060. set shadowMaxZ(value: number);
  9061. /**
  9062. * Callback defining a custom Projection Matrix Builder.
  9063. * This can be used to override the default projection matrix computation.
  9064. */
  9065. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9066. /**
  9067. * The transformed position. Position of the light in world space taking parenting in account.
  9068. */
  9069. transformedPosition: Vector3;
  9070. /**
  9071. * The transformed direction. Direction of the light in world space taking parenting in account.
  9072. */
  9073. transformedDirection: Vector3;
  9074. private _needProjectionMatrixCompute;
  9075. /**
  9076. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9077. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9078. */
  9079. computeTransformedInformation(): boolean;
  9080. /**
  9081. * Return the depth scale used for the shadow map.
  9082. * @returns the depth scale.
  9083. */
  9084. getDepthScale(): number;
  9085. /**
  9086. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9087. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9088. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9089. */
  9090. getShadowDirection(faceIndex?: number): Vector3;
  9091. /**
  9092. * Returns the ShadowLight absolute position in the World.
  9093. * @returns the position vector in world space
  9094. */
  9095. getAbsolutePosition(): Vector3;
  9096. /**
  9097. * Sets the ShadowLight direction toward the passed target.
  9098. * @param target The point to target in local space
  9099. * @returns the updated ShadowLight direction
  9100. */
  9101. setDirectionToTarget(target: Vector3): Vector3;
  9102. /**
  9103. * Returns the light rotation in euler definition.
  9104. * @returns the x y z rotation in local space.
  9105. */
  9106. getRotation(): Vector3;
  9107. /**
  9108. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9109. * @returns true if a cube texture needs to be use
  9110. */
  9111. needCube(): boolean;
  9112. /**
  9113. * Detects if the projection matrix requires to be recomputed this frame.
  9114. * @returns true if it requires to be recomputed otherwise, false.
  9115. */
  9116. needProjectionMatrixCompute(): boolean;
  9117. /**
  9118. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9119. */
  9120. forceProjectionMatrixCompute(): void;
  9121. /** @hidden */
  9122. _initCache(): void;
  9123. /** @hidden */
  9124. _isSynchronized(): boolean;
  9125. /**
  9126. * Computes the world matrix of the node
  9127. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9128. * @returns the world matrix
  9129. */
  9130. computeWorldMatrix(force?: boolean): Matrix;
  9131. /**
  9132. * Gets the minZ used for shadow according to both the scene and the light.
  9133. * @param activeCamera The camera we are returning the min for
  9134. * @returns the depth min z
  9135. */
  9136. getDepthMinZ(activeCamera: Camera): number;
  9137. /**
  9138. * Gets the maxZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the max for
  9140. * @returns the depth max z
  9141. */
  9142. getDepthMaxZ(activeCamera: Camera): number;
  9143. /**
  9144. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9145. * @param matrix The materix to updated with the projection information
  9146. * @param viewMatrix The transform matrix of the light
  9147. * @param renderList The list of mesh to render in the map
  9148. * @returns The current light
  9149. */
  9150. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9151. }
  9152. }
  9153. declare module "babylonjs/Materials/effectFallbacks" {
  9154. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9155. import { Effect } from "babylonjs/Materials/effect";
  9156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9157. /**
  9158. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9159. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9160. */
  9161. export class EffectFallbacks implements IEffectFallbacks {
  9162. private _defines;
  9163. private _currentRank;
  9164. private _maxRank;
  9165. private _mesh;
  9166. /**
  9167. * Removes the fallback from the bound mesh.
  9168. */
  9169. unBindMesh(): void;
  9170. /**
  9171. * Adds a fallback on the specified property.
  9172. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9173. * @param define The name of the define in the shader
  9174. */
  9175. addFallback(rank: number, define: string): void;
  9176. /**
  9177. * Sets the mesh to use CPU skinning when needing to fallback.
  9178. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9179. * @param mesh The mesh to use the fallbacks.
  9180. */
  9181. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9182. /**
  9183. * Checks to see if more fallbacks are still availible.
  9184. */
  9185. get hasMoreFallbacks(): boolean;
  9186. /**
  9187. * Removes the defines that should be removed when falling back.
  9188. * @param currentDefines defines the current define statements for the shader.
  9189. * @param effect defines the current effect we try to compile
  9190. * @returns The resulting defines with defines of the current rank removed.
  9191. */
  9192. reduce(currentDefines: string, effect: Effect): string;
  9193. }
  9194. }
  9195. declare module "babylonjs/Materials/materialHelper" {
  9196. import { Nullable } from "babylonjs/types";
  9197. import { Scene } from "babylonjs/scene";
  9198. import { Engine } from "babylonjs/Engines/engine";
  9199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9200. import { Light } from "babylonjs/Lights/light";
  9201. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9202. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9204. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9205. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9206. /**
  9207. * "Static Class" containing the most commonly used helper while dealing with material for
  9208. * rendering purpose.
  9209. *
  9210. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9211. *
  9212. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9213. */
  9214. export class MaterialHelper {
  9215. /**
  9216. * Bind the current view position to an effect.
  9217. * @param effect The effect to be bound
  9218. * @param scene The scene the eyes position is used from
  9219. */
  9220. static BindEyePosition(effect: Effect, scene: Scene): void;
  9221. /**
  9222. * Helps preparing the defines values about the UVs in used in the effect.
  9223. * UVs are shared as much as we can accross channels in the shaders.
  9224. * @param texture The texture we are preparing the UVs for
  9225. * @param defines The defines to update
  9226. * @param key The channel key "diffuse", "specular"... used in the shader
  9227. */
  9228. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9229. /**
  9230. * Binds a texture matrix value to its corrsponding uniform
  9231. * @param texture The texture to bind the matrix for
  9232. * @param uniformBuffer The uniform buffer receivin the data
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9236. /**
  9237. * Gets the current status of the fog (should it be enabled?)
  9238. * @param mesh defines the mesh to evaluate for fog support
  9239. * @param scene defines the hosting scene
  9240. * @returns true if fog must be enabled
  9241. */
  9242. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9243. /**
  9244. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9245. * @param mesh defines the current mesh
  9246. * @param scene defines the current scene
  9247. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9248. * @param pointsCloud defines if point cloud rendering has to be turned on
  9249. * @param fogEnabled defines if fog has to be turned on
  9250. * @param alphaTest defines if alpha testing has to be turned on
  9251. * @param defines defines the current list of defines
  9252. */
  9253. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9256. * @param scene defines the current scene
  9257. * @param engine defines the current engine
  9258. * @param defines specifies the list of active defines
  9259. * @param useInstances defines if instances have to be turned on
  9260. * @param useClipPlane defines if clip plane have to be turned on
  9261. */
  9262. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9263. /**
  9264. * Prepares the defines for bones
  9265. * @param mesh The mesh containing the geometry data we will draw
  9266. * @param defines The defines to update
  9267. */
  9268. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9269. /**
  9270. * Prepares the defines for morph targets
  9271. * @param mesh The mesh containing the geometry data we will draw
  9272. * @param defines The defines to update
  9273. */
  9274. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9275. /**
  9276. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9277. * @param mesh The mesh containing the geometry data we will draw
  9278. * @param defines The defines to update
  9279. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9280. * @param useBones Precise whether bones should be used or not (override mesh info)
  9281. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9282. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9283. * @returns false if defines are considered not dirty and have not been checked
  9284. */
  9285. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9286. /**
  9287. * Prepares the defines related to multiview
  9288. * @param scene The scene we are intending to draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9292. /**
  9293. * Prepares the defines related to the light information passed in parameter
  9294. * @param scene The scene we are intending to draw
  9295. * @param mesh The mesh the effect is compiling for
  9296. * @param light The light the effect is compiling for
  9297. * @param lightIndex The index of the light
  9298. * @param defines The defines to update
  9299. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9300. * @param state Defines the current state regarding what is needed (normals, etc...)
  9301. */
  9302. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9303. needNormals: boolean;
  9304. needRebuild: boolean;
  9305. shadowEnabled: boolean;
  9306. specularEnabled: boolean;
  9307. lightmapMode: boolean;
  9308. }): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param defines The defines to update
  9314. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9315. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9316. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9317. * @returns true if normals will be required for the rest of the effect
  9318. */
  9319. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9320. /**
  9321. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9322. * @param lightIndex defines the light index
  9323. * @param uniformsList The uniform list
  9324. * @param samplersList The sampler list
  9325. * @param projectedLightTexture defines if projected texture must be used
  9326. * @param uniformBuffersList defines an optional list of uniform buffers
  9327. */
  9328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect
  9331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9332. * @param samplersList The sampler list
  9333. * @param defines The defines helping in the list generation
  9334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9335. */
  9336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9337. /**
  9338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9339. * @param defines The defines to update while falling back
  9340. * @param fallbacks The authorized effect fallbacks
  9341. * @param maxSimultaneousLights The maximum number of lights allowed
  9342. * @param rank the current rank of the Effect
  9343. * @returns The newly affected rank
  9344. */
  9345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9346. private static _TmpMorphInfluencers;
  9347. /**
  9348. * Prepares the list of attributes required for morph targets according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the morph targets attributes for
  9351. * @param influencers The number of influencers
  9352. */
  9353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param defines The current Defines of the effect
  9359. */
  9360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9361. /**
  9362. * Prepares the list of attributes required for bones according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the bones attributes for
  9365. * @param defines The current Defines of the effect
  9366. * @param fallbacks The current efffect fallback strategy
  9367. */
  9368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9369. /**
  9370. * Check and prepare the list of attributes required for instances according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param defines The current MaterialDefines of the effect
  9373. */
  9374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9375. /**
  9376. * Add the list of attributes required for instances to the attribs array.
  9377. * @param attribs The current list of supported attribs
  9378. */
  9379. static PushAttributesForInstances(attribs: string[]): void;
  9380. /**
  9381. * Binds the light information to the effect.
  9382. * @param light The light containing the generator
  9383. * @param effect The effect we are binding the data to
  9384. * @param lightIndex The light index in the effect used to render
  9385. */
  9386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9387. /**
  9388. * Binds the lights information from the scene to the effect for the given mesh.
  9389. * @param light Light to bind
  9390. * @param lightIndex Light index
  9391. * @param scene The scene where the light belongs to
  9392. * @param effect The effect we are binding the data to
  9393. * @param useSpecular Defines if specular is supported
  9394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9395. */
  9396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9397. /**
  9398. * Binds the lights information from the scene to the effect for the given mesh.
  9399. * @param scene The scene the lights belongs to
  9400. * @param mesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. * @param defines The generated defines for the effect
  9403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9405. */
  9406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9407. private static _tempFogColor;
  9408. /**
  9409. * Binds the fog information from the scene to the effect for the given mesh.
  9410. * @param scene The scene the lights belongs to
  9411. * @param mesh The mesh we are binding the information to render
  9412. * @param effect The effect we are binding the data to
  9413. * @param linearSpace Defines if the fog effect is applied in linear space
  9414. */
  9415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9416. /**
  9417. * Binds the bones information from the mesh to the effect.
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. */
  9421. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9422. /**
  9423. * Binds the morph targets information from the mesh to the effect.
  9424. * @param abstractMesh The mesh we are binding the information to render
  9425. * @param effect The effect we are binding the data to
  9426. */
  9427. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9428. /**
  9429. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9430. * @param defines The generated defines used in the effect
  9431. * @param effect The effect we are binding the data to
  9432. * @param scene The scene we are willing to render with logarithmic scale for
  9433. */
  9434. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9435. /**
  9436. * Binds the clip plane information from the scene to the effect.
  9437. * @param scene The scene the clip plane information are extracted from
  9438. * @param effect The effect we are binding the data to
  9439. */
  9440. static BindClipPlane(effect: Effect, scene: Scene): void;
  9441. }
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9444. /** @hidden */
  9445. export var packingFunctions: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9451. /** @hidden */
  9452. export var clipPlaneFragmentDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9458. /** @hidden */
  9459. export var clipPlaneFragment: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9468. /** @hidden */
  9469. export var shadowMapPixelShader: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9475. /** @hidden */
  9476. export var bonesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9482. /** @hidden */
  9483. export var morphTargetsVertexGlobalDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9496. /** @hidden */
  9497. export var instancesDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9503. /** @hidden */
  9504. export var helperFunctions: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9510. /** @hidden */
  9511. export var clipPlaneVertexDeclaration: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9517. /** @hidden */
  9518. export var morphTargetsVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9524. /** @hidden */
  9525. export var instancesVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9531. /** @hidden */
  9532. export var bonesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9555. /** @hidden */
  9556. export var shadowMapVertexShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9562. /** @hidden */
  9563. export var depthBoxBlurPixelShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Culling/ray" {
  9569. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9573. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9574. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9575. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9576. import { Plane } from "babylonjs/Maths/math.plane";
  9577. /**
  9578. * Class representing a ray with position and direction
  9579. */
  9580. export class Ray {
  9581. /** origin point */
  9582. origin: Vector3;
  9583. /** direction */
  9584. direction: Vector3;
  9585. /** length of the ray */
  9586. length: number;
  9587. private static readonly TmpVector3;
  9588. private _tmpRay;
  9589. /**
  9590. * Creates a new ray
  9591. * @param origin origin point
  9592. * @param direction direction
  9593. * @param length length of the ray
  9594. */
  9595. constructor(
  9596. /** origin point */
  9597. origin: Vector3,
  9598. /** direction */
  9599. direction: Vector3,
  9600. /** length of the ray */
  9601. length?: number);
  9602. /**
  9603. * Checks if the ray intersects a box
  9604. * @param minimum bound of the box
  9605. * @param maximum bound of the box
  9606. * @param intersectionTreshold extra extend to be added to the box in all direction
  9607. * @returns if the box was hit
  9608. */
  9609. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * Checks if the ray intersects a box
  9612. * @param box the bounding box to check
  9613. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9614. * @returns if the box was hit
  9615. */
  9616. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9617. /**
  9618. * If the ray hits a sphere
  9619. * @param sphere the bounding sphere to check
  9620. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9621. * @returns true if it hits the sphere
  9622. */
  9623. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9624. /**
  9625. * If the ray hits a triange
  9626. * @param vertex0 triangle vertex
  9627. * @param vertex1 triangle vertex
  9628. * @param vertex2 triangle vertex
  9629. * @returns intersection information if hit
  9630. */
  9631. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9632. /**
  9633. * Checks if ray intersects a plane
  9634. * @param plane the plane to check
  9635. * @returns the distance away it was hit
  9636. */
  9637. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9638. /**
  9639. * Calculate the intercept of a ray on a given axis
  9640. * @param axis to check 'x' | 'y' | 'z'
  9641. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9642. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9643. */
  9644. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9645. /**
  9646. * Checks if ray intersects a mesh
  9647. * @param mesh the mesh to check
  9648. * @param fastCheck if only the bounding box should checked
  9649. * @returns picking info of the intersecton
  9650. */
  9651. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9652. /**
  9653. * Checks if ray intersects a mesh
  9654. * @param meshes the meshes to check
  9655. * @param fastCheck if only the bounding box should checked
  9656. * @param results array to store result in
  9657. * @returns Array of picking infos
  9658. */
  9659. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9660. private _comparePickingInfo;
  9661. private static smallnum;
  9662. private static rayl;
  9663. /**
  9664. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9665. * @param sega the first point of the segment to test the intersection against
  9666. * @param segb the second point of the segment to test the intersection against
  9667. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9668. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9669. */
  9670. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9671. /**
  9672. * Update the ray from viewport position
  9673. * @param x position
  9674. * @param y y position
  9675. * @param viewportWidth viewport width
  9676. * @param viewportHeight viewport height
  9677. * @param world world matrix
  9678. * @param view view matrix
  9679. * @param projection projection matrix
  9680. * @returns this ray updated
  9681. */
  9682. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9683. /**
  9684. * Creates a ray with origin and direction of 0,0,0
  9685. * @returns the new ray
  9686. */
  9687. static Zero(): Ray;
  9688. /**
  9689. * Creates a new ray from screen space and viewport
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns new ray
  9698. */
  9699. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * 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
  9702. * transformed to the given world matrix.
  9703. * @param origin The origin point
  9704. * @param end The end point
  9705. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9706. * @returns the new ray
  9707. */
  9708. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * Transforms a ray by a matrix
  9711. * @param ray ray to transform
  9712. * @param matrix matrix to apply
  9713. * @returns the resulting new ray
  9714. */
  9715. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9716. /**
  9717. * Transforms a ray by a matrix
  9718. * @param ray ray to transform
  9719. * @param matrix matrix to apply
  9720. * @param result ray to store result in
  9721. */
  9722. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9723. /**
  9724. * Unproject a ray from screen space to object space
  9725. * @param sourceX defines the screen space x coordinate to use
  9726. * @param sourceY defines the screen space y coordinate to use
  9727. * @param viewportWidth defines the current width of the viewport
  9728. * @param viewportHeight defines the current height of the viewport
  9729. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9730. * @param view defines the view matrix to use
  9731. * @param projection defines the projection matrix to use
  9732. */
  9733. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9734. }
  9735. /**
  9736. * Type used to define predicate used to select faces when a mesh intersection is detected
  9737. */
  9738. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9739. module "babylonjs/scene" {
  9740. interface Scene {
  9741. /** @hidden */
  9742. _tempPickingRay: Nullable<Ray>;
  9743. /** @hidden */
  9744. _cachedRayForTransform: Ray;
  9745. /** @hidden */
  9746. _pickWithRayInverseMatrix: Matrix;
  9747. /** @hidden */
  9748. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9749. /** @hidden */
  9750. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9751. }
  9752. }
  9753. }
  9754. declare module "babylonjs/sceneComponent" {
  9755. import { Scene } from "babylonjs/scene";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9758. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9759. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9760. import { Nullable } from "babylonjs/types";
  9761. import { Camera } from "babylonjs/Cameras/camera";
  9762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9763. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9764. import { AbstractScene } from "babylonjs/abstractScene";
  9765. import { Mesh } from "babylonjs/Meshes/mesh";
  9766. /**
  9767. * Groups all the scene component constants in one place to ease maintenance.
  9768. * @hidden
  9769. */
  9770. export class SceneComponentConstants {
  9771. static readonly NAME_EFFECTLAYER: string;
  9772. static readonly NAME_LAYER: string;
  9773. static readonly NAME_LENSFLARESYSTEM: string;
  9774. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9775. static readonly NAME_PARTICLESYSTEM: string;
  9776. static readonly NAME_GAMEPAD: string;
  9777. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9778. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9779. static readonly NAME_DEPTHRENDERER: string;
  9780. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9781. static readonly NAME_SPRITE: string;
  9782. static readonly NAME_OUTLINERENDERER: string;
  9783. static readonly NAME_PROCEDURALTEXTURE: string;
  9784. static readonly NAME_SHADOWGENERATOR: string;
  9785. static readonly NAME_OCTREE: string;
  9786. static readonly NAME_PHYSICSENGINE: string;
  9787. static readonly NAME_AUDIO: string;
  9788. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9789. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9790. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9791. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9792. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9793. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9794. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9795. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9796. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9797. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9798. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9799. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9801. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9802. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9803. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9805. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9807. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9808. static readonly STEP_AFTERRENDER_AUDIO: number;
  9809. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9810. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9811. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9812. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9813. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9814. static readonly STEP_POINTERMOVE_SPRITE: number;
  9815. static readonly STEP_POINTERDOWN_SPRITE: number;
  9816. static readonly STEP_POINTERUP_SPRITE: number;
  9817. }
  9818. /**
  9819. * This represents a scene component.
  9820. *
  9821. * This is used to decouple the dependency the scene is having on the different workloads like
  9822. * layers, post processes...
  9823. */
  9824. export interface ISceneComponent {
  9825. /**
  9826. * The name of the component. Each component must have a unique name.
  9827. */
  9828. name: string;
  9829. /**
  9830. * The scene the component belongs to.
  9831. */
  9832. scene: Scene;
  9833. /**
  9834. * Register the component to one instance of a scene.
  9835. */
  9836. register(): void;
  9837. /**
  9838. * Rebuilds the elements related to this component in case of
  9839. * context lost for instance.
  9840. */
  9841. rebuild(): void;
  9842. /**
  9843. * Disposes the component and the associated ressources.
  9844. */
  9845. dispose(): void;
  9846. }
  9847. /**
  9848. * This represents a SERIALIZABLE scene component.
  9849. *
  9850. * This extends Scene Component to add Serialization methods on top.
  9851. */
  9852. export interface ISceneSerializableComponent extends ISceneComponent {
  9853. /**
  9854. * Adds all the elements from the container to the scene
  9855. * @param container the container holding the elements
  9856. */
  9857. addFromContainer(container: AbstractScene): void;
  9858. /**
  9859. * Removes all the elements in the container from the scene
  9860. * @param container contains the elements to remove
  9861. * @param dispose if the removed element should be disposed (default: false)
  9862. */
  9863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9864. /**
  9865. * Serializes the component data to the specified json object
  9866. * @param serializationObject The object to serialize to
  9867. */
  9868. serialize(serializationObject: any): void;
  9869. }
  9870. /**
  9871. * Strong typing of a Mesh related stage step action
  9872. */
  9873. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9874. /**
  9875. * Strong typing of a Evaluate Sub Mesh related stage step action
  9876. */
  9877. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9878. /**
  9879. * Strong typing of a Active Mesh related stage step action
  9880. */
  9881. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9882. /**
  9883. * Strong typing of a Camera related stage step action
  9884. */
  9885. export type CameraStageAction = (camera: Camera) => void;
  9886. /**
  9887. * Strong typing of a Camera Frame buffer related stage step action
  9888. */
  9889. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9890. /**
  9891. * Strong typing of a Render Target related stage step action
  9892. */
  9893. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9894. /**
  9895. * Strong typing of a RenderingGroup related stage step action
  9896. */
  9897. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9898. /**
  9899. * Strong typing of a Mesh Render related stage step action
  9900. */
  9901. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9902. /**
  9903. * Strong typing of a simple stage step action
  9904. */
  9905. export type SimpleStageAction = () => void;
  9906. /**
  9907. * Strong typing of a render target action.
  9908. */
  9909. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9910. /**
  9911. * Strong typing of a pointer move action.
  9912. */
  9913. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9914. /**
  9915. * Strong typing of a pointer up/down action.
  9916. */
  9917. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9918. /**
  9919. * Representation of a stage in the scene (Basically a list of ordered steps)
  9920. * @hidden
  9921. */
  9922. export class Stage<T extends Function> extends Array<{
  9923. index: number;
  9924. component: ISceneComponent;
  9925. action: T;
  9926. }> {
  9927. /**
  9928. * Hide ctor from the rest of the world.
  9929. * @param items The items to add.
  9930. */
  9931. private constructor();
  9932. /**
  9933. * Creates a new Stage.
  9934. * @returns A new instance of a Stage
  9935. */
  9936. static Create<T extends Function>(): Stage<T>;
  9937. /**
  9938. * Registers a step in an ordered way in the targeted stage.
  9939. * @param index Defines the position to register the step in
  9940. * @param component Defines the component attached to the step
  9941. * @param action Defines the action to launch during the step
  9942. */
  9943. registerStep(index: number, component: ISceneComponent, action: T): void;
  9944. /**
  9945. * Clears all the steps from the stage.
  9946. */
  9947. clear(): void;
  9948. }
  9949. }
  9950. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9951. import { Nullable } from "babylonjs/types";
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Scene } from "babylonjs/scene";
  9954. import { Sprite } from "babylonjs/Sprites/sprite";
  9955. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9956. import { Ray } from "babylonjs/Culling/ray";
  9957. import { Camera } from "babylonjs/Cameras/camera";
  9958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9959. import { ISceneComponent } from "babylonjs/sceneComponent";
  9960. module "babylonjs/scene" {
  9961. interface Scene {
  9962. /** @hidden */
  9963. _pointerOverSprite: Nullable<Sprite>;
  9964. /** @hidden */
  9965. _pickedDownSprite: Nullable<Sprite>;
  9966. /** @hidden */
  9967. _tempSpritePickingRay: Nullable<Ray>;
  9968. /**
  9969. * All of the sprite managers added to this scene
  9970. * @see http://doc.babylonjs.com/babylon101/sprites
  9971. */
  9972. spriteManagers: Array<ISpriteManager>;
  9973. /**
  9974. * An event triggered when sprites rendering is about to start
  9975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9976. */
  9977. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9978. /**
  9979. * An event triggered when sprites rendering is done
  9980. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9981. */
  9982. onAfterSpritesRenderingObservable: Observable<Scene>;
  9983. /** @hidden */
  9984. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9985. /** Launch a ray to try to pick a sprite in the scene
  9986. * @param x position on screen
  9987. * @param y position on screen
  9988. * @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
  9989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9991. * @returns a PickingInfo
  9992. */
  9993. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Use the given ray to pick a sprite in the scene
  9995. * @param ray The ray (in world space) to use to pick meshes
  9996. * @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
  9997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9998. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9999. * @returns a PickingInfo
  10000. */
  10001. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** @hidden */
  10003. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10004. /** Launch a ray to try to pick sprites in the scene
  10005. * @param x position on screen
  10006. * @param y position on screen
  10007. * @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
  10008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10009. * @returns a PickingInfo array
  10010. */
  10011. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10012. /** Use the given ray to pick sprites in the scene
  10013. * @param ray The ray (in world space) to use to pick meshes
  10014. * @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
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo array
  10017. */
  10018. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10019. /**
  10020. * Force the sprite under the pointer
  10021. * @param sprite defines the sprite to use
  10022. */
  10023. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10024. /**
  10025. * Gets the sprite under the pointer
  10026. * @returns a Sprite or null if no sprite is under the pointer
  10027. */
  10028. getPointerOverSprite(): Nullable<Sprite>;
  10029. }
  10030. }
  10031. /**
  10032. * Defines the sprite scene component responsible to manage sprites
  10033. * in a given scene.
  10034. */
  10035. export class SpriteSceneComponent implements ISceneComponent {
  10036. /**
  10037. * The component name helpfull to identify the component in the list of scene components.
  10038. */
  10039. readonly name: string;
  10040. /**
  10041. * The scene the component belongs to.
  10042. */
  10043. scene: Scene;
  10044. /** @hidden */
  10045. private _spritePredicate;
  10046. /**
  10047. * Creates a new instance of the component for the given scene
  10048. * @param scene Defines the scene to register the component in
  10049. */
  10050. constructor(scene: Scene);
  10051. /**
  10052. * Registers the component in a given scene
  10053. */
  10054. register(): void;
  10055. /**
  10056. * Rebuilds the elements related to this component in case of
  10057. * context lost for instance.
  10058. */
  10059. rebuild(): void;
  10060. /**
  10061. * Disposes the component and the associated ressources.
  10062. */
  10063. dispose(): void;
  10064. private _pickSpriteButKeepRay;
  10065. private _pointerMove;
  10066. private _pointerDown;
  10067. private _pointerUp;
  10068. }
  10069. }
  10070. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10071. /** @hidden */
  10072. export var fogFragmentDeclaration: {
  10073. name: string;
  10074. shader: string;
  10075. };
  10076. }
  10077. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10078. /** @hidden */
  10079. export var fogFragment: {
  10080. name: string;
  10081. shader: string;
  10082. };
  10083. }
  10084. declare module "babylonjs/Shaders/sprites.fragment" {
  10085. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10086. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10087. /** @hidden */
  10088. export var spritesPixelShader: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10094. /** @hidden */
  10095. export var fogVertexDeclaration: {
  10096. name: string;
  10097. shader: string;
  10098. };
  10099. }
  10100. declare module "babylonjs/Shaders/sprites.vertex" {
  10101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10102. /** @hidden */
  10103. export var spritesVertexShader: {
  10104. name: string;
  10105. shader: string;
  10106. };
  10107. }
  10108. declare module "babylonjs/Sprites/spriteManager" {
  10109. import { IDisposable, Scene } from "babylonjs/scene";
  10110. import { Nullable } from "babylonjs/types";
  10111. import { Observable } from "babylonjs/Misc/observable";
  10112. import { Sprite } from "babylonjs/Sprites/sprite";
  10113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10114. import { Camera } from "babylonjs/Cameras/camera";
  10115. import { Texture } from "babylonjs/Materials/Textures/texture";
  10116. import "babylonjs/Shaders/sprites.fragment";
  10117. import "babylonjs/Shaders/sprites.vertex";
  10118. import { Ray } from "babylonjs/Culling/ray";
  10119. /**
  10120. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10121. */
  10122. export interface ISpriteManager extends IDisposable {
  10123. /**
  10124. * Restricts the camera to viewing objects with the same layerMask.
  10125. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10126. */
  10127. layerMask: number;
  10128. /**
  10129. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10130. */
  10131. isPickable: boolean;
  10132. /**
  10133. * Specifies the rendering group id for this mesh (0 by default)
  10134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10135. */
  10136. renderingGroupId: number;
  10137. /**
  10138. * Defines the list of sprites managed by the manager.
  10139. */
  10140. sprites: Array<Sprite>;
  10141. /**
  10142. * Tests the intersection of a sprite with a specific ray.
  10143. * @param ray The ray we are sending to test the collision
  10144. * @param camera The camera space we are sending rays in
  10145. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10146. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10147. * @returns picking info or null.
  10148. */
  10149. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10150. /**
  10151. * Intersects the sprites with a ray
  10152. * @param ray defines the ray to intersect with
  10153. * @param camera defines the current active camera
  10154. * @param predicate defines a predicate used to select candidate sprites
  10155. * @returns null if no hit or a PickingInfo array
  10156. */
  10157. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10158. /**
  10159. * Renders the list of sprites on screen.
  10160. */
  10161. render(): void;
  10162. }
  10163. /**
  10164. * Class used to manage multiple sprites on the same spritesheet
  10165. * @see http://doc.babylonjs.com/babylon101/sprites
  10166. */
  10167. export class SpriteManager implements ISpriteManager {
  10168. /** defines the manager's name */
  10169. name: string;
  10170. /** Gets the list of sprites */
  10171. sprites: Sprite[];
  10172. /** Gets or sets the rendering group id (0 by default) */
  10173. renderingGroupId: number;
  10174. /** Gets or sets camera layer mask */
  10175. layerMask: number;
  10176. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10177. fogEnabled: boolean;
  10178. /** Gets or sets a boolean indicating if the sprites are pickable */
  10179. isPickable: boolean;
  10180. /** Defines the default width of a cell in the spritesheet */
  10181. cellWidth: number;
  10182. /** Defines the default height of a cell in the spritesheet */
  10183. cellHeight: number;
  10184. /** Associative array from JSON sprite data file */
  10185. private _cellData;
  10186. /** Array of sprite names from JSON sprite data file */
  10187. private _spriteMap;
  10188. /** True when packed cell data from JSON file is ready*/
  10189. private _packedAndReady;
  10190. /**
  10191. * An event triggered when the manager is disposed.
  10192. */
  10193. onDisposeObservable: Observable<SpriteManager>;
  10194. private _onDisposeObserver;
  10195. /**
  10196. * Callback called when the manager is disposed
  10197. */
  10198. set onDispose(callback: () => void);
  10199. private _capacity;
  10200. private _fromPacked;
  10201. private _spriteTexture;
  10202. private _epsilon;
  10203. private _scene;
  10204. private _vertexData;
  10205. private _buffer;
  10206. private _vertexBuffers;
  10207. private _indexBuffer;
  10208. private _effectBase;
  10209. private _effectFog;
  10210. /**
  10211. * Gets or sets the spritesheet texture
  10212. */
  10213. get texture(): Texture;
  10214. set texture(value: Texture);
  10215. /**
  10216. * Creates a new sprite manager
  10217. * @param name defines the manager's name
  10218. * @param imgUrl defines the sprite sheet url
  10219. * @param capacity defines the maximum allowed number of sprites
  10220. * @param cellSize defines the size of a sprite cell
  10221. * @param scene defines the hosting scene
  10222. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10223. * @param samplingMode defines the smapling mode to use with spritesheet
  10224. * @param fromPacked set to false; do not alter
  10225. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10226. */
  10227. constructor(
  10228. /** defines the manager's name */
  10229. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10230. private _makePacked;
  10231. private _appendSpriteVertex;
  10232. /**
  10233. * Intersects the sprites with a ray
  10234. * @param ray defines the ray to intersect with
  10235. * @param camera defines the current active camera
  10236. * @param predicate defines a predicate used to select candidate sprites
  10237. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10238. * @returns null if no hit or a PickingInfo
  10239. */
  10240. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10241. /**
  10242. * Intersects the sprites with a ray
  10243. * @param ray defines the ray to intersect with
  10244. * @param camera defines the current active camera
  10245. * @param predicate defines a predicate used to select candidate sprites
  10246. * @returns null if no hit or a PickingInfo array
  10247. */
  10248. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10249. /**
  10250. * Render all child sprites
  10251. */
  10252. render(): void;
  10253. /**
  10254. * Release associated resources
  10255. */
  10256. dispose(): void;
  10257. }
  10258. }
  10259. declare module "babylonjs/Misc/gradients" {
  10260. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10261. /** Interface used by value gradients (color, factor, ...) */
  10262. export interface IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. }
  10268. /** Class used to store color4 gradient */
  10269. export class ColorGradient implements IValueGradient {
  10270. /**
  10271. * Gets or sets the gradient value (between 0 and 1)
  10272. */
  10273. gradient: number;
  10274. /**
  10275. * Gets or sets first associated color
  10276. */
  10277. color1: Color4;
  10278. /**
  10279. * Gets or sets second associated color
  10280. */
  10281. color2?: Color4;
  10282. /**
  10283. * Will get a color picked randomly between color1 and color2.
  10284. * If color2 is undefined then color1 will be used
  10285. * @param result defines the target Color4 to store the result in
  10286. */
  10287. getColorToRef(result: Color4): void;
  10288. }
  10289. /** Class used to store color 3 gradient */
  10290. export class Color3Gradient implements IValueGradient {
  10291. /**
  10292. * Gets or sets the gradient value (between 0 and 1)
  10293. */
  10294. gradient: number;
  10295. /**
  10296. * Gets or sets the associated color
  10297. */
  10298. color: Color3;
  10299. }
  10300. /** Class used to store factor gradient */
  10301. export class FactorGradient implements IValueGradient {
  10302. /**
  10303. * Gets or sets the gradient value (between 0 and 1)
  10304. */
  10305. gradient: number;
  10306. /**
  10307. * Gets or sets first associated factor
  10308. */
  10309. factor1: number;
  10310. /**
  10311. * Gets or sets second associated factor
  10312. */
  10313. factor2?: number;
  10314. /**
  10315. * Will get a number picked randomly between factor1 and factor2.
  10316. * If factor2 is undefined then factor1 will be used
  10317. * @returns the picked number
  10318. */
  10319. getFactor(): number;
  10320. }
  10321. /**
  10322. * Helper used to simplify some generic gradient tasks
  10323. */
  10324. export class GradientHelper {
  10325. /**
  10326. * Gets the current gradient from an array of IValueGradient
  10327. * @param ratio defines the current ratio to get
  10328. * @param gradients defines the array of IValueGradient
  10329. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10330. */
  10331. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10332. }
  10333. }
  10334. declare module "babylonjs/Maths/math.size" {
  10335. /**
  10336. * Interface for the size containing width and height
  10337. */
  10338. export interface ISize {
  10339. /**
  10340. * Width
  10341. */
  10342. width: number;
  10343. /**
  10344. * Heighht
  10345. */
  10346. height: number;
  10347. }
  10348. /**
  10349. * Size containing widht and height
  10350. */
  10351. export class Size implements ISize {
  10352. /**
  10353. * Width
  10354. */
  10355. width: number;
  10356. /**
  10357. * Height
  10358. */
  10359. height: number;
  10360. /**
  10361. * Creates a Size object from the given width and height (floats).
  10362. * @param width width of the new size
  10363. * @param height height of the new size
  10364. */
  10365. constructor(width: number, height: number);
  10366. /**
  10367. * Returns a string with the Size width and height
  10368. * @returns a string with the Size width and height
  10369. */
  10370. toString(): string;
  10371. /**
  10372. * "Size"
  10373. * @returns the string "Size"
  10374. */
  10375. getClassName(): string;
  10376. /**
  10377. * Returns the Size hash code.
  10378. * @returns a hash code for a unique width and height
  10379. */
  10380. getHashCode(): number;
  10381. /**
  10382. * Updates the current size from the given one.
  10383. * @param src the given size
  10384. */
  10385. copyFrom(src: Size): void;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width of the new size
  10389. * @param height height of the new size
  10390. * @returns the updated Size.
  10391. */
  10392. copyFromFloats(width: number, height: number): Size;
  10393. /**
  10394. * Updates in place the current Size from the given floats.
  10395. * @param width width to set
  10396. * @param height height to set
  10397. * @returns the updated Size.
  10398. */
  10399. set(width: number, height: number): Size;
  10400. /**
  10401. * Multiplies the width and height by numbers
  10402. * @param w factor to multiple the width by
  10403. * @param h factor to multiple the height by
  10404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10405. */
  10406. multiplyByFloats(w: number, h: number): Size;
  10407. /**
  10408. * Clones the size
  10409. * @returns a new Size copied from the given one.
  10410. */
  10411. clone(): Size;
  10412. /**
  10413. * True if the current Size and the given one width and height are strictly equal.
  10414. * @param other the other size to compare against
  10415. * @returns True if the current Size and the given one width and height are strictly equal.
  10416. */
  10417. equals(other: Size): boolean;
  10418. /**
  10419. * The surface of the Size : width * height (float).
  10420. */
  10421. get surface(): number;
  10422. /**
  10423. * Create a new size of zero
  10424. * @returns a new Size set to (0.0, 0.0)
  10425. */
  10426. static Zero(): Size;
  10427. /**
  10428. * Sums the width and height of two sizes
  10429. * @param otherSize size to add to this size
  10430. * @returns a new Size set as the addition result of the current Size and the given one.
  10431. */
  10432. add(otherSize: Size): Size;
  10433. /**
  10434. * Subtracts the width and height of two
  10435. * @param otherSize size to subtract to this size
  10436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10437. */
  10438. subtract(otherSize: Size): Size;
  10439. /**
  10440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10441. * @param start starting size to lerp between
  10442. * @param end end size to lerp between
  10443. * @param amount amount to lerp between the start and end values
  10444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10445. */
  10446. static Lerp(start: Size, end: Size, amount: number): Size;
  10447. }
  10448. }
  10449. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10451. import { Nullable } from "babylonjs/types";
  10452. module "babylonjs/Engines/thinEngine" {
  10453. interface ThinEngine {
  10454. /**
  10455. * Creates a dynamic texture
  10456. * @param width defines the width of the texture
  10457. * @param height defines the height of the texture
  10458. * @param generateMipMaps defines if the engine should generate the mip levels
  10459. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10460. * @returns the dynamic texture inside an InternalTexture
  10461. */
  10462. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10463. /**
  10464. * Update the content of a dynamic texture
  10465. * @param texture defines the texture to update
  10466. * @param canvas defines the canvas containing the source
  10467. * @param invertY defines if data must be stored with Y axis inverted
  10468. * @param premulAlpha defines if alpha is stored as premultiplied
  10469. * @param format defines the format of the data
  10470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10471. */
  10472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10473. }
  10474. }
  10475. }
  10476. declare module "babylonjs/Misc/canvasGenerator" {
  10477. /**
  10478. * Helper class used to generate a canvas to manipulate images
  10479. */
  10480. export class CanvasGenerator {
  10481. /**
  10482. * Create a new canvas (or offscreen canvas depending on the context)
  10483. * @param width defines the expected width
  10484. * @param height defines the expected height
  10485. * @return a new canvas or offscreen canvas
  10486. */
  10487. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10488. }
  10489. }
  10490. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10491. import { Scene } from "babylonjs/scene";
  10492. import { Texture } from "babylonjs/Materials/Textures/texture";
  10493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10494. /**
  10495. * A class extending Texture allowing drawing on a texture
  10496. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10497. */
  10498. export class DynamicTexture extends Texture {
  10499. private _generateMipMaps;
  10500. private _canvas;
  10501. private _context;
  10502. private _engine;
  10503. /**
  10504. * Creates a DynamicTexture
  10505. * @param name defines the name of the texture
  10506. * @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
  10507. * @param scene defines the scene where you want the texture
  10508. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10509. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10510. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10511. */
  10512. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10513. /**
  10514. * Get the current class name of the texture useful for serialization or dynamic coding.
  10515. * @returns "DynamicTexture"
  10516. */
  10517. getClassName(): string;
  10518. /**
  10519. * Gets the current state of canRescale
  10520. */
  10521. get canRescale(): boolean;
  10522. private _recreate;
  10523. /**
  10524. * Scales the texture
  10525. * @param ratio the scale factor to apply to both width and height
  10526. */
  10527. scale(ratio: number): void;
  10528. /**
  10529. * Resizes the texture
  10530. * @param width the new width
  10531. * @param height the new height
  10532. */
  10533. scaleTo(width: number, height: number): void;
  10534. /**
  10535. * Gets the context of the canvas used by the texture
  10536. * @returns the canvas context of the dynamic texture
  10537. */
  10538. getContext(): CanvasRenderingContext2D;
  10539. /**
  10540. * Clears the texture
  10541. */
  10542. clear(): void;
  10543. /**
  10544. * Updates the texture
  10545. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10546. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10547. */
  10548. update(invertY?: boolean, premulAlpha?: boolean): void;
  10549. /**
  10550. * Draws text onto the texture
  10551. * @param text defines the text to be drawn
  10552. * @param x defines the placement of the text from the left
  10553. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10554. * @param font defines the font to be used with font-style, font-size, font-name
  10555. * @param color defines the color used for the text
  10556. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10557. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10558. * @param update defines whether texture is immediately update (default is true)
  10559. */
  10560. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10561. /**
  10562. * Clones the texture
  10563. * @returns the clone of the texture.
  10564. */
  10565. clone(): DynamicTexture;
  10566. /**
  10567. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10568. * @returns a serialized dynamic texture object
  10569. */
  10570. serialize(): any;
  10571. /** @hidden */
  10572. _rebuild(): void;
  10573. }
  10574. }
  10575. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10576. import { Nullable } from "babylonjs/types";
  10577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10578. import { Scene } from "babylonjs/scene";
  10579. module "babylonjs/Engines/engine" {
  10580. interface Engine {
  10581. /**
  10582. * Creates a raw texture
  10583. * @param data defines the data to store in the texture
  10584. * @param width defines the width of the texture
  10585. * @param height defines the height of the texture
  10586. * @param format defines the format of the data
  10587. * @param generateMipMaps defines if the engine should generate the mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10590. * @param compression defines the compression used (null by default)
  10591. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10592. * @returns the raw texture inside an InternalTexture
  10593. */
  10594. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10595. /**
  10596. * Update a raw texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store in the texture
  10599. * @param format defines the format of the data
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store in the texture
  10607. * @param format defines the format of the data
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the compression used (null by default)
  10610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10611. */
  10612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10613. /**
  10614. * Creates a new raw cube texture
  10615. * @param data defines the array of data to use to create each face
  10616. * @param size defines the size of the textures
  10617. * @param format defines the format of the data
  10618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10619. * @param generateMipMaps defines if the engine should generate the mip levels
  10620. * @param invertY defines if data must be stored with Y axis inverted
  10621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10622. * @param compression defines the compression used (null by default)
  10623. * @returns the cube texture as an InternalTexture
  10624. */
  10625. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10626. /**
  10627. * Update a raw cube texture
  10628. * @param texture defines the texture to udpdate
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10632. * @param invertY defines if data must be stored with Y axis inverted
  10633. */
  10634. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10635. /**
  10636. * Update a raw cube texture
  10637. * @param texture defines the texture to udpdate
  10638. * @param data defines the data to store
  10639. * @param format defines the data format
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the compression used (null by default)
  10643. */
  10644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10645. /**
  10646. * Update a raw cube texture
  10647. * @param texture defines the texture to udpdate
  10648. * @param data defines the data to store
  10649. * @param format defines the data format
  10650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10651. * @param invertY defines if data must be stored with Y axis inverted
  10652. * @param compression defines the compression used (null by default)
  10653. * @param level defines which level of the texture to update
  10654. */
  10655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10656. /**
  10657. * Creates a new raw cube texture from a specified url
  10658. * @param url defines the url where the data is located
  10659. * @param scene defines the current scene
  10660. * @param size defines the size of the textures
  10661. * @param format defines the format of the data
  10662. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10663. * @param noMipmap defines if the engine should avoid generating the mip levels
  10664. * @param callback defines a callback used to extract texture data from loaded data
  10665. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10666. * @param onLoad defines a callback called when texture is loaded
  10667. * @param onError defines a callback called if there is an error
  10668. * @returns the cube texture as an InternalTexture
  10669. */
  10670. 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;
  10671. /**
  10672. * Creates a new raw cube texture from a specified url
  10673. * @param url defines the url where the data is located
  10674. * @param scene defines the current scene
  10675. * @param size defines the size of the textures
  10676. * @param format defines the format of the data
  10677. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10678. * @param noMipmap defines if the engine should avoid generating the mip levels
  10679. * @param callback defines a callback used to extract texture data from loaded data
  10680. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10681. * @param onLoad defines a callback called when texture is loaded
  10682. * @param onError defines a callback called if there is an error
  10683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10684. * @param invertY defines if data must be stored with Y axis inverted
  10685. * @returns the cube texture as an InternalTexture
  10686. */
  10687. 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;
  10688. /**
  10689. * Creates a new raw 3D texture
  10690. * @param data defines the data used to create the texture
  10691. * @param width defines the width of the texture
  10692. * @param height defines the height of the texture
  10693. * @param depth defines the depth of the texture
  10694. * @param format defines the format of the texture
  10695. * @param generateMipMaps defines if the engine must generate mip levels
  10696. * @param invertY defines if data must be stored with Y axis inverted
  10697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10698. * @param compression defines the compressed used (can be null)
  10699. * @param textureType defines the compressed used (can be null)
  10700. * @returns a new raw 3D texture (stored in an InternalTexture)
  10701. */
  10702. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10703. /**
  10704. * Update a raw 3D texture
  10705. * @param texture defines the texture to update
  10706. * @param data defines the data to store
  10707. * @param format defines the data format
  10708. * @param invertY defines if data must be stored with Y axis inverted
  10709. */
  10710. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10711. /**
  10712. * Update a raw 3D texture
  10713. * @param texture defines the texture to update
  10714. * @param data defines the data to store
  10715. * @param format defines the data format
  10716. * @param invertY defines if data must be stored with Y axis inverted
  10717. * @param compression defines the used compression (can be null)
  10718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10719. */
  10720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10721. /**
  10722. * Creates a new raw 2D array texture
  10723. * @param data defines the data used to create the texture
  10724. * @param width defines the width of the texture
  10725. * @param height defines the height of the texture
  10726. * @param depth defines the number of layers of the texture
  10727. * @param format defines the format of the texture
  10728. * @param generateMipMaps defines if the engine must generate mip levels
  10729. * @param invertY defines if data must be stored with Y axis inverted
  10730. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10731. * @param compression defines the compressed used (can be null)
  10732. * @param textureType defines the compressed used (can be null)
  10733. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10734. */
  10735. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10736. /**
  10737. * Update a raw 2D array texture
  10738. * @param texture defines the texture to update
  10739. * @param data defines the data to store
  10740. * @param format defines the data format
  10741. * @param invertY defines if data must be stored with Y axis inverted
  10742. */
  10743. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10744. /**
  10745. * Update a raw 2D array texture
  10746. * @param texture defines the texture to update
  10747. * @param data defines the data to store
  10748. * @param format defines the data format
  10749. * @param invertY defines if data must be stored with Y axis inverted
  10750. * @param compression defines the used compression (can be null)
  10751. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10752. */
  10753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10754. }
  10755. }
  10756. }
  10757. declare module "babylonjs/Materials/Textures/rawTexture" {
  10758. import { Scene } from "babylonjs/scene";
  10759. import { Texture } from "babylonjs/Materials/Textures/texture";
  10760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10761. /**
  10762. * Raw texture can help creating a texture directly from an array of data.
  10763. * This can be super useful if you either get the data from an uncompressed source or
  10764. * if you wish to create your texture pixel by pixel.
  10765. */
  10766. export class RawTexture extends Texture {
  10767. /**
  10768. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10769. */
  10770. format: number;
  10771. private _engine;
  10772. /**
  10773. * Instantiates a new RawTexture.
  10774. * Raw texture can help creating a texture directly from an array of data.
  10775. * This can be super useful if you either get the data from an uncompressed source or
  10776. * if you wish to create your texture pixel by pixel.
  10777. * @param data define the array of data to use to create the texture
  10778. * @param width define the width of the texture
  10779. * @param height define the height of the texture
  10780. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10781. * @param scene define the scene the texture belongs to
  10782. * @param generateMipMaps define whether mip maps should be generated or not
  10783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10786. */
  10787. constructor(data: ArrayBufferView, width: number, height: number,
  10788. /**
  10789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10790. */
  10791. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10792. /**
  10793. * Updates the texture underlying data.
  10794. * @param data Define the new data of the texture
  10795. */
  10796. update(data: ArrayBufferView): void;
  10797. /**
  10798. * Creates a luminance texture from some data.
  10799. * @param data Define the texture data
  10800. * @param width Define the width of the texture
  10801. * @param height Define the height of the texture
  10802. * @param scene Define the scene the texture belongs to
  10803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10806. * @returns the luminance texture
  10807. */
  10808. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10809. /**
  10810. * Creates a luminance alpha texture from some data.
  10811. * @param data Define the texture data
  10812. * @param width Define the width of the texture
  10813. * @param height Define the height of the texture
  10814. * @param scene Define the scene the texture belongs to
  10815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10818. * @returns the luminance alpha texture
  10819. */
  10820. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10821. /**
  10822. * Creates an alpha texture from some data.
  10823. * @param data Define the texture data
  10824. * @param width Define the width of the texture
  10825. * @param height Define the height of the texture
  10826. * @param scene Define the scene the texture belongs to
  10827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10830. * @returns the alpha texture
  10831. */
  10832. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10833. /**
  10834. * Creates a RGB texture from some data.
  10835. * @param data Define the texture data
  10836. * @param width Define the width of the texture
  10837. * @param height Define the height of the texture
  10838. * @param scene Define the scene the texture belongs to
  10839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10843. * @returns the RGB alpha texture
  10844. */
  10845. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10846. /**
  10847. * Creates a RGBA texture from some data.
  10848. * @param data Define the texture data
  10849. * @param width Define the width of the texture
  10850. * @param height Define the height of the texture
  10851. * @param scene Define the scene the texture belongs to
  10852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10856. * @returns the RGBA texture
  10857. */
  10858. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10859. /**
  10860. * Creates a R texture from some data.
  10861. * @param data Define the texture data
  10862. * @param width Define the width of the texture
  10863. * @param height Define the height of the texture
  10864. * @param scene Define the scene the texture belongs to
  10865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10869. * @returns the R texture
  10870. */
  10871. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10872. }
  10873. }
  10874. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10875. import { Scene } from "babylonjs/scene";
  10876. import { ISceneComponent } from "babylonjs/sceneComponent";
  10877. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10878. module "babylonjs/abstractScene" {
  10879. interface AbstractScene {
  10880. /**
  10881. * The list of procedural textures added to the scene
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. */
  10884. proceduralTextures: Array<ProceduralTexture>;
  10885. }
  10886. }
  10887. /**
  10888. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10889. * in a given scene.
  10890. */
  10891. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10892. /**
  10893. * The component name helpfull to identify the component in the list of scene components.
  10894. */
  10895. readonly name: string;
  10896. /**
  10897. * The scene the component belongs to.
  10898. */
  10899. scene: Scene;
  10900. /**
  10901. * Creates a new instance of the component for the given scene
  10902. * @param scene Defines the scene to register the component in
  10903. */
  10904. constructor(scene: Scene);
  10905. /**
  10906. * Registers the component in a given scene
  10907. */
  10908. register(): void;
  10909. /**
  10910. * Rebuilds the elements related to this component in case of
  10911. * context lost for instance.
  10912. */
  10913. rebuild(): void;
  10914. /**
  10915. * Disposes the component and the associated ressources.
  10916. */
  10917. dispose(): void;
  10918. private _beforeClear;
  10919. }
  10920. }
  10921. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10923. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10924. module "babylonjs/Engines/thinEngine" {
  10925. interface ThinEngine {
  10926. /**
  10927. * Creates a new render target cube texture
  10928. * @param size defines the size of the texture
  10929. * @param options defines the options used to create the texture
  10930. * @returns a new render target cube texture stored in an InternalTexture
  10931. */
  10932. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10933. }
  10934. }
  10935. }
  10936. declare module "babylonjs/Shaders/procedural.vertex" {
  10937. /** @hidden */
  10938. export var proceduralVertexShader: {
  10939. name: string;
  10940. shader: string;
  10941. };
  10942. }
  10943. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10944. import { Observable } from "babylonjs/Misc/observable";
  10945. import { Nullable } from "babylonjs/types";
  10946. import { Scene } from "babylonjs/scene";
  10947. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10948. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10949. import { Effect } from "babylonjs/Materials/effect";
  10950. import { Texture } from "babylonjs/Materials/Textures/texture";
  10951. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10952. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10953. import "babylonjs/Shaders/procedural.vertex";
  10954. /**
  10955. * 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.
  10956. * This is the base class of any Procedural texture and contains most of the shareable code.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10958. */
  10959. export class ProceduralTexture extends Texture {
  10960. isCube: boolean;
  10961. /**
  10962. * Define if the texture is enabled or not (disabled texture will not render)
  10963. */
  10964. isEnabled: boolean;
  10965. /**
  10966. * Define if the texture must be cleared before rendering (default is true)
  10967. */
  10968. autoClear: boolean;
  10969. /**
  10970. * Callback called when the texture is generated
  10971. */
  10972. onGenerated: () => void;
  10973. /**
  10974. * Event raised when the texture is generated
  10975. */
  10976. onGeneratedObservable: Observable<ProceduralTexture>;
  10977. /** @hidden */
  10978. _generateMipMaps: boolean;
  10979. /** @hidden **/
  10980. _effect: Effect;
  10981. /** @hidden */
  10982. _textures: {
  10983. [key: string]: Texture;
  10984. };
  10985. private _size;
  10986. private _currentRefreshId;
  10987. private _frameId;
  10988. private _refreshRate;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _uniforms;
  10992. private _samplers;
  10993. private _fragment;
  10994. private _floats;
  10995. private _ints;
  10996. private _floatsArrays;
  10997. private _colors3;
  10998. private _colors4;
  10999. private _vectors2;
  11000. private _vectors3;
  11001. private _matrices;
  11002. private _fallbackTexture;
  11003. private _fallbackTextureUsed;
  11004. private _engine;
  11005. private _cachedDefines;
  11006. private _contentUpdateId;
  11007. private _contentData;
  11008. /**
  11009. * Instantiates a new procedural texture.
  11010. * 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.
  11011. * This is the base class of any Procedural texture and contains most of the shareable code.
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11013. * @param name Define the name of the texture
  11014. * @param size Define the size of the texture to create
  11015. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11016. * @param scene Define the scene the texture belongs to
  11017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11018. * @param generateMipMaps Define if the texture should creates mip maps or not
  11019. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11020. */
  11021. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11022. /**
  11023. * The effect that is created when initializing the post process.
  11024. * @returns The created effect corresponding the the postprocess.
  11025. */
  11026. getEffect(): Effect;
  11027. /**
  11028. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11029. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11030. */
  11031. getContent(): Nullable<ArrayBufferView>;
  11032. private _createIndexBuffer;
  11033. /** @hidden */
  11034. _rebuild(): void;
  11035. /**
  11036. * Resets the texture in order to recreate its associated resources.
  11037. * This can be called in case of context loss
  11038. */
  11039. reset(): void;
  11040. protected _getDefines(): string;
  11041. /**
  11042. * Is the texture ready to be used ? (rendered at least once)
  11043. * @returns true if ready, otherwise, false.
  11044. */
  11045. isReady(): boolean;
  11046. /**
  11047. * Resets the refresh counter of the texture and start bak from scratch.
  11048. * Could be useful to regenerate the texture if it is setup to render only once.
  11049. */
  11050. resetRefreshCounter(): void;
  11051. /**
  11052. * Set the fragment shader to use in order to render the texture.
  11053. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11054. */
  11055. setFragment(fragment: any): void;
  11056. /**
  11057. * Define the refresh rate of the texture or the rendering frequency.
  11058. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11059. */
  11060. get refreshRate(): number;
  11061. set refreshRate(value: number);
  11062. /** @hidden */
  11063. _shouldRender(): boolean;
  11064. /**
  11065. * Get the size the texture is rendering at.
  11066. * @returns the size (texture is always squared)
  11067. */
  11068. getRenderSize(): number;
  11069. /**
  11070. * Resize the texture to new value.
  11071. * @param size Define the new size the texture should have
  11072. * @param generateMipMaps Define whether the new texture should create mip maps
  11073. */
  11074. resize(size: number, generateMipMaps: boolean): void;
  11075. private _checkUniform;
  11076. /**
  11077. * Set a texture in the shader program used to render.
  11078. * @param name Define the name of the uniform samplers as defined in the shader
  11079. * @param texture Define the texture to bind to this sampler
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setTexture(name: string, texture: Texture): ProceduralTexture;
  11083. /**
  11084. * Set a float in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setFloat(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set a int in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setInt(name: string, value: number): ProceduralTexture;
  11097. /**
  11098. * Set an array of floats in the shader.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setFloats(name: string, value: number[]): ProceduralTexture;
  11104. /**
  11105. * Set a vec3 in the shader from a Color3.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor3(name: string, value: Color3): ProceduralTexture;
  11111. /**
  11112. * Set a vec4 in the shader from a Color4.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setColor4(name: string, value: Color4): ProceduralTexture;
  11118. /**
  11119. * Set a vec2 in the shader from a Vector2.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector2(name: string, value: Vector2): ProceduralTexture;
  11125. /**
  11126. * Set a vec3 in the shader from a Vector3.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setVector3(name: string, value: Vector3): ProceduralTexture;
  11132. /**
  11133. * Set a mat4 in the shader from a MAtrix.
  11134. * @param name Define the name of the uniform as defined in the shader
  11135. * @param value Define the value to give to the uniform
  11136. * @return the texture itself allowing "fluent" like uniform updates
  11137. */
  11138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11139. /**
  11140. * Render the texture to its associated render target.
  11141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11142. */
  11143. render(useCameraPostProcess?: boolean): void;
  11144. /**
  11145. * Clone the texture.
  11146. * @returns the cloned texture
  11147. */
  11148. clone(): ProceduralTexture;
  11149. /**
  11150. * Dispose the texture and release its asoociated resources.
  11151. */
  11152. dispose(): void;
  11153. }
  11154. }
  11155. declare module "babylonjs/Particles/baseParticleSystem" {
  11156. import { Nullable } from "babylonjs/types";
  11157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11160. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11161. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11162. import { Scene } from "babylonjs/scene";
  11163. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11164. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11165. import { Texture } from "babylonjs/Materials/Textures/texture";
  11166. import { Color4 } from "babylonjs/Maths/math.color";
  11167. import { Animation } from "babylonjs/Animations/animation";
  11168. /**
  11169. * This represents the base class for particle system in Babylon.
  11170. * 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.
  11171. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11172. * @example https://doc.babylonjs.com/babylon101/particles
  11173. */
  11174. export class BaseParticleSystem {
  11175. /**
  11176. * Source color is added to the destination color without alpha affecting the result
  11177. */
  11178. static BLENDMODE_ONEONE: number;
  11179. /**
  11180. * Blend current color and particle color using particle’s alpha
  11181. */
  11182. static BLENDMODE_STANDARD: number;
  11183. /**
  11184. * Add current color and particle color multiplied by particle’s alpha
  11185. */
  11186. static BLENDMODE_ADD: number;
  11187. /**
  11188. * Multiply current color with particle color
  11189. */
  11190. static BLENDMODE_MULTIPLY: number;
  11191. /**
  11192. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11193. */
  11194. static BLENDMODE_MULTIPLYADD: number;
  11195. /**
  11196. * List of animations used by the particle system.
  11197. */
  11198. animations: Animation[];
  11199. /**
  11200. * The id of the Particle system.
  11201. */
  11202. id: string;
  11203. /**
  11204. * The friendly name of the Particle system.
  11205. */
  11206. name: string;
  11207. /**
  11208. * The rendering group used by the Particle system to chose when to render.
  11209. */
  11210. renderingGroupId: number;
  11211. /**
  11212. * The emitter represents the Mesh or position we are attaching the particle system to.
  11213. */
  11214. emitter: Nullable<AbstractMesh | Vector3>;
  11215. /**
  11216. * The maximum number of particles to emit per frame
  11217. */
  11218. emitRate: number;
  11219. /**
  11220. * If you want to launch only a few particles at once, that can be done, as well.
  11221. */
  11222. manualEmitCount: number;
  11223. /**
  11224. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11225. */
  11226. updateSpeed: number;
  11227. /**
  11228. * The amount of time the particle system is running (depends of the overall update speed).
  11229. */
  11230. targetStopDuration: number;
  11231. /**
  11232. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11233. */
  11234. disposeOnStop: boolean;
  11235. /**
  11236. * Minimum power of emitting particles.
  11237. */
  11238. minEmitPower: number;
  11239. /**
  11240. * Maximum power of emitting particles.
  11241. */
  11242. maxEmitPower: number;
  11243. /**
  11244. * Minimum life time of emitting particles.
  11245. */
  11246. minLifeTime: number;
  11247. /**
  11248. * Maximum life time of emitting particles.
  11249. */
  11250. maxLifeTime: number;
  11251. /**
  11252. * Minimum Size of emitting particles.
  11253. */
  11254. minSize: number;
  11255. /**
  11256. * Maximum Size of emitting particles.
  11257. */
  11258. maxSize: number;
  11259. /**
  11260. * Minimum scale of emitting particles on X axis.
  11261. */
  11262. minScaleX: number;
  11263. /**
  11264. * Maximum scale of emitting particles on X axis.
  11265. */
  11266. maxScaleX: number;
  11267. /**
  11268. * Minimum scale of emitting particles on Y axis.
  11269. */
  11270. minScaleY: number;
  11271. /**
  11272. * Maximum scale of emitting particles on Y axis.
  11273. */
  11274. maxScaleY: number;
  11275. /**
  11276. * Gets or sets the minimal initial rotation in radians.
  11277. */
  11278. minInitialRotation: number;
  11279. /**
  11280. * Gets or sets the maximal initial rotation in radians.
  11281. */
  11282. maxInitialRotation: number;
  11283. /**
  11284. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11285. */
  11286. minAngularSpeed: number;
  11287. /**
  11288. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11289. */
  11290. maxAngularSpeed: number;
  11291. /**
  11292. * The texture used to render each particle. (this can be a spritesheet)
  11293. */
  11294. particleTexture: Nullable<Texture>;
  11295. /**
  11296. * The layer mask we are rendering the particles through.
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * This can help using your own shader to render the particle system.
  11301. * The according effect will be created
  11302. */
  11303. customShader: any;
  11304. /**
  11305. * By default particle system starts as soon as they are created. This prevents the
  11306. * automatic start to happen and let you decide when to start emitting particles.
  11307. */
  11308. preventAutoStart: boolean;
  11309. private _noiseTexture;
  11310. /**
  11311. * Gets or sets a texture used to add random noise to particle positions
  11312. */
  11313. get noiseTexture(): Nullable<ProceduralTexture>;
  11314. set noiseTexture(value: Nullable<ProceduralTexture>);
  11315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11316. noiseStrength: Vector3;
  11317. /**
  11318. * Callback triggered when the particle animation is ending.
  11319. */
  11320. onAnimationEnd: Nullable<() => void>;
  11321. /**
  11322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11323. */
  11324. blendMode: number;
  11325. /**
  11326. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11327. * to override the particles.
  11328. */
  11329. forceDepthWrite: boolean;
  11330. /** 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 */
  11331. preWarmCycles: number;
  11332. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11333. preWarmStepOffset: number;
  11334. /**
  11335. * 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)
  11336. */
  11337. spriteCellChangeSpeed: number;
  11338. /**
  11339. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11340. */
  11341. startSpriteCellID: number;
  11342. /**
  11343. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11344. */
  11345. endSpriteCellID: number;
  11346. /**
  11347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11348. */
  11349. spriteCellWidth: number;
  11350. /**
  11351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11352. */
  11353. spriteCellHeight: number;
  11354. /**
  11355. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11356. */
  11357. spriteRandomStartCell: boolean;
  11358. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11359. translationPivot: Vector2;
  11360. /** @hidden */
  11361. protected _isAnimationSheetEnabled: boolean;
  11362. /**
  11363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11364. */
  11365. beginAnimationOnStart: boolean;
  11366. /**
  11367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11368. */
  11369. beginAnimationFrom: number;
  11370. /**
  11371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11372. */
  11373. beginAnimationTo: number;
  11374. /**
  11375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11376. */
  11377. beginAnimationLoop: boolean;
  11378. /**
  11379. * Gets or sets a world offset applied to all particles
  11380. */
  11381. worldOffset: Vector3;
  11382. /**
  11383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11384. */
  11385. get isAnimationSheetEnabled(): boolean;
  11386. set isAnimationSheetEnabled(value: boolean);
  11387. /**
  11388. * Get hosting scene
  11389. * @returns the scene
  11390. */
  11391. getScene(): Scene;
  11392. /**
  11393. * You can use gravity if you want to give an orientation to your particles.
  11394. */
  11395. gravity: Vector3;
  11396. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11397. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11399. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11400. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11402. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11403. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11404. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11405. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11406. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11408. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11409. /**
  11410. * Defines the delay in milliseconds before starting the system (0 by default)
  11411. */
  11412. startDelay: number;
  11413. /**
  11414. * Gets the current list of drag gradients.
  11415. * You must use addDragGradient and removeDragGradient to udpate this list
  11416. * @returns the list of drag gradients
  11417. */
  11418. getDragGradients(): Nullable<Array<FactorGradient>>;
  11419. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11420. limitVelocityDamping: number;
  11421. /**
  11422. * Gets the current list of limit velocity gradients.
  11423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11424. * @returns the list of limit velocity gradients
  11425. */
  11426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11427. /**
  11428. * Gets the current list of color gradients.
  11429. * You must use addColorGradient and removeColorGradient to udpate this list
  11430. * @returns the list of color gradients
  11431. */
  11432. getColorGradients(): Nullable<Array<ColorGradient>>;
  11433. /**
  11434. * Gets the current list of size gradients.
  11435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11436. * @returns the list of size gradients
  11437. */
  11438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11439. /**
  11440. * Gets the current list of color remap gradients.
  11441. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11442. * @returns the list of color remap gradients
  11443. */
  11444. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11445. /**
  11446. * Gets the current list of alpha remap gradients.
  11447. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11448. * @returns the list of alpha remap gradients
  11449. */
  11450. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11451. /**
  11452. * Gets the current list of life time gradients.
  11453. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11454. * @returns the list of life time gradients
  11455. */
  11456. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of angular speed gradients.
  11459. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11460. * @returns the list of angular speed gradients
  11461. */
  11462. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11463. /**
  11464. * Gets the current list of velocity gradients.
  11465. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11466. * @returns the list of velocity gradients
  11467. */
  11468. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of start size gradients.
  11471. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11472. * @returns the list of start size gradients
  11473. */
  11474. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of emit rate gradients.
  11477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11478. * @returns the list of emit rate gradients
  11479. */
  11480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11484. */
  11485. get direction1(): Vector3;
  11486. set direction1(value: Vector3);
  11487. /**
  11488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11490. */
  11491. get direction2(): Vector3;
  11492. set direction2(value: Vector3);
  11493. /**
  11494. * 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.
  11495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11496. */
  11497. get minEmitBox(): Vector3;
  11498. set minEmitBox(value: Vector3);
  11499. /**
  11500. * 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.
  11501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11502. */
  11503. get maxEmitBox(): Vector3;
  11504. set maxEmitBox(value: Vector3);
  11505. /**
  11506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11507. */
  11508. color1: Color4;
  11509. /**
  11510. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11511. */
  11512. color2: Color4;
  11513. /**
  11514. * Color the particle will have at the end of its lifetime
  11515. */
  11516. colorDead: Color4;
  11517. /**
  11518. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11519. */
  11520. textureMask: Color4;
  11521. /**
  11522. * The particle emitter type defines the emitter used by the particle system.
  11523. * It can be for example box, sphere, or cone...
  11524. */
  11525. particleEmitterType: IParticleEmitterType;
  11526. /** @hidden */
  11527. _isSubEmitter: boolean;
  11528. /**
  11529. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11530. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11531. */
  11532. billboardMode: number;
  11533. protected _isBillboardBased: boolean;
  11534. /**
  11535. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11536. */
  11537. get isBillboardBased(): boolean;
  11538. set isBillboardBased(value: boolean);
  11539. /**
  11540. * The scene the particle system belongs to.
  11541. */
  11542. protected _scene: Scene;
  11543. /**
  11544. * Local cache of defines for image processing.
  11545. */
  11546. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11547. /**
  11548. * Default configuration related to image processing available in the standard Material.
  11549. */
  11550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11551. /**
  11552. * Gets the image processing configuration used either in this material.
  11553. */
  11554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11555. /**
  11556. * Sets the Default image processing configuration used either in the this material.
  11557. *
  11558. * If sets to null, the scene one is in use.
  11559. */
  11560. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11561. /**
  11562. * Attaches a new image processing configuration to the Standard Material.
  11563. * @param configuration
  11564. */
  11565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11566. /** @hidden */
  11567. protected _reset(): void;
  11568. /** @hidden */
  11569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11570. /**
  11571. * Instantiates a particle system.
  11572. * 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.
  11573. * @param name The name of the particle system
  11574. */
  11575. constructor(name: string);
  11576. /**
  11577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11580. * @returns the emitter
  11581. */
  11582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11583. /**
  11584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11585. * @param radius The radius of the hemisphere to emit from
  11586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11590. /**
  11591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11594. * @returns the emitter
  11595. */
  11596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11597. /**
  11598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11599. * @param radius The radius of the sphere to emit from
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11602. * @returns the emitter
  11603. */
  11604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11605. /**
  11606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11607. * @param radius The radius of the emission cylinder
  11608. * @param height The height of the emission cylinder
  11609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11611. * @returns the emitter
  11612. */
  11613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11614. /**
  11615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11616. * @param radius The radius of the cylinder to emit from
  11617. * @param height The height of the emission cylinder
  11618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11621. * @returns the emitter
  11622. */
  11623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11624. /**
  11625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11626. * @param radius The radius of the cone to emit from
  11627. * @param angle The base angle of the cone
  11628. * @returns the emitter
  11629. */
  11630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11631. /**
  11632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11637. * @returns the emitter
  11638. */
  11639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11640. }
  11641. }
  11642. declare module "babylonjs/Particles/subEmitter" {
  11643. import { Scene } from "babylonjs/scene";
  11644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11645. /**
  11646. * Type of sub emitter
  11647. */
  11648. export enum SubEmitterType {
  11649. /**
  11650. * Attached to the particle over it's lifetime
  11651. */
  11652. ATTACHED = 0,
  11653. /**
  11654. * Created when the particle dies
  11655. */
  11656. END = 1
  11657. }
  11658. /**
  11659. * Sub emitter class used to emit particles from an existing particle
  11660. */
  11661. export class SubEmitter {
  11662. /**
  11663. * the particle system to be used by the sub emitter
  11664. */
  11665. particleSystem: ParticleSystem;
  11666. /**
  11667. * Type of the submitter (Default: END)
  11668. */
  11669. type: SubEmitterType;
  11670. /**
  11671. * 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)
  11672. * Note: This only is supported when using an emitter of type Mesh
  11673. */
  11674. inheritDirection: boolean;
  11675. /**
  11676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11677. */
  11678. inheritedVelocityAmount: number;
  11679. /**
  11680. * Creates a sub emitter
  11681. * @param particleSystem the particle system to be used by the sub emitter
  11682. */
  11683. constructor(
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem);
  11688. /**
  11689. * Clones the sub emitter
  11690. * @returns the cloned sub emitter
  11691. */
  11692. clone(): SubEmitter;
  11693. /**
  11694. * Serialize current object to a JSON object
  11695. * @returns the serialized object
  11696. */
  11697. serialize(): any;
  11698. /** @hidden */
  11699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11700. /**
  11701. * Creates a new SubEmitter from a serialized JSON version
  11702. * @param serializationObject defines the JSON object to read from
  11703. * @param scene defines the hosting scene
  11704. * @param rootUrl defines the rootUrl for data loading
  11705. * @returns a new SubEmitter
  11706. */
  11707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11708. /** Release associated resources */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11713. /** @hidden */
  11714. export var imageProcessingDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11720. /** @hidden */
  11721. export var imageProcessingFunctions: {
  11722. name: string;
  11723. shader: string;
  11724. };
  11725. }
  11726. declare module "babylonjs/Shaders/particles.fragment" {
  11727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11729. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11732. /** @hidden */
  11733. export var particlesPixelShader: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/particles.vertex" {
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11741. /** @hidden */
  11742. export var particlesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Particles/particleSystem" {
  11748. import { Nullable } from "babylonjs/types";
  11749. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11752. import { Effect } from "babylonjs/Materials/effect";
  11753. import { Scene, IDisposable } from "babylonjs/scene";
  11754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11755. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11756. import { Particle } from "babylonjs/Particles/particle";
  11757. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11759. import "babylonjs/Shaders/particles.fragment";
  11760. import "babylonjs/Shaders/particles.vertex";
  11761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11762. /**
  11763. * This represents a particle system in Babylon.
  11764. * 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.
  11765. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11766. * @example https://doc.babylonjs.com/babylon101/particles
  11767. */
  11768. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11769. /**
  11770. * Billboard mode will only apply to Y axis
  11771. */
  11772. static readonly BILLBOARDMODE_Y: number;
  11773. /**
  11774. * Billboard mode will apply to all axes
  11775. */
  11776. static readonly BILLBOARDMODE_ALL: number;
  11777. /**
  11778. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11779. */
  11780. static readonly BILLBOARDMODE_STRETCHED: number;
  11781. /**
  11782. * This function can be defined to provide custom update for active particles.
  11783. * This function will be called instead of regular update (age, position, color, etc.).
  11784. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11785. */
  11786. updateFunction: (particles: Particle[]) => void;
  11787. private _emitterWorldMatrix;
  11788. /**
  11789. * This function can be defined to specify initial direction for every new particle.
  11790. * It by default use the emitterType defined function
  11791. */
  11792. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11793. /**
  11794. * This function can be defined to specify initial position for every new particle.
  11795. * It by default use the emitterType defined function
  11796. */
  11797. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11798. /**
  11799. * @hidden
  11800. */
  11801. _inheritedVelocityOffset: Vector3;
  11802. /**
  11803. * An event triggered when the system is disposed
  11804. */
  11805. onDisposeObservable: Observable<ParticleSystem>;
  11806. private _onDisposeObserver;
  11807. /**
  11808. * Sets a callback that will be triggered when the system is disposed
  11809. */
  11810. set onDispose(callback: () => void);
  11811. private _particles;
  11812. private _epsilon;
  11813. private _capacity;
  11814. private _stockParticles;
  11815. private _newPartsExcess;
  11816. private _vertexData;
  11817. private _vertexBuffer;
  11818. private _vertexBuffers;
  11819. private _spriteBuffer;
  11820. private _indexBuffer;
  11821. private _effect;
  11822. private _customEffect;
  11823. private _cachedDefines;
  11824. private _scaledColorStep;
  11825. private _colorDiff;
  11826. private _scaledDirection;
  11827. private _scaledGravity;
  11828. private _currentRenderId;
  11829. private _alive;
  11830. private _useInstancing;
  11831. private _started;
  11832. private _stopped;
  11833. private _actualFrame;
  11834. private _scaledUpdateSpeed;
  11835. private _vertexBufferSize;
  11836. /** @hidden */
  11837. _currentEmitRateGradient: Nullable<FactorGradient>;
  11838. /** @hidden */
  11839. _currentEmitRate1: number;
  11840. /** @hidden */
  11841. _currentEmitRate2: number;
  11842. /** @hidden */
  11843. _currentStartSizeGradient: Nullable<FactorGradient>;
  11844. /** @hidden */
  11845. _currentStartSize1: number;
  11846. /** @hidden */
  11847. _currentStartSize2: number;
  11848. private readonly _rawTextureWidth;
  11849. private _rampGradientsTexture;
  11850. private _useRampGradients;
  11851. /** Gets or sets a boolean indicating that ramp gradients must be used
  11852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11853. */
  11854. get useRampGradients(): boolean;
  11855. set useRampGradients(value: boolean);
  11856. /**
  11857. * 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.
  11858. * 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: [])
  11859. */
  11860. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11861. private _subEmitters;
  11862. /**
  11863. * @hidden
  11864. * If the particle systems emitter should be disposed when the particle system is disposed
  11865. */
  11866. _disposeEmitterOnDispose: boolean;
  11867. /**
  11868. * The current active Sub-systems, this property is used by the root particle system only.
  11869. */
  11870. activeSubSystems: Array<ParticleSystem>;
  11871. private _rootParticleSystem;
  11872. /**
  11873. * Gets the current list of active particles
  11874. */
  11875. get particles(): Particle[];
  11876. /**
  11877. * Returns the string "ParticleSystem"
  11878. * @returns a string containing the class name
  11879. */
  11880. getClassName(): string;
  11881. /**
  11882. * Instantiates a particle system.
  11883. * 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.
  11884. * @param name The name of the particle system
  11885. * @param capacity The max number of particles alive at the same time
  11886. * @param scene The scene the particle system belongs to
  11887. * @param customEffect a custom effect used to change the way particles are rendered by default
  11888. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11889. * @param epsilon Offset used to render the particles
  11890. */
  11891. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11892. private _addFactorGradient;
  11893. private _removeFactorGradient;
  11894. /**
  11895. * Adds a new life time gradient
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param factor defines the life time factor to affect to the specified gradient
  11898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11899. * @returns the current particle system
  11900. */
  11901. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11902. /**
  11903. * Remove a specific life time gradient
  11904. * @param gradient defines the gradient to remove
  11905. * @returns the current particle system
  11906. */
  11907. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11908. /**
  11909. * Adds a new size gradient
  11910. * @param gradient defines the gradient to use (between 0 and 1)
  11911. * @param factor defines the size factor to affect to the specified gradient
  11912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11913. * @returns the current particle system
  11914. */
  11915. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11916. /**
  11917. * Remove a specific size gradient
  11918. * @param gradient defines the gradient to remove
  11919. * @returns the current particle system
  11920. */
  11921. removeSizeGradient(gradient: number): IParticleSystem;
  11922. /**
  11923. * Adds a new color remap gradient
  11924. * @param gradient defines the gradient to use (between 0 and 1)
  11925. * @param min defines the color remap minimal range
  11926. * @param max defines the color remap maximal range
  11927. * @returns the current particle system
  11928. */
  11929. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11930. /**
  11931. * Remove a specific color remap gradient
  11932. * @param gradient defines the gradient to remove
  11933. * @returns the current particle system
  11934. */
  11935. removeColorRemapGradient(gradient: number): IParticleSystem;
  11936. /**
  11937. * Adds a new alpha remap gradient
  11938. * @param gradient defines the gradient to use (between 0 and 1)
  11939. * @param min defines the alpha remap minimal range
  11940. * @param max defines the alpha remap maximal range
  11941. * @returns the current particle system
  11942. */
  11943. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11944. /**
  11945. * Remove a specific alpha remap gradient
  11946. * @param gradient defines the gradient to remove
  11947. * @returns the current particle system
  11948. */
  11949. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11950. /**
  11951. * Adds a new angular speed gradient
  11952. * @param gradient defines the gradient to use (between 0 and 1)
  11953. * @param factor defines the angular speed to affect to the specified gradient
  11954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11955. * @returns the current particle system
  11956. */
  11957. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11958. /**
  11959. * Remove a specific angular speed gradient
  11960. * @param gradient defines the gradient to remove
  11961. * @returns the current particle system
  11962. */
  11963. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11964. /**
  11965. * Adds a new velocity gradient
  11966. * @param gradient defines the gradient to use (between 0 and 1)
  11967. * @param factor defines the velocity to affect to the specified gradient
  11968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11969. * @returns the current particle system
  11970. */
  11971. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11972. /**
  11973. * Remove a specific velocity gradient
  11974. * @param gradient defines the gradient to remove
  11975. * @returns the current particle system
  11976. */
  11977. removeVelocityGradient(gradient: number): IParticleSystem;
  11978. /**
  11979. * Adds a new limit velocity gradient
  11980. * @param gradient defines the gradient to use (between 0 and 1)
  11981. * @param factor defines the limit velocity value to affect to the specified gradient
  11982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11983. * @returns the current particle system
  11984. */
  11985. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11986. /**
  11987. * Remove a specific limit velocity gradient
  11988. * @param gradient defines the gradient to remove
  11989. * @returns the current particle system
  11990. */
  11991. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11992. /**
  11993. * Adds a new drag gradient
  11994. * @param gradient defines the gradient to use (between 0 and 1)
  11995. * @param factor defines the drag value to affect to the specified gradient
  11996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11997. * @returns the current particle system
  11998. */
  11999. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12000. /**
  12001. * Remove a specific drag gradient
  12002. * @param gradient defines the gradient to remove
  12003. * @returns the current particle system
  12004. */
  12005. removeDragGradient(gradient: number): IParticleSystem;
  12006. /**
  12007. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12008. * @param gradient defines the gradient to use (between 0 and 1)
  12009. * @param factor defines the emit rate value to affect to the specified gradient
  12010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12011. * @returns the current particle system
  12012. */
  12013. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12014. /**
  12015. * Remove a specific emit rate gradient
  12016. * @param gradient defines the gradient to remove
  12017. * @returns the current particle system
  12018. */
  12019. removeEmitRateGradient(gradient: number): IParticleSystem;
  12020. /**
  12021. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12022. * @param gradient defines the gradient to use (between 0 and 1)
  12023. * @param factor defines the start size value to affect to the specified gradient
  12024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12025. * @returns the current particle system
  12026. */
  12027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12028. /**
  12029. * Remove a specific start size gradient
  12030. * @param gradient defines the gradient to remove
  12031. * @returns the current particle system
  12032. */
  12033. removeStartSizeGradient(gradient: number): IParticleSystem;
  12034. private _createRampGradientTexture;
  12035. /**
  12036. * Gets the current list of ramp gradients.
  12037. * You must use addRampGradient and removeRampGradient to udpate this list
  12038. * @returns the list of ramp gradients
  12039. */
  12040. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12041. /**
  12042. * Adds a new ramp gradient used to remap particle colors
  12043. * @param gradient defines the gradient to use (between 0 and 1)
  12044. * @param color defines the color to affect to the specified gradient
  12045. * @returns the current particle system
  12046. */
  12047. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12048. /**
  12049. * Remove a specific ramp gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeRampGradient(gradient: number): ParticleSystem;
  12054. /**
  12055. * Adds a new color gradient
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param color1 defines the color to affect to the specified gradient
  12058. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12059. * @returns this particle system
  12060. */
  12061. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12062. /**
  12063. * Remove a specific color gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns this particle system
  12066. */
  12067. removeColorGradient(gradient: number): IParticleSystem;
  12068. private _fetchR;
  12069. protected _reset(): void;
  12070. private _resetEffect;
  12071. private _createVertexBuffers;
  12072. private _createIndexBuffer;
  12073. /**
  12074. * Gets the maximum number of particles active at the same time.
  12075. * @returns The max number of active particles.
  12076. */
  12077. getCapacity(): number;
  12078. /**
  12079. * Gets whether there are still active particles in the system.
  12080. * @returns True if it is alive, otherwise false.
  12081. */
  12082. isAlive(): boolean;
  12083. /**
  12084. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12085. * @returns True if it has been started, otherwise false.
  12086. */
  12087. isStarted(): boolean;
  12088. private _prepareSubEmitterInternalArray;
  12089. /**
  12090. * Starts the particle system and begins to emit
  12091. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12092. */
  12093. start(delay?: number): void;
  12094. /**
  12095. * Stops the particle system.
  12096. * @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.
  12097. */
  12098. stop(stopSubEmitters?: boolean): void;
  12099. /**
  12100. * Remove all active particles
  12101. */
  12102. reset(): void;
  12103. /**
  12104. * @hidden (for internal use only)
  12105. */
  12106. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12107. /**
  12108. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12109. * Its lifetime will start back at 0.
  12110. */
  12111. recycleParticle: (particle: Particle) => void;
  12112. private _stopSubEmitters;
  12113. private _createParticle;
  12114. private _removeFromRoot;
  12115. private _emitFromParticle;
  12116. private _update;
  12117. /** @hidden */
  12118. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12119. /** @hidden */
  12120. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12121. /** @hidden */
  12122. private _getEffect;
  12123. /**
  12124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12125. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12126. */
  12127. animate(preWarmOnly?: boolean): void;
  12128. private _appendParticleVertices;
  12129. /**
  12130. * Rebuilds the particle system.
  12131. */
  12132. rebuild(): void;
  12133. /**
  12134. * Is this system ready to be used/rendered
  12135. * @return true if the system is ready
  12136. */
  12137. isReady(): boolean;
  12138. private _render;
  12139. /**
  12140. * Renders the particle system in its current state.
  12141. * @returns the current number of particles
  12142. */
  12143. render(): number;
  12144. /**
  12145. * Disposes the particle system and free the associated resources
  12146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12147. */
  12148. dispose(disposeTexture?: boolean): void;
  12149. /**
  12150. * Clones the particle system.
  12151. * @param name The name of the cloned object
  12152. * @param newEmitter The new emitter to use
  12153. * @returns the cloned particle system
  12154. */
  12155. clone(name: string, newEmitter: any): ParticleSystem;
  12156. /**
  12157. * Serializes the particle system to a JSON object.
  12158. * @returns the JSON object
  12159. */
  12160. serialize(): any;
  12161. /** @hidden */
  12162. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12163. /** @hidden */
  12164. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12165. /**
  12166. * Parses a JSON object to create a particle system.
  12167. * @param parsedParticleSystem The JSON object to parse
  12168. * @param scene The scene to create the particle system in
  12169. * @param rootUrl The root url to use to load external dependencies like texture
  12170. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12171. * @returns the Parsed particle system
  12172. */
  12173. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12174. }
  12175. }
  12176. declare module "babylonjs/Particles/particle" {
  12177. import { Nullable } from "babylonjs/types";
  12178. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12181. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12182. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12183. /**
  12184. * A particle represents one of the element emitted by a particle system.
  12185. * This is mainly define by its coordinates, direction, velocity and age.
  12186. */
  12187. export class Particle {
  12188. /**
  12189. * The particle system the particle belongs to.
  12190. */
  12191. particleSystem: ParticleSystem;
  12192. private static _Count;
  12193. /**
  12194. * Unique ID of the particle
  12195. */
  12196. id: number;
  12197. /**
  12198. * The world position of the particle in the scene.
  12199. */
  12200. position: Vector3;
  12201. /**
  12202. * The world direction of the particle in the scene.
  12203. */
  12204. direction: Vector3;
  12205. /**
  12206. * The color of the particle.
  12207. */
  12208. color: Color4;
  12209. /**
  12210. * The color change of the particle per step.
  12211. */
  12212. colorStep: Color4;
  12213. /**
  12214. * Defines how long will the life of the particle be.
  12215. */
  12216. lifeTime: number;
  12217. /**
  12218. * The current age of the particle.
  12219. */
  12220. age: number;
  12221. /**
  12222. * The current size of the particle.
  12223. */
  12224. size: number;
  12225. /**
  12226. * The current scale of the particle.
  12227. */
  12228. scale: Vector2;
  12229. /**
  12230. * The current angle of the particle.
  12231. */
  12232. angle: number;
  12233. /**
  12234. * Defines how fast is the angle changing.
  12235. */
  12236. angularSpeed: number;
  12237. /**
  12238. * Defines the cell index used by the particle to be rendered from a sprite.
  12239. */
  12240. cellIndex: number;
  12241. /**
  12242. * The information required to support color remapping
  12243. */
  12244. remapData: Vector4;
  12245. /** @hidden */
  12246. _randomCellOffset?: number;
  12247. /** @hidden */
  12248. _initialDirection: Nullable<Vector3>;
  12249. /** @hidden */
  12250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12251. /** @hidden */
  12252. _initialStartSpriteCellID: number;
  12253. /** @hidden */
  12254. _initialEndSpriteCellID: number;
  12255. /** @hidden */
  12256. _currentColorGradient: Nullable<ColorGradient>;
  12257. /** @hidden */
  12258. _currentColor1: Color4;
  12259. /** @hidden */
  12260. _currentColor2: Color4;
  12261. /** @hidden */
  12262. _currentSizeGradient: Nullable<FactorGradient>;
  12263. /** @hidden */
  12264. _currentSize1: number;
  12265. /** @hidden */
  12266. _currentSize2: number;
  12267. /** @hidden */
  12268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12269. /** @hidden */
  12270. _currentAngularSpeed1: number;
  12271. /** @hidden */
  12272. _currentAngularSpeed2: number;
  12273. /** @hidden */
  12274. _currentVelocityGradient: Nullable<FactorGradient>;
  12275. /** @hidden */
  12276. _currentVelocity1: number;
  12277. /** @hidden */
  12278. _currentVelocity2: number;
  12279. /** @hidden */
  12280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12281. /** @hidden */
  12282. _currentLimitVelocity1: number;
  12283. /** @hidden */
  12284. _currentLimitVelocity2: number;
  12285. /** @hidden */
  12286. _currentDragGradient: Nullable<FactorGradient>;
  12287. /** @hidden */
  12288. _currentDrag1: number;
  12289. /** @hidden */
  12290. _currentDrag2: number;
  12291. /** @hidden */
  12292. _randomNoiseCoordinates1: Vector3;
  12293. /** @hidden */
  12294. _randomNoiseCoordinates2: Vector3;
  12295. /**
  12296. * Creates a new instance Particle
  12297. * @param particleSystem the particle system the particle belongs to
  12298. */
  12299. constructor(
  12300. /**
  12301. * The particle system the particle belongs to.
  12302. */
  12303. particleSystem: ParticleSystem);
  12304. private updateCellInfoFromSystem;
  12305. /**
  12306. * Defines how the sprite cell index is updated for the particle
  12307. */
  12308. updateCellIndex(): void;
  12309. /** @hidden */
  12310. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12311. /** @hidden */
  12312. _inheritParticleInfoToSubEmitters(): void;
  12313. /** @hidden */
  12314. _reset(): void;
  12315. /**
  12316. * Copy the properties of particle to another one.
  12317. * @param other the particle to copy the information to.
  12318. */
  12319. copyTo(other: Particle): void;
  12320. }
  12321. }
  12322. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12323. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12324. import { Effect } from "babylonjs/Materials/effect";
  12325. import { Particle } from "babylonjs/Particles/particle";
  12326. import { Scene } from "babylonjs/scene";
  12327. /**
  12328. * Particle emitter represents a volume emitting particles.
  12329. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12330. */
  12331. export interface IParticleEmitterType {
  12332. /**
  12333. * Called by the particle System when the direction is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param directionToUpdate is the direction vector to update with the result
  12336. * @param particle is the particle we are computed the direction for
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. */
  12345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12346. /**
  12347. * Clones the current emitter and returns a copy of it
  12348. * @returns the new emitter
  12349. */
  12350. clone(): IParticleEmitterType;
  12351. /**
  12352. * Called by the GPUParticleSystem to setup the update shader
  12353. * @param effect defines the update shader
  12354. */
  12355. applyToShader(effect: Effect): void;
  12356. /**
  12357. * Returns a string to use to update the GPU particles update shader
  12358. * @returns the effect defines string
  12359. */
  12360. getEffectDefines(): string;
  12361. /**
  12362. * Returns a string representing the class name
  12363. * @returns a string containing the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Serializes the particle system to a JSON object.
  12368. * @returns the JSON object
  12369. */
  12370. serialize(): any;
  12371. /**
  12372. * Parse properties from a JSON object
  12373. * @param serializationObject defines the JSON object
  12374. * @param scene defines the hosting scene
  12375. */
  12376. parse(serializationObject: any, scene: Scene): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12380. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12381. import { Effect } from "babylonjs/Materials/effect";
  12382. import { Particle } from "babylonjs/Particles/particle";
  12383. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12384. /**
  12385. * Particle emitter emitting particles from the inside of a box.
  12386. * It emits the particles randomly between 2 given directions.
  12387. */
  12388. export class BoxParticleEmitter implements IParticleEmitterType {
  12389. /**
  12390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12391. */
  12392. direction1: Vector3;
  12393. /**
  12394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12395. */
  12396. direction2: Vector3;
  12397. /**
  12398. * 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.
  12399. */
  12400. minEmitBox: Vector3;
  12401. /**
  12402. * 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.
  12403. */
  12404. maxEmitBox: Vector3;
  12405. /**
  12406. * Creates a new instance BoxParticleEmitter
  12407. */
  12408. constructor();
  12409. /**
  12410. * Called by the particle System when the direction is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param directionToUpdate is the direction vector to update with the result
  12413. * @param particle is the particle we are computed the direction for
  12414. */
  12415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Called by the particle System when the position is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param positionToUpdate is the position vector to update with the result
  12420. * @param particle is the particle we are computed the position for
  12421. */
  12422. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12423. /**
  12424. * Clones the current emitter and returns a copy of it
  12425. * @returns the new emitter
  12426. */
  12427. clone(): BoxParticleEmitter;
  12428. /**
  12429. * Called by the GPUParticleSystem to setup the update shader
  12430. * @param effect defines the update shader
  12431. */
  12432. applyToShader(effect: Effect): void;
  12433. /**
  12434. * Returns a string to use to update the GPU particles update shader
  12435. * @returns a string containng the defines string
  12436. */
  12437. getEffectDefines(): string;
  12438. /**
  12439. * Returns the string "BoxParticleEmitter"
  12440. * @returns a string containing the class name
  12441. */
  12442. getClassName(): string;
  12443. /**
  12444. * Serializes the particle system to a JSON object.
  12445. * @returns the JSON object
  12446. */
  12447. serialize(): any;
  12448. /**
  12449. * Parse properties from a JSON object
  12450. * @param serializationObject defines the JSON object
  12451. */
  12452. parse(serializationObject: any): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12456. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12457. import { Effect } from "babylonjs/Materials/effect";
  12458. import { Particle } from "babylonjs/Particles/particle";
  12459. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12460. /**
  12461. * Particle emitter emitting particles from the inside of a cone.
  12462. * It emits the particles alongside the cone volume from the base to the particle.
  12463. * The emission direction might be randomized.
  12464. */
  12465. export class ConeParticleEmitter implements IParticleEmitterType {
  12466. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12467. directionRandomizer: number;
  12468. private _radius;
  12469. private _angle;
  12470. private _height;
  12471. /**
  12472. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12473. */
  12474. radiusRange: number;
  12475. /**
  12476. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12477. */
  12478. heightRange: number;
  12479. /**
  12480. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12481. */
  12482. emitFromSpawnPointOnly: boolean;
  12483. /**
  12484. * Gets or sets the radius of the emission cone
  12485. */
  12486. get radius(): number;
  12487. set radius(value: number);
  12488. /**
  12489. * Gets or sets the angle of the emission cone
  12490. */
  12491. get angle(): number;
  12492. set angle(value: number);
  12493. private _buildHeight;
  12494. /**
  12495. * Creates a new instance ConeParticleEmitter
  12496. * @param radius the radius of the emission cone (1 by default)
  12497. * @param angle the cone base angle (PI by default)
  12498. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12499. */
  12500. constructor(radius?: number, angle?: number,
  12501. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12502. directionRandomizer?: number);
  12503. /**
  12504. * Called by the particle System when the direction is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param directionToUpdate is the direction vector to update with the result
  12507. * @param particle is the particle we are computed the direction for
  12508. */
  12509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Called by the particle System when the position is computed for the created particle.
  12512. * @param worldMatrix is the world matrix of the particle system
  12513. * @param positionToUpdate is the position vector to update with the result
  12514. * @param particle is the particle we are computed the position for
  12515. */
  12516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12517. /**
  12518. * Clones the current emitter and returns a copy of it
  12519. * @returns the new emitter
  12520. */
  12521. clone(): ConeParticleEmitter;
  12522. /**
  12523. * Called by the GPUParticleSystem to setup the update shader
  12524. * @param effect defines the update shader
  12525. */
  12526. applyToShader(effect: Effect): void;
  12527. /**
  12528. * Returns a string to use to update the GPU particles update shader
  12529. * @returns a string containng the defines string
  12530. */
  12531. getEffectDefines(): string;
  12532. /**
  12533. * Returns the string "ConeParticleEmitter"
  12534. * @returns a string containing the class name
  12535. */
  12536. getClassName(): string;
  12537. /**
  12538. * Serializes the particle system to a JSON object.
  12539. * @returns the JSON object
  12540. */
  12541. serialize(): any;
  12542. /**
  12543. * Parse properties from a JSON object
  12544. * @param serializationObject defines the JSON object
  12545. */
  12546. parse(serializationObject: any): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12550. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12551. import { Effect } from "babylonjs/Materials/effect";
  12552. import { Particle } from "babylonjs/Particles/particle";
  12553. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12554. /**
  12555. * Particle emitter emitting particles from the inside of a cylinder.
  12556. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12557. */
  12558. export class CylinderParticleEmitter implements IParticleEmitterType {
  12559. /**
  12560. * The radius of the emission cylinder.
  12561. */
  12562. radius: number;
  12563. /**
  12564. * The height of the emission cylinder.
  12565. */
  12566. height: number;
  12567. /**
  12568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12569. */
  12570. radiusRange: number;
  12571. /**
  12572. * How much to randomize the particle direction [0-1].
  12573. */
  12574. directionRandomizer: number;
  12575. /**
  12576. * Creates a new instance CylinderParticleEmitter
  12577. * @param radius the radius of the emission cylinder (1 by default)
  12578. * @param height the height of the emission cylinder (1 by default)
  12579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12581. */
  12582. constructor(
  12583. /**
  12584. * The radius of the emission cylinder.
  12585. */
  12586. radius?: number,
  12587. /**
  12588. * The height of the emission cylinder.
  12589. */
  12590. height?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. */
  12605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Called by the particle System when the position is computed for the created particle.
  12608. * @param worldMatrix is the world matrix of the particle system
  12609. * @param positionToUpdate is the position vector to update with the result
  12610. * @param particle is the particle we are computed the position for
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): CylinderParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "CylinderParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. /**
  12645. * Particle emitter emitting particles from the inside of a cylinder.
  12646. * It emits the particles randomly between two vectors.
  12647. */
  12648. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12649. /**
  12650. * The min limit of the emission direction.
  12651. */
  12652. direction1: Vector3;
  12653. /**
  12654. * The max limit of the emission direction.
  12655. */
  12656. direction2: Vector3;
  12657. /**
  12658. * Creates a new instance CylinderDirectedParticleEmitter
  12659. * @param radius the radius of the emission cylinder (1 by default)
  12660. * @param height the height of the emission cylinder (1 by default)
  12661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12662. * @param direction1 the min limit of the emission direction (up vector by default)
  12663. * @param direction2 the max limit of the emission direction (up vector by default)
  12664. */
  12665. constructor(radius?: number, height?: number, radiusRange?: number,
  12666. /**
  12667. * The min limit of the emission direction.
  12668. */
  12669. direction1?: Vector3,
  12670. /**
  12671. * The max limit of the emission direction.
  12672. */
  12673. direction2?: Vector3);
  12674. /**
  12675. * Called by the particle System when the direction is computed for the created particle.
  12676. * @param worldMatrix is the world matrix of the particle system
  12677. * @param directionToUpdate is the direction vector to update with the result
  12678. * @param particle is the particle we are computed the direction for
  12679. */
  12680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): CylinderDirectedParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "CylinderDirectedParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12714. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12715. import { Effect } from "babylonjs/Materials/effect";
  12716. import { Particle } from "babylonjs/Particles/particle";
  12717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12718. /**
  12719. * Particle emitter emitting particles from the inside of a hemisphere.
  12720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12721. */
  12722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12723. /**
  12724. * The radius of the emission hemisphere.
  12725. */
  12726. radius: number;
  12727. /**
  12728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12729. */
  12730. radiusRange: number;
  12731. /**
  12732. * How much to randomize the particle direction [0-1].
  12733. */
  12734. directionRandomizer: number;
  12735. /**
  12736. * Creates a new instance HemisphericParticleEmitter
  12737. * @param radius the radius of the emission hemisphere (1 by default)
  12738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12740. */
  12741. constructor(
  12742. /**
  12743. * The radius of the emission hemisphere.
  12744. */
  12745. radius?: number,
  12746. /**
  12747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12748. */
  12749. radiusRange?: number,
  12750. /**
  12751. * How much to randomize the particle direction [0-1].
  12752. */
  12753. directionRandomizer?: number);
  12754. /**
  12755. * Called by the particle System when the direction is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param directionToUpdate is the direction vector to update with the result
  12758. * @param particle is the particle we are computed the direction for
  12759. */
  12760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Called by the particle System when the position is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param positionToUpdate is the position vector to update with the result
  12765. * @param particle is the particle we are computed the position for
  12766. */
  12767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12768. /**
  12769. * Clones the current emitter and returns a copy of it
  12770. * @returns the new emitter
  12771. */
  12772. clone(): HemisphericParticleEmitter;
  12773. /**
  12774. * Called by the GPUParticleSystem to setup the update shader
  12775. * @param effect defines the update shader
  12776. */
  12777. applyToShader(effect: Effect): void;
  12778. /**
  12779. * Returns a string to use to update the GPU particles update shader
  12780. * @returns a string containng the defines string
  12781. */
  12782. getEffectDefines(): string;
  12783. /**
  12784. * Returns the string "HemisphericParticleEmitter"
  12785. * @returns a string containing the class name
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Serializes the particle system to a JSON object.
  12790. * @returns the JSON object
  12791. */
  12792. serialize(): any;
  12793. /**
  12794. * Parse properties from a JSON object
  12795. * @param serializationObject defines the JSON object
  12796. */
  12797. parse(serializationObject: any): void;
  12798. }
  12799. }
  12800. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12801. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Particle } from "babylonjs/Particles/particle";
  12804. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12805. /**
  12806. * Particle emitter emitting particles from a point.
  12807. * It emits the particles randomly between 2 given directions.
  12808. */
  12809. export class PointParticleEmitter implements IParticleEmitterType {
  12810. /**
  12811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12812. */
  12813. direction1: Vector3;
  12814. /**
  12815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12816. */
  12817. direction2: Vector3;
  12818. /**
  12819. * Creates a new instance PointParticleEmitter
  12820. */
  12821. constructor();
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): PointParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "PointParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. */
  12865. parse(serializationObject: any): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12870. import { Effect } from "babylonjs/Materials/effect";
  12871. import { Particle } from "babylonjs/Particles/particle";
  12872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12873. /**
  12874. * Particle emitter emitting particles from the inside of a sphere.
  12875. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12876. */
  12877. export class SphereParticleEmitter implements IParticleEmitterType {
  12878. /**
  12879. * The radius of the emission sphere.
  12880. */
  12881. radius: number;
  12882. /**
  12883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12884. */
  12885. radiusRange: number;
  12886. /**
  12887. * How much to randomize the particle direction [0-1].
  12888. */
  12889. directionRandomizer: number;
  12890. /**
  12891. * Creates a new instance SphereParticleEmitter
  12892. * @param radius the radius of the emission sphere (1 by default)
  12893. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12895. */
  12896. constructor(
  12897. /**
  12898. * The radius of the emission sphere.
  12899. */
  12900. radius?: number,
  12901. /**
  12902. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12903. */
  12904. radiusRange?: number,
  12905. /**
  12906. * How much to randomize the particle direction [0-1].
  12907. */
  12908. directionRandomizer?: number);
  12909. /**
  12910. * Called by the particle System when the direction is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param directionToUpdate is the direction vector to update with the result
  12913. * @param particle is the particle we are computed the direction for
  12914. */
  12915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Called by the particle System when the position is computed for the created particle.
  12918. * @param worldMatrix is the world matrix of the particle system
  12919. * @param positionToUpdate is the position vector to update with the result
  12920. * @param particle is the particle we are computed the position for
  12921. */
  12922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12923. /**
  12924. * Clones the current emitter and returns a copy of it
  12925. * @returns the new emitter
  12926. */
  12927. clone(): SphereParticleEmitter;
  12928. /**
  12929. * Called by the GPUParticleSystem to setup the update shader
  12930. * @param effect defines the update shader
  12931. */
  12932. applyToShader(effect: Effect): void;
  12933. /**
  12934. * Returns a string to use to update the GPU particles update shader
  12935. * @returns a string containng the defines string
  12936. */
  12937. getEffectDefines(): string;
  12938. /**
  12939. * Returns the string "SphereParticleEmitter"
  12940. * @returns a string containing the class name
  12941. */
  12942. getClassName(): string;
  12943. /**
  12944. * Serializes the particle system to a JSON object.
  12945. * @returns the JSON object
  12946. */
  12947. serialize(): any;
  12948. /**
  12949. * Parse properties from a JSON object
  12950. * @param serializationObject defines the JSON object
  12951. */
  12952. parse(serializationObject: any): void;
  12953. }
  12954. /**
  12955. * Particle emitter emitting particles from the inside of a sphere.
  12956. * It emits the particles randomly between two vectors.
  12957. */
  12958. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12959. /**
  12960. * The min limit of the emission direction.
  12961. */
  12962. direction1: Vector3;
  12963. /**
  12964. * The max limit of the emission direction.
  12965. */
  12966. direction2: Vector3;
  12967. /**
  12968. * Creates a new instance SphereDirectedParticleEmitter
  12969. * @param radius the radius of the emission sphere (1 by default)
  12970. * @param direction1 the min limit of the emission direction (up vector by default)
  12971. * @param direction2 the max limit of the emission direction (up vector by default)
  12972. */
  12973. constructor(radius?: number,
  12974. /**
  12975. * The min limit of the emission direction.
  12976. */
  12977. direction1?: Vector3,
  12978. /**
  12979. * The max limit of the emission direction.
  12980. */
  12981. direction2?: Vector3);
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. */
  12988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12989. /**
  12990. * Clones the current emitter and returns a copy of it
  12991. * @returns the new emitter
  12992. */
  12993. clone(): SphereDirectedParticleEmitter;
  12994. /**
  12995. * Called by the GPUParticleSystem to setup the update shader
  12996. * @param effect defines the update shader
  12997. */
  12998. applyToShader(effect: Effect): void;
  12999. /**
  13000. * Returns a string to use to update the GPU particles update shader
  13001. * @returns a string containng the defines string
  13002. */
  13003. getEffectDefines(): string;
  13004. /**
  13005. * Returns the string "SphereDirectedParticleEmitter"
  13006. * @returns a string containing the class name
  13007. */
  13008. getClassName(): string;
  13009. /**
  13010. * Serializes the particle system to a JSON object.
  13011. * @returns the JSON object
  13012. */
  13013. serialize(): any;
  13014. /**
  13015. * Parse properties from a JSON object
  13016. * @param serializationObject defines the JSON object
  13017. */
  13018. parse(serializationObject: any): void;
  13019. }
  13020. }
  13021. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13023. import { Effect } from "babylonjs/Materials/effect";
  13024. import { Particle } from "babylonjs/Particles/particle";
  13025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13026. import { Nullable } from "babylonjs/types";
  13027. /**
  13028. * Particle emitter emitting particles from a custom list of positions.
  13029. */
  13030. export class CustomParticleEmitter implements IParticleEmitterType {
  13031. /**
  13032. * Gets or sets the position generator that will create the inital position of each particle.
  13033. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13034. */
  13035. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13036. /**
  13037. * Gets or sets the destination generator that will create the final destination of each particle.
  13038. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13039. */
  13040. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13041. /**
  13042. * Creates a new instance CustomParticleEmitter
  13043. */
  13044. constructor();
  13045. /**
  13046. * Called by the particle System when the direction is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param directionToUpdate is the direction vector to update with the result
  13049. * @param particle is the particle we are computed the direction for
  13050. */
  13051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Called by the particle System when the position is computed for the created particle.
  13054. * @param worldMatrix is the world matrix of the particle system
  13055. * @param positionToUpdate is the position vector to update with the result
  13056. * @param particle is the particle we are computed the position for
  13057. */
  13058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13059. /**
  13060. * Clones the current emitter and returns a copy of it
  13061. * @returns the new emitter
  13062. */
  13063. clone(): CustomParticleEmitter;
  13064. /**
  13065. * Called by the GPUParticleSystem to setup the update shader
  13066. * @param effect defines the update shader
  13067. */
  13068. applyToShader(effect: Effect): void;
  13069. /**
  13070. * Returns a string to use to update the GPU particles update shader
  13071. * @returns a string containng the defines string
  13072. */
  13073. getEffectDefines(): string;
  13074. /**
  13075. * Returns the string "PointParticleEmitter"
  13076. * @returns a string containing the class name
  13077. */
  13078. getClassName(): string;
  13079. /**
  13080. * Serializes the particle system to a JSON object.
  13081. * @returns the JSON object
  13082. */
  13083. serialize(): any;
  13084. /**
  13085. * Parse properties from a JSON object
  13086. * @param serializationObject defines the JSON object
  13087. */
  13088. parse(serializationObject: any): void;
  13089. }
  13090. }
  13091. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13093. import { Effect } from "babylonjs/Materials/effect";
  13094. import { Particle } from "babylonjs/Particles/particle";
  13095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13096. import { Scene } from "babylonjs/scene";
  13097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13098. /**
  13099. * Particle emitter emitting particles from the inside of a box.
  13100. * It emits the particles randomly between 2 given directions.
  13101. */
  13102. export class MeshParticleEmitter implements IParticleEmitterType {
  13103. /** Defines the mesh to use as source */
  13104. mesh?: AbstractMesh | undefined;
  13105. private _indices;
  13106. private _positions;
  13107. private _normals;
  13108. private _storedNormal;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction1: Vector3;
  13113. /**
  13114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13115. */
  13116. direction2: Vector3;
  13117. /**
  13118. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13119. */
  13120. useMeshNormalsForDirection: boolean;
  13121. /**
  13122. * Creates a new instance MeshParticleEmitter
  13123. * @param mesh defines the mesh to use as source
  13124. */
  13125. constructor(
  13126. /** Defines the mesh to use as source */
  13127. mesh?: AbstractMesh | undefined);
  13128. /**
  13129. * Called by the particle System when the direction is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param directionToUpdate is the direction vector to update with the result
  13132. * @param particle is the particle we are computed the direction for
  13133. */
  13134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Called by the particle System when the position is computed for the created particle.
  13137. * @param worldMatrix is the world matrix of the particle system
  13138. * @param positionToUpdate is the position vector to update with the result
  13139. * @param particle is the particle we are computed the position for
  13140. */
  13141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13142. /**
  13143. * Clones the current emitter and returns a copy of it
  13144. * @returns the new emitter
  13145. */
  13146. clone(): MeshParticleEmitter;
  13147. /**
  13148. * Called by the GPUParticleSystem to setup the update shader
  13149. * @param effect defines the update shader
  13150. */
  13151. applyToShader(effect: Effect): void;
  13152. /**
  13153. * Returns a string to use to update the GPU particles update shader
  13154. * @returns a string containng the defines string
  13155. */
  13156. getEffectDefines(): string;
  13157. /**
  13158. * Returns the string "BoxParticleEmitter"
  13159. * @returns a string containing the class name
  13160. */
  13161. getClassName(): string;
  13162. /**
  13163. * Serializes the particle system to a JSON object.
  13164. * @returns the JSON object
  13165. */
  13166. serialize(): any;
  13167. /**
  13168. * Parse properties from a JSON object
  13169. * @param serializationObject defines the JSON object
  13170. * @param scene defines the hosting scene
  13171. */
  13172. parse(serializationObject: any, scene: Scene): void;
  13173. }
  13174. }
  13175. declare module "babylonjs/Particles/EmitterTypes/index" {
  13176. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13178. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13179. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13180. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13181. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13182. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13183. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13184. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13185. }
  13186. declare module "babylonjs/Particles/IParticleSystem" {
  13187. import { Nullable } from "babylonjs/types";
  13188. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13189. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13192. import { Texture } from "babylonjs/Materials/Textures/texture";
  13193. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13194. import { Scene } from "babylonjs/scene";
  13195. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13196. import { Animation } from "babylonjs/Animations/animation";
  13197. /**
  13198. * Interface representing a particle system in Babylon.js.
  13199. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13200. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13201. */
  13202. export interface IParticleSystem {
  13203. /**
  13204. * List of animations used by the particle system.
  13205. */
  13206. animations: Animation[];
  13207. /**
  13208. * The id of the Particle system.
  13209. */
  13210. id: string;
  13211. /**
  13212. * The name of the Particle system.
  13213. */
  13214. name: string;
  13215. /**
  13216. * The emitter represents the Mesh or position we are attaching the particle system to.
  13217. */
  13218. emitter: Nullable<AbstractMesh | Vector3>;
  13219. /**
  13220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13221. */
  13222. isBillboardBased: boolean;
  13223. /**
  13224. * The rendering group used by the Particle system to chose when to render.
  13225. */
  13226. renderingGroupId: number;
  13227. /**
  13228. * The layer mask we are rendering the particles through.
  13229. */
  13230. layerMask: number;
  13231. /**
  13232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13233. */
  13234. updateSpeed: number;
  13235. /**
  13236. * The amount of time the particle system is running (depends of the overall update speed).
  13237. */
  13238. targetStopDuration: number;
  13239. /**
  13240. * The texture used to render each particle. (this can be a spritesheet)
  13241. */
  13242. particleTexture: Nullable<Texture>;
  13243. /**
  13244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13245. */
  13246. blendMode: number;
  13247. /**
  13248. * Minimum life time of emitting particles.
  13249. */
  13250. minLifeTime: number;
  13251. /**
  13252. * Maximum life time of emitting particles.
  13253. */
  13254. maxLifeTime: number;
  13255. /**
  13256. * Minimum Size of emitting particles.
  13257. */
  13258. minSize: number;
  13259. /**
  13260. * Maximum Size of emitting particles.
  13261. */
  13262. maxSize: number;
  13263. /**
  13264. * Minimum scale of emitting particles on X axis.
  13265. */
  13266. minScaleX: number;
  13267. /**
  13268. * Maximum scale of emitting particles on X axis.
  13269. */
  13270. maxScaleX: number;
  13271. /**
  13272. * Minimum scale of emitting particles on Y axis.
  13273. */
  13274. minScaleY: number;
  13275. /**
  13276. * Maximum scale of emitting particles on Y axis.
  13277. */
  13278. maxScaleY: number;
  13279. /**
  13280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13281. */
  13282. color1: Color4;
  13283. /**
  13284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13285. */
  13286. color2: Color4;
  13287. /**
  13288. * Color the particle will have at the end of its lifetime.
  13289. */
  13290. colorDead: Color4;
  13291. /**
  13292. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13293. */
  13294. emitRate: number;
  13295. /**
  13296. * You can use gravity if you want to give an orientation to your particles.
  13297. */
  13298. gravity: Vector3;
  13299. /**
  13300. * Minimum power of emitting particles.
  13301. */
  13302. minEmitPower: number;
  13303. /**
  13304. * Maximum power of emitting particles.
  13305. */
  13306. maxEmitPower: number;
  13307. /**
  13308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13309. */
  13310. minAngularSpeed: number;
  13311. /**
  13312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13313. */
  13314. maxAngularSpeed: number;
  13315. /**
  13316. * Gets or sets the minimal initial rotation in radians.
  13317. */
  13318. minInitialRotation: number;
  13319. /**
  13320. * Gets or sets the maximal initial rotation in radians.
  13321. */
  13322. maxInitialRotation: number;
  13323. /**
  13324. * The particle emitter type defines the emitter used by the particle system.
  13325. * It can be for example box, sphere, or cone...
  13326. */
  13327. particleEmitterType: Nullable<IParticleEmitterType>;
  13328. /**
  13329. * Defines the delay in milliseconds before starting the system (0 by default)
  13330. */
  13331. startDelay: number;
  13332. /**
  13333. * 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
  13334. */
  13335. preWarmCycles: number;
  13336. /**
  13337. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13338. */
  13339. preWarmStepOffset: number;
  13340. /**
  13341. * 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)
  13342. */
  13343. spriteCellChangeSpeed: number;
  13344. /**
  13345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13346. */
  13347. startSpriteCellID: number;
  13348. /**
  13349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13350. */
  13351. endSpriteCellID: number;
  13352. /**
  13353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13354. */
  13355. spriteCellWidth: number;
  13356. /**
  13357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13358. */
  13359. spriteCellHeight: number;
  13360. /**
  13361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13362. */
  13363. spriteRandomStartCell: boolean;
  13364. /**
  13365. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13366. */
  13367. isAnimationSheetEnabled: boolean;
  13368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13369. translationPivot: Vector2;
  13370. /**
  13371. * Gets or sets a texture used to add random noise to particle positions
  13372. */
  13373. noiseTexture: Nullable<BaseTexture>;
  13374. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13375. noiseStrength: Vector3;
  13376. /**
  13377. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13378. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13379. */
  13380. billboardMode: number;
  13381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13382. limitVelocityDamping: number;
  13383. /**
  13384. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13385. */
  13386. beginAnimationOnStart: boolean;
  13387. /**
  13388. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13389. */
  13390. beginAnimationFrom: number;
  13391. /**
  13392. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13393. */
  13394. beginAnimationTo: number;
  13395. /**
  13396. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13397. */
  13398. beginAnimationLoop: boolean;
  13399. /**
  13400. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13401. */
  13402. disposeOnStop: boolean;
  13403. /**
  13404. * Gets the maximum number of particles active at the same time.
  13405. * @returns The max number of active particles.
  13406. */
  13407. getCapacity(): number;
  13408. /**
  13409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13410. * @returns True if it has been started, otherwise false.
  13411. */
  13412. isStarted(): boolean;
  13413. /**
  13414. * Animates the particle system for this frame.
  13415. */
  13416. animate(): void;
  13417. /**
  13418. * Renders the particle system in its current state.
  13419. * @returns the current number of particles
  13420. */
  13421. render(): number;
  13422. /**
  13423. * Dispose the particle system and frees its associated resources.
  13424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13425. */
  13426. dispose(disposeTexture?: boolean): void;
  13427. /**
  13428. * Clones the particle system.
  13429. * @param name The name of the cloned object
  13430. * @param newEmitter The new emitter to use
  13431. * @returns the cloned particle system
  13432. */
  13433. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13434. /**
  13435. * Serializes the particle system to a JSON object.
  13436. * @returns the JSON object
  13437. */
  13438. serialize(): any;
  13439. /**
  13440. * Rebuild the particle system
  13441. */
  13442. rebuild(): void;
  13443. /**
  13444. * Starts the particle system and begins to emit
  13445. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13446. */
  13447. start(delay?: number): void;
  13448. /**
  13449. * Stops the particle system.
  13450. */
  13451. stop(): void;
  13452. /**
  13453. * Remove all active particles
  13454. */
  13455. reset(): void;
  13456. /**
  13457. * Is this system ready to be used/rendered
  13458. * @return true if the system is ready
  13459. */
  13460. isReady(): boolean;
  13461. /**
  13462. * Adds a new color gradient
  13463. * @param gradient defines the gradient to use (between 0 and 1)
  13464. * @param color1 defines the color to affect to the specified gradient
  13465. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13466. * @returns the current particle system
  13467. */
  13468. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13469. /**
  13470. * Remove a specific color gradient
  13471. * @param gradient defines the gradient to remove
  13472. * @returns the current particle system
  13473. */
  13474. removeColorGradient(gradient: number): IParticleSystem;
  13475. /**
  13476. * Adds a new size gradient
  13477. * @param gradient defines the gradient to use (between 0 and 1)
  13478. * @param factor defines the size factor to affect to the specified gradient
  13479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13480. * @returns the current particle system
  13481. */
  13482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13483. /**
  13484. * Remove a specific size gradient
  13485. * @param gradient defines the gradient to remove
  13486. * @returns the current particle system
  13487. */
  13488. removeSizeGradient(gradient: number): IParticleSystem;
  13489. /**
  13490. * Gets the current list of color gradients.
  13491. * You must use addColorGradient and removeColorGradient to udpate this list
  13492. * @returns the list of color gradients
  13493. */
  13494. getColorGradients(): Nullable<Array<ColorGradient>>;
  13495. /**
  13496. * Gets the current list of size gradients.
  13497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13498. * @returns the list of size gradients
  13499. */
  13500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13501. /**
  13502. * Gets the current list of angular speed gradients.
  13503. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13504. * @returns the list of angular speed gradients
  13505. */
  13506. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13507. /**
  13508. * Adds a new angular speed gradient
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the angular speed to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific angular speed gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of velocity gradients.
  13523. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13524. * @returns the list of velocity gradients
  13525. */
  13526. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13527. /**
  13528. * Adds a new velocity gradient
  13529. * @param gradient defines the gradient to use (between 0 and 1)
  13530. * @param factor defines the velocity to affect to the specified gradient
  13531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13532. * @returns the current particle system
  13533. */
  13534. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13535. /**
  13536. * Remove a specific velocity gradient
  13537. * @param gradient defines the gradient to remove
  13538. * @returns the current particle system
  13539. */
  13540. removeVelocityGradient(gradient: number): IParticleSystem;
  13541. /**
  13542. * Gets the current list of limit velocity gradients.
  13543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13544. * @returns the list of limit velocity gradients
  13545. */
  13546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13547. /**
  13548. * Adds a new limit velocity gradient
  13549. * @param gradient defines the gradient to use (between 0 and 1)
  13550. * @param factor defines the limit velocity to affect to the specified gradient
  13551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13552. * @returns the current particle system
  13553. */
  13554. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13555. /**
  13556. * Remove a specific limit velocity gradient
  13557. * @param gradient defines the gradient to remove
  13558. * @returns the current particle system
  13559. */
  13560. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13561. /**
  13562. * Adds a new drag gradient
  13563. * @param gradient defines the gradient to use (between 0 and 1)
  13564. * @param factor defines the drag to affect to the specified gradient
  13565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13566. * @returns the current particle system
  13567. */
  13568. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13569. /**
  13570. * Remove a specific drag gradient
  13571. * @param gradient defines the gradient to remove
  13572. * @returns the current particle system
  13573. */
  13574. removeDragGradient(gradient: number): IParticleSystem;
  13575. /**
  13576. * Gets the current list of drag gradients.
  13577. * You must use addDragGradient and removeDragGradient to udpate this list
  13578. * @returns the list of drag gradients
  13579. */
  13580. getDragGradients(): Nullable<Array<FactorGradient>>;
  13581. /**
  13582. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13583. * @param gradient defines the gradient to use (between 0 and 1)
  13584. * @param factor defines the emit rate to affect to the specified gradient
  13585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13586. * @returns the current particle system
  13587. */
  13588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13589. /**
  13590. * Remove a specific emit rate gradient
  13591. * @param gradient defines the gradient to remove
  13592. * @returns the current particle system
  13593. */
  13594. removeEmitRateGradient(gradient: number): IParticleSystem;
  13595. /**
  13596. * Gets the current list of emit rate gradients.
  13597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13598. * @returns the list of emit rate gradients
  13599. */
  13600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13601. /**
  13602. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13603. * @param gradient defines the gradient to use (between 0 and 1)
  13604. * @param factor defines the start size to affect to the specified gradient
  13605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13606. * @returns the current particle system
  13607. */
  13608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13609. /**
  13610. * Remove a specific start size gradient
  13611. * @param gradient defines the gradient to remove
  13612. * @returns the current particle system
  13613. */
  13614. removeStartSizeGradient(gradient: number): IParticleSystem;
  13615. /**
  13616. * Gets the current list of start size gradients.
  13617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13618. * @returns the list of start size gradients
  13619. */
  13620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13621. /**
  13622. * Adds a new life time gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param factor defines the life time factor to affect to the specified gradient
  13625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13626. * @returns the current particle system
  13627. */
  13628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13629. /**
  13630. * Remove a specific life time gradient
  13631. * @param gradient defines the gradient to remove
  13632. * @returns the current particle system
  13633. */
  13634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13635. /**
  13636. * Gets the current list of life time gradients.
  13637. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13638. * @returns the list of life time gradients
  13639. */
  13640. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13641. /**
  13642. * Gets the current list of color gradients.
  13643. * You must use addColorGradient and removeColorGradient to udpate this list
  13644. * @returns the list of color gradients
  13645. */
  13646. getColorGradients(): Nullable<Array<ColorGradient>>;
  13647. /**
  13648. * Adds a new ramp gradient used to remap particle colors
  13649. * @param gradient defines the gradient to use (between 0 and 1)
  13650. * @param color defines the color to affect to the specified gradient
  13651. * @returns the current particle system
  13652. */
  13653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13654. /**
  13655. * Gets the current list of ramp gradients.
  13656. * You must use addRampGradient and removeRampGradient to udpate this list
  13657. * @returns the list of ramp gradients
  13658. */
  13659. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13660. /** Gets or sets a boolean indicating that ramp gradients must be used
  13661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13662. */
  13663. useRampGradients: boolean;
  13664. /**
  13665. * Adds a new color remap gradient
  13666. * @param gradient defines the gradient to use (between 0 and 1)
  13667. * @param min defines the color remap minimal range
  13668. * @param max defines the color remap maximal range
  13669. * @returns the current particle system
  13670. */
  13671. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13672. /**
  13673. * Gets the current list of color remap gradients.
  13674. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13675. * @returns the list of color remap gradients
  13676. */
  13677. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13678. /**
  13679. * Adds a new alpha remap gradient
  13680. * @param gradient defines the gradient to use (between 0 and 1)
  13681. * @param min defines the alpha remap minimal range
  13682. * @param max defines the alpha remap maximal range
  13683. * @returns the current particle system
  13684. */
  13685. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13686. /**
  13687. * Gets the current list of alpha remap gradients.
  13688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13689. * @returns the list of alpha remap gradients
  13690. */
  13691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13692. /**
  13693. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13696. * @returns the emitter
  13697. */
  13698. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13699. /**
  13700. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13701. * @param radius The radius of the hemisphere to emit from
  13702. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13706. /**
  13707. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13710. * @returns the emitter
  13711. */
  13712. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13713. /**
  13714. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13715. * @param radius The radius of the sphere to emit from
  13716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13718. * @returns the emitter
  13719. */
  13720. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13721. /**
  13722. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13723. * @param radius The radius of the emission cylinder
  13724. * @param height The height of the emission cylinder
  13725. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13726. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13727. * @returns the emitter
  13728. */
  13729. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13730. /**
  13731. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13732. * @param radius The radius of the cylinder to emit from
  13733. * @param height The height of the emission cylinder
  13734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13737. * @returns the emitter
  13738. */
  13739. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13740. /**
  13741. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13742. * @param radius The radius of the cone to emit from
  13743. * @param angle The base angle of the cone
  13744. * @returns the emitter
  13745. */
  13746. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13747. /**
  13748. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13751. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13752. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13753. * @returns the emitter
  13754. */
  13755. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13756. /**
  13757. * Get hosting scene
  13758. * @returns the scene
  13759. */
  13760. getScene(): Scene;
  13761. }
  13762. }
  13763. declare module "babylonjs/Meshes/transformNode" {
  13764. import { DeepImmutable } from "babylonjs/types";
  13765. import { Observable } from "babylonjs/Misc/observable";
  13766. import { Nullable } from "babylonjs/types";
  13767. import { Camera } from "babylonjs/Cameras/camera";
  13768. import { Scene } from "babylonjs/scene";
  13769. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13770. import { Node } from "babylonjs/node";
  13771. import { Bone } from "babylonjs/Bones/bone";
  13772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13773. import { Space } from "babylonjs/Maths/math.axis";
  13774. /**
  13775. * 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.
  13776. * @see https://doc.babylonjs.com/how_to/transformnode
  13777. */
  13778. export class TransformNode extends Node {
  13779. /**
  13780. * Object will not rotate to face the camera
  13781. */
  13782. static BILLBOARDMODE_NONE: number;
  13783. /**
  13784. * Object will rotate to face the camera but only on the x axis
  13785. */
  13786. static BILLBOARDMODE_X: number;
  13787. /**
  13788. * Object will rotate to face the camera but only on the y axis
  13789. */
  13790. static BILLBOARDMODE_Y: number;
  13791. /**
  13792. * Object will rotate to face the camera but only on the z axis
  13793. */
  13794. static BILLBOARDMODE_Z: number;
  13795. /**
  13796. * Object will rotate to face the camera
  13797. */
  13798. static BILLBOARDMODE_ALL: number;
  13799. /**
  13800. * Object will rotate to face the camera's position instead of orientation
  13801. */
  13802. static BILLBOARDMODE_USE_POSITION: number;
  13803. private _forward;
  13804. private _forwardInverted;
  13805. private _up;
  13806. private _right;
  13807. private _rightInverted;
  13808. private _position;
  13809. private _rotation;
  13810. private _rotationQuaternion;
  13811. protected _scaling: Vector3;
  13812. protected _isDirty: boolean;
  13813. private _transformToBoneReferal;
  13814. private _isAbsoluteSynced;
  13815. private _billboardMode;
  13816. /**
  13817. * Gets or sets the billboard mode. Default is 0.
  13818. *
  13819. * | Value | Type | Description |
  13820. * | --- | --- | --- |
  13821. * | 0 | BILLBOARDMODE_NONE | |
  13822. * | 1 | BILLBOARDMODE_X | |
  13823. * | 2 | BILLBOARDMODE_Y | |
  13824. * | 4 | BILLBOARDMODE_Z | |
  13825. * | 7 | BILLBOARDMODE_ALL | |
  13826. *
  13827. */
  13828. get billboardMode(): number;
  13829. set billboardMode(value: number);
  13830. private _preserveParentRotationForBillboard;
  13831. /**
  13832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13834. */
  13835. get preserveParentRotationForBillboard(): boolean;
  13836. set preserveParentRotationForBillboard(value: boolean);
  13837. /**
  13838. * 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
  13839. */
  13840. scalingDeterminant: number;
  13841. private _infiniteDistance;
  13842. /**
  13843. * Gets or sets the distance of the object to max, often used by skybox
  13844. */
  13845. get infiniteDistance(): boolean;
  13846. set infiniteDistance(value: boolean);
  13847. /**
  13848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13849. * By default the system will update normals to compensate
  13850. */
  13851. ignoreNonUniformScaling: boolean;
  13852. /**
  13853. * 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
  13854. */
  13855. reIntegrateRotationIntoRotationQuaternion: boolean;
  13856. /** @hidden */
  13857. _poseMatrix: Nullable<Matrix>;
  13858. /** @hidden */
  13859. _localMatrix: Matrix;
  13860. private _usePivotMatrix;
  13861. private _absolutePosition;
  13862. private _absoluteScaling;
  13863. private _absoluteRotationQuaternion;
  13864. private _pivotMatrix;
  13865. private _pivotMatrixInverse;
  13866. protected _postMultiplyPivotMatrix: boolean;
  13867. protected _isWorldMatrixFrozen: boolean;
  13868. /** @hidden */
  13869. _indexInSceneTransformNodesArray: number;
  13870. /**
  13871. * An event triggered after the world matrix is updated
  13872. */
  13873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13875. /**
  13876. * Gets a string identifying the name of the class
  13877. * @returns "TransformNode" string
  13878. */
  13879. getClassName(): string;
  13880. /**
  13881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13882. */
  13883. get position(): Vector3;
  13884. set position(newPosition: Vector3);
  13885. /**
  13886. * 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)).
  13887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13888. */
  13889. get rotation(): Vector3;
  13890. set rotation(newRotation: Vector3);
  13891. /**
  13892. * 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)).
  13893. */
  13894. get scaling(): Vector3;
  13895. set scaling(newScaling: Vector3);
  13896. /**
  13897. * 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).
  13898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13899. */
  13900. get rotationQuaternion(): Nullable<Quaternion>;
  13901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13902. /**
  13903. * The forward direction of that transform in world space.
  13904. */
  13905. get forward(): Vector3;
  13906. /**
  13907. * The up direction of that transform in world space.
  13908. */
  13909. get up(): Vector3;
  13910. /**
  13911. * The right direction of that transform in world space.
  13912. */
  13913. get right(): Vector3;
  13914. /**
  13915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13916. * @param matrix the matrix to copy the pose from
  13917. * @returns this TransformNode.
  13918. */
  13919. updatePoseMatrix(matrix: Matrix): TransformNode;
  13920. /**
  13921. * Returns the mesh Pose matrix.
  13922. * @returns the pose matrix
  13923. */
  13924. getPoseMatrix(): Matrix;
  13925. /** @hidden */
  13926. _isSynchronized(): boolean;
  13927. /** @hidden */
  13928. _initCache(): void;
  13929. /**
  13930. * Flag the transform node as dirty (Forcing it to update everything)
  13931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13932. * @returns this transform node
  13933. */
  13934. markAsDirty(property: string): TransformNode;
  13935. /**
  13936. * Returns the current mesh absolute position.
  13937. * Returns a Vector3.
  13938. */
  13939. get absolutePosition(): Vector3;
  13940. /**
  13941. * Returns the current mesh absolute scaling.
  13942. * Returns a Vector3.
  13943. */
  13944. get absoluteScaling(): Vector3;
  13945. /**
  13946. * Returns the current mesh absolute rotation.
  13947. * Returns a Quaternion.
  13948. */
  13949. get absoluteRotationQuaternion(): Quaternion;
  13950. /**
  13951. * Sets a new matrix to apply before all other transformation
  13952. * @param matrix defines the transform matrix
  13953. * @returns the current TransformNode
  13954. */
  13955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13956. /**
  13957. * Sets a new pivot matrix to the current node
  13958. * @param matrix defines the new pivot matrix to use
  13959. * @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
  13960. * @returns the current TransformNode
  13961. */
  13962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13963. /**
  13964. * Returns the mesh pivot matrix.
  13965. * Default : Identity.
  13966. * @returns the matrix
  13967. */
  13968. getPivotMatrix(): Matrix;
  13969. /**
  13970. * Instantiate (when possible) or clone that node with its hierarchy
  13971. * @param newParent defines the new parent to use for the instance (or clone)
  13972. * @param options defines options to configure how copy is done
  13973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13974. * @returns an instance (or a clone) of the current node with its hiearchy
  13975. */
  13976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13977. doNotInstantiate: boolean;
  13978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13979. /**
  13980. * Prevents the World matrix to be computed any longer
  13981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13982. * @returns the TransformNode.
  13983. */
  13984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13985. /**
  13986. * Allows back the World matrix computation.
  13987. * @returns the TransformNode.
  13988. */
  13989. unfreezeWorldMatrix(): this;
  13990. /**
  13991. * True if the World matrix has been frozen.
  13992. */
  13993. get isWorldMatrixFrozen(): boolean;
  13994. /**
  13995. * Retuns the mesh absolute position in the World.
  13996. * @returns a Vector3.
  13997. */
  13998. getAbsolutePosition(): Vector3;
  13999. /**
  14000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14001. * @param absolutePosition the absolute position to set
  14002. * @returns the TransformNode.
  14003. */
  14004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14005. /**
  14006. * Sets the mesh position in its local space.
  14007. * @param vector3 the position to set in localspace
  14008. * @returns the TransformNode.
  14009. */
  14010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14011. /**
  14012. * Returns the mesh position in the local space from the current World matrix values.
  14013. * @returns a new Vector3.
  14014. */
  14015. getPositionExpressedInLocalSpace(): Vector3;
  14016. /**
  14017. * Translates the mesh along the passed Vector3 in its local space.
  14018. * @param vector3 the distance to translate in localspace
  14019. * @returns the TransformNode.
  14020. */
  14021. locallyTranslate(vector3: Vector3): TransformNode;
  14022. private static _lookAtVectorCache;
  14023. /**
  14024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14025. * @param targetPoint the position (must be in same space as current mesh) to look at
  14026. * @param yawCor optional yaw (y-axis) correction in radians
  14027. * @param pitchCor optional pitch (x-axis) correction in radians
  14028. * @param rollCor optional roll (z-axis) correction in radians
  14029. * @param space the choosen space of the target
  14030. * @returns the TransformNode.
  14031. */
  14032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14033. /**
  14034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14035. * This Vector3 is expressed in the World space.
  14036. * @param localAxis axis to rotate
  14037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14038. */
  14039. getDirection(localAxis: Vector3): Vector3;
  14040. /**
  14041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14042. * localAxis is expressed in the mesh local space.
  14043. * result is computed in the Wordl space from the mesh World matrix.
  14044. * @param localAxis axis to rotate
  14045. * @param result the resulting transformnode
  14046. * @returns this TransformNode.
  14047. */
  14048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14049. /**
  14050. * Sets this transform node rotation to the given local axis.
  14051. * @param localAxis the axis in local space
  14052. * @param yawCor optional yaw (y-axis) correction in radians
  14053. * @param pitchCor optional pitch (x-axis) correction in radians
  14054. * @param rollCor optional roll (z-axis) correction in radians
  14055. * @returns this TransformNode
  14056. */
  14057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14058. /**
  14059. * Sets a new pivot point to the current node
  14060. * @param point defines the new pivot point to use
  14061. * @param space defines if the point is in world or local space (local by default)
  14062. * @returns the current TransformNode
  14063. */
  14064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14065. /**
  14066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14067. * @returns the pivot point
  14068. */
  14069. getPivotPoint(): Vector3;
  14070. /**
  14071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14072. * @param result the vector3 to store the result
  14073. * @returns this TransformNode.
  14074. */
  14075. getPivotPointToRef(result: Vector3): TransformNode;
  14076. /**
  14077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14079. */
  14080. getAbsolutePivotPoint(): Vector3;
  14081. /**
  14082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14083. * @param result vector3 to store the result
  14084. * @returns this TransformNode.
  14085. */
  14086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14087. /**
  14088. * Defines the passed node as the parent of the current node.
  14089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14090. * @see https://doc.babylonjs.com/how_to/parenting
  14091. * @param node the node ot set as the parent
  14092. * @returns this TransformNode.
  14093. */
  14094. setParent(node: Nullable<Node>): TransformNode;
  14095. private _nonUniformScaling;
  14096. /**
  14097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14098. */
  14099. get nonUniformScaling(): boolean;
  14100. /** @hidden */
  14101. _updateNonUniformScalingState(value: boolean): boolean;
  14102. /**
  14103. * Attach the current TransformNode to another TransformNode associated with a bone
  14104. * @param bone Bone affecting the TransformNode
  14105. * @param affectedTransformNode TransformNode associated with the bone
  14106. * @returns this object
  14107. */
  14108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14109. /**
  14110. * Detach the transform node if its associated with a bone
  14111. * @returns this object
  14112. */
  14113. detachFromBone(): TransformNode;
  14114. private static _rotationAxisCache;
  14115. /**
  14116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14119. * The passed axis is also normalized.
  14120. * @param axis the axis to rotate around
  14121. * @param amount the amount to rotate in radians
  14122. * @param space Space to rotate in (Default: local)
  14123. * @returns the TransformNode.
  14124. */
  14125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14126. /**
  14127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14129. * The passed axis is also normalized. .
  14130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14131. * @param point the point to rotate around
  14132. * @param axis the axis to rotate around
  14133. * @param amount the amount to rotate in radians
  14134. * @returns the TransformNode
  14135. */
  14136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14137. /**
  14138. * Translates the mesh along the axis vector for the passed distance in the given space.
  14139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14140. * @param axis the axis to translate in
  14141. * @param distance the distance to translate
  14142. * @param space Space to rotate in (Default: local)
  14143. * @returns the TransformNode.
  14144. */
  14145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14146. /**
  14147. * Adds a rotation step to the mesh current rotation.
  14148. * x, y, z are Euler angles expressed in radians.
  14149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14150. * This means this rotation is made in the mesh local space only.
  14151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14153. * ```javascript
  14154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14155. * ```
  14156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14157. * 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.
  14158. * @param x Rotation to add
  14159. * @param y Rotation to add
  14160. * @param z Rotation to add
  14161. * @returns the TransformNode.
  14162. */
  14163. addRotation(x: number, y: number, z: number): TransformNode;
  14164. /**
  14165. * @hidden
  14166. */
  14167. protected _getEffectiveParent(): Nullable<Node>;
  14168. /**
  14169. * Computes the world matrix of the node
  14170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14171. * @returns the world matrix
  14172. */
  14173. computeWorldMatrix(force?: boolean): Matrix;
  14174. /**
  14175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14177. */
  14178. resetLocalMatrix(independentOfChildren?: boolean): void;
  14179. protected _afterComputeWorldMatrix(): void;
  14180. /**
  14181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14182. * @param func callback function to add
  14183. *
  14184. * @returns the TransformNode.
  14185. */
  14186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14187. /**
  14188. * Removes a registered callback function.
  14189. * @param func callback function to remove
  14190. * @returns the TransformNode.
  14191. */
  14192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14193. /**
  14194. * Gets the position of the current mesh in camera space
  14195. * @param camera defines the camera to use
  14196. * @returns a position
  14197. */
  14198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14199. /**
  14200. * Returns the distance from the mesh to the active camera
  14201. * @param camera defines the camera to use
  14202. * @returns the distance
  14203. */
  14204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14205. /**
  14206. * Clone the current transform node
  14207. * @param name Name of the new clone
  14208. * @param newParent New parent for the clone
  14209. * @param doNotCloneChildren Do not clone children hierarchy
  14210. * @returns the new transform node
  14211. */
  14212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14213. /**
  14214. * Serializes the objects information.
  14215. * @param currentSerializationObject defines the object to serialize in
  14216. * @returns the serialized object
  14217. */
  14218. serialize(currentSerializationObject?: any): any;
  14219. /**
  14220. * Returns a new TransformNode object parsed from the source provided.
  14221. * @param parsedTransformNode is the source.
  14222. * @param scene the scne the object belongs to
  14223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14224. * @returns a new TransformNode object parsed from the source provided.
  14225. */
  14226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14227. /**
  14228. * Get all child-transformNodes of this node
  14229. * @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
  14230. * @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
  14231. * @returns an array of TransformNode
  14232. */
  14233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14234. /**
  14235. * Releases resources associated with this transform node.
  14236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14238. */
  14239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14240. /**
  14241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14245. * @returns the current mesh
  14246. */
  14247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14248. private _syncAbsoluteScalingAndRotation;
  14249. }
  14250. }
  14251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14252. /**
  14253. * Class used to override all child animations of a given target
  14254. */
  14255. export class AnimationPropertiesOverride {
  14256. /**
  14257. * Gets or sets a value indicating if animation blending must be used
  14258. */
  14259. enableBlending: boolean;
  14260. /**
  14261. * Gets or sets the blending speed to use when enableBlending is true
  14262. */
  14263. blendingSpeed: number;
  14264. /**
  14265. * Gets or sets the default loop mode to use
  14266. */
  14267. loopMode: number;
  14268. }
  14269. }
  14270. declare module "babylonjs/Bones/bone" {
  14271. import { Skeleton } from "babylonjs/Bones/skeleton";
  14272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14273. import { Nullable } from "babylonjs/types";
  14274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14276. import { Node } from "babylonjs/node";
  14277. import { Space } from "babylonjs/Maths/math.axis";
  14278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14279. /**
  14280. * Class used to store bone information
  14281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14282. */
  14283. export class Bone extends Node {
  14284. /**
  14285. * defines the bone name
  14286. */
  14287. name: string;
  14288. private static _tmpVecs;
  14289. private static _tmpQuat;
  14290. private static _tmpMats;
  14291. /**
  14292. * Gets the list of child bones
  14293. */
  14294. children: Bone[];
  14295. /** Gets the animations associated with this bone */
  14296. animations: import("babylonjs/Animations/animation").Animation[];
  14297. /**
  14298. * Gets or sets bone length
  14299. */
  14300. length: number;
  14301. /**
  14302. * @hidden Internal only
  14303. * Set this value to map this bone to a different index in the transform matrices
  14304. * Set this value to -1 to exclude the bone from the transform matrices
  14305. */
  14306. _index: Nullable<number>;
  14307. private _skeleton;
  14308. private _localMatrix;
  14309. private _restPose;
  14310. private _baseMatrix;
  14311. private _absoluteTransform;
  14312. private _invertedAbsoluteTransform;
  14313. private _parent;
  14314. private _scalingDeterminant;
  14315. private _worldTransform;
  14316. private _localScaling;
  14317. private _localRotation;
  14318. private _localPosition;
  14319. private _needToDecompose;
  14320. private _needToCompose;
  14321. /** @hidden */
  14322. _linkedTransformNode: Nullable<TransformNode>;
  14323. /** @hidden */
  14324. _waitingTransformNodeId: Nullable<string>;
  14325. /** @hidden */
  14326. get _matrix(): Matrix;
  14327. /** @hidden */
  14328. set _matrix(value: Matrix);
  14329. /**
  14330. * Create a new bone
  14331. * @param name defines the bone name
  14332. * @param skeleton defines the parent skeleton
  14333. * @param parentBone defines the parent (can be null if the bone is the root)
  14334. * @param localMatrix defines the local matrix
  14335. * @param restPose defines the rest pose matrix
  14336. * @param baseMatrix defines the base matrix
  14337. * @param index defines index of the bone in the hiearchy
  14338. */
  14339. constructor(
  14340. /**
  14341. * defines the bone name
  14342. */
  14343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14344. /**
  14345. * Gets the current object class name.
  14346. * @return the class name
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Gets the parent skeleton
  14351. * @returns a skeleton
  14352. */
  14353. getSkeleton(): Skeleton;
  14354. /**
  14355. * Gets parent bone
  14356. * @returns a bone or null if the bone is the root of the bone hierarchy
  14357. */
  14358. getParent(): Nullable<Bone>;
  14359. /**
  14360. * Returns an array containing the root bones
  14361. * @returns an array containing the root bones
  14362. */
  14363. getChildren(): Array<Bone>;
  14364. /**
  14365. * Gets the node index in matrix array generated for rendering
  14366. * @returns the node index
  14367. */
  14368. getIndex(): number;
  14369. /**
  14370. * Sets the parent bone
  14371. * @param parent defines the parent (can be null if the bone is the root)
  14372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14373. */
  14374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14375. /**
  14376. * Gets the local matrix
  14377. * @returns a matrix
  14378. */
  14379. getLocalMatrix(): Matrix;
  14380. /**
  14381. * Gets the base matrix (initial matrix which remains unchanged)
  14382. * @returns a matrix
  14383. */
  14384. getBaseMatrix(): Matrix;
  14385. /**
  14386. * Gets the rest pose matrix
  14387. * @returns a matrix
  14388. */
  14389. getRestPose(): Matrix;
  14390. /**
  14391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14392. */
  14393. getWorldMatrix(): Matrix;
  14394. /**
  14395. * Sets the local matrix to rest pose matrix
  14396. */
  14397. returnToRest(): void;
  14398. /**
  14399. * Gets the inverse of the absolute transform matrix.
  14400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14401. * @returns a matrix
  14402. */
  14403. getInvertedAbsoluteTransform(): Matrix;
  14404. /**
  14405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14406. * @returns a matrix
  14407. */
  14408. getAbsoluteTransform(): Matrix;
  14409. /**
  14410. * Links with the given transform node.
  14411. * The local matrix of this bone is copied from the transform node every frame.
  14412. * @param transformNode defines the transform node to link to
  14413. */
  14414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14415. /**
  14416. * Gets the node used to drive the bone's transformation
  14417. * @returns a transform node or null
  14418. */
  14419. getTransformNode(): Nullable<TransformNode>;
  14420. /** Gets or sets current position (in local space) */
  14421. get position(): Vector3;
  14422. set position(newPosition: Vector3);
  14423. /** Gets or sets current rotation (in local space) */
  14424. get rotation(): Vector3;
  14425. set rotation(newRotation: Vector3);
  14426. /** Gets or sets current rotation quaternion (in local space) */
  14427. get rotationQuaternion(): Quaternion;
  14428. set rotationQuaternion(newRotation: Quaternion);
  14429. /** Gets or sets current scaling (in local space) */
  14430. get scaling(): Vector3;
  14431. set scaling(newScaling: Vector3);
  14432. /**
  14433. * Gets the animation properties override
  14434. */
  14435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14436. private _decompose;
  14437. private _compose;
  14438. /**
  14439. * Update the base and local matrices
  14440. * @param matrix defines the new base or local matrix
  14441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14442. * @param updateLocalMatrix defines if the local matrix should be updated
  14443. */
  14444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14445. /** @hidden */
  14446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14447. /**
  14448. * Flag the bone as dirty (Forcing it to update everything)
  14449. */
  14450. markAsDirty(): void;
  14451. /** @hidden */
  14452. _markAsDirtyAndCompose(): void;
  14453. private _markAsDirtyAndDecompose;
  14454. /**
  14455. * Translate the bone in local or world space
  14456. * @param vec The amount to translate the bone
  14457. * @param space The space that the translation is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the postion of the bone in local or world space
  14463. * @param position The position to set the bone
  14464. * @param space The space that the position is in
  14465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14466. */
  14467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14468. /**
  14469. * Set the absolute position of the bone (world space)
  14470. * @param position The position to set the bone
  14471. * @param mesh The mesh that this bone is attached to
  14472. */
  14473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14474. /**
  14475. * Scale the bone on the x, y and z axes (in local space)
  14476. * @param x The amount to scale the bone on the x axis
  14477. * @param y The amount to scale the bone on the y axis
  14478. * @param z The amount to scale the bone on the z axis
  14479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14480. */
  14481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14482. /**
  14483. * Set the bone scaling in local space
  14484. * @param scale defines the scaling vector
  14485. */
  14486. setScale(scale: Vector3): void;
  14487. /**
  14488. * Gets the current scaling in local space
  14489. * @returns the current scaling vector
  14490. */
  14491. getScale(): Vector3;
  14492. /**
  14493. * Gets the current scaling in local space and stores it in a target vector
  14494. * @param result defines the target vector
  14495. */
  14496. getScaleToRef(result: Vector3): void;
  14497. /**
  14498. * Set the yaw, pitch, and roll of the bone in local or world space
  14499. * @param yaw The rotation of the bone on the y axis
  14500. * @param pitch The rotation of the bone on the x axis
  14501. * @param roll The rotation of the bone on the z axis
  14502. * @param space The space that the axes of rotation are in
  14503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14504. */
  14505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14506. /**
  14507. * Add a rotation to the bone on an axis in local or world space
  14508. * @param axis The axis to rotate the bone on
  14509. * @param amount The amount to rotate the bone
  14510. * @param space The space that the axis is in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. */
  14513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14514. /**
  14515. * Set the rotation of the bone to a particular axis angle in local or world space
  14516. * @param axis The axis to rotate the bone on
  14517. * @param angle The angle that the bone should be rotated to
  14518. * @param space The space that the axis is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the euler rotation of the bone in local of world space
  14524. * @param rotation The euler rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the quaternion rotation of the bone in local of world space
  14531. * @param quat The quaternion rotation that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14536. /**
  14537. * Set the rotation matrix of the bone in local of world space
  14538. * @param rotMat The rotation matrix that the bone should be set to
  14539. * @param space The space that the rotation is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14543. private _rotateWithMatrix;
  14544. private _getNegativeRotationToRef;
  14545. /**
  14546. * Get the position of the bone in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @returns The position of the bone
  14550. */
  14551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14552. /**
  14553. * Copy the position of the bone to a vector3 in local or world space
  14554. * @param space The space that the returned position is in
  14555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14556. * @param result The vector3 to copy the position to
  14557. */
  14558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14559. /**
  14560. * Get the absolute position of the bone (world space)
  14561. * @param mesh The mesh that this bone is attached to
  14562. * @returns The absolute position of the bone
  14563. */
  14564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14565. /**
  14566. * Copy the absolute position of the bone (world space) to the result param
  14567. * @param mesh The mesh that this bone is attached to
  14568. * @param result The vector3 to copy the absolute position to
  14569. */
  14570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14571. /**
  14572. * Compute the absolute transforms of this bone and its children
  14573. */
  14574. computeAbsoluteTransforms(): void;
  14575. /**
  14576. * Get the world direction from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @returns The world direction
  14580. */
  14581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14582. /**
  14583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14584. * @param localAxis The local direction that is used to compute the world direction
  14585. * @param mesh The mesh that this bone is attached to
  14586. * @param result The vector3 that the world direction will be copied to
  14587. */
  14588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14589. /**
  14590. * Get the euler rotation of the bone in local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @returns The euler rotation
  14594. */
  14595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14596. /**
  14597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @param result The vector3 that the rotation should be copied to
  14601. */
  14602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14603. /**
  14604. * Get the quaternion rotation of the bone in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @returns The quaternion rotation
  14608. */
  14609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14610. /**
  14611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @param result The quaternion that the rotation should be copied to
  14615. */
  14616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14617. /**
  14618. * Get the rotation matrix of the bone in local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @returns The rotation matrix
  14622. */
  14623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14624. /**
  14625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @param result The quaternion that the rotation should be copied to
  14629. */
  14630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @returns The world position
  14636. */
  14637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14638. /**
  14639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14640. * @param position The local position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @param result The vector3 that the world position should be copied to
  14643. */
  14644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14645. /**
  14646. * Get the local position of a point that is in world space
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @returns The local position
  14650. */
  14651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14652. /**
  14653. * Get the local position of a point that is in world space and copy it to the result param
  14654. * @param position The world position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @param result The vector3 that the local position should be copied to
  14657. */
  14658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14659. }
  14660. }
  14661. declare module "babylonjs/Animations/runtimeAnimation" {
  14662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14663. import { Animatable } from "babylonjs/Animations/animatable";
  14664. import { Scene } from "babylonjs/scene";
  14665. /**
  14666. * Defines a runtime animation
  14667. */
  14668. export class RuntimeAnimation {
  14669. private _events;
  14670. /**
  14671. * The current frame of the runtime animation
  14672. */
  14673. private _currentFrame;
  14674. /**
  14675. * The animation used by the runtime animation
  14676. */
  14677. private _animation;
  14678. /**
  14679. * The target of the runtime animation
  14680. */
  14681. private _target;
  14682. /**
  14683. * The initiating animatable
  14684. */
  14685. private _host;
  14686. /**
  14687. * The original value of the runtime animation
  14688. */
  14689. private _originalValue;
  14690. /**
  14691. * The original blend value of the runtime animation
  14692. */
  14693. private _originalBlendValue;
  14694. /**
  14695. * The offsets cache of the runtime animation
  14696. */
  14697. private _offsetsCache;
  14698. /**
  14699. * The high limits cache of the runtime animation
  14700. */
  14701. private _highLimitsCache;
  14702. /**
  14703. * Specifies if the runtime animation has been stopped
  14704. */
  14705. private _stopped;
  14706. /**
  14707. * The blending factor of the runtime animation
  14708. */
  14709. private _blendingFactor;
  14710. /**
  14711. * The BabylonJS scene
  14712. */
  14713. private _scene;
  14714. /**
  14715. * The current value of the runtime animation
  14716. */
  14717. private _currentValue;
  14718. /** @hidden */
  14719. _animationState: _IAnimationState;
  14720. /**
  14721. * The active target of the runtime animation
  14722. */
  14723. private _activeTargets;
  14724. private _currentActiveTarget;
  14725. private _directTarget;
  14726. /**
  14727. * The target path of the runtime animation
  14728. */
  14729. private _targetPath;
  14730. /**
  14731. * The weight of the runtime animation
  14732. */
  14733. private _weight;
  14734. /**
  14735. * The ratio offset of the runtime animation
  14736. */
  14737. private _ratioOffset;
  14738. /**
  14739. * The previous delay of the runtime animation
  14740. */
  14741. private _previousDelay;
  14742. /**
  14743. * The previous ratio of the runtime animation
  14744. */
  14745. private _previousRatio;
  14746. private _enableBlending;
  14747. private _keys;
  14748. private _minFrame;
  14749. private _maxFrame;
  14750. private _minValue;
  14751. private _maxValue;
  14752. private _targetIsArray;
  14753. /**
  14754. * Gets the current frame of the runtime animation
  14755. */
  14756. get currentFrame(): number;
  14757. /**
  14758. * Gets the weight of the runtime animation
  14759. */
  14760. get weight(): number;
  14761. /**
  14762. * Gets the current value of the runtime animation
  14763. */
  14764. get currentValue(): any;
  14765. /**
  14766. * Gets the target path of the runtime animation
  14767. */
  14768. get targetPath(): string;
  14769. /**
  14770. * Gets the actual target of the runtime animation
  14771. */
  14772. get target(): any;
  14773. /** @hidden */
  14774. _onLoop: () => void;
  14775. /**
  14776. * Create a new RuntimeAnimation object
  14777. * @param target defines the target of the animation
  14778. * @param animation defines the source animation object
  14779. * @param scene defines the hosting scene
  14780. * @param host defines the initiating Animatable
  14781. */
  14782. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14783. private _preparePath;
  14784. /**
  14785. * Gets the animation from the runtime animation
  14786. */
  14787. get animation(): Animation;
  14788. /**
  14789. * Resets the runtime animation to the beginning
  14790. * @param restoreOriginal defines whether to restore the target property to the original value
  14791. */
  14792. reset(restoreOriginal?: boolean): void;
  14793. /**
  14794. * Specifies if the runtime animation is stopped
  14795. * @returns Boolean specifying if the runtime animation is stopped
  14796. */
  14797. isStopped(): boolean;
  14798. /**
  14799. * Disposes of the runtime animation
  14800. */
  14801. dispose(): void;
  14802. /**
  14803. * Apply the interpolated value to the target
  14804. * @param currentValue defines the value computed by the animation
  14805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14806. */
  14807. setValue(currentValue: any, weight: number): void;
  14808. private _getOriginalValues;
  14809. private _setValue;
  14810. /**
  14811. * Gets the loop pmode of the runtime animation
  14812. * @returns Loop Mode
  14813. */
  14814. private _getCorrectLoopMode;
  14815. /**
  14816. * Move the current animation to a given frame
  14817. * @param frame defines the frame to move to
  14818. */
  14819. goToFrame(frame: number): void;
  14820. /**
  14821. * @hidden Internal use only
  14822. */
  14823. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14824. /**
  14825. * Execute the current animation
  14826. * @param delay defines the delay to add to the current frame
  14827. * @param from defines the lower bound of the animation range
  14828. * @param to defines the upper bound of the animation range
  14829. * @param loop defines if the current animation must loop
  14830. * @param speedRatio defines the current speed ratio
  14831. * @param weight defines the weight of the animation (default is -1 so no weight)
  14832. * @param onLoop optional callback called when animation loops
  14833. * @returns a boolean indicating if the animation is running
  14834. */
  14835. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14836. }
  14837. }
  14838. declare module "babylonjs/Animations/animatable" {
  14839. import { Animation } from "babylonjs/Animations/animation";
  14840. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14841. import { Nullable } from "babylonjs/types";
  14842. import { Observable } from "babylonjs/Misc/observable";
  14843. import { Scene } from "babylonjs/scene";
  14844. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14845. import { Node } from "babylonjs/node";
  14846. /**
  14847. * Class used to store an actual running animation
  14848. */
  14849. export class Animatable {
  14850. /** defines the target object */
  14851. target: any;
  14852. /** defines the starting frame number (default is 0) */
  14853. fromFrame: number;
  14854. /** defines the ending frame number (default is 100) */
  14855. toFrame: number;
  14856. /** defines if the animation must loop (default is false) */
  14857. loopAnimation: boolean;
  14858. /** defines a callback to call when animation ends if it is not looping */
  14859. onAnimationEnd?: (() => void) | null | undefined;
  14860. /** defines a callback to call when animation loops */
  14861. onAnimationLoop?: (() => void) | null | undefined;
  14862. private _localDelayOffset;
  14863. private _pausedDelay;
  14864. private _runtimeAnimations;
  14865. private _paused;
  14866. private _scene;
  14867. private _speedRatio;
  14868. private _weight;
  14869. private _syncRoot;
  14870. /**
  14871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14872. * This will only apply for non looping animation (default is true)
  14873. */
  14874. disposeOnEnd: boolean;
  14875. /**
  14876. * Gets a boolean indicating if the animation has started
  14877. */
  14878. animationStarted: boolean;
  14879. /**
  14880. * Observer raised when the animation ends
  14881. */
  14882. onAnimationEndObservable: Observable<Animatable>;
  14883. /**
  14884. * Observer raised when the animation loops
  14885. */
  14886. onAnimationLoopObservable: Observable<Animatable>;
  14887. /**
  14888. * Gets the root Animatable used to synchronize and normalize animations
  14889. */
  14890. get syncRoot(): Nullable<Animatable>;
  14891. /**
  14892. * Gets the current frame of the first RuntimeAnimation
  14893. * Used to synchronize Animatables
  14894. */
  14895. get masterFrame(): number;
  14896. /**
  14897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14898. */
  14899. get weight(): number;
  14900. set weight(value: number);
  14901. /**
  14902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14903. */
  14904. get speedRatio(): number;
  14905. set speedRatio(value: number);
  14906. /**
  14907. * Creates a new Animatable
  14908. * @param scene defines the hosting scene
  14909. * @param target defines the target object
  14910. * @param fromFrame defines the starting frame number (default is 0)
  14911. * @param toFrame defines the ending frame number (default is 100)
  14912. * @param loopAnimation defines if the animation must loop (default is false)
  14913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14915. * @param animations defines a group of animation to add to the new Animatable
  14916. * @param onAnimationLoop defines a callback to call when animation loops
  14917. */
  14918. constructor(scene: Scene,
  14919. /** defines the target object */
  14920. target: any,
  14921. /** defines the starting frame number (default is 0) */
  14922. fromFrame?: number,
  14923. /** defines the ending frame number (default is 100) */
  14924. toFrame?: number,
  14925. /** defines if the animation must loop (default is false) */
  14926. loopAnimation?: boolean, speedRatio?: number,
  14927. /** defines a callback to call when animation ends if it is not looping */
  14928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14929. /** defines a callback to call when animation loops */
  14930. onAnimationLoop?: (() => void) | null | undefined);
  14931. /**
  14932. * Synchronize and normalize current Animatable with a source Animatable
  14933. * This is useful when using animation weights and when animations are not of the same length
  14934. * @param root defines the root Animatable to synchronize with
  14935. * @returns the current Animatable
  14936. */
  14937. syncWith(root: Animatable): Animatable;
  14938. /**
  14939. * Gets the list of runtime animations
  14940. * @returns an array of RuntimeAnimation
  14941. */
  14942. getAnimations(): RuntimeAnimation[];
  14943. /**
  14944. * Adds more animations to the current animatable
  14945. * @param target defines the target of the animations
  14946. * @param animations defines the new animations to add
  14947. */
  14948. appendAnimations(target: any, animations: Animation[]): void;
  14949. /**
  14950. * Gets the source animation for a specific property
  14951. * @param property defines the propertyu to look for
  14952. * @returns null or the source animation for the given property
  14953. */
  14954. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14955. /**
  14956. * Gets the runtime animation for a specific property
  14957. * @param property defines the propertyu to look for
  14958. * @returns null or the runtime animation for the given property
  14959. */
  14960. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14961. /**
  14962. * Resets the animatable to its original state
  14963. */
  14964. reset(): void;
  14965. /**
  14966. * Allows the animatable to blend with current running animations
  14967. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14968. * @param blendingSpeed defines the blending speed to use
  14969. */
  14970. enableBlending(blendingSpeed: number): void;
  14971. /**
  14972. * Disable animation blending
  14973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14974. */
  14975. disableBlending(): void;
  14976. /**
  14977. * Jump directly to a given frame
  14978. * @param frame defines the frame to jump to
  14979. */
  14980. goToFrame(frame: number): void;
  14981. /**
  14982. * Pause the animation
  14983. */
  14984. pause(): void;
  14985. /**
  14986. * Restart the animation
  14987. */
  14988. restart(): void;
  14989. private _raiseOnAnimationEnd;
  14990. /**
  14991. * Stop and delete the current animation
  14992. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14993. * @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)
  14994. */
  14995. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14996. /**
  14997. * Wait asynchronously for the animation to end
  14998. * @returns a promise which will be fullfilled when the animation ends
  14999. */
  15000. waitAsync(): Promise<Animatable>;
  15001. /** @hidden */
  15002. _animate(delay: number): boolean;
  15003. }
  15004. module "babylonjs/scene" {
  15005. interface Scene {
  15006. /** @hidden */
  15007. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15008. /** @hidden */
  15009. _processLateAnimationBindingsForMatrices(holder: {
  15010. totalWeight: number;
  15011. animations: RuntimeAnimation[];
  15012. originalValue: Matrix;
  15013. }): any;
  15014. /** @hidden */
  15015. _processLateAnimationBindingsForQuaternions(holder: {
  15016. totalWeight: number;
  15017. animations: RuntimeAnimation[];
  15018. originalValue: Quaternion;
  15019. }, refQuaternion: Quaternion): Quaternion;
  15020. /** @hidden */
  15021. _processLateAnimationBindings(): void;
  15022. /**
  15023. * Will start the animation sequence of a given target
  15024. * @param target defines the target
  15025. * @param from defines from which frame should animation start
  15026. * @param to defines until which frame should animation run.
  15027. * @param weight defines the weight to apply to the animation (1.0 by default)
  15028. * @param loop defines if the animation loops
  15029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15030. * @param onAnimationEnd defines the function to be executed when the animation ends
  15031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15033. * @param onAnimationLoop defines the callback to call when an animation loops
  15034. * @returns the animatable object created for this animation
  15035. */
  15036. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15037. /**
  15038. * Will start the animation sequence of a given target
  15039. * @param target defines the target
  15040. * @param from defines from which frame should animation start
  15041. * @param to defines until which frame should animation run.
  15042. * @param loop defines if the animation loops
  15043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15044. * @param onAnimationEnd defines the function to be executed when the animation ends
  15045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15046. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15047. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15048. * @param onAnimationLoop defines the callback to call when an animation loops
  15049. * @returns the animatable object created for this animation
  15050. */
  15051. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15052. /**
  15053. * Will start the animation sequence of a given target and its hierarchy
  15054. * @param target defines the target
  15055. * @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.
  15056. * @param from defines from which frame should animation start
  15057. * @param to defines until which frame should animation run.
  15058. * @param loop defines if the animation loops
  15059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15060. * @param onAnimationEnd defines the function to be executed when the animation ends
  15061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15062. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15063. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15064. * @param onAnimationLoop defines the callback to call when an animation loops
  15065. * @returns the list of created animatables
  15066. */
  15067. 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[];
  15068. /**
  15069. * Begin a new animation on a given node
  15070. * @param target defines the target where the animation will take place
  15071. * @param animations defines the list of animations to start
  15072. * @param from defines the initial value
  15073. * @param to defines the final value
  15074. * @param loop defines if you want animation to loop (off by default)
  15075. * @param speedRatio defines the speed ratio to apply to all animations
  15076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15077. * @param onAnimationLoop defines the callback to call when an animation loops
  15078. * @returns the list of created animatables
  15079. */
  15080. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15081. /**
  15082. * Begin a new animation on a given node and its hierarchy
  15083. * @param target defines the root node where the animation will take place
  15084. * @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.
  15085. * @param animations defines the list of animations to start
  15086. * @param from defines the initial value
  15087. * @param to defines the final value
  15088. * @param loop defines if you want animation to loop (off by default)
  15089. * @param speedRatio defines the speed ratio to apply to all animations
  15090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15091. * @param onAnimationLoop defines the callback to call when an animation loops
  15092. * @returns the list of animatables created for all nodes
  15093. */
  15094. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15095. /**
  15096. * Gets the animatable associated with a specific target
  15097. * @param target defines the target of the animatable
  15098. * @returns the required animatable if found
  15099. */
  15100. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15101. /**
  15102. * Gets all animatables associated with a given target
  15103. * @param target defines the target to look animatables for
  15104. * @returns an array of Animatables
  15105. */
  15106. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15107. /**
  15108. * Stops and removes all animations that have been applied to the scene
  15109. */
  15110. stopAllAnimations(): void;
  15111. /**
  15112. * Gets the current delta time used by animation engine
  15113. */
  15114. deltaTime: number;
  15115. }
  15116. }
  15117. module "babylonjs/Bones/bone" {
  15118. interface Bone {
  15119. /**
  15120. * Copy an animation range from another bone
  15121. * @param source defines the source bone
  15122. * @param rangeName defines the range name to copy
  15123. * @param frameOffset defines the frame offset
  15124. * @param rescaleAsRequired defines if rescaling must be applied if required
  15125. * @param skelDimensionsRatio defines the scaling ratio
  15126. * @returns true if operation was successful
  15127. */
  15128. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15129. }
  15130. }
  15131. }
  15132. declare module "babylonjs/Bones/skeleton" {
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { Observable } from "babylonjs/Misc/observable";
  15135. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Nullable } from "babylonjs/types";
  15138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15139. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15140. import { Animatable } from "babylonjs/Animations/animatable";
  15141. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15142. import { Animation } from "babylonjs/Animations/animation";
  15143. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15144. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15146. /**
  15147. * Class used to handle skinning animations
  15148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15149. */
  15150. export class Skeleton implements IAnimatable {
  15151. /** defines the skeleton name */
  15152. name: string;
  15153. /** defines the skeleton Id */
  15154. id: string;
  15155. /**
  15156. * Defines the list of child bones
  15157. */
  15158. bones: Bone[];
  15159. /**
  15160. * Defines an estimate of the dimension of the skeleton at rest
  15161. */
  15162. dimensionsAtRest: Vector3;
  15163. /**
  15164. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15165. */
  15166. needInitialSkinMatrix: boolean;
  15167. /**
  15168. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15169. */
  15170. overrideMesh: Nullable<AbstractMesh>;
  15171. /**
  15172. * Gets the list of animations attached to this skeleton
  15173. */
  15174. animations: Array<Animation>;
  15175. private _scene;
  15176. private _isDirty;
  15177. private _transformMatrices;
  15178. private _transformMatrixTexture;
  15179. private _meshesWithPoseMatrix;
  15180. private _animatables;
  15181. private _identity;
  15182. private _synchronizedWithMesh;
  15183. private _ranges;
  15184. private _lastAbsoluteTransformsUpdateId;
  15185. private _canUseTextureForBones;
  15186. private _uniqueId;
  15187. /** @hidden */
  15188. _numBonesWithLinkedTransformNode: number;
  15189. /** @hidden */
  15190. _hasWaitingData: Nullable<boolean>;
  15191. /**
  15192. * Specifies if the skeleton should be serialized
  15193. */
  15194. doNotSerialize: boolean;
  15195. private _useTextureToStoreBoneMatrices;
  15196. /**
  15197. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15198. * Please note that this option is not available if the hardware does not support it
  15199. */
  15200. get useTextureToStoreBoneMatrices(): boolean;
  15201. set useTextureToStoreBoneMatrices(value: boolean);
  15202. private _animationPropertiesOverride;
  15203. /**
  15204. * Gets or sets the animation properties override
  15205. */
  15206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15208. /**
  15209. * List of inspectable custom properties (used by the Inspector)
  15210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15211. */
  15212. inspectableCustomProperties: IInspectable[];
  15213. /**
  15214. * An observable triggered before computing the skeleton's matrices
  15215. */
  15216. onBeforeComputeObservable: Observable<Skeleton>;
  15217. /**
  15218. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15219. */
  15220. get isUsingTextureForMatrices(): boolean;
  15221. /**
  15222. * Gets the unique ID of this skeleton
  15223. */
  15224. get uniqueId(): number;
  15225. /**
  15226. * Creates a new skeleton
  15227. * @param name defines the skeleton name
  15228. * @param id defines the skeleton Id
  15229. * @param scene defines the hosting scene
  15230. */
  15231. constructor(
  15232. /** defines the skeleton name */
  15233. name: string,
  15234. /** defines the skeleton Id */
  15235. id: string, scene: Scene);
  15236. /**
  15237. * Gets the current object class name.
  15238. * @return the class name
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Returns an array containing the root bones
  15243. * @returns an array containing the root bones
  15244. */
  15245. getChildren(): Array<Bone>;
  15246. /**
  15247. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15248. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15249. * @returns a Float32Array containing matrices data
  15250. */
  15251. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15252. /**
  15253. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15254. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15255. * @returns a raw texture containing the data
  15256. */
  15257. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15258. /**
  15259. * Gets the current hosting scene
  15260. * @returns a scene object
  15261. */
  15262. getScene(): Scene;
  15263. /**
  15264. * Gets a string representing the current skeleton data
  15265. * @param fullDetails defines a boolean indicating if we want a verbose version
  15266. * @returns a string representing the current skeleton data
  15267. */
  15268. toString(fullDetails?: boolean): string;
  15269. /**
  15270. * Get bone's index searching by name
  15271. * @param name defines bone's name to search for
  15272. * @return the indice of the bone. Returns -1 if not found
  15273. */
  15274. getBoneIndexByName(name: string): number;
  15275. /**
  15276. * Creater a new animation range
  15277. * @param name defines the name of the range
  15278. * @param from defines the start key
  15279. * @param to defines the end key
  15280. */
  15281. createAnimationRange(name: string, from: number, to: number): void;
  15282. /**
  15283. * Delete a specific animation range
  15284. * @param name defines the name of the range
  15285. * @param deleteFrames defines if frames must be removed as well
  15286. */
  15287. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15288. /**
  15289. * Gets a specific animation range
  15290. * @param name defines the name of the range to look for
  15291. * @returns the requested animation range or null if not found
  15292. */
  15293. getAnimationRange(name: string): Nullable<AnimationRange>;
  15294. /**
  15295. * Gets the list of all animation ranges defined on this skeleton
  15296. * @returns an array
  15297. */
  15298. getAnimationRanges(): Nullable<AnimationRange>[];
  15299. /**
  15300. * Copy animation range from a source skeleton.
  15301. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15302. * @param source defines the source skeleton
  15303. * @param name defines the name of the range to copy
  15304. * @param rescaleAsRequired defines if rescaling must be applied if required
  15305. * @returns true if operation was successful
  15306. */
  15307. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15308. /**
  15309. * Forces the skeleton to go to rest pose
  15310. */
  15311. returnToRest(): void;
  15312. private _getHighestAnimationFrame;
  15313. /**
  15314. * Begin a specific animation range
  15315. * @param name defines the name of the range to start
  15316. * @param loop defines if looping must be turned on (false by default)
  15317. * @param speedRatio defines the speed ratio to apply (1 by default)
  15318. * @param onAnimationEnd defines a callback which will be called when animation will end
  15319. * @returns a new animatable
  15320. */
  15321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15322. /** @hidden */
  15323. _markAsDirty(): void;
  15324. /** @hidden */
  15325. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15326. /** @hidden */
  15327. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15328. private _computeTransformMatrices;
  15329. /**
  15330. * Build all resources required to render a skeleton
  15331. */
  15332. prepare(): void;
  15333. /**
  15334. * Gets the list of animatables currently running for this skeleton
  15335. * @returns an array of animatables
  15336. */
  15337. getAnimatables(): IAnimatable[];
  15338. /**
  15339. * Clone the current skeleton
  15340. * @param name defines the name of the new skeleton
  15341. * @param id defines the id of the new skeleton
  15342. * @returns the new skeleton
  15343. */
  15344. clone(name: string, id?: string): Skeleton;
  15345. /**
  15346. * Enable animation blending for this skeleton
  15347. * @param blendingSpeed defines the blending speed to apply
  15348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15349. */
  15350. enableBlending(blendingSpeed?: number): void;
  15351. /**
  15352. * Releases all resources associated with the current skeleton
  15353. */
  15354. dispose(): void;
  15355. /**
  15356. * Serialize the skeleton in a JSON object
  15357. * @returns a JSON object
  15358. */
  15359. serialize(): any;
  15360. /**
  15361. * Creates a new skeleton from serialized data
  15362. * @param parsedSkeleton defines the serialized data
  15363. * @param scene defines the hosting scene
  15364. * @returns a new skeleton
  15365. */
  15366. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15367. /**
  15368. * Compute all node absolute transforms
  15369. * @param forceUpdate defines if computation must be done even if cache is up to date
  15370. */
  15371. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15372. /**
  15373. * Gets the root pose matrix
  15374. * @returns a matrix
  15375. */
  15376. getPoseMatrix(): Nullable<Matrix>;
  15377. /**
  15378. * Sorts bones per internal index
  15379. */
  15380. sortBones(): void;
  15381. private _sortBones;
  15382. }
  15383. }
  15384. declare module "babylonjs/Meshes/instancedMesh" {
  15385. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Camera } from "babylonjs/Cameras/camera";
  15388. import { Node } from "babylonjs/node";
  15389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15390. import { Mesh } from "babylonjs/Meshes/mesh";
  15391. import { Material } from "babylonjs/Materials/material";
  15392. import { Skeleton } from "babylonjs/Bones/skeleton";
  15393. import { Light } from "babylonjs/Lights/light";
  15394. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15395. /**
  15396. * Creates an instance based on a source mesh.
  15397. */
  15398. export class InstancedMesh extends AbstractMesh {
  15399. private _sourceMesh;
  15400. private _currentLOD;
  15401. /** @hidden */
  15402. _indexInSourceMeshInstanceArray: number;
  15403. constructor(name: string, source: Mesh);
  15404. /**
  15405. * Returns the string "InstancedMesh".
  15406. */
  15407. getClassName(): string;
  15408. /** Gets the list of lights affecting that mesh */
  15409. get lightSources(): Light[];
  15410. _resyncLightSources(): void;
  15411. _resyncLightSource(light: Light): void;
  15412. _removeLightSource(light: Light, dispose: boolean): void;
  15413. /**
  15414. * If the source mesh receives shadows
  15415. */
  15416. get receiveShadows(): boolean;
  15417. /**
  15418. * The material of the source mesh
  15419. */
  15420. get material(): Nullable<Material>;
  15421. /**
  15422. * Visibility of the source mesh
  15423. */
  15424. get visibility(): number;
  15425. /**
  15426. * Skeleton of the source mesh
  15427. */
  15428. get skeleton(): Nullable<Skeleton>;
  15429. /**
  15430. * Rendering ground id of the source mesh
  15431. */
  15432. get renderingGroupId(): number;
  15433. set renderingGroupId(value: number);
  15434. /**
  15435. * Returns the total number of vertices (integer).
  15436. */
  15437. getTotalVertices(): number;
  15438. /**
  15439. * Returns a positive integer : the total number of indices in this mesh geometry.
  15440. * @returns the numner of indices or zero if the mesh has no geometry.
  15441. */
  15442. getTotalIndices(): number;
  15443. /**
  15444. * The source mesh of the instance
  15445. */
  15446. get sourceMesh(): Mesh;
  15447. /**
  15448. * Is this node ready to be used/rendered
  15449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15450. * @return {boolean} is it ready
  15451. */
  15452. isReady(completeCheck?: boolean): boolean;
  15453. /**
  15454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15455. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15456. * @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.
  15457. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15458. */
  15459. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15460. /**
  15461. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15462. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15463. * The `data` are either a numeric array either a Float32Array.
  15464. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15465. * 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).
  15466. * Note that a new underlying VertexBuffer object is created each call.
  15467. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15468. *
  15469. * Possible `kind` values :
  15470. * - VertexBuffer.PositionKind
  15471. * - VertexBuffer.UVKind
  15472. * - VertexBuffer.UV2Kind
  15473. * - VertexBuffer.UV3Kind
  15474. * - VertexBuffer.UV4Kind
  15475. * - VertexBuffer.UV5Kind
  15476. * - VertexBuffer.UV6Kind
  15477. * - VertexBuffer.ColorKind
  15478. * - VertexBuffer.MatricesIndicesKind
  15479. * - VertexBuffer.MatricesIndicesExtraKind
  15480. * - VertexBuffer.MatricesWeightsKind
  15481. * - VertexBuffer.MatricesWeightsExtraKind
  15482. *
  15483. * Returns the Mesh.
  15484. */
  15485. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15486. /**
  15487. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15488. * If the mesh has no geometry, it is simply returned as it is.
  15489. * The `data` are either a numeric array either a Float32Array.
  15490. * No new underlying VertexBuffer object is created.
  15491. * 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.
  15492. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15493. *
  15494. * Possible `kind` values :
  15495. * - VertexBuffer.PositionKind
  15496. * - VertexBuffer.UVKind
  15497. * - VertexBuffer.UV2Kind
  15498. * - VertexBuffer.UV3Kind
  15499. * - VertexBuffer.UV4Kind
  15500. * - VertexBuffer.UV5Kind
  15501. * - VertexBuffer.UV6Kind
  15502. * - VertexBuffer.ColorKind
  15503. * - VertexBuffer.MatricesIndicesKind
  15504. * - VertexBuffer.MatricesIndicesExtraKind
  15505. * - VertexBuffer.MatricesWeightsKind
  15506. * - VertexBuffer.MatricesWeightsExtraKind
  15507. *
  15508. * Returns the Mesh.
  15509. */
  15510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15511. /**
  15512. * Sets the mesh indices.
  15513. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15515. * This method creates a new index buffer each call.
  15516. * Returns the Mesh.
  15517. */
  15518. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15519. /**
  15520. * Boolean : True if the mesh owns the requested kind of data.
  15521. */
  15522. isVerticesDataPresent(kind: string): boolean;
  15523. /**
  15524. * Returns an array of indices (IndicesArray).
  15525. */
  15526. getIndices(): Nullable<IndicesArray>;
  15527. get _positions(): Nullable<Vector3[]>;
  15528. /**
  15529. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15530. * This means the mesh underlying bounding box and sphere are recomputed.
  15531. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15532. * @returns the current mesh
  15533. */
  15534. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15535. /** @hidden */
  15536. _preActivate(): InstancedMesh;
  15537. /** @hidden */
  15538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15539. /** @hidden */
  15540. _postActivate(): void;
  15541. getWorldMatrix(): Matrix;
  15542. get isAnInstance(): boolean;
  15543. /**
  15544. * Returns the current associated LOD AbstractMesh.
  15545. */
  15546. getLOD(camera: Camera): AbstractMesh;
  15547. /** @hidden */
  15548. _syncSubMeshes(): InstancedMesh;
  15549. /** @hidden */
  15550. _generatePointsArray(): boolean;
  15551. /**
  15552. * Creates a new InstancedMesh from the current mesh.
  15553. * - name (string) : the cloned mesh name
  15554. * - newParent (optional Node) : the optional Node to parent the clone to.
  15555. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15556. *
  15557. * Returns the clone.
  15558. */
  15559. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15560. /**
  15561. * Disposes the InstancedMesh.
  15562. * Returns nothing.
  15563. */
  15564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15565. }
  15566. module "babylonjs/Meshes/mesh" {
  15567. interface Mesh {
  15568. /**
  15569. * Register a custom buffer that will be instanced
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15571. * @param kind defines the buffer kind
  15572. * @param stride defines the stride in floats
  15573. */
  15574. registerInstancedBuffer(kind: string, stride: number): void;
  15575. /** @hidden */
  15576. _userInstancedBuffersStorage: {
  15577. data: {
  15578. [key: string]: Float32Array;
  15579. };
  15580. sizes: {
  15581. [key: string]: number;
  15582. };
  15583. vertexBuffers: {
  15584. [key: string]: Nullable<VertexBuffer>;
  15585. };
  15586. strides: {
  15587. [key: string]: number;
  15588. };
  15589. };
  15590. }
  15591. }
  15592. module "babylonjs/Meshes/abstractMesh" {
  15593. interface AbstractMesh {
  15594. /**
  15595. * Object used to store instanced buffers defined by user
  15596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15597. */
  15598. instancedBuffers: {
  15599. [key: string]: any;
  15600. };
  15601. }
  15602. }
  15603. }
  15604. declare module "babylonjs/Materials/shaderMaterial" {
  15605. import { Scene } from "babylonjs/scene";
  15606. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15608. import { Mesh } from "babylonjs/Meshes/mesh";
  15609. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15611. import { Texture } from "babylonjs/Materials/Textures/texture";
  15612. import { Material } from "babylonjs/Materials/material";
  15613. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15614. /**
  15615. * Defines the options associated with the creation of a shader material.
  15616. */
  15617. export interface IShaderMaterialOptions {
  15618. /**
  15619. * Does the material work in alpha blend mode
  15620. */
  15621. needAlphaBlending: boolean;
  15622. /**
  15623. * Does the material work in alpha test mode
  15624. */
  15625. needAlphaTesting: boolean;
  15626. /**
  15627. * The list of attribute names used in the shader
  15628. */
  15629. attributes: string[];
  15630. /**
  15631. * The list of unifrom names used in the shader
  15632. */
  15633. uniforms: string[];
  15634. /**
  15635. * The list of UBO names used in the shader
  15636. */
  15637. uniformBuffers: string[];
  15638. /**
  15639. * The list of sampler names used in the shader
  15640. */
  15641. samplers: string[];
  15642. /**
  15643. * The list of defines used in the shader
  15644. */
  15645. defines: string[];
  15646. }
  15647. /**
  15648. * 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.
  15649. *
  15650. * This returned material effects how the mesh will look based on the code in the shaders.
  15651. *
  15652. * @see http://doc.babylonjs.com/how_to/shader_material
  15653. */
  15654. export class ShaderMaterial extends Material {
  15655. private _shaderPath;
  15656. private _options;
  15657. private _textures;
  15658. private _textureArrays;
  15659. private _floats;
  15660. private _ints;
  15661. private _floatsArrays;
  15662. private _colors3;
  15663. private _colors3Arrays;
  15664. private _colors4;
  15665. private _colors4Arrays;
  15666. private _vectors2;
  15667. private _vectors3;
  15668. private _vectors4;
  15669. private _matrices;
  15670. private _matrixArrays;
  15671. private _matrices3x3;
  15672. private _matrices2x2;
  15673. private _vectors2Arrays;
  15674. private _vectors3Arrays;
  15675. private _vectors4Arrays;
  15676. private _cachedWorldViewMatrix;
  15677. private _cachedWorldViewProjectionMatrix;
  15678. private _renderId;
  15679. private _multiview;
  15680. /**
  15681. * Instantiate a new shader material.
  15682. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15683. * This returned material effects how the mesh will look based on the code in the shaders.
  15684. * @see http://doc.babylonjs.com/how_to/shader_material
  15685. * @param name Define the name of the material in the scene
  15686. * @param scene Define the scene the material belongs to
  15687. * @param shaderPath Defines the route to the shader code in one of three ways:
  15688. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15689. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15690. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15691. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15692. * @param options Define the options used to create the shader
  15693. */
  15694. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15695. /**
  15696. * Gets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. get shaderPath(): any;
  15700. /**
  15701. * Sets the shader path used to define the shader code
  15702. * It can be modified to trigger a new compilation
  15703. */
  15704. set shaderPath(shaderPath: any);
  15705. /**
  15706. * Gets the options used to compile the shader.
  15707. * They can be modified to trigger a new compilation
  15708. */
  15709. get options(): IShaderMaterialOptions;
  15710. /**
  15711. * Gets the current class name of the material e.g. "ShaderMaterial"
  15712. * Mainly use in serialization.
  15713. * @returns the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Specifies if the material will require alpha blending
  15718. * @returns a boolean specifying if alpha blending is needed
  15719. */
  15720. needAlphaBlending(): boolean;
  15721. /**
  15722. * Specifies if this material should be rendered in alpha test mode
  15723. * @returns a boolean specifying if an alpha test is needed.
  15724. */
  15725. needAlphaTesting(): boolean;
  15726. private _checkUniform;
  15727. /**
  15728. * Set a texture in the shader.
  15729. * @param name Define the name of the uniform samplers as defined in the shader
  15730. * @param texture Define the texture to bind to this sampler
  15731. * @return the material itself allowing "fluent" like uniform updates
  15732. */
  15733. setTexture(name: string, texture: Texture): ShaderMaterial;
  15734. /**
  15735. * Set a texture array in the shader.
  15736. * @param name Define the name of the uniform sampler array as defined in the shader
  15737. * @param textures Define the list of textures to bind to this sampler
  15738. * @return the material itself allowing "fluent" like uniform updates
  15739. */
  15740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15741. /**
  15742. * Set a float in the shader.
  15743. * @param name Define the name of the uniform as defined in the shader
  15744. * @param value Define the value to give to the uniform
  15745. * @return the material itself allowing "fluent" like uniform updates
  15746. */
  15747. setFloat(name: string, value: number): ShaderMaterial;
  15748. /**
  15749. * Set a int in the shader.
  15750. * @param name Define the name of the uniform as defined in the shader
  15751. * @param value Define the value to give to the uniform
  15752. * @return the material itself allowing "fluent" like uniform updates
  15753. */
  15754. setInt(name: string, value: number): ShaderMaterial;
  15755. /**
  15756. * Set an array of floats in the shader.
  15757. * @param name Define the name of the uniform as defined in the shader
  15758. * @param value Define the value to give to the uniform
  15759. * @return the material itself allowing "fluent" like uniform updates
  15760. */
  15761. setFloats(name: string, value: number[]): ShaderMaterial;
  15762. /**
  15763. * Set a vec3 in the shader from a Color3.
  15764. * @param name Define the name of the uniform as defined in the shader
  15765. * @param value Define the value to give to the uniform
  15766. * @return the material itself allowing "fluent" like uniform updates
  15767. */
  15768. setColor3(name: string, value: Color3): ShaderMaterial;
  15769. /**
  15770. * Set a vec3 array in the shader from a Color3 array.
  15771. * @param name Define the name of the uniform as defined in the shader
  15772. * @param value Define the value to give to the uniform
  15773. * @return the material itself allowing "fluent" like uniform updates
  15774. */
  15775. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15776. /**
  15777. * Set a vec4 in the shader from a Color4.
  15778. * @param name Define the name of the uniform as defined in the shader
  15779. * @param value Define the value to give to the uniform
  15780. * @return the material itself allowing "fluent" like uniform updates
  15781. */
  15782. setColor4(name: string, value: Color4): ShaderMaterial;
  15783. /**
  15784. * Set a vec4 array in the shader from a Color4 array.
  15785. * @param name Define the name of the uniform as defined in the shader
  15786. * @param value Define the value to give to the uniform
  15787. * @return the material itself allowing "fluent" like uniform updates
  15788. */
  15789. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15790. /**
  15791. * Set a vec2 in the shader from a Vector2.
  15792. * @param name Define the name of the uniform as defined in the shader
  15793. * @param value Define the value to give to the uniform
  15794. * @return the material itself allowing "fluent" like uniform updates
  15795. */
  15796. setVector2(name: string, value: Vector2): ShaderMaterial;
  15797. /**
  15798. * Set a vec3 in the shader from a Vector3.
  15799. * @param name Define the name of the uniform as defined in the shader
  15800. * @param value Define the value to give to the uniform
  15801. * @return the material itself allowing "fluent" like uniform updates
  15802. */
  15803. setVector3(name: string, value: Vector3): ShaderMaterial;
  15804. /**
  15805. * Set a vec4 in the shader from a Vector4.
  15806. * @param name Define the name of the uniform as defined in the shader
  15807. * @param value Define the value to give to the uniform
  15808. * @return the material itself allowing "fluent" like uniform updates
  15809. */
  15810. setVector4(name: string, value: Vector4): ShaderMaterial;
  15811. /**
  15812. * Set a mat4 in the shader from a Matrix.
  15813. * @param name Define the name of the uniform as defined in the shader
  15814. * @param value Define the value to give to the uniform
  15815. * @return the material itself allowing "fluent" like uniform updates
  15816. */
  15817. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15818. /**
  15819. * Set a float32Array in the shader from a matrix array.
  15820. * @param name Define the name of the uniform as defined in the shader
  15821. * @param value Define the value to give to the uniform
  15822. * @return the material itself allowing "fluent" like uniform updates
  15823. */
  15824. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15825. /**
  15826. * Set a mat3 in the shader from a Float32Array.
  15827. * @param name Define the name of the uniform as defined in the shader
  15828. * @param value Define the value to give to the uniform
  15829. * @return the material itself allowing "fluent" like uniform updates
  15830. */
  15831. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15832. /**
  15833. * Set a mat2 in the shader from a Float32Array.
  15834. * @param name Define the name of the uniform as defined in the shader
  15835. * @param value Define the value to give to the uniform
  15836. * @return the material itself allowing "fluent" like uniform updates
  15837. */
  15838. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15839. /**
  15840. * Set a vec2 array in the shader from a number array.
  15841. * @param name Define the name of the uniform as defined in the shader
  15842. * @param value Define the value to give to the uniform
  15843. * @return the material itself allowing "fluent" like uniform updates
  15844. */
  15845. setArray2(name: string, value: number[]): ShaderMaterial;
  15846. /**
  15847. * Set a vec3 array in the shader from a number array.
  15848. * @param name Define the name of the uniform as defined in the shader
  15849. * @param value Define the value to give to the uniform
  15850. * @return the material itself allowing "fluent" like uniform updates
  15851. */
  15852. setArray3(name: string, value: number[]): ShaderMaterial;
  15853. /**
  15854. * Set a vec4 array in the shader from a number array.
  15855. * @param name Define the name of the uniform as defined in the shader
  15856. * @param value Define the value to give to the uniform
  15857. * @return the material itself allowing "fluent" like uniform updates
  15858. */
  15859. setArray4(name: string, value: number[]): ShaderMaterial;
  15860. private _checkCache;
  15861. /**
  15862. * Specifies that the submesh is ready to be used
  15863. * @param mesh defines the mesh to check
  15864. * @param subMesh defines which submesh to check
  15865. * @param useInstances specifies that instances should be used
  15866. * @returns a boolean indicating that the submesh is ready or not
  15867. */
  15868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15869. /**
  15870. * Checks if the material is ready to render the requested mesh
  15871. * @param mesh Define the mesh to render
  15872. * @param useInstances Define whether or not the material is used with instances
  15873. * @returns true if ready, otherwise false
  15874. */
  15875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15876. /**
  15877. * Binds the world matrix to the material
  15878. * @param world defines the world transformation matrix
  15879. */
  15880. bindOnlyWorldMatrix(world: Matrix): void;
  15881. /**
  15882. * Binds the material to the mesh
  15883. * @param world defines the world transformation matrix
  15884. * @param mesh defines the mesh to bind the material to
  15885. */
  15886. bind(world: Matrix, mesh?: Mesh): void;
  15887. /**
  15888. * Gets the active textures from the material
  15889. * @returns an array of textures
  15890. */
  15891. getActiveTextures(): BaseTexture[];
  15892. /**
  15893. * Specifies if the material uses a texture
  15894. * @param texture defines the texture to check against the material
  15895. * @returns a boolean specifying if the material uses the texture
  15896. */
  15897. hasTexture(texture: BaseTexture): boolean;
  15898. /**
  15899. * Makes a duplicate of the material, and gives it a new name
  15900. * @param name defines the new name for the duplicated material
  15901. * @returns the cloned material
  15902. */
  15903. clone(name: string): ShaderMaterial;
  15904. /**
  15905. * Disposes the material
  15906. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15907. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15908. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15909. */
  15910. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15911. /**
  15912. * Serializes this material in a JSON representation
  15913. * @returns the serialized material object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Creates a shader material from parsed shader material data
  15918. * @param source defines the JSON represnetation of the material
  15919. * @param scene defines the hosting scene
  15920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15921. * @returns a new material
  15922. */
  15923. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15924. }
  15925. }
  15926. declare module "babylonjs/Shaders/color.fragment" {
  15927. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15929. /** @hidden */
  15930. export var colorPixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module "babylonjs/Shaders/color.vertex" {
  15936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15937. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15942. /** @hidden */
  15943. export var colorVertexShader: {
  15944. name: string;
  15945. shader: string;
  15946. };
  15947. }
  15948. declare module "babylonjs/Meshes/linesMesh" {
  15949. import { Nullable } from "babylonjs/types";
  15950. import { Scene } from "babylonjs/scene";
  15951. import { Color3 } from "babylonjs/Maths/math.color";
  15952. import { Node } from "babylonjs/node";
  15953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15954. import { Mesh } from "babylonjs/Meshes/mesh";
  15955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15956. import { Effect } from "babylonjs/Materials/effect";
  15957. import { Material } from "babylonjs/Materials/material";
  15958. import "babylonjs/Shaders/color.fragment";
  15959. import "babylonjs/Shaders/color.vertex";
  15960. /**
  15961. * Line mesh
  15962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15963. */
  15964. export class LinesMesh extends Mesh {
  15965. /**
  15966. * If vertex color should be applied to the mesh
  15967. */
  15968. readonly useVertexColor?: boolean | undefined;
  15969. /**
  15970. * If vertex alpha should be applied to the mesh
  15971. */
  15972. readonly useVertexAlpha?: boolean | undefined;
  15973. /**
  15974. * Color of the line (Default: White)
  15975. */
  15976. color: Color3;
  15977. /**
  15978. * Alpha of the line (Default: 1)
  15979. */
  15980. alpha: number;
  15981. /**
  15982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15983. * This margin is expressed in world space coordinates, so its value may vary.
  15984. * Default value is 0.1
  15985. */
  15986. intersectionThreshold: number;
  15987. private _colorShader;
  15988. private color4;
  15989. /**
  15990. * Creates a new LinesMesh
  15991. * @param name defines the name
  15992. * @param scene defines the hosting scene
  15993. * @param parent defines the parent mesh if any
  15994. * @param source defines the optional source LinesMesh used to clone data from
  15995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15996. * When false, achieved by calling a clone(), also passing False.
  15997. * This will make creation of children, recursive.
  15998. * @param useVertexColor defines if this LinesMesh supports vertex color
  15999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16000. */
  16001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16002. /**
  16003. * If vertex color should be applied to the mesh
  16004. */
  16005. useVertexColor?: boolean | undefined,
  16006. /**
  16007. * If vertex alpha should be applied to the mesh
  16008. */
  16009. useVertexAlpha?: boolean | undefined);
  16010. private _addClipPlaneDefine;
  16011. private _removeClipPlaneDefine;
  16012. isReady(): boolean;
  16013. /**
  16014. * Returns the string "LineMesh"
  16015. */
  16016. getClassName(): string;
  16017. /**
  16018. * @hidden
  16019. */
  16020. get material(): Material;
  16021. /**
  16022. * @hidden
  16023. */
  16024. set material(value: Material);
  16025. /**
  16026. * @hidden
  16027. */
  16028. get checkCollisions(): boolean;
  16029. /** @hidden */
  16030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16031. /** @hidden */
  16032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16033. /**
  16034. * Disposes of the line mesh
  16035. * @param doNotRecurse If children should be disposed
  16036. */
  16037. dispose(doNotRecurse?: boolean): void;
  16038. /**
  16039. * Returns a new LineMesh object cloned from the current one.
  16040. */
  16041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16042. /**
  16043. * Creates a new InstancedLinesMesh object from the mesh model.
  16044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16045. * @param name defines the name of the new instance
  16046. * @returns a new InstancedLinesMesh
  16047. */
  16048. createInstance(name: string): InstancedLinesMesh;
  16049. }
  16050. /**
  16051. * Creates an instance based on a source LinesMesh
  16052. */
  16053. export class InstancedLinesMesh extends InstancedMesh {
  16054. /**
  16055. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16056. * This margin is expressed in world space coordinates, so its value may vary.
  16057. * Initilized with the intersectionThreshold value of the source LinesMesh
  16058. */
  16059. intersectionThreshold: number;
  16060. constructor(name: string, source: LinesMesh);
  16061. /**
  16062. * Returns the string "InstancedLinesMesh".
  16063. */
  16064. getClassName(): string;
  16065. }
  16066. }
  16067. declare module "babylonjs/Shaders/line.fragment" {
  16068. /** @hidden */
  16069. export var linePixelShader: {
  16070. name: string;
  16071. shader: string;
  16072. };
  16073. }
  16074. declare module "babylonjs/Shaders/line.vertex" {
  16075. /** @hidden */
  16076. export var lineVertexShader: {
  16077. name: string;
  16078. shader: string;
  16079. };
  16080. }
  16081. declare module "babylonjs/Rendering/edgesRenderer" {
  16082. import { Nullable } from "babylonjs/types";
  16083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16085. import { Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { IDisposable } from "babylonjs/scene";
  16087. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16088. import "babylonjs/Shaders/line.fragment";
  16089. import "babylonjs/Shaders/line.vertex";
  16090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16091. module "babylonjs/Meshes/abstractMesh" {
  16092. interface AbstractMesh {
  16093. /**
  16094. * Gets the edgesRenderer associated with the mesh
  16095. */
  16096. edgesRenderer: Nullable<EdgesRenderer>;
  16097. }
  16098. }
  16099. module "babylonjs/Meshes/linesMesh" {
  16100. interface LinesMesh {
  16101. /**
  16102. * Enables the edge rendering mode on the mesh.
  16103. * This mode makes the mesh edges visible
  16104. * @param epsilon defines the maximal distance between two angles to detect a face
  16105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16106. * @returns the currentAbstractMesh
  16107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16108. */
  16109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16110. }
  16111. }
  16112. module "babylonjs/Meshes/linesMesh" {
  16113. interface InstancedLinesMesh {
  16114. /**
  16115. * Enables the edge rendering mode on the mesh.
  16116. * This mode makes the mesh edges visible
  16117. * @param epsilon defines the maximal distance between two angles to detect a face
  16118. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16119. * @returns the current InstancedLinesMesh
  16120. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16121. */
  16122. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16123. }
  16124. }
  16125. /**
  16126. * Defines the minimum contract an Edges renderer should follow.
  16127. */
  16128. export interface IEdgesRenderer extends IDisposable {
  16129. /**
  16130. * Gets or sets a boolean indicating if the edgesRenderer is active
  16131. */
  16132. isEnabled: boolean;
  16133. /**
  16134. * Renders the edges of the attached mesh,
  16135. */
  16136. render(): void;
  16137. /**
  16138. * Checks wether or not the edges renderer is ready to render.
  16139. * @return true if ready, otherwise false.
  16140. */
  16141. isReady(): boolean;
  16142. }
  16143. /**
  16144. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16145. */
  16146. export class EdgesRenderer implements IEdgesRenderer {
  16147. /**
  16148. * Define the size of the edges with an orthographic camera
  16149. */
  16150. edgesWidthScalerForOrthographic: number;
  16151. /**
  16152. * Define the size of the edges with a perspective camera
  16153. */
  16154. edgesWidthScalerForPerspective: number;
  16155. protected _source: AbstractMesh;
  16156. protected _linesPositions: number[];
  16157. protected _linesNormals: number[];
  16158. protected _linesIndices: number[];
  16159. protected _epsilon: number;
  16160. protected _indicesCount: number;
  16161. protected _lineShader: ShaderMaterial;
  16162. protected _ib: DataBuffer;
  16163. protected _buffers: {
  16164. [key: string]: Nullable<VertexBuffer>;
  16165. };
  16166. protected _checkVerticesInsteadOfIndices: boolean;
  16167. private _meshRebuildObserver;
  16168. private _meshDisposeObserver;
  16169. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16170. isEnabled: boolean;
  16171. /**
  16172. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16173. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16174. * @param source Mesh used to create edges
  16175. * @param epsilon sum of angles in adjacency to check for edge
  16176. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16177. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16178. */
  16179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16180. protected _prepareRessources(): void;
  16181. /** @hidden */
  16182. _rebuild(): void;
  16183. /**
  16184. * Releases the required resources for the edges renderer
  16185. */
  16186. dispose(): void;
  16187. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16188. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16189. /**
  16190. * Checks if the pair of p0 and p1 is en edge
  16191. * @param faceIndex
  16192. * @param edge
  16193. * @param faceNormals
  16194. * @param p0
  16195. * @param p1
  16196. * @private
  16197. */
  16198. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16199. /**
  16200. * push line into the position, normal and index buffer
  16201. * @protected
  16202. */
  16203. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16204. /**
  16205. * Generates lines edges from adjacencjes
  16206. * @private
  16207. */
  16208. _generateEdgesLines(): void;
  16209. /**
  16210. * Checks wether or not the edges renderer is ready to render.
  16211. * @return true if ready, otherwise false.
  16212. */
  16213. isReady(): boolean;
  16214. /**
  16215. * Renders the edges of the attached mesh,
  16216. */
  16217. render(): void;
  16218. }
  16219. /**
  16220. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16221. */
  16222. export class LineEdgesRenderer extends EdgesRenderer {
  16223. /**
  16224. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16225. * @param source LineMesh used to generate edges
  16226. * @param epsilon not important (specified angle for edge detection)
  16227. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16228. */
  16229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16230. /**
  16231. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16232. */
  16233. _generateEdgesLines(): void;
  16234. }
  16235. }
  16236. declare module "babylonjs/Rendering/renderingGroup" {
  16237. import { SmartArray } from "babylonjs/Misc/smartArray";
  16238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16240. import { Nullable } from "babylonjs/types";
  16241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16242. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16243. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16244. import { Material } from "babylonjs/Materials/material";
  16245. import { Scene } from "babylonjs/scene";
  16246. /**
  16247. * This represents the object necessary to create a rendering group.
  16248. * This is exclusively used and created by the rendering manager.
  16249. * To modify the behavior, you use the available helpers in your scene or meshes.
  16250. * @hidden
  16251. */
  16252. export class RenderingGroup {
  16253. index: number;
  16254. private static _zeroVector;
  16255. private _scene;
  16256. private _opaqueSubMeshes;
  16257. private _transparentSubMeshes;
  16258. private _alphaTestSubMeshes;
  16259. private _depthOnlySubMeshes;
  16260. private _particleSystems;
  16261. private _spriteManagers;
  16262. private _opaqueSortCompareFn;
  16263. private _alphaTestSortCompareFn;
  16264. private _transparentSortCompareFn;
  16265. private _renderOpaque;
  16266. private _renderAlphaTest;
  16267. private _renderTransparent;
  16268. /** @hidden */
  16269. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16270. onBeforeTransparentRendering: () => void;
  16271. /**
  16272. * Set the opaque sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the alpha test sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Set the transparent sort comparison function.
  16283. * If null the sub meshes will be render in the order they were created
  16284. */
  16285. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16286. /**
  16287. * Creates a new rendering group.
  16288. * @param index The rendering group index
  16289. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16290. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16291. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16292. */
  16293. 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>);
  16294. /**
  16295. * Render all the sub meshes contained in the group.
  16296. * @param customRenderFunction Used to override the default render behaviour of the group.
  16297. * @returns true if rendered some submeshes.
  16298. */
  16299. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderOpaqueSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderAlphaTestSorted;
  16310. /**
  16311. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16312. * @param subMeshes The submeshes to render
  16313. */
  16314. private renderTransparentSorted;
  16315. /**
  16316. * Renders the submeshes in a specified order.
  16317. * @param subMeshes The submeshes to sort before render
  16318. * @param sortCompareFn The comparison function use to sort
  16319. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16320. * @param transparent Specifies to activate blending if true
  16321. */
  16322. private static renderSorted;
  16323. /**
  16324. * Renders the submeshes in the order they were dispatched (no sort applied).
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private static renderUnsorted;
  16328. /**
  16329. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16330. * are rendered back to front if in the same alpha index.
  16331. *
  16332. * @param a The first submesh
  16333. * @param b The second submesh
  16334. * @returns The result of the comparison
  16335. */
  16336. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16337. /**
  16338. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16339. * are rendered back to front.
  16340. *
  16341. * @param a The first submesh
  16342. * @param b The second submesh
  16343. * @returns The result of the comparison
  16344. */
  16345. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16346. /**
  16347. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16348. * are rendered front to back (prevent overdraw).
  16349. *
  16350. * @param a The first submesh
  16351. * @param b The second submesh
  16352. * @returns The result of the comparison
  16353. */
  16354. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16355. /**
  16356. * Resets the different lists of submeshes to prepare a new frame.
  16357. */
  16358. prepare(): void;
  16359. dispose(): void;
  16360. /**
  16361. * Inserts the submesh in its correct queue depending on its material.
  16362. * @param subMesh The submesh to dispatch
  16363. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16364. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16365. */
  16366. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16367. dispatchSprites(spriteManager: ISpriteManager): void;
  16368. dispatchParticles(particleSystem: IParticleSystem): void;
  16369. private _renderParticles;
  16370. private _renderSprites;
  16371. }
  16372. }
  16373. declare module "babylonjs/Rendering/renderingManager" {
  16374. import { Nullable } from "babylonjs/types";
  16375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16377. import { SmartArray } from "babylonjs/Misc/smartArray";
  16378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16379. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16380. import { Material } from "babylonjs/Materials/material";
  16381. import { Scene } from "babylonjs/scene";
  16382. import { Camera } from "babylonjs/Cameras/camera";
  16383. /**
  16384. * Interface describing the different options available in the rendering manager
  16385. * regarding Auto Clear between groups.
  16386. */
  16387. export interface IRenderingManagerAutoClearSetup {
  16388. /**
  16389. * Defines whether or not autoclear is enable.
  16390. */
  16391. autoClear: boolean;
  16392. /**
  16393. * Defines whether or not to autoclear the depth buffer.
  16394. */
  16395. depth: boolean;
  16396. /**
  16397. * Defines whether or not to autoclear the stencil buffer.
  16398. */
  16399. stencil: boolean;
  16400. }
  16401. /**
  16402. * This class is used by the onRenderingGroupObservable
  16403. */
  16404. export class RenderingGroupInfo {
  16405. /**
  16406. * The Scene that being rendered
  16407. */
  16408. scene: Scene;
  16409. /**
  16410. * The camera currently used for the rendering pass
  16411. */
  16412. camera: Nullable<Camera>;
  16413. /**
  16414. * The ID of the renderingGroup being processed
  16415. */
  16416. renderingGroupId: number;
  16417. }
  16418. /**
  16419. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16420. * It is enable to manage the different groups as well as the different necessary sort functions.
  16421. * This should not be used directly aside of the few static configurations
  16422. */
  16423. export class RenderingManager {
  16424. /**
  16425. * The max id used for rendering groups (not included)
  16426. */
  16427. static MAX_RENDERINGGROUPS: number;
  16428. /**
  16429. * The min id used for rendering groups (included)
  16430. */
  16431. static MIN_RENDERINGGROUPS: number;
  16432. /**
  16433. * Used to globally prevent autoclearing scenes.
  16434. */
  16435. static AUTOCLEAR: boolean;
  16436. /**
  16437. * @hidden
  16438. */
  16439. _useSceneAutoClearSetup: boolean;
  16440. private _scene;
  16441. private _renderingGroups;
  16442. private _depthStencilBufferAlreadyCleaned;
  16443. private _autoClearDepthStencil;
  16444. private _customOpaqueSortCompareFn;
  16445. private _customAlphaTestSortCompareFn;
  16446. private _customTransparentSortCompareFn;
  16447. private _renderingGroupInfo;
  16448. /**
  16449. * Instantiates a new rendering group for a particular scene
  16450. * @param scene Defines the scene the groups belongs to
  16451. */
  16452. constructor(scene: Scene);
  16453. private _clearDepthStencilBuffer;
  16454. /**
  16455. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16456. * @hidden
  16457. */
  16458. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16459. /**
  16460. * Resets the different information of the group to prepare a new frame
  16461. * @hidden
  16462. */
  16463. reset(): void;
  16464. /**
  16465. * Dispose and release the group and its associated resources.
  16466. * @hidden
  16467. */
  16468. dispose(): void;
  16469. /**
  16470. * Clear the info related to rendering groups preventing retention points during dispose.
  16471. */
  16472. freeRenderingGroups(): void;
  16473. private _prepareRenderingGroup;
  16474. /**
  16475. * Add a sprite manager to the rendering manager in order to render it this frame.
  16476. * @param spriteManager Define the sprite manager to render
  16477. */
  16478. dispatchSprites(spriteManager: ISpriteManager): void;
  16479. /**
  16480. * Add a particle system to the rendering manager in order to render it this frame.
  16481. * @param particleSystem Define the particle system to render
  16482. */
  16483. dispatchParticles(particleSystem: IParticleSystem): void;
  16484. /**
  16485. * Add a submesh to the manager in order to render it this frame
  16486. * @param subMesh The submesh to dispatch
  16487. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16488. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16489. */
  16490. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16491. /**
  16492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16493. * This allowed control for front to back rendering or reversly depending of the special needs.
  16494. *
  16495. * @param renderingGroupId The rendering group id corresponding to its index
  16496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16499. */
  16500. 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;
  16501. /**
  16502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16503. *
  16504. * @param renderingGroupId The rendering group id corresponding to its index
  16505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16508. */
  16509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16510. /**
  16511. * Gets the current auto clear configuration for one rendering group of the rendering
  16512. * manager.
  16513. * @param index the rendering group index to get the information for
  16514. * @returns The auto clear setup for the requested rendering group
  16515. */
  16516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16517. }
  16518. }
  16519. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16520. import { SmartArray } from "babylonjs/Misc/smartArray";
  16521. import { Nullable } from "babylonjs/types";
  16522. import { Scene } from "babylonjs/scene";
  16523. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16526. import { Mesh } from "babylonjs/Meshes/mesh";
  16527. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16528. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16529. import { Effect } from "babylonjs/Materials/effect";
  16530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16532. import "babylonjs/Shaders/shadowMap.fragment";
  16533. import "babylonjs/Shaders/shadowMap.vertex";
  16534. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. /**
  16537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16538. */
  16539. export interface ICustomShaderOptions {
  16540. /**
  16541. * Gets or sets the custom shader name to use
  16542. */
  16543. shaderName: string;
  16544. /**
  16545. * The list of attribute names used in the shader
  16546. */
  16547. attributes?: string[];
  16548. /**
  16549. * The list of unifrom names used in the shader
  16550. */
  16551. uniforms?: string[];
  16552. /**
  16553. * The list of sampler names used in the shader
  16554. */
  16555. samplers?: string[];
  16556. /**
  16557. * The list of defines used in the shader
  16558. */
  16559. defines?: string[];
  16560. }
  16561. /**
  16562. * Interface to implement to create a shadow generator compatible with BJS.
  16563. */
  16564. export interface IShadowGenerator {
  16565. /**
  16566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16567. * @returns The render target texture if present otherwise, null
  16568. */
  16569. getShadowMap(): Nullable<RenderTargetTexture>;
  16570. /**
  16571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16572. * @param subMesh The submesh we want to render in the shadow map
  16573. * @param useInstances Defines wether will draw in the map using instances
  16574. * @returns true if ready otherwise, false
  16575. */
  16576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16577. /**
  16578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16579. * @param defines Defines of the material we want to update
  16580. * @param lightIndex Index of the light in the enabled light list of the material
  16581. */
  16582. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16583. /**
  16584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16585. * defined in the generator but impacting the effect).
  16586. * It implies the unifroms available on the materials are the standard BJS ones.
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. /**
  16603. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16604. * @param onCompiled Callback triggered at the and of the effects compilation
  16605. * @param options Sets of optional options forcing the compilation with different modes
  16606. */
  16607. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16608. useInstances: boolean;
  16609. }>): void;
  16610. /**
  16611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16612. * @param options Sets of optional options forcing the compilation with different modes
  16613. * @returns A promise that resolves when the compilation completes
  16614. */
  16615. forceCompilationAsync(options?: Partial<{
  16616. useInstances: boolean;
  16617. }>): Promise<void>;
  16618. /**
  16619. * Serializes the shadow generator setup to a json object.
  16620. * @returns The serialized JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Disposes the Shadow map and related Textures and effects.
  16625. */
  16626. dispose(): void;
  16627. }
  16628. /**
  16629. * Default implementation IShadowGenerator.
  16630. * This is the main object responsible of generating shadows in the framework.
  16631. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16632. */
  16633. export class ShadowGenerator implements IShadowGenerator {
  16634. /**
  16635. * Name of the shadow generator class
  16636. */
  16637. static CLASSNAME: string;
  16638. /**
  16639. * Shadow generator mode None: no filtering applied.
  16640. */
  16641. static readonly FILTER_NONE: number;
  16642. /**
  16643. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16645. */
  16646. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16647. /**
  16648. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16649. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16650. */
  16651. static readonly FILTER_POISSONSAMPLING: number;
  16652. /**
  16653. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16655. */
  16656. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16657. /**
  16658. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16659. * edge artifacts on steep falloff.
  16660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16661. */
  16662. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16663. /**
  16664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16665. * edge artifacts on steep falloff.
  16666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16667. */
  16668. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16669. /**
  16670. * Shadow generator mode PCF: Percentage Closer Filtering
  16671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16672. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16673. */
  16674. static readonly FILTER_PCF: number;
  16675. /**
  16676. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16677. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16678. * Contact Hardening
  16679. */
  16680. static readonly FILTER_PCSS: number;
  16681. /**
  16682. * Reserved for PCF and PCSS
  16683. * Highest Quality.
  16684. *
  16685. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16686. *
  16687. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16688. */
  16689. static readonly QUALITY_HIGH: number;
  16690. /**
  16691. * Reserved for PCF and PCSS
  16692. * Good tradeoff for quality/perf cross devices
  16693. *
  16694. * Execute PCF on a 3*3 kernel.
  16695. *
  16696. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16697. */
  16698. static readonly QUALITY_MEDIUM: number;
  16699. /**
  16700. * Reserved for PCF and PCSS
  16701. * The lowest quality but the fastest.
  16702. *
  16703. * Execute PCF on a 1*1 kernel.
  16704. *
  16705. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16706. */
  16707. static readonly QUALITY_LOW: number;
  16708. /** Gets or sets the custom shader name to use */
  16709. customShaderOptions: ICustomShaderOptions;
  16710. /**
  16711. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16712. */
  16713. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16714. /**
  16715. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16716. */
  16717. onAfterShadowMapRenderObservable: Observable<Effect>;
  16718. /**
  16719. * Observable triggered before a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16721. */
  16722. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. /**
  16724. * Observable triggered after a mesh is rendered in the shadow map.
  16725. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16726. */
  16727. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16728. protected _bias: number;
  16729. /**
  16730. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16731. */
  16732. get bias(): number;
  16733. /**
  16734. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16735. */
  16736. set bias(bias: number);
  16737. protected _normalBias: number;
  16738. /**
  16739. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16740. */
  16741. get normalBias(): number;
  16742. /**
  16743. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16744. */
  16745. set normalBias(normalBias: number);
  16746. protected _blurBoxOffset: number;
  16747. /**
  16748. * Gets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. get blurBoxOffset(): number;
  16752. /**
  16753. * Sets the blur box offset: offset applied during the blur pass.
  16754. * Only useful if useKernelBlur = false
  16755. */
  16756. set blurBoxOffset(value: number);
  16757. protected _blurScale: number;
  16758. /**
  16759. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. get blurScale(): number;
  16763. /**
  16764. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16765. * 2 means half of the size.
  16766. */
  16767. set blurScale(value: number);
  16768. protected _blurKernel: number;
  16769. /**
  16770. * Gets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. get blurKernel(): number;
  16774. /**
  16775. * Sets the blur kernel: kernel size of the blur pass.
  16776. * Only useful if useKernelBlur = true
  16777. */
  16778. set blurKernel(value: number);
  16779. protected _useKernelBlur: boolean;
  16780. /**
  16781. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. get useKernelBlur(): boolean;
  16785. /**
  16786. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16788. */
  16789. set useKernelBlur(value: boolean);
  16790. protected _depthScale: number;
  16791. /**
  16792. * Gets the depth scale used in ESM mode.
  16793. */
  16794. get depthScale(): number;
  16795. /**
  16796. * Sets the depth scale used in ESM mode.
  16797. * This can override the scale stored on the light.
  16798. */
  16799. set depthScale(value: number);
  16800. protected _validateFilter(filter: number): number;
  16801. protected _filter: number;
  16802. /**
  16803. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. get filter(): number;
  16807. /**
  16808. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16810. */
  16811. set filter(value: number);
  16812. /**
  16813. * Gets if the current filter is set to Poisson Sampling.
  16814. */
  16815. get usePoissonSampling(): boolean;
  16816. /**
  16817. * Sets the current filter to Poisson Sampling.
  16818. */
  16819. set usePoissonSampling(value: boolean);
  16820. /**
  16821. * Gets if the current filter is set to ESM.
  16822. */
  16823. get useExponentialShadowMap(): boolean;
  16824. /**
  16825. * Sets the current filter is to ESM.
  16826. */
  16827. set useExponentialShadowMap(value: boolean);
  16828. /**
  16829. * Gets if the current filter is set to filtered ESM.
  16830. */
  16831. get useBlurExponentialShadowMap(): boolean;
  16832. /**
  16833. * Gets if the current filter is set to filtered ESM.
  16834. */
  16835. set useBlurExponentialShadowMap(value: boolean);
  16836. /**
  16837. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. get useCloseExponentialShadowMap(): boolean;
  16841. /**
  16842. * Sets the current filter to "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. set useCloseExponentialShadowMap(value: boolean);
  16846. /**
  16847. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. get useBlurCloseExponentialShadowMap(): boolean;
  16851. /**
  16852. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16853. * exponential to prevent steep falloff artifacts).
  16854. */
  16855. set useBlurCloseExponentialShadowMap(value: boolean);
  16856. /**
  16857. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16858. */
  16859. get usePercentageCloserFiltering(): boolean;
  16860. /**
  16861. * Sets the current filter to "PCF" (percentage closer filtering).
  16862. */
  16863. set usePercentageCloserFiltering(value: boolean);
  16864. protected _filteringQuality: number;
  16865. /**
  16866. * Gets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. get filteringQuality(): number;
  16870. /**
  16871. * Sets the PCF or PCSS Quality.
  16872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16873. */
  16874. set filteringQuality(filteringQuality: number);
  16875. /**
  16876. * Gets if the current filter is set to "PCSS" (contact hardening).
  16877. */
  16878. get useContactHardeningShadow(): boolean;
  16879. /**
  16880. * Sets the current filter to "PCSS" (contact hardening).
  16881. */
  16882. set useContactHardeningShadow(value: boolean);
  16883. protected _contactHardeningLightSizeUVRatio: number;
  16884. /**
  16885. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16886. * Using a ratio helps keeping shape stability independently of the map size.
  16887. *
  16888. * It does not account for the light projection as it was having too much
  16889. * instability during the light setup or during light position changes.
  16890. *
  16891. * Only valid if useContactHardeningShadow is true.
  16892. */
  16893. get contactHardeningLightSizeUVRatio(): number;
  16894. /**
  16895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16896. * Using a ratio helps keeping shape stability independently of the map size.
  16897. *
  16898. * It does not account for the light projection as it was having too much
  16899. * instability during the light setup or during light position changes.
  16900. *
  16901. * Only valid if useContactHardeningShadow is true.
  16902. */
  16903. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16904. protected _darkness: number;
  16905. /** Gets or sets the actual darkness of a shadow */
  16906. get darkness(): number;
  16907. set darkness(value: number);
  16908. /**
  16909. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16910. * 0 means strongest and 1 would means no shadow.
  16911. * @returns the darkness.
  16912. */
  16913. getDarkness(): number;
  16914. /**
  16915. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16916. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16917. * @returns the shadow generator allowing fluent coding.
  16918. */
  16919. setDarkness(darkness: number): ShadowGenerator;
  16920. protected _transparencyShadow: boolean;
  16921. /** Gets or sets the ability to have transparent shadow */
  16922. get transparencyShadow(): boolean;
  16923. set transparencyShadow(value: boolean);
  16924. /**
  16925. * Sets the ability to have transparent shadow (boolean).
  16926. * @param transparent True if transparent else False
  16927. * @returns the shadow generator allowing fluent coding
  16928. */
  16929. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16930. protected _shadowMap: Nullable<RenderTargetTexture>;
  16931. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16934. * @returns The render target texture if present otherwise, null
  16935. */
  16936. getShadowMap(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16939. * @returns The render target texture if the shadow map is present otherwise, null
  16940. */
  16941. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16942. /**
  16943. * Gets the class name of that object
  16944. * @returns "ShadowGenerator"
  16945. */
  16946. getClassName(): string;
  16947. /**
  16948. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16949. * @param mesh Mesh to add
  16950. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16951. * @returns the Shadow Generator itself
  16952. */
  16953. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16954. /**
  16955. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16956. * @param mesh Mesh to remove
  16957. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16958. * @returns the Shadow Generator itself
  16959. */
  16960. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16961. /**
  16962. * Controls the extent to which the shadows fade out at the edge of the frustum
  16963. */
  16964. frustumEdgeFalloff: number;
  16965. protected _light: IShadowLight;
  16966. /**
  16967. * Returns the associated light object.
  16968. * @returns the light generating the shadow
  16969. */
  16970. getLight(): IShadowLight;
  16971. /**
  16972. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16973. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16974. * It might on the other hand introduce peter panning.
  16975. */
  16976. forceBackFacesOnly: boolean;
  16977. protected _scene: Scene;
  16978. protected _lightDirection: Vector3;
  16979. protected _effect: Effect;
  16980. protected _viewMatrix: Matrix;
  16981. protected _projectionMatrix: Matrix;
  16982. protected _transformMatrix: Matrix;
  16983. protected _cachedPosition: Vector3;
  16984. protected _cachedDirection: Vector3;
  16985. protected _cachedDefines: string;
  16986. protected _currentRenderID: number;
  16987. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16988. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16989. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16990. protected _blurPostProcesses: PostProcess[];
  16991. protected _mapSize: number;
  16992. protected _currentFaceIndex: number;
  16993. protected _currentFaceIndexCache: number;
  16994. protected _textureType: number;
  16995. protected _defaultTextureMatrix: Matrix;
  16996. protected _storedUniqueId: Nullable<number>;
  16997. /** @hidden */
  16998. static _SceneComponentInitialization: (scene: Scene) => void;
  16999. /**
  17000. * Creates a ShadowGenerator object.
  17001. * A ShadowGenerator is the required tool to use the shadows.
  17002. * Each light casting shadows needs to use its own ShadowGenerator.
  17003. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17004. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17005. * @param light The light object generating the shadows.
  17006. * @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.
  17007. */
  17008. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17009. protected _initializeGenerator(): void;
  17010. protected _createTargetRenderTexture(): void;
  17011. protected _initializeShadowMap(): void;
  17012. protected _initializeBlurRTTAndPostProcesses(): void;
  17013. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17014. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17015. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17016. protected _applyFilterValues(): void;
  17017. /**
  17018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17019. * @param onCompiled Callback triggered at the and of the effects compilation
  17020. * @param options Sets of optional options forcing the compilation with different modes
  17021. */
  17022. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17023. useInstances: boolean;
  17024. }>): void;
  17025. /**
  17026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17027. * @param options Sets of optional options forcing the compilation with different modes
  17028. * @returns A promise that resolves when the compilation completes
  17029. */
  17030. forceCompilationAsync(options?: Partial<{
  17031. useInstances: boolean;
  17032. }>): Promise<void>;
  17033. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17034. /**
  17035. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17036. * @param subMesh The submesh we want to render in the shadow map
  17037. * @param useInstances Defines wether will draw in the map using instances
  17038. * @returns true if ready otherwise, false
  17039. */
  17040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17041. /**
  17042. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17043. * @param defines Defines of the material we want to update
  17044. * @param lightIndex Index of the light in the enabled light list of the material
  17045. */
  17046. prepareDefines(defines: any, lightIndex: number): void;
  17047. /**
  17048. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17049. * defined in the generator but impacting the effect).
  17050. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17051. * @param effect The effect we are binfing the information for
  17052. */
  17053. bindShadowLight(lightIndex: string, effect: Effect): void;
  17054. /**
  17055. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17056. * (eq to shadow prjection matrix * light transform matrix)
  17057. * @returns The transform matrix used to create the shadow map
  17058. */
  17059. getTransformMatrix(): Matrix;
  17060. /**
  17061. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17062. * Cube and 2D textures for instance.
  17063. */
  17064. recreateShadowMap(): void;
  17065. protected _disposeBlurPostProcesses(): void;
  17066. protected _disposeRTTandPostProcesses(): void;
  17067. /**
  17068. * Disposes the ShadowGenerator.
  17069. * Returns nothing.
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Serializes the shadow generator setup to a json object.
  17074. * @returns The serialized JSON object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17079. * @param parsedShadowGenerator The JSON object to parse
  17080. * @param scene The scene to create the shadow map for
  17081. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17082. * @returns The parsed shadow generator
  17083. */
  17084. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17085. }
  17086. }
  17087. declare module "babylonjs/Lights/light" {
  17088. import { Nullable } from "babylonjs/types";
  17089. import { Scene } from "babylonjs/scene";
  17090. import { Vector3 } from "babylonjs/Maths/math.vector";
  17091. import { Color3 } from "babylonjs/Maths/math.color";
  17092. import { Node } from "babylonjs/node";
  17093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17094. import { Effect } from "babylonjs/Materials/effect";
  17095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17096. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17097. /**
  17098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17100. * 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.
  17101. */
  17102. export abstract class Light extends Node {
  17103. /**
  17104. * Falloff Default: light is falling off following the material specification:
  17105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17106. */
  17107. static readonly FALLOFF_DEFAULT: number;
  17108. /**
  17109. * Falloff Physical: light is falling off following the inverse squared distance law.
  17110. */
  17111. static readonly FALLOFF_PHYSICAL: number;
  17112. /**
  17113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17114. * to enhance interoperability with other engines.
  17115. */
  17116. static readonly FALLOFF_GLTF: number;
  17117. /**
  17118. * Falloff Standard: light is falling off like in the standard material
  17119. * to enhance interoperability with other materials.
  17120. */
  17121. static readonly FALLOFF_STANDARD: number;
  17122. /**
  17123. * If every light affecting the material is in this lightmapMode,
  17124. * material.lightmapTexture adds or multiplies
  17125. * (depends on material.useLightmapAsShadowmap)
  17126. * after every other light calculations.
  17127. */
  17128. static readonly LIGHTMAP_DEFAULT: number;
  17129. /**
  17130. * material.lightmapTexture as only diffuse lighting from this light
  17131. * adds only specular lighting from this light
  17132. * adds dynamic shadows
  17133. */
  17134. static readonly LIGHTMAP_SPECULAR: number;
  17135. /**
  17136. * material.lightmapTexture as only lighting
  17137. * no light calculation from this light
  17138. * only adds dynamic shadows from this light
  17139. */
  17140. static readonly LIGHTMAP_SHADOWSONLY: number;
  17141. /**
  17142. * Each light type uses the default quantity according to its type:
  17143. * point/spot lights use luminous intensity
  17144. * directional lights use illuminance
  17145. */
  17146. static readonly INTENSITYMODE_AUTOMATIC: number;
  17147. /**
  17148. * lumen (lm)
  17149. */
  17150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17151. /**
  17152. * candela (lm/sr)
  17153. */
  17154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17155. /**
  17156. * lux (lm/m^2)
  17157. */
  17158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17159. /**
  17160. * nit (cd/m^2)
  17161. */
  17162. static readonly INTENSITYMODE_LUMINANCE: number;
  17163. /**
  17164. * Light type const id of the point light.
  17165. */
  17166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17167. /**
  17168. * Light type const id of the directional light.
  17169. */
  17170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17171. /**
  17172. * Light type const id of the spot light.
  17173. */
  17174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17175. /**
  17176. * Light type const id of the hemispheric light.
  17177. */
  17178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17179. /**
  17180. * Diffuse gives the basic color to an object.
  17181. */
  17182. diffuse: Color3;
  17183. /**
  17184. * Specular produces a highlight color on an object.
  17185. * Note: This is note affecting PBR materials.
  17186. */
  17187. specular: Color3;
  17188. /**
  17189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17190. * falling off base on range or angle.
  17191. * This can be set to any values in Light.FALLOFF_x.
  17192. *
  17193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17194. * other types of materials.
  17195. */
  17196. falloffType: number;
  17197. /**
  17198. * Strength of the light.
  17199. * Note: By default it is define in the framework own unit.
  17200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17201. */
  17202. intensity: number;
  17203. private _range;
  17204. protected _inverseSquaredRange: number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. get range(): number;
  17210. /**
  17211. * Defines how far from the source the light is impacting in scene units.
  17212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17213. */
  17214. set range(value: number);
  17215. /**
  17216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17217. * of light.
  17218. */
  17219. private _photometricScale;
  17220. private _intensityMode;
  17221. /**
  17222. * Gets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. get intensityMode(): number;
  17226. /**
  17227. * Sets the photometric scale used to interpret the intensity.
  17228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17229. */
  17230. set intensityMode(value: number);
  17231. private _radius;
  17232. /**
  17233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17234. */
  17235. get radius(): number;
  17236. /**
  17237. * sets the light radius used by PBR Materials to simulate soft area lights.
  17238. */
  17239. set radius(value: number);
  17240. private _renderPriority;
  17241. /**
  17242. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17243. * exceeding the number allowed of the materials.
  17244. */
  17245. renderPriority: number;
  17246. private _shadowEnabled;
  17247. /**
  17248. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. get shadowEnabled(): boolean;
  17252. /**
  17253. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17254. * the current shadow generator.
  17255. */
  17256. set shadowEnabled(value: boolean);
  17257. private _includedOnlyMeshes;
  17258. /**
  17259. * Gets the only meshes impacted by this light.
  17260. */
  17261. get includedOnlyMeshes(): AbstractMesh[];
  17262. /**
  17263. * Sets the only meshes impacted by this light.
  17264. */
  17265. set includedOnlyMeshes(value: AbstractMesh[]);
  17266. private _excludedMeshes;
  17267. /**
  17268. * Gets the meshes not impacted by this light.
  17269. */
  17270. get excludedMeshes(): AbstractMesh[];
  17271. /**
  17272. * Sets the meshes not impacted by this light.
  17273. */
  17274. set excludedMeshes(value: AbstractMesh[]);
  17275. private _excludeWithLayerMask;
  17276. /**
  17277. * Gets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. get excludeWithLayerMask(): number;
  17281. /**
  17282. * Sets the layer id use to find what meshes are not impacted by the light.
  17283. * Inactive if 0
  17284. */
  17285. set excludeWithLayerMask(value: number);
  17286. private _includeOnlyWithLayerMask;
  17287. /**
  17288. * Gets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. get includeOnlyWithLayerMask(): number;
  17292. /**
  17293. * Sets the layer id use to find what meshes are impacted by the light.
  17294. * Inactive if 0
  17295. */
  17296. set includeOnlyWithLayerMask(value: number);
  17297. private _lightmapMode;
  17298. /**
  17299. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17300. */
  17301. get lightmapMode(): number;
  17302. /**
  17303. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17304. */
  17305. set lightmapMode(value: number);
  17306. /**
  17307. * Shadow generator associted to the light.
  17308. * @hidden Internal use only.
  17309. */
  17310. _shadowGenerator: Nullable<IShadowGenerator>;
  17311. /**
  17312. * @hidden Internal use only.
  17313. */
  17314. _excludedMeshesIds: string[];
  17315. /**
  17316. * @hidden Internal use only.
  17317. */
  17318. _includedOnlyMeshesIds: string[];
  17319. /**
  17320. * The current light unifom buffer.
  17321. * @hidden Internal use only.
  17322. */
  17323. _uniformBuffer: UniformBuffer;
  17324. /** @hidden */
  17325. _renderId: number;
  17326. /**
  17327. * Creates a Light object in the scene.
  17328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17329. * @param name The firendly name of the light
  17330. * @param scene The scene the light belongs too
  17331. */
  17332. constructor(name: string, scene: Scene);
  17333. protected abstract _buildUniformLayout(): void;
  17334. /**
  17335. * Sets the passed Effect "effect" with the Light information.
  17336. * @param effect The effect to update
  17337. * @param lightIndex The index of the light in the effect to update
  17338. * @returns The light
  17339. */
  17340. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17341. /**
  17342. * Sets the passed Effect "effect" with the Light textures.
  17343. * @param effect The effect to update
  17344. * @param lightIndex The index of the light in the effect to update
  17345. * @returns The light
  17346. */
  17347. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17348. /**
  17349. * Binds the lights information from the scene to the effect for the given mesh.
  17350. * @param lightIndex Light index
  17351. * @param scene The scene where the light belongs to
  17352. * @param effect The effect we are binding the data to
  17353. * @param useSpecular Defines if specular is supported
  17354. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17355. */
  17356. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17361. * @returns The light
  17362. */
  17363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17364. /**
  17365. * Returns the string "Light".
  17366. * @returns the class name
  17367. */
  17368. getClassName(): string;
  17369. /** @hidden */
  17370. readonly _isLight: boolean;
  17371. /**
  17372. * Converts the light information to a readable string for debug purpose.
  17373. * @param fullDetails Supports for multiple levels of logging within scene loading
  17374. * @returns the human readable light info
  17375. */
  17376. toString(fullDetails?: boolean): string;
  17377. /** @hidden */
  17378. protected _syncParentEnabledState(): void;
  17379. /**
  17380. * Set the enabled state of this node.
  17381. * @param value - the new enabled state
  17382. */
  17383. setEnabled(value: boolean): void;
  17384. /**
  17385. * Returns the Light associated shadow generator if any.
  17386. * @return the associated shadow generator.
  17387. */
  17388. getShadowGenerator(): Nullable<IShadowGenerator>;
  17389. /**
  17390. * Returns a Vector3, the absolute light position in the World.
  17391. * @returns the world space position of the light
  17392. */
  17393. getAbsolutePosition(): Vector3;
  17394. /**
  17395. * Specifies if the light will affect the passed mesh.
  17396. * @param mesh The mesh to test against the light
  17397. * @return true the mesh is affected otherwise, false.
  17398. */
  17399. canAffectMesh(mesh: AbstractMesh): boolean;
  17400. /**
  17401. * Sort function to order lights for rendering.
  17402. * @param a First Light object to compare to second.
  17403. * @param b Second Light object to compare first.
  17404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17405. */
  17406. static CompareLightsPriority(a: Light, b: Light): number;
  17407. /**
  17408. * Releases resources associated with this node.
  17409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17411. */
  17412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17413. /**
  17414. * Returns the light type ID (integer).
  17415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17416. */
  17417. getTypeID(): number;
  17418. /**
  17419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17420. * @returns the scaled intensity in intensity mode unit
  17421. */
  17422. getScaledIntensity(): number;
  17423. /**
  17424. * Returns a new Light object, named "name", from the current one.
  17425. * @param name The name of the cloned light
  17426. * @returns the new created light
  17427. */
  17428. clone(name: string): Nullable<Light>;
  17429. /**
  17430. * Serializes the current light into a Serialization object.
  17431. * @returns the serialized object.
  17432. */
  17433. serialize(): any;
  17434. /**
  17435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17436. * This new light is named "name" and added to the passed scene.
  17437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17438. * @param name The friendly name of the light
  17439. * @param scene The scene the new light will belong to
  17440. * @returns the constructor function
  17441. */
  17442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17443. /**
  17444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17445. * @param parsedLight The JSON representation of the light
  17446. * @param scene The scene to create the parsed light in
  17447. * @returns the created light after parsing
  17448. */
  17449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17450. private _hookArrayForExcluded;
  17451. private _hookArrayForIncludedOnly;
  17452. private _resyncMeshes;
  17453. /**
  17454. * Forces the meshes to update their light related information in their rendering used effects
  17455. * @hidden Internal Use Only
  17456. */
  17457. _markMeshesAsLightDirty(): void;
  17458. /**
  17459. * Recomputes the cached photometric scale if needed.
  17460. */
  17461. private _computePhotometricScale;
  17462. /**
  17463. * Returns the Photometric Scale according to the light type and intensity mode.
  17464. */
  17465. private _getPhotometricScale;
  17466. /**
  17467. * Reorder the light in the scene according to their defined priority.
  17468. * @hidden Internal Use Only
  17469. */
  17470. _reorderLightsInScene(): void;
  17471. /**
  17472. * Prepares the list of defines specific to the light type.
  17473. * @param defines the list of defines
  17474. * @param lightIndex defines the index of the light for the effect
  17475. */
  17476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17477. }
  17478. }
  17479. declare module "babylonjs/Actions/action" {
  17480. import { Observable } from "babylonjs/Misc/observable";
  17481. import { Condition } from "babylonjs/Actions/condition";
  17482. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17483. import { ActionManager } from "babylonjs/Actions/actionManager";
  17484. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17485. /**
  17486. * Interface used to define Action
  17487. */
  17488. export interface IAction {
  17489. /**
  17490. * Trigger for the action
  17491. */
  17492. trigger: number;
  17493. /** Options of the trigger */
  17494. triggerOptions: any;
  17495. /**
  17496. * Gets the trigger parameters
  17497. * @returns the trigger parameters
  17498. */
  17499. getTriggerParameter(): any;
  17500. /**
  17501. * Internal only - executes current action event
  17502. * @hidden
  17503. */
  17504. _executeCurrent(evt?: ActionEvent): void;
  17505. /**
  17506. * Serialize placeholder for child classes
  17507. * @param parent of child
  17508. * @returns the serialized object
  17509. */
  17510. serialize(parent: any): any;
  17511. /**
  17512. * Internal only
  17513. * @hidden
  17514. */
  17515. _prepare(): void;
  17516. /**
  17517. * Internal only - manager for action
  17518. * @hidden
  17519. */
  17520. _actionManager: AbstractActionManager;
  17521. /**
  17522. * Adds action to chain of actions, may be a DoNothingAction
  17523. * @param action defines the next action to execute
  17524. * @returns The action passed in
  17525. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17526. */
  17527. then(action: IAction): IAction;
  17528. }
  17529. /**
  17530. * The action to be carried out following a trigger
  17531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17532. */
  17533. export class Action implements IAction {
  17534. /** the trigger, with or without parameters, for the action */
  17535. triggerOptions: any;
  17536. /**
  17537. * Trigger for the action
  17538. */
  17539. trigger: number;
  17540. /**
  17541. * Internal only - manager for action
  17542. * @hidden
  17543. */
  17544. _actionManager: ActionManager;
  17545. private _nextActiveAction;
  17546. private _child;
  17547. private _condition?;
  17548. private _triggerParameter;
  17549. /**
  17550. * An event triggered prior to action being executed.
  17551. */
  17552. onBeforeExecuteObservable: Observable<Action>;
  17553. /**
  17554. * Creates a new Action
  17555. * @param triggerOptions the trigger, with or without parameters, for the action
  17556. * @param condition an optional determinant of action
  17557. */
  17558. constructor(
  17559. /** the trigger, with or without parameters, for the action */
  17560. triggerOptions: any, condition?: Condition);
  17561. /**
  17562. * Internal only
  17563. * @hidden
  17564. */
  17565. _prepare(): void;
  17566. /**
  17567. * Gets the trigger parameters
  17568. * @returns the trigger parameters
  17569. */
  17570. getTriggerParameter(): any;
  17571. /**
  17572. * Internal only - executes current action event
  17573. * @hidden
  17574. */
  17575. _executeCurrent(evt?: ActionEvent): void;
  17576. /**
  17577. * Execute placeholder for child classes
  17578. * @param evt optional action event
  17579. */
  17580. execute(evt?: ActionEvent): void;
  17581. /**
  17582. * Skips to next active action
  17583. */
  17584. skipToNextActiveAction(): void;
  17585. /**
  17586. * Adds action to chain of actions, may be a DoNothingAction
  17587. * @param action defines the next action to execute
  17588. * @returns The action passed in
  17589. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17590. */
  17591. then(action: Action): Action;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getProperty(propertyPath: string): string;
  17597. /**
  17598. * Internal only
  17599. * @hidden
  17600. */
  17601. _getEffectiveTarget(target: any, propertyPath: string): any;
  17602. /**
  17603. * Serialize placeholder for child classes
  17604. * @param parent of child
  17605. * @returns the serialized object
  17606. */
  17607. serialize(parent: any): any;
  17608. /**
  17609. * Internal only called by serialize
  17610. * @hidden
  17611. */
  17612. protected _serialize(serializedAction: any, parent?: any): any;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _SerializeValueAsString: (value: any) => string;
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17623. name: string;
  17624. targetType: string;
  17625. value: string;
  17626. };
  17627. }
  17628. }
  17629. declare module "babylonjs/Actions/condition" {
  17630. import { ActionManager } from "babylonjs/Actions/actionManager";
  17631. /**
  17632. * A Condition applied to an Action
  17633. */
  17634. export class Condition {
  17635. /**
  17636. * Internal only - manager for action
  17637. * @hidden
  17638. */
  17639. _actionManager: ActionManager;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _evaluationId: number;
  17645. /**
  17646. * Internal only
  17647. * @hidden
  17648. */
  17649. _currentResult: boolean;
  17650. /**
  17651. * Creates a new Condition
  17652. * @param actionManager the manager of the action the condition is applied to
  17653. */
  17654. constructor(actionManager: ActionManager);
  17655. /**
  17656. * Check if the current condition is valid
  17657. * @returns a boolean
  17658. */
  17659. isValid(): boolean;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getProperty(propertyPath: string): string;
  17665. /**
  17666. * Internal only
  17667. * @hidden
  17668. */
  17669. _getEffectiveTarget(target: any, propertyPath: string): any;
  17670. /**
  17671. * Serialize placeholder for child classes
  17672. * @returns the serialized object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Internal only
  17677. * @hidden
  17678. */
  17679. protected _serialize(serializedCondition: any): any;
  17680. }
  17681. /**
  17682. * Defines specific conditional operators as extensions of Condition
  17683. */
  17684. export class ValueCondition extends Condition {
  17685. /** path to specify the property of the target the conditional operator uses */
  17686. propertyPath: string;
  17687. /** the value compared by the conditional operator against the current value of the property */
  17688. value: any;
  17689. /** the conditional operator, default ValueCondition.IsEqual */
  17690. operator: number;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsEqual;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsDifferent;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsGreater;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. private static _IsLesser;
  17711. /**
  17712. * returns the number for IsEqual
  17713. */
  17714. static get IsEqual(): number;
  17715. /**
  17716. * Returns the number for IsDifferent
  17717. */
  17718. static get IsDifferent(): number;
  17719. /**
  17720. * Returns the number for IsGreater
  17721. */
  17722. static get IsGreater(): number;
  17723. /**
  17724. * Returns the number for IsLesser
  17725. */
  17726. static get IsLesser(): number;
  17727. /**
  17728. * Internal only The action manager for the condition
  17729. * @hidden
  17730. */
  17731. _actionManager: ActionManager;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _target;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _effectiveTarget;
  17742. /**
  17743. * Internal only
  17744. * @hidden
  17745. */
  17746. private _property;
  17747. /**
  17748. * Creates a new ValueCondition
  17749. * @param actionManager manager for the action the condition applies to
  17750. * @param target for the action
  17751. * @param propertyPath path to specify the property of the target the conditional operator uses
  17752. * @param value the value compared by the conditional operator against the current value of the property
  17753. * @param operator the conditional operator, default ValueCondition.IsEqual
  17754. */
  17755. constructor(actionManager: ActionManager, target: any,
  17756. /** path to specify the property of the target the conditional operator uses */
  17757. propertyPath: string,
  17758. /** the value compared by the conditional operator against the current value of the property */
  17759. value: any,
  17760. /** the conditional operator, default ValueCondition.IsEqual */
  17761. operator?: number);
  17762. /**
  17763. * Compares the given value with the property value for the specified conditional operator
  17764. * @returns the result of the comparison
  17765. */
  17766. isValid(): boolean;
  17767. /**
  17768. * Serialize the ValueCondition into a JSON compatible object
  17769. * @returns serialization object
  17770. */
  17771. serialize(): any;
  17772. /**
  17773. * Gets the name of the conditional operator for the ValueCondition
  17774. * @param operator the conditional operator
  17775. * @returns the name
  17776. */
  17777. static GetOperatorName(operator: number): string;
  17778. }
  17779. /**
  17780. * Defines a predicate condition as an extension of Condition
  17781. */
  17782. export class PredicateCondition extends Condition {
  17783. /** defines the predicate function used to validate the condition */
  17784. predicate: () => boolean;
  17785. /**
  17786. * Internal only - manager for action
  17787. * @hidden
  17788. */
  17789. _actionManager: ActionManager;
  17790. /**
  17791. * Creates a new PredicateCondition
  17792. * @param actionManager manager for the action the condition applies to
  17793. * @param predicate defines the predicate function used to validate the condition
  17794. */
  17795. constructor(actionManager: ActionManager,
  17796. /** defines the predicate function used to validate the condition */
  17797. predicate: () => boolean);
  17798. /**
  17799. * @returns the validity of the predicate condition
  17800. */
  17801. isValid(): boolean;
  17802. }
  17803. /**
  17804. * Defines a state condition as an extension of Condition
  17805. */
  17806. export class StateCondition extends Condition {
  17807. /** Value to compare with target state */
  17808. value: string;
  17809. /**
  17810. * Internal only - manager for action
  17811. * @hidden
  17812. */
  17813. _actionManager: ActionManager;
  17814. /**
  17815. * Internal only
  17816. * @hidden
  17817. */
  17818. private _target;
  17819. /**
  17820. * Creates a new StateCondition
  17821. * @param actionManager manager for the action the condition applies to
  17822. * @param target of the condition
  17823. * @param value to compare with target state
  17824. */
  17825. constructor(actionManager: ActionManager, target: any,
  17826. /** Value to compare with target state */
  17827. value: string);
  17828. /**
  17829. * Gets a boolean indicating if the current condition is met
  17830. * @returns the validity of the state
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the StateCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. }
  17839. }
  17840. declare module "babylonjs/Actions/directActions" {
  17841. import { Action } from "babylonjs/Actions/action";
  17842. import { Condition } from "babylonjs/Actions/condition";
  17843. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17844. /**
  17845. * This defines an action responsible to toggle a boolean once triggered.
  17846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17847. */
  17848. export class SwitchBooleanAction extends Action {
  17849. /**
  17850. * The path to the boolean property in the target object
  17851. */
  17852. propertyPath: string;
  17853. private _target;
  17854. private _effectiveTarget;
  17855. private _property;
  17856. /**
  17857. * Instantiate the action
  17858. * @param triggerOptions defines the trigger options
  17859. * @param target defines the object containing the boolean
  17860. * @param propertyPath defines the path to the boolean property in the target object
  17861. * @param condition defines the trigger related conditions
  17862. */
  17863. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17864. /** @hidden */
  17865. _prepare(): void;
  17866. /**
  17867. * Execute the action toggle the boolean value.
  17868. */
  17869. execute(): void;
  17870. /**
  17871. * Serializes the actions and its related information.
  17872. * @param parent defines the object to serialize in
  17873. * @returns the serialized object
  17874. */
  17875. serialize(parent: any): any;
  17876. }
  17877. /**
  17878. * This defines an action responsible to set a the state field of the target
  17879. * to a desired value once triggered.
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17881. */
  17882. export class SetStateAction extends Action {
  17883. /**
  17884. * The value to store in the state field.
  17885. */
  17886. value: string;
  17887. private _target;
  17888. /**
  17889. * Instantiate the action
  17890. * @param triggerOptions defines the trigger options
  17891. * @param target defines the object containing the state property
  17892. * @param value defines the value to store in the state field
  17893. * @param condition defines the trigger related conditions
  17894. */
  17895. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17896. /**
  17897. * Execute the action and store the value on the target state property.
  17898. */
  17899. execute(): void;
  17900. /**
  17901. * Serializes the actions and its related information.
  17902. * @param parent defines the object to serialize in
  17903. * @returns the serialized object
  17904. */
  17905. serialize(parent: any): any;
  17906. }
  17907. /**
  17908. * This defines an action responsible to set a property of the target
  17909. * to a desired value once triggered.
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. export class SetValueAction extends Action {
  17913. /**
  17914. * The path of the property to set in the target.
  17915. */
  17916. propertyPath: string;
  17917. /**
  17918. * The value to set in the property
  17919. */
  17920. value: any;
  17921. private _target;
  17922. private _effectiveTarget;
  17923. private _property;
  17924. /**
  17925. * Instantiate the action
  17926. * @param triggerOptions defines the trigger options
  17927. * @param target defines the object containing the property
  17928. * @param propertyPath defines the path of the property to set in the target
  17929. * @param value defines the value to set in the property
  17930. * @param condition defines the trigger related conditions
  17931. */
  17932. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17933. /** @hidden */
  17934. _prepare(): void;
  17935. /**
  17936. * Execute the action and set the targetted property to the desired value.
  17937. */
  17938. execute(): void;
  17939. /**
  17940. * Serializes the actions and its related information.
  17941. * @param parent defines the object to serialize in
  17942. * @returns the serialized object
  17943. */
  17944. serialize(parent: any): any;
  17945. }
  17946. /**
  17947. * This defines an action responsible to increment the target value
  17948. * to a desired value once triggered.
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17950. */
  17951. export class IncrementValueAction extends Action {
  17952. /**
  17953. * The path of the property to increment in the target.
  17954. */
  17955. propertyPath: string;
  17956. /**
  17957. * The value we should increment the property by.
  17958. */
  17959. value: any;
  17960. private _target;
  17961. private _effectiveTarget;
  17962. private _property;
  17963. /**
  17964. * Instantiate the action
  17965. * @param triggerOptions defines the trigger options
  17966. * @param target defines the object containing the property
  17967. * @param propertyPath defines the path of the property to increment in the target
  17968. * @param value defines the value value we should increment the property by
  17969. * @param condition defines the trigger related conditions
  17970. */
  17971. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17972. /** @hidden */
  17973. _prepare(): void;
  17974. /**
  17975. * Execute the action and increment the target of the value amount.
  17976. */
  17977. execute(): void;
  17978. /**
  17979. * Serializes the actions and its related information.
  17980. * @param parent defines the object to serialize in
  17981. * @returns the serialized object
  17982. */
  17983. serialize(parent: any): any;
  17984. }
  17985. /**
  17986. * This defines an action responsible to start an animation once triggered.
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17988. */
  17989. export class PlayAnimationAction extends Action {
  17990. /**
  17991. * Where the animation should start (animation frame)
  17992. */
  17993. from: number;
  17994. /**
  17995. * Where the animation should stop (animation frame)
  17996. */
  17997. to: number;
  17998. /**
  17999. * Define if the animation should loop or stop after the first play.
  18000. */
  18001. loop?: boolean;
  18002. private _target;
  18003. /**
  18004. * Instantiate the action
  18005. * @param triggerOptions defines the trigger options
  18006. * @param target defines the target animation or animation name
  18007. * @param from defines from where the animation should start (animation frame)
  18008. * @param end defines where the animation should stop (animation frame)
  18009. * @param loop defines if the animation should loop or stop after the first play
  18010. * @param condition defines the trigger related conditions
  18011. */
  18012. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18013. /** @hidden */
  18014. _prepare(): void;
  18015. /**
  18016. * Execute the action and play the animation.
  18017. */
  18018. execute(): void;
  18019. /**
  18020. * Serializes the actions and its related information.
  18021. * @param parent defines the object to serialize in
  18022. * @returns the serialized object
  18023. */
  18024. serialize(parent: any): any;
  18025. }
  18026. /**
  18027. * This defines an action responsible to stop an animation once triggered.
  18028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18029. */
  18030. export class StopAnimationAction extends Action {
  18031. private _target;
  18032. /**
  18033. * Instantiate the action
  18034. * @param triggerOptions defines the trigger options
  18035. * @param target defines the target animation or animation name
  18036. * @param condition defines the trigger related conditions
  18037. */
  18038. constructor(triggerOptions: any, target: any, condition?: Condition);
  18039. /** @hidden */
  18040. _prepare(): void;
  18041. /**
  18042. * Execute the action and stop the animation.
  18043. */
  18044. execute(): void;
  18045. /**
  18046. * Serializes the actions and its related information.
  18047. * @param parent defines the object to serialize in
  18048. * @returns the serialized object
  18049. */
  18050. serialize(parent: any): any;
  18051. }
  18052. /**
  18053. * This defines an action responsible that does nothing once triggered.
  18054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18055. */
  18056. export class DoNothingAction extends Action {
  18057. /**
  18058. * Instantiate the action
  18059. * @param triggerOptions defines the trigger options
  18060. * @param condition defines the trigger related conditions
  18061. */
  18062. constructor(triggerOptions?: any, condition?: Condition);
  18063. /**
  18064. * Execute the action and do nothing.
  18065. */
  18066. execute(): void;
  18067. /**
  18068. * Serializes the actions and its related information.
  18069. * @param parent defines the object to serialize in
  18070. * @returns the serialized object
  18071. */
  18072. serialize(parent: any): any;
  18073. }
  18074. /**
  18075. * This defines an action responsible to trigger several actions once triggered.
  18076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18077. */
  18078. export class CombineAction extends Action {
  18079. /**
  18080. * The list of aggregated animations to run.
  18081. */
  18082. children: Action[];
  18083. /**
  18084. * Instantiate the action
  18085. * @param triggerOptions defines the trigger options
  18086. * @param children defines the list of aggregated animations to run
  18087. * @param condition defines the trigger related conditions
  18088. */
  18089. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18090. /** @hidden */
  18091. _prepare(): void;
  18092. /**
  18093. * Execute the action and executes all the aggregated actions.
  18094. */
  18095. execute(evt: ActionEvent): void;
  18096. /**
  18097. * Serializes the actions and its related information.
  18098. * @param parent defines the object to serialize in
  18099. * @returns the serialized object
  18100. */
  18101. serialize(parent: any): any;
  18102. }
  18103. /**
  18104. * This defines an action responsible to run code (external event) once triggered.
  18105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18106. */
  18107. export class ExecuteCodeAction extends Action {
  18108. /**
  18109. * The callback function to run.
  18110. */
  18111. func: (evt: ActionEvent) => void;
  18112. /**
  18113. * Instantiate the action
  18114. * @param triggerOptions defines the trigger options
  18115. * @param func defines the callback function to run
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18119. /**
  18120. * Execute the action and run the attached code.
  18121. */
  18122. execute(evt: ActionEvent): void;
  18123. }
  18124. /**
  18125. * This defines an action responsible to set the parent property of the target once triggered.
  18126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18127. */
  18128. export class SetParentAction extends Action {
  18129. private _parent;
  18130. private _target;
  18131. /**
  18132. * Instantiate the action
  18133. * @param triggerOptions defines the trigger options
  18134. * @param target defines the target containing the parent property
  18135. * @param parent defines from where the animation should start (animation frame)
  18136. * @param condition defines the trigger related conditions
  18137. */
  18138. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18139. /** @hidden */
  18140. _prepare(): void;
  18141. /**
  18142. * Execute the action and set the parent property.
  18143. */
  18144. execute(): void;
  18145. /**
  18146. * Serializes the actions and its related information.
  18147. * @param parent defines the object to serialize in
  18148. * @returns the serialized object
  18149. */
  18150. serialize(parent: any): any;
  18151. }
  18152. }
  18153. declare module "babylonjs/Actions/actionManager" {
  18154. import { Nullable } from "babylonjs/types";
  18155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18156. import { Scene } from "babylonjs/scene";
  18157. import { IAction } from "babylonjs/Actions/action";
  18158. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18160. /**
  18161. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18162. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18164. */
  18165. export class ActionManager extends AbstractActionManager {
  18166. /**
  18167. * Nothing
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly NothingTrigger: number;
  18171. /**
  18172. * On pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnPickTrigger: number;
  18176. /**
  18177. * On left pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnLeftPickTrigger: number;
  18181. /**
  18182. * On right pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnRightPickTrigger: number;
  18186. /**
  18187. * On center pick
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnCenterPickTrigger: number;
  18191. /**
  18192. * On pick down
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnPickDownTrigger: number;
  18196. /**
  18197. * On double pick
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnDoublePickTrigger: number;
  18201. /**
  18202. * On pick up
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18204. */
  18205. static readonly OnPickUpTrigger: number;
  18206. /**
  18207. * On pick out.
  18208. * This trigger will only be raised if you also declared a OnPickDown
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnPickOutTrigger: number;
  18212. /**
  18213. * On long press
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnLongPressTrigger: number;
  18217. /**
  18218. * On pointer over
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOverTrigger: number;
  18222. /**
  18223. * On pointer out
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnPointerOutTrigger: number;
  18227. /**
  18228. * On every frame
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnEveryFrameTrigger: number;
  18232. /**
  18233. * On intersection enter
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionEnterTrigger: number;
  18237. /**
  18238. * On intersection exit
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnIntersectionExitTrigger: number;
  18242. /**
  18243. * On key down
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyDownTrigger: number;
  18247. /**
  18248. * On key up
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnKeyUpTrigger: number;
  18252. private _scene;
  18253. /**
  18254. * Creates a new action manager
  18255. * @param scene defines the hosting scene
  18256. */
  18257. constructor(scene: Scene);
  18258. /**
  18259. * Releases all associated resources
  18260. */
  18261. dispose(): void;
  18262. /**
  18263. * Gets hosting scene
  18264. * @returns the hosting scene
  18265. */
  18266. getScene(): Scene;
  18267. /**
  18268. * Does this action manager handles actions of any of the given triggers
  18269. * @param triggers defines the triggers to be tested
  18270. * @return a boolean indicating whether one (or more) of the triggers is handled
  18271. */
  18272. hasSpecificTriggers(triggers: number[]): boolean;
  18273. /**
  18274. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18275. * speed.
  18276. * @param triggerA defines the trigger to be tested
  18277. * @param triggerB defines the trigger to be tested
  18278. * @return a boolean indicating whether one (or more) of the triggers is handled
  18279. */
  18280. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18281. /**
  18282. * Does this action manager handles actions of a given trigger
  18283. * @param trigger defines the trigger to be tested
  18284. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18285. * @return whether the trigger is handled
  18286. */
  18287. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18288. /**
  18289. * Does this action manager has pointer triggers
  18290. */
  18291. get hasPointerTriggers(): boolean;
  18292. /**
  18293. * Does this action manager has pick triggers
  18294. */
  18295. get hasPickTriggers(): boolean;
  18296. /**
  18297. * Registers an action to this action manager
  18298. * @param action defines the action to be registered
  18299. * @return the action amended (prepared) after registration
  18300. */
  18301. registerAction(action: IAction): Nullable<IAction>;
  18302. /**
  18303. * Unregisters an action to this action manager
  18304. * @param action defines the action to be unregistered
  18305. * @return a boolean indicating whether the action has been unregistered
  18306. */
  18307. unregisterAction(action: IAction): Boolean;
  18308. /**
  18309. * Process a specific trigger
  18310. * @param trigger defines the trigger to process
  18311. * @param evt defines the event details to be processed
  18312. */
  18313. processTrigger(trigger: number, evt?: IActionEvent): void;
  18314. /** @hidden */
  18315. _getEffectiveTarget(target: any, propertyPath: string): any;
  18316. /** @hidden */
  18317. _getProperty(propertyPath: string): string;
  18318. /**
  18319. * Serialize this manager to a JSON object
  18320. * @param name defines the property name to store this manager
  18321. * @returns a JSON representation of this manager
  18322. */
  18323. serialize(name: string): any;
  18324. /**
  18325. * Creates a new ActionManager from a JSON data
  18326. * @param parsedActions defines the JSON data to read from
  18327. * @param object defines the hosting mesh
  18328. * @param scene defines the hosting scene
  18329. */
  18330. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18331. /**
  18332. * Get a trigger name by index
  18333. * @param trigger defines the trigger index
  18334. * @returns a trigger name
  18335. */
  18336. static GetTriggerName(trigger: number): string;
  18337. }
  18338. }
  18339. declare module "babylonjs/Sprites/sprite" {
  18340. import { Vector3 } from "babylonjs/Maths/math.vector";
  18341. import { Nullable } from "babylonjs/types";
  18342. import { ActionManager } from "babylonjs/Actions/actionManager";
  18343. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18344. import { Color4 } from "babylonjs/Maths/math.color";
  18345. /**
  18346. * Class used to represent a sprite
  18347. * @see http://doc.babylonjs.com/babylon101/sprites
  18348. */
  18349. export class Sprite {
  18350. /** defines the name */
  18351. name: string;
  18352. /** Gets or sets the current world position */
  18353. position: Vector3;
  18354. /** Gets or sets the main color */
  18355. color: Color4;
  18356. /** Gets or sets the width */
  18357. width: number;
  18358. /** Gets or sets the height */
  18359. height: number;
  18360. /** Gets or sets rotation angle */
  18361. angle: number;
  18362. /** Gets or sets the cell index in the sprite sheet */
  18363. cellIndex: number;
  18364. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18365. cellRef: string;
  18366. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18367. invertU: number;
  18368. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18369. invertV: number;
  18370. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18371. disposeWhenFinishedAnimating: boolean;
  18372. /** Gets the list of attached animations */
  18373. animations: Animation[];
  18374. /** Gets or sets a boolean indicating if the sprite can be picked */
  18375. isPickable: boolean;
  18376. /**
  18377. * Gets or sets the associated action manager
  18378. */
  18379. actionManager: Nullable<ActionManager>;
  18380. private _animationStarted;
  18381. private _loopAnimation;
  18382. private _fromIndex;
  18383. private _toIndex;
  18384. private _delay;
  18385. private _direction;
  18386. private _manager;
  18387. private _time;
  18388. private _onAnimationEnd;
  18389. /**
  18390. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18391. */
  18392. isVisible: boolean;
  18393. /**
  18394. * Gets or sets the sprite size
  18395. */
  18396. get size(): number;
  18397. set size(value: number);
  18398. /**
  18399. * Creates a new Sprite
  18400. * @param name defines the name
  18401. * @param manager defines the manager
  18402. */
  18403. constructor(
  18404. /** defines the name */
  18405. name: string, manager: ISpriteManager);
  18406. /**
  18407. * Starts an animation
  18408. * @param from defines the initial key
  18409. * @param to defines the end key
  18410. * @param loop defines if the animation must loop
  18411. * @param delay defines the start delay (in ms)
  18412. * @param onAnimationEnd defines a callback to call when animation ends
  18413. */
  18414. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18415. /** Stops current animation (if any) */
  18416. stopAnimation(): void;
  18417. /** @hidden */
  18418. _animate(deltaTime: number): void;
  18419. /** Release associated resources */
  18420. dispose(): void;
  18421. }
  18422. }
  18423. declare module "babylonjs/Collisions/pickingInfo" {
  18424. import { Nullable } from "babylonjs/types";
  18425. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18427. import { Sprite } from "babylonjs/Sprites/sprite";
  18428. import { Ray } from "babylonjs/Culling/ray";
  18429. /**
  18430. * Information about the result of picking within a scene
  18431. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18432. */
  18433. export class PickingInfo {
  18434. /** @hidden */
  18435. _pickingUnavailable: boolean;
  18436. /**
  18437. * If the pick collided with an object
  18438. */
  18439. hit: boolean;
  18440. /**
  18441. * Distance away where the pick collided
  18442. */
  18443. distance: number;
  18444. /**
  18445. * The location of pick collision
  18446. */
  18447. pickedPoint: Nullable<Vector3>;
  18448. /**
  18449. * The mesh corresponding the the pick collision
  18450. */
  18451. pickedMesh: Nullable<AbstractMesh>;
  18452. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18453. bu: number;
  18454. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18455. bv: number;
  18456. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18457. faceId: number;
  18458. /** Id of the the submesh that was picked */
  18459. subMeshId: number;
  18460. /** If a sprite was picked, this will be the sprite the pick collided with */
  18461. pickedSprite: Nullable<Sprite>;
  18462. /**
  18463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18464. */
  18465. originMesh: Nullable<AbstractMesh>;
  18466. /**
  18467. * The ray that was used to perform the picking.
  18468. */
  18469. ray: Nullable<Ray>;
  18470. /**
  18471. * Gets the normal correspodning to the face the pick collided with
  18472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18474. * @returns The normal correspodning to the face the pick collided with
  18475. */
  18476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18477. /**
  18478. * Gets the texture coordinates of where the pick occured
  18479. * @returns the vector containing the coordnates of the texture
  18480. */
  18481. getTextureCoordinates(): Nullable<Vector2>;
  18482. }
  18483. }
  18484. declare module "babylonjs/Events/pointerEvents" {
  18485. import { Nullable } from "babylonjs/types";
  18486. import { Vector2 } from "babylonjs/Maths/math.vector";
  18487. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18488. import { Ray } from "babylonjs/Culling/ray";
  18489. /**
  18490. * Gather the list of pointer event types as constants.
  18491. */
  18492. export class PointerEventTypes {
  18493. /**
  18494. * 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.
  18495. */
  18496. static readonly POINTERDOWN: number;
  18497. /**
  18498. * The pointerup event is fired when a pointer is no longer active.
  18499. */
  18500. static readonly POINTERUP: number;
  18501. /**
  18502. * The pointermove event is fired when a pointer changes coordinates.
  18503. */
  18504. static readonly POINTERMOVE: number;
  18505. /**
  18506. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18507. */
  18508. static readonly POINTERWHEEL: number;
  18509. /**
  18510. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18511. */
  18512. static readonly POINTERPICK: number;
  18513. /**
  18514. * The pointertap event is fired when a the object has been touched and released without drag.
  18515. */
  18516. static readonly POINTERTAP: number;
  18517. /**
  18518. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18519. */
  18520. static readonly POINTERDOUBLETAP: number;
  18521. }
  18522. /**
  18523. * Base class of pointer info types.
  18524. */
  18525. export class PointerInfoBase {
  18526. /**
  18527. * Defines the type of event (PointerEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: PointerEvent | MouseWheelEvent;
  18534. /**
  18535. * Instantiates the base class of pointers info.
  18536. * @param type Defines the type of event (PointerEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (PointerEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: PointerEvent | MouseWheelEvent);
  18548. }
  18549. /**
  18550. * This class is used to store pointer related info for the onPrePointerObservable event.
  18551. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18552. */
  18553. export class PointerInfoPre extends PointerInfoBase {
  18554. /**
  18555. * Ray from a pointer if availible (eg. 6dof controller)
  18556. */
  18557. ray: Nullable<Ray>;
  18558. /**
  18559. * Defines the local position of the pointer on the canvas.
  18560. */
  18561. localPosition: Vector2;
  18562. /**
  18563. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18568. * @param type Defines the type of event (PointerEventTypes)
  18569. * @param event Defines the related dom event
  18570. * @param localX Defines the local x coordinates of the pointer when the event occured
  18571. * @param localY Defines the local y coordinates of the pointer when the event occured
  18572. */
  18573. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18574. }
  18575. /**
  18576. * This type contains all the data related to a pointer event in Babylon.js.
  18577. * 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.
  18578. */
  18579. export class PointerInfo extends PointerInfoBase {
  18580. /**
  18581. * Defines the picking info associated to the info (if any)\
  18582. */
  18583. pickInfo: Nullable<PickingInfo>;
  18584. /**
  18585. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18586. * @param type Defines the type of event (PointerEventTypes)
  18587. * @param event Defines the related dom event
  18588. * @param pickInfo Defines the picking info associated to the info (if any)\
  18589. */
  18590. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18591. /**
  18592. * Defines the picking info associated to the info (if any)\
  18593. */
  18594. pickInfo: Nullable<PickingInfo>);
  18595. }
  18596. /**
  18597. * Data relating to a touch event on the screen.
  18598. */
  18599. export interface PointerTouch {
  18600. /**
  18601. * X coordinate of touch.
  18602. */
  18603. x: number;
  18604. /**
  18605. * Y coordinate of touch.
  18606. */
  18607. y: number;
  18608. /**
  18609. * Id of touch. Unique for each finger.
  18610. */
  18611. pointerId: number;
  18612. /**
  18613. * Event type passed from DOM.
  18614. */
  18615. type: any;
  18616. }
  18617. }
  18618. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18619. import { Observable } from "babylonjs/Misc/observable";
  18620. import { Nullable } from "babylonjs/types";
  18621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. */
  18627. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18628. /**
  18629. * Define if touch is enabled in the mouse input
  18630. */
  18631. touchEnabled: boolean;
  18632. /**
  18633. * Defines the camera the input is attached to.
  18634. */
  18635. camera: FreeCamera;
  18636. /**
  18637. * Defines the buttons associated with the input to handle camera move.
  18638. */
  18639. buttons: number[];
  18640. /**
  18641. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18642. */
  18643. angularSensibility: number;
  18644. private _pointerInput;
  18645. private _onMouseMove;
  18646. private _observer;
  18647. private previousPosition;
  18648. /**
  18649. * Observable for when a pointer move event occurs containing the move offset
  18650. */
  18651. onPointerMovedObservable: Observable<{
  18652. offsetX: number;
  18653. offsetY: number;
  18654. }>;
  18655. /**
  18656. * @hidden
  18657. * If the camera should be rotated automatically based on pointer movement
  18658. */
  18659. _allowCameraRotation: boolean;
  18660. /**
  18661. * Manage the mouse inputs to control the movement of a free camera.
  18662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18663. * @param touchEnabled Defines if touch is enabled or not
  18664. */
  18665. constructor(
  18666. /**
  18667. * Define if touch is enabled in the mouse input
  18668. */
  18669. touchEnabled?: boolean);
  18670. /**
  18671. * Attach the input controls to a specific dom element to get the input from.
  18672. * @param element Defines the element the controls should be listened from
  18673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18674. */
  18675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18676. /**
  18677. * Called on JS contextmenu event.
  18678. * Override this method to provide functionality.
  18679. */
  18680. protected onContextMenu(evt: PointerEvent): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Gets the class name of the current intput.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Get the friendly name associated with the input class.
  18693. * @returns the input friendly name
  18694. */
  18695. getSimpleName(): string;
  18696. }
  18697. }
  18698. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18699. import { Nullable } from "babylonjs/types";
  18700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18702. /**
  18703. * Manage the touch inputs to control the movement of a free camera.
  18704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18705. */
  18706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18707. /**
  18708. * Defines the camera the input is attached to.
  18709. */
  18710. camera: FreeCamera;
  18711. /**
  18712. * Defines the touch sensibility for rotation.
  18713. * The higher the faster.
  18714. */
  18715. touchAngularSensibility: number;
  18716. /**
  18717. * Defines the touch sensibility for move.
  18718. * The higher the faster.
  18719. */
  18720. touchMoveSensibility: number;
  18721. private _offsetX;
  18722. private _offsetY;
  18723. private _pointerPressed;
  18724. private _pointerInput;
  18725. private _observer;
  18726. private _onLostFocus;
  18727. /**
  18728. * Attach the input controls to a specific dom element to get the input from.
  18729. * @param element Defines the element the controls should be listened from
  18730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18731. */
  18732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18733. /**
  18734. * Detach the current controls from the specified dom element.
  18735. * @param element Defines the element to stop listening the inputs from
  18736. */
  18737. detachControl(element: Nullable<HTMLElement>): void;
  18738. /**
  18739. * Update the current camera state depending on the inputs that have been used this frame.
  18740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18741. */
  18742. checkInputs(): void;
  18743. /**
  18744. * Gets the class name of the current intput.
  18745. * @returns the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Get the friendly name associated with the input class.
  18750. * @returns the input friendly name
  18751. */
  18752. getSimpleName(): string;
  18753. }
  18754. }
  18755. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18758. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18759. import { Nullable } from "babylonjs/types";
  18760. /**
  18761. * Default Inputs manager for the FreeCamera.
  18762. * It groups all the default supported inputs for ease of use.
  18763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18764. */
  18765. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18766. /**
  18767. * @hidden
  18768. */
  18769. _mouseInput: Nullable<FreeCameraMouseInput>;
  18770. /**
  18771. * Instantiates a new FreeCameraInputsManager.
  18772. * @param camera Defines the camera the inputs belong to
  18773. */
  18774. constructor(camera: FreeCamera);
  18775. /**
  18776. * Add keyboard input support to the input manager.
  18777. * @returns the current input manager
  18778. */
  18779. addKeyboard(): FreeCameraInputsManager;
  18780. /**
  18781. * Add mouse input support to the input manager.
  18782. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18783. * @returns the current input manager
  18784. */
  18785. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18786. /**
  18787. * Removes the mouse input support from the manager
  18788. * @returns the current input manager
  18789. */
  18790. removeMouse(): FreeCameraInputsManager;
  18791. /**
  18792. * Add touch input support to the input manager.
  18793. * @returns the current input manager
  18794. */
  18795. addTouch(): FreeCameraInputsManager;
  18796. /**
  18797. * Remove all attached input methods from a camera
  18798. */
  18799. clear(): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Cameras/freeCamera" {
  18803. import { Vector3 } from "babylonjs/Maths/math.vector";
  18804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18805. import { Scene } from "babylonjs/scene";
  18806. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18807. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18808. /**
  18809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18810. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18812. */
  18813. export class FreeCamera extends TargetCamera {
  18814. /**
  18815. * Define the collision ellipsoid of the camera.
  18816. * This is helpful to simulate a camera body like the player body around the camera
  18817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18818. */
  18819. ellipsoid: Vector3;
  18820. /**
  18821. * Define an offset for the position of the ellipsoid around the camera.
  18822. * This can be helpful to determine the center of the body near the gravity center of the body
  18823. * instead of its head.
  18824. */
  18825. ellipsoidOffset: Vector3;
  18826. /**
  18827. * Enable or disable collisions of the camera with the rest of the scene objects.
  18828. */
  18829. checkCollisions: boolean;
  18830. /**
  18831. * Enable or disable gravity on the camera.
  18832. */
  18833. applyGravity: boolean;
  18834. /**
  18835. * Define the input manager associated to the camera.
  18836. */
  18837. inputs: FreeCameraInputsManager;
  18838. /**
  18839. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. get angularSensibility(): number;
  18843. /**
  18844. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. set angularSensibility(value: number);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18850. */
  18851. get keysUp(): number[];
  18852. set keysUp(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18855. */
  18856. get keysDown(): number[];
  18857. set keysDown(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18860. */
  18861. get keysLeft(): number[];
  18862. set keysLeft(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18865. */
  18866. get keysRight(): number[];
  18867. set keysRight(value: number[]);
  18868. /**
  18869. * Event raised when the camera collide with a mesh in the scene.
  18870. */
  18871. onCollide: (collidedMesh: AbstractMesh) => void;
  18872. private _collider;
  18873. private _needMoveForGravity;
  18874. private _oldPosition;
  18875. private _diffPosition;
  18876. private _newPosition;
  18877. /** @hidden */
  18878. _localDirection: Vector3;
  18879. /** @hidden */
  18880. _transformedDirection: Vector3;
  18881. /**
  18882. * Instantiates a Free Camera.
  18883. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18884. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18886. * @param name Define the name of the camera in the scene
  18887. * @param position Define the start position of the camera in the scene
  18888. * @param scene Define the scene the camera belongs to
  18889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18890. */
  18891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18892. /**
  18893. * Attached controls to the current camera.
  18894. * @param element Defines the element the controls should be listened from
  18895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18896. */
  18897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18898. /**
  18899. * Detach the current controls from the camera.
  18900. * The camera will stop reacting to inputs.
  18901. * @param element Defines the element to stop listening the inputs from
  18902. */
  18903. detachControl(element: HTMLElement): void;
  18904. private _collisionMask;
  18905. /**
  18906. * Define a collision mask to limit the list of object the camera can collide with
  18907. */
  18908. get collisionMask(): number;
  18909. set collisionMask(mask: number);
  18910. /** @hidden */
  18911. _collideWithWorld(displacement: Vector3): void;
  18912. private _onCollisionPositionChange;
  18913. /** @hidden */
  18914. _checkInputs(): void;
  18915. /** @hidden */
  18916. _decideIfNeedsToMove(): boolean;
  18917. /** @hidden */
  18918. _updatePosition(): void;
  18919. /**
  18920. * Destroy the camera and release the current resources hold by it.
  18921. */
  18922. dispose(): void;
  18923. /**
  18924. * Gets the current object class name.
  18925. * @return the class name
  18926. */
  18927. getClassName(): string;
  18928. }
  18929. }
  18930. declare module "babylonjs/Gamepads/gamepad" {
  18931. import { Observable } from "babylonjs/Misc/observable";
  18932. /**
  18933. * Represents a gamepad control stick position
  18934. */
  18935. export class StickValues {
  18936. /**
  18937. * The x component of the control stick
  18938. */
  18939. x: number;
  18940. /**
  18941. * The y component of the control stick
  18942. */
  18943. y: number;
  18944. /**
  18945. * Initializes the gamepad x and y control stick values
  18946. * @param x The x component of the gamepad control stick value
  18947. * @param y The y component of the gamepad control stick value
  18948. */
  18949. constructor(
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number,
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number);
  18958. }
  18959. /**
  18960. * An interface which manages callbacks for gamepad button changes
  18961. */
  18962. export interface GamepadButtonChanges {
  18963. /**
  18964. * Called when a gamepad has been changed
  18965. */
  18966. changed: boolean;
  18967. /**
  18968. * Called when a gamepad press event has been triggered
  18969. */
  18970. pressChanged: boolean;
  18971. /**
  18972. * Called when a touch event has been triggered
  18973. */
  18974. touchChanged: boolean;
  18975. /**
  18976. * Called when a value has changed
  18977. */
  18978. valueChanged: boolean;
  18979. }
  18980. /**
  18981. * Represents a gamepad
  18982. */
  18983. export class Gamepad {
  18984. /**
  18985. * The id of the gamepad
  18986. */
  18987. id: string;
  18988. /**
  18989. * The index of the gamepad
  18990. */
  18991. index: number;
  18992. /**
  18993. * The browser gamepad
  18994. */
  18995. browserGamepad: any;
  18996. /**
  18997. * Specifies what type of gamepad this represents
  18998. */
  18999. type: number;
  19000. private _leftStick;
  19001. private _rightStick;
  19002. /** @hidden */
  19003. _isConnected: boolean;
  19004. private _leftStickAxisX;
  19005. private _leftStickAxisY;
  19006. private _rightStickAxisX;
  19007. private _rightStickAxisY;
  19008. /**
  19009. * Triggered when the left control stick has been changed
  19010. */
  19011. private _onleftstickchanged;
  19012. /**
  19013. * Triggered when the right control stick has been changed
  19014. */
  19015. private _onrightstickchanged;
  19016. /**
  19017. * Represents a gamepad controller
  19018. */
  19019. static GAMEPAD: number;
  19020. /**
  19021. * Represents a generic controller
  19022. */
  19023. static GENERIC: number;
  19024. /**
  19025. * Represents an XBox controller
  19026. */
  19027. static XBOX: number;
  19028. /**
  19029. * Represents a pose-enabled controller
  19030. */
  19031. static POSE_ENABLED: number;
  19032. /**
  19033. * Represents an Dual Shock controller
  19034. */
  19035. static DUALSHOCK: number;
  19036. /**
  19037. * Specifies whether the left control stick should be Y-inverted
  19038. */
  19039. protected _invertLeftStickY: boolean;
  19040. /**
  19041. * Specifies if the gamepad has been connected
  19042. */
  19043. get isConnected(): boolean;
  19044. /**
  19045. * Initializes the gamepad
  19046. * @param id The id of the gamepad
  19047. * @param index The index of the gamepad
  19048. * @param browserGamepad The browser gamepad
  19049. * @param leftStickX The x component of the left joystick
  19050. * @param leftStickY The y component of the left joystick
  19051. * @param rightStickX The x component of the right joystick
  19052. * @param rightStickY The y component of the right joystick
  19053. */
  19054. constructor(
  19055. /**
  19056. * The id of the gamepad
  19057. */
  19058. id: string,
  19059. /**
  19060. * The index of the gamepad
  19061. */
  19062. index: number,
  19063. /**
  19064. * The browser gamepad
  19065. */
  19066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19067. /**
  19068. * Callback triggered when the left joystick has changed
  19069. * @param callback
  19070. */
  19071. onleftstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Callback triggered when the right joystick has changed
  19074. * @param callback
  19075. */
  19076. onrightstickchanged(callback: (values: StickValues) => void): void;
  19077. /**
  19078. * Gets the left joystick
  19079. */
  19080. get leftStick(): StickValues;
  19081. /**
  19082. * Sets the left joystick values
  19083. */
  19084. set leftStick(newValues: StickValues);
  19085. /**
  19086. * Gets the right joystick
  19087. */
  19088. get rightStick(): StickValues;
  19089. /**
  19090. * Sets the right joystick value
  19091. */
  19092. set rightStick(newValues: StickValues);
  19093. /**
  19094. * Updates the gamepad joystick positions
  19095. */
  19096. update(): void;
  19097. /**
  19098. * Disposes the gamepad
  19099. */
  19100. dispose(): void;
  19101. }
  19102. /**
  19103. * Represents a generic gamepad
  19104. */
  19105. export class GenericPad extends Gamepad {
  19106. private _buttons;
  19107. private _onbuttondown;
  19108. private _onbuttonup;
  19109. /**
  19110. * Observable triggered when a button has been pressed
  19111. */
  19112. onButtonDownObservable: Observable<number>;
  19113. /**
  19114. * Observable triggered when a button has been released
  19115. */
  19116. onButtonUpObservable: Observable<number>;
  19117. /**
  19118. * Callback triggered when a button has been pressed
  19119. * @param callback Called when a button has been pressed
  19120. */
  19121. onbuttondown(callback: (buttonPressed: number) => void): void;
  19122. /**
  19123. * Callback triggered when a button has been released
  19124. * @param callback Called when a button has been released
  19125. */
  19126. onbuttonup(callback: (buttonReleased: number) => void): void;
  19127. /**
  19128. * Initializes the generic gamepad
  19129. * @param id The id of the generic gamepad
  19130. * @param index The index of the generic gamepad
  19131. * @param browserGamepad The browser gamepad
  19132. */
  19133. constructor(id: string, index: number, browserGamepad: any);
  19134. private _setButtonValue;
  19135. /**
  19136. * Updates the generic gamepad
  19137. */
  19138. update(): void;
  19139. /**
  19140. * Disposes the generic gamepad
  19141. */
  19142. dispose(): void;
  19143. }
  19144. }
  19145. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19146. import { Observable } from "babylonjs/Misc/observable";
  19147. import { Nullable } from "babylonjs/types";
  19148. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19151. import { Ray } from "babylonjs/Culling/ray";
  19152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19153. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19154. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19155. /**
  19156. * Defines the types of pose enabled controllers that are supported
  19157. */
  19158. export enum PoseEnabledControllerType {
  19159. /**
  19160. * HTC Vive
  19161. */
  19162. VIVE = 0,
  19163. /**
  19164. * Oculus Rift
  19165. */
  19166. OCULUS = 1,
  19167. /**
  19168. * Windows mixed reality
  19169. */
  19170. WINDOWS = 2,
  19171. /**
  19172. * Samsung gear VR
  19173. */
  19174. GEAR_VR = 3,
  19175. /**
  19176. * Google Daydream
  19177. */
  19178. DAYDREAM = 4,
  19179. /**
  19180. * Generic
  19181. */
  19182. GENERIC = 5
  19183. }
  19184. /**
  19185. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19186. */
  19187. export interface MutableGamepadButton {
  19188. /**
  19189. * Value of the button/trigger
  19190. */
  19191. value: number;
  19192. /**
  19193. * If the button/trigger is currently touched
  19194. */
  19195. touched: boolean;
  19196. /**
  19197. * If the button/trigger is currently pressed
  19198. */
  19199. pressed: boolean;
  19200. }
  19201. /**
  19202. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19203. * @hidden
  19204. */
  19205. export interface ExtendedGamepadButton extends GamepadButton {
  19206. /**
  19207. * If the button/trigger is currently pressed
  19208. */
  19209. readonly pressed: boolean;
  19210. /**
  19211. * If the button/trigger is currently touched
  19212. */
  19213. readonly touched: boolean;
  19214. /**
  19215. * Value of the button/trigger
  19216. */
  19217. readonly value: number;
  19218. }
  19219. /** @hidden */
  19220. export interface _GamePadFactory {
  19221. /**
  19222. * Returns whether or not the current gamepad can be created for this type of controller.
  19223. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19224. * @returns true if it can be created, otherwise false
  19225. */
  19226. canCreate(gamepadInfo: any): boolean;
  19227. /**
  19228. * Creates a new instance of the Gamepad.
  19229. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19230. * @returns the new gamepad instance
  19231. */
  19232. create(gamepadInfo: any): Gamepad;
  19233. }
  19234. /**
  19235. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19236. */
  19237. export class PoseEnabledControllerHelper {
  19238. /** @hidden */
  19239. static _ControllerFactories: _GamePadFactory[];
  19240. /** @hidden */
  19241. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19242. /**
  19243. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19244. * @param vrGamepad the gamepad to initialized
  19245. * @returns a vr controller of the type the gamepad identified as
  19246. */
  19247. static InitiateController(vrGamepad: any): Gamepad;
  19248. }
  19249. /**
  19250. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19251. */
  19252. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19253. /**
  19254. * If the controller is used in a webXR session
  19255. */
  19256. isXR: boolean;
  19257. private _deviceRoomPosition;
  19258. private _deviceRoomRotationQuaternion;
  19259. /**
  19260. * The device position in babylon space
  19261. */
  19262. devicePosition: Vector3;
  19263. /**
  19264. * The device rotation in babylon space
  19265. */
  19266. deviceRotationQuaternion: Quaternion;
  19267. /**
  19268. * The scale factor of the device in babylon space
  19269. */
  19270. deviceScaleFactor: number;
  19271. /**
  19272. * (Likely devicePosition should be used instead) The device position in its room space
  19273. */
  19274. position: Vector3;
  19275. /**
  19276. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19277. */
  19278. rotationQuaternion: Quaternion;
  19279. /**
  19280. * The type of controller (Eg. Windows mixed reality)
  19281. */
  19282. controllerType: PoseEnabledControllerType;
  19283. protected _calculatedPosition: Vector3;
  19284. private _calculatedRotation;
  19285. /**
  19286. * The raw pose from the device
  19287. */
  19288. rawPose: DevicePose;
  19289. private _trackPosition;
  19290. private _maxRotationDistFromHeadset;
  19291. private _draggedRoomRotation;
  19292. /**
  19293. * @hidden
  19294. */
  19295. _disableTrackPosition(fixedPosition: Vector3): void;
  19296. /**
  19297. * Internal, the mesh attached to the controller
  19298. * @hidden
  19299. */
  19300. _mesh: Nullable<AbstractMesh>;
  19301. private _poseControlledCamera;
  19302. private _leftHandSystemQuaternion;
  19303. /**
  19304. * Internal, matrix used to convert room space to babylon space
  19305. * @hidden
  19306. */
  19307. _deviceToWorld: Matrix;
  19308. /**
  19309. * Node to be used when casting a ray from the controller
  19310. * @hidden
  19311. */
  19312. _pointingPoseNode: Nullable<TransformNode>;
  19313. /**
  19314. * Name of the child mesh that can be used to cast a ray from the controller
  19315. */
  19316. static readonly POINTING_POSE: string;
  19317. /**
  19318. * Creates a new PoseEnabledController from a gamepad
  19319. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19320. */
  19321. constructor(browserGamepad: any);
  19322. private _workingMatrix;
  19323. /**
  19324. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19325. */
  19326. update(): void;
  19327. /**
  19328. * Updates only the pose device and mesh without doing any button event checking
  19329. */
  19330. protected _updatePoseAndMesh(): void;
  19331. /**
  19332. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19333. * @param poseData raw pose fromthe device
  19334. */
  19335. updateFromDevice(poseData: DevicePose): void;
  19336. /**
  19337. * @hidden
  19338. */
  19339. _meshAttachedObservable: Observable<AbstractMesh>;
  19340. /**
  19341. * Attaches a mesh to the controller
  19342. * @param mesh the mesh to be attached
  19343. */
  19344. attachToMesh(mesh: AbstractMesh): void;
  19345. /**
  19346. * Attaches the controllers mesh to a camera
  19347. * @param camera the camera the mesh should be attached to
  19348. */
  19349. attachToPoseControlledCamera(camera: TargetCamera): void;
  19350. /**
  19351. * Disposes of the controller
  19352. */
  19353. dispose(): void;
  19354. /**
  19355. * The mesh that is attached to the controller
  19356. */
  19357. get mesh(): Nullable<AbstractMesh>;
  19358. /**
  19359. * Gets the ray of the controller in the direction the controller is pointing
  19360. * @param length the length the resulting ray should be
  19361. * @returns a ray in the direction the controller is pointing
  19362. */
  19363. getForwardRay(length?: number): Ray;
  19364. }
  19365. }
  19366. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19367. import { Observable } from "babylonjs/Misc/observable";
  19368. import { Scene } from "babylonjs/scene";
  19369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19370. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19371. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19372. import { Nullable } from "babylonjs/types";
  19373. /**
  19374. * Defines the WebVRController object that represents controllers tracked in 3D space
  19375. */
  19376. export abstract class WebVRController extends PoseEnabledController {
  19377. /**
  19378. * Internal, the default controller model for the controller
  19379. */
  19380. protected _defaultModel: Nullable<AbstractMesh>;
  19381. /**
  19382. * Fired when the trigger state has changed
  19383. */
  19384. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19385. /**
  19386. * Fired when the main button state has changed
  19387. */
  19388. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19389. /**
  19390. * Fired when the secondary button state has changed
  19391. */
  19392. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19393. /**
  19394. * Fired when the pad state has changed
  19395. */
  19396. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19397. /**
  19398. * Fired when controllers stick values have changed
  19399. */
  19400. onPadValuesChangedObservable: Observable<StickValues>;
  19401. /**
  19402. * Array of button availible on the controller
  19403. */
  19404. protected _buttons: Array<MutableGamepadButton>;
  19405. private _onButtonStateChange;
  19406. /**
  19407. * Fired when a controller button's state has changed
  19408. * @param callback the callback containing the button that was modified
  19409. */
  19410. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19411. /**
  19412. * X and Y axis corresponding to the controllers joystick
  19413. */
  19414. pad: StickValues;
  19415. /**
  19416. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19417. */
  19418. hand: string;
  19419. /**
  19420. * The default controller model for the controller
  19421. */
  19422. get defaultModel(): Nullable<AbstractMesh>;
  19423. /**
  19424. * Creates a new WebVRController from a gamepad
  19425. * @param vrGamepad the gamepad that the WebVRController should be created from
  19426. */
  19427. constructor(vrGamepad: any);
  19428. /**
  19429. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19430. */
  19431. update(): void;
  19432. /**
  19433. * Function to be called when a button is modified
  19434. */
  19435. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19436. /**
  19437. * Loads a mesh and attaches it to the controller
  19438. * @param scene the scene the mesh should be added to
  19439. * @param meshLoaded callback for when the mesh has been loaded
  19440. */
  19441. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19442. private _setButtonValue;
  19443. private _changes;
  19444. private _checkChanges;
  19445. /**
  19446. * Disposes of th webVRCOntroller
  19447. */
  19448. dispose(): void;
  19449. }
  19450. }
  19451. declare module "babylonjs/Lights/hemisphericLight" {
  19452. import { Nullable } from "babylonjs/types";
  19453. import { Scene } from "babylonjs/scene";
  19454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19455. import { Color3 } from "babylonjs/Maths/math.color";
  19456. import { Effect } from "babylonjs/Materials/effect";
  19457. import { Light } from "babylonjs/Lights/light";
  19458. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19459. /**
  19460. * The HemisphericLight simulates the ambient environment light,
  19461. * so the passed direction is the light reflection direction, not the incoming direction.
  19462. */
  19463. export class HemisphericLight extends Light {
  19464. /**
  19465. * The groundColor is the light in the opposite direction to the one specified during creation.
  19466. * 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.
  19467. */
  19468. groundColor: Color3;
  19469. /**
  19470. * The light reflection direction, not the incoming direction.
  19471. */
  19472. direction: Vector3;
  19473. /**
  19474. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19475. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19476. * The HemisphericLight can't cast shadows.
  19477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19478. * @param name The friendly name of the light
  19479. * @param direction The direction of the light reflection
  19480. * @param scene The scene the light belongs to
  19481. */
  19482. constructor(name: string, direction: Vector3, scene: Scene);
  19483. protected _buildUniformLayout(): void;
  19484. /**
  19485. * Returns the string "HemisphericLight".
  19486. * @return The class name
  19487. */
  19488. getClassName(): string;
  19489. /**
  19490. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19491. * Returns the updated direction.
  19492. * @param target The target the direction should point to
  19493. * @return The computed direction
  19494. */
  19495. setDirectionToTarget(target: Vector3): Vector3;
  19496. /**
  19497. * Returns the shadow generator associated to the light.
  19498. * @returns Always null for hemispheric lights because it does not support shadows.
  19499. */
  19500. getShadowGenerator(): Nullable<IShadowGenerator>;
  19501. /**
  19502. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19503. * @param effect The effect to update
  19504. * @param lightIndex The index of the light in the effect to update
  19505. * @returns The hemispheric light
  19506. */
  19507. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19508. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19509. /**
  19510. * Computes the world matrix of the node
  19511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19512. * @param useWasUpdatedFlag defines a reserved property
  19513. * @returns the world matrix
  19514. */
  19515. computeWorldMatrix(): Matrix;
  19516. /**
  19517. * Returns the integer 3.
  19518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19519. */
  19520. getTypeID(): number;
  19521. /**
  19522. * Prepares the list of defines specific to the light type.
  19523. * @param defines the list of defines
  19524. * @param lightIndex defines the index of the light for the effect
  19525. */
  19526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19527. }
  19528. }
  19529. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19530. /** @hidden */
  19531. export var vrMultiviewToSingleviewPixelShader: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19538. import { Scene } from "babylonjs/scene";
  19539. /**
  19540. * Renders to multiple views with a single draw call
  19541. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19542. */
  19543. export class MultiviewRenderTarget extends RenderTargetTexture {
  19544. /**
  19545. * Creates a multiview render target
  19546. * @param scene scene used with the render target
  19547. * @param size the size of the render target (used for each view)
  19548. */
  19549. constructor(scene: Scene, size?: number | {
  19550. width: number;
  19551. height: number;
  19552. } | {
  19553. ratio: number;
  19554. });
  19555. /**
  19556. * @hidden
  19557. * @param faceIndex the face index, if its a cube texture
  19558. */
  19559. _bindFrameBuffer(faceIndex?: number): void;
  19560. /**
  19561. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19562. * @returns the view count
  19563. */
  19564. getViewCount(): number;
  19565. }
  19566. }
  19567. declare module "babylonjs/Maths/math.frustum" {
  19568. import { Matrix } from "babylonjs/Maths/math.vector";
  19569. import { DeepImmutable } from "babylonjs/types";
  19570. import { Plane } from "babylonjs/Maths/math.plane";
  19571. /**
  19572. * Represents a camera frustum
  19573. */
  19574. export class Frustum {
  19575. /**
  19576. * Gets the planes representing the frustum
  19577. * @param transform matrix to be applied to the returned planes
  19578. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19579. */
  19580. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19581. /**
  19582. * Gets the near frustum plane transformed by the transform matrix
  19583. * @param transform transformation matrix to be applied to the resulting frustum plane
  19584. * @param frustumPlane the resuling frustum plane
  19585. */
  19586. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19587. /**
  19588. * Gets the far frustum plane transformed by the transform matrix
  19589. * @param transform transformation matrix to be applied to the resulting frustum plane
  19590. * @param frustumPlane the resuling frustum plane
  19591. */
  19592. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19593. /**
  19594. * Gets the left frustum plane transformed by the transform matrix
  19595. * @param transform transformation matrix to be applied to the resulting frustum plane
  19596. * @param frustumPlane the resuling frustum plane
  19597. */
  19598. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19599. /**
  19600. * Gets the right frustum plane transformed by the transform matrix
  19601. * @param transform transformation matrix to be applied to the resulting frustum plane
  19602. * @param frustumPlane the resuling frustum plane
  19603. */
  19604. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19605. /**
  19606. * Gets the top frustum plane transformed by the transform matrix
  19607. * @param transform transformation matrix to be applied to the resulting frustum plane
  19608. * @param frustumPlane the resuling frustum plane
  19609. */
  19610. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19611. /**
  19612. * Gets the bottom frustum plane transformed by the transform matrix
  19613. * @param transform transformation matrix to be applied to the resulting frustum plane
  19614. * @param frustumPlane the resuling frustum plane
  19615. */
  19616. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19617. /**
  19618. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19619. * @param transform transformation matrix to be applied to the resulting frustum planes
  19620. * @param frustumPlanes the resuling frustum planes
  19621. */
  19622. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19623. }
  19624. }
  19625. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19626. import { Camera } from "babylonjs/Cameras/camera";
  19627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19628. import { Nullable } from "babylonjs/types";
  19629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19630. import { Matrix } from "babylonjs/Maths/math.vector";
  19631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19632. module "babylonjs/Engines/engine" {
  19633. interface Engine {
  19634. /**
  19635. * Creates a new multiview render target
  19636. * @param width defines the width of the texture
  19637. * @param height defines the height of the texture
  19638. * @returns the created multiview texture
  19639. */
  19640. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19641. /**
  19642. * Binds a multiview framebuffer to be drawn to
  19643. * @param multiviewTexture texture to bind
  19644. */
  19645. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19646. }
  19647. }
  19648. module "babylonjs/Cameras/camera" {
  19649. interface Camera {
  19650. /**
  19651. * @hidden
  19652. * 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)
  19653. */
  19654. _useMultiviewToSingleView: boolean;
  19655. /**
  19656. * @hidden
  19657. * 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)
  19658. */
  19659. _multiviewTexture: Nullable<RenderTargetTexture>;
  19660. /**
  19661. * @hidden
  19662. * ensures the multiview texture of the camera exists and has the specified width/height
  19663. * @param width height to set on the multiview texture
  19664. * @param height width to set on the multiview texture
  19665. */
  19666. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19667. }
  19668. }
  19669. module "babylonjs/scene" {
  19670. interface Scene {
  19671. /** @hidden */
  19672. _transformMatrixR: Matrix;
  19673. /** @hidden */
  19674. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19675. /** @hidden */
  19676. _createMultiviewUbo(): void;
  19677. /** @hidden */
  19678. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19679. /** @hidden */
  19680. _renderMultiviewToSingleView(camera: Camera): void;
  19681. }
  19682. }
  19683. }
  19684. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19685. import { Camera } from "babylonjs/Cameras/camera";
  19686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19687. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19688. import "babylonjs/Engines/Extensions/engine.multiview";
  19689. /**
  19690. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19691. * This will not be used for webXR as it supports displaying texture arrays directly
  19692. */
  19693. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19694. /**
  19695. * Initializes a VRMultiviewToSingleview
  19696. * @param name name of the post process
  19697. * @param camera camera to be applied to
  19698. * @param scaleFactor scaling factor to the size of the output texture
  19699. */
  19700. constructor(name: string, camera: Camera, scaleFactor: number);
  19701. }
  19702. }
  19703. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19704. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19705. import { Nullable } from "babylonjs/types";
  19706. import { Size } from "babylonjs/Maths/math.size";
  19707. import { Observable } from "babylonjs/Misc/observable";
  19708. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19709. /**
  19710. * Interface used to define additional presentation attributes
  19711. */
  19712. export interface IVRPresentationAttributes {
  19713. /**
  19714. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19715. */
  19716. highRefreshRate: boolean;
  19717. /**
  19718. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19719. */
  19720. foveationLevel: number;
  19721. }
  19722. module "babylonjs/Engines/engine" {
  19723. interface Engine {
  19724. /** @hidden */
  19725. _vrDisplay: any;
  19726. /** @hidden */
  19727. _vrSupported: boolean;
  19728. /** @hidden */
  19729. _oldSize: Size;
  19730. /** @hidden */
  19731. _oldHardwareScaleFactor: number;
  19732. /** @hidden */
  19733. _vrExclusivePointerMode: boolean;
  19734. /** @hidden */
  19735. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19736. /** @hidden */
  19737. _onVRDisplayPointerRestricted: () => void;
  19738. /** @hidden */
  19739. _onVRDisplayPointerUnrestricted: () => void;
  19740. /** @hidden */
  19741. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19742. /** @hidden */
  19743. _onVrDisplayDisconnect: Nullable<() => void>;
  19744. /** @hidden */
  19745. _onVrDisplayPresentChange: Nullable<() => void>;
  19746. /**
  19747. * Observable signaled when VR display mode changes
  19748. */
  19749. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19750. /**
  19751. * Observable signaled when VR request present is complete
  19752. */
  19753. onVRRequestPresentComplete: Observable<boolean>;
  19754. /**
  19755. * Observable signaled when VR request present starts
  19756. */
  19757. onVRRequestPresentStart: Observable<Engine>;
  19758. /**
  19759. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19760. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19761. */
  19762. isInVRExclusivePointerMode: boolean;
  19763. /**
  19764. * Gets a boolean indicating if a webVR device was detected
  19765. * @returns true if a webVR device was detected
  19766. */
  19767. isVRDevicePresent(): boolean;
  19768. /**
  19769. * Gets the current webVR device
  19770. * @returns the current webVR device (or null)
  19771. */
  19772. getVRDevice(): any;
  19773. /**
  19774. * Initializes a webVR display and starts listening to display change events
  19775. * The onVRDisplayChangedObservable will be notified upon these changes
  19776. * @returns A promise containing a VRDisplay and if vr is supported
  19777. */
  19778. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19779. /** @hidden */
  19780. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19781. /**
  19782. * Gets or sets the presentation attributes used to configure VR rendering
  19783. */
  19784. vrPresentationAttributes?: IVRPresentationAttributes;
  19785. /**
  19786. * Call this function to switch to webVR mode
  19787. * Will do nothing if webVR is not supported or if there is no webVR device
  19788. * @param options the webvr options provided to the camera. mainly used for multiview
  19789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19790. */
  19791. enableVR(options: WebVROptions): void;
  19792. /** @hidden */
  19793. _onVRFullScreenTriggered(): void;
  19794. }
  19795. }
  19796. }
  19797. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19798. import { Nullable } from "babylonjs/types";
  19799. import { Observable } from "babylonjs/Misc/observable";
  19800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19801. import { Scene } from "babylonjs/scene";
  19802. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19804. import { Node } from "babylonjs/node";
  19805. import { Ray } from "babylonjs/Culling/ray";
  19806. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19807. import "babylonjs/Engines/Extensions/engine.webVR";
  19808. /**
  19809. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19810. * IMPORTANT!! The data is right-hand data.
  19811. * @export
  19812. * @interface DevicePose
  19813. */
  19814. export interface DevicePose {
  19815. /**
  19816. * The position of the device, values in array are [x,y,z].
  19817. */
  19818. readonly position: Nullable<Float32Array>;
  19819. /**
  19820. * The linearVelocity of the device, values in array are [x,y,z].
  19821. */
  19822. readonly linearVelocity: Nullable<Float32Array>;
  19823. /**
  19824. * The linearAcceleration of the device, values in array are [x,y,z].
  19825. */
  19826. readonly linearAcceleration: Nullable<Float32Array>;
  19827. /**
  19828. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19829. */
  19830. readonly orientation: Nullable<Float32Array>;
  19831. /**
  19832. * The angularVelocity of the device, values in array are [x,y,z].
  19833. */
  19834. readonly angularVelocity: Nullable<Float32Array>;
  19835. /**
  19836. * The angularAcceleration of the device, values in array are [x,y,z].
  19837. */
  19838. readonly angularAcceleration: Nullable<Float32Array>;
  19839. }
  19840. /**
  19841. * Interface representing a pose controlled object in Babylon.
  19842. * A pose controlled object has both regular pose values as well as pose values
  19843. * from an external device such as a VR head mounted display
  19844. */
  19845. export interface PoseControlled {
  19846. /**
  19847. * The position of the object in babylon space.
  19848. */
  19849. position: Vector3;
  19850. /**
  19851. * The rotation quaternion of the object in babylon space.
  19852. */
  19853. rotationQuaternion: Quaternion;
  19854. /**
  19855. * The position of the device in babylon space.
  19856. */
  19857. devicePosition?: Vector3;
  19858. /**
  19859. * The rotation quaternion of the device in babylon space.
  19860. */
  19861. deviceRotationQuaternion: Quaternion;
  19862. /**
  19863. * The raw pose coming from the device.
  19864. */
  19865. rawPose: Nullable<DevicePose>;
  19866. /**
  19867. * The scale of the device to be used when translating from device space to babylon space.
  19868. */
  19869. deviceScaleFactor: number;
  19870. /**
  19871. * Updates the poseControlled values based on the input device pose.
  19872. * @param poseData the pose data to update the object with
  19873. */
  19874. updateFromDevice(poseData: DevicePose): void;
  19875. }
  19876. /**
  19877. * Set of options to customize the webVRCamera
  19878. */
  19879. export interface WebVROptions {
  19880. /**
  19881. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19882. */
  19883. trackPosition?: boolean;
  19884. /**
  19885. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19886. */
  19887. positionScale?: number;
  19888. /**
  19889. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19890. */
  19891. displayName?: string;
  19892. /**
  19893. * Should the native controller meshes be initialized. (default: true)
  19894. */
  19895. controllerMeshes?: boolean;
  19896. /**
  19897. * Creating a default HemiLight only on controllers. (default: true)
  19898. */
  19899. defaultLightingOnControllers?: boolean;
  19900. /**
  19901. * If you don't want to use the default VR button of the helper. (default: false)
  19902. */
  19903. useCustomVRButton?: boolean;
  19904. /**
  19905. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19906. */
  19907. customVRButton?: HTMLButtonElement;
  19908. /**
  19909. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19910. */
  19911. rayLength?: number;
  19912. /**
  19913. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19914. */
  19915. defaultHeight?: number;
  19916. /**
  19917. * If multiview should be used if availible (default: false)
  19918. */
  19919. useMultiview?: boolean;
  19920. }
  19921. /**
  19922. * This represents a WebVR camera.
  19923. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19924. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19925. */
  19926. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19927. private webVROptions;
  19928. /**
  19929. * @hidden
  19930. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19931. */
  19932. _vrDevice: any;
  19933. /**
  19934. * The rawPose of the vrDevice.
  19935. */
  19936. rawPose: Nullable<DevicePose>;
  19937. private _onVREnabled;
  19938. private _specsVersion;
  19939. private _attached;
  19940. private _frameData;
  19941. protected _descendants: Array<Node>;
  19942. private _deviceRoomPosition;
  19943. /** @hidden */
  19944. _deviceRoomRotationQuaternion: Quaternion;
  19945. private _standingMatrix;
  19946. /**
  19947. * Represents device position in babylon space.
  19948. */
  19949. devicePosition: Vector3;
  19950. /**
  19951. * Represents device rotation in babylon space.
  19952. */
  19953. deviceRotationQuaternion: Quaternion;
  19954. /**
  19955. * The scale of the device to be used when translating from device space to babylon space.
  19956. */
  19957. deviceScaleFactor: number;
  19958. private _deviceToWorld;
  19959. private _worldToDevice;
  19960. /**
  19961. * References to the webVR controllers for the vrDevice.
  19962. */
  19963. controllers: Array<WebVRController>;
  19964. /**
  19965. * Emits an event when a controller is attached.
  19966. */
  19967. onControllersAttachedObservable: Observable<WebVRController[]>;
  19968. /**
  19969. * Emits an event when a controller's mesh has been loaded;
  19970. */
  19971. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19972. /**
  19973. * Emits an event when the HMD's pose has been updated.
  19974. */
  19975. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19976. private _poseSet;
  19977. /**
  19978. * If the rig cameras be used as parent instead of this camera.
  19979. */
  19980. rigParenting: boolean;
  19981. private _lightOnControllers;
  19982. private _defaultHeight?;
  19983. /**
  19984. * Instantiates a WebVRFreeCamera.
  19985. * @param name The name of the WebVRFreeCamera
  19986. * @param position The starting anchor position for the camera
  19987. * @param scene The scene the camera belongs to
  19988. * @param webVROptions a set of customizable options for the webVRCamera
  19989. */
  19990. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19991. /**
  19992. * Gets the device distance from the ground in meters.
  19993. * @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.
  19994. */
  19995. deviceDistanceToRoomGround(): number;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19999. */
  20000. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20001. /**
  20002. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20003. * @returns A promise with a boolean set to if the standing matrix is supported.
  20004. */
  20005. useStandingMatrixAsync(): Promise<boolean>;
  20006. /**
  20007. * Disposes the camera
  20008. */
  20009. dispose(): void;
  20010. /**
  20011. * Gets a vrController by name.
  20012. * @param name The name of the controller to retreive
  20013. * @returns the controller matching the name specified or null if not found
  20014. */
  20015. getControllerByName(name: string): Nullable<WebVRController>;
  20016. private _leftController;
  20017. /**
  20018. * The controller corresponding to the users left hand.
  20019. */
  20020. get leftController(): Nullable<WebVRController>;
  20021. private _rightController;
  20022. /**
  20023. * The controller corresponding to the users right hand.
  20024. */
  20025. get rightController(): Nullable<WebVRController>;
  20026. /**
  20027. * Casts a ray forward from the vrCamera's gaze.
  20028. * @param length Length of the ray (default: 100)
  20029. * @returns the ray corresponding to the gaze
  20030. */
  20031. getForwardRay(length?: number): Ray;
  20032. /**
  20033. * @hidden
  20034. * Updates the camera based on device's frame data
  20035. */
  20036. _checkInputs(): void;
  20037. /**
  20038. * Updates the poseControlled values based on the input device pose.
  20039. * @param poseData Pose coming from the device
  20040. */
  20041. updateFromDevice(poseData: DevicePose): void;
  20042. private _htmlElementAttached;
  20043. private _detachIfAttached;
  20044. /**
  20045. * WebVR's attach control will start broadcasting frames to the device.
  20046. * Note that in certain browsers (chrome for example) this function must be called
  20047. * within a user-interaction callback. Example:
  20048. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20049. *
  20050. * @param element html element to attach the vrDevice to
  20051. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20052. */
  20053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20054. /**
  20055. * Detaches the camera from the html element and disables VR
  20056. *
  20057. * @param element html element to detach from
  20058. */
  20059. detachControl(element: HTMLElement): void;
  20060. /**
  20061. * @returns the name of this class
  20062. */
  20063. getClassName(): string;
  20064. /**
  20065. * Calls resetPose on the vrDisplay
  20066. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20067. */
  20068. resetToCurrentRotation(): void;
  20069. /**
  20070. * @hidden
  20071. * Updates the rig cameras (left and right eye)
  20072. */
  20073. _updateRigCameras(): void;
  20074. private _workingVector;
  20075. private _oneVector;
  20076. private _workingMatrix;
  20077. private updateCacheCalled;
  20078. private _correctPositionIfNotTrackPosition;
  20079. /**
  20080. * @hidden
  20081. * Updates the cached values of the camera
  20082. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20083. */
  20084. _updateCache(ignoreParentClass?: boolean): void;
  20085. /**
  20086. * @hidden
  20087. * Get current device position in babylon world
  20088. */
  20089. _computeDevicePosition(): void;
  20090. /**
  20091. * Updates the current device position and rotation in the babylon world
  20092. */
  20093. update(): void;
  20094. /**
  20095. * @hidden
  20096. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20097. * @returns an identity matrix
  20098. */
  20099. _getViewMatrix(): Matrix;
  20100. private _tmpMatrix;
  20101. /**
  20102. * This function is called by the two RIG cameras.
  20103. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20104. * @hidden
  20105. */
  20106. _getWebVRViewMatrix(): Matrix;
  20107. /** @hidden */
  20108. _getWebVRProjectionMatrix(): Matrix;
  20109. private _onGamepadConnectedObserver;
  20110. private _onGamepadDisconnectedObserver;
  20111. private _updateCacheWhenTrackingDisabledObserver;
  20112. /**
  20113. * Initializes the controllers and their meshes
  20114. */
  20115. initControllers(): void;
  20116. }
  20117. }
  20118. declare module "babylonjs/PostProcesses/postProcess" {
  20119. import { Nullable } from "babylonjs/types";
  20120. import { SmartArray } from "babylonjs/Misc/smartArray";
  20121. import { Observable } from "babylonjs/Misc/observable";
  20122. import { Vector2 } from "babylonjs/Maths/math.vector";
  20123. import { Camera } from "babylonjs/Cameras/camera";
  20124. import { Effect } from "babylonjs/Materials/effect";
  20125. import "babylonjs/Shaders/postprocess.vertex";
  20126. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20127. import { Engine } from "babylonjs/Engines/engine";
  20128. import { Color4 } from "babylonjs/Maths/math.color";
  20129. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20131. /**
  20132. * Size options for a post process
  20133. */
  20134. export type PostProcessOptions = {
  20135. width: number;
  20136. height: number;
  20137. };
  20138. /**
  20139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20141. */
  20142. export class PostProcess {
  20143. /** Name of the PostProcess. */
  20144. name: string;
  20145. /**
  20146. * Gets or sets the unique id of the post process
  20147. */
  20148. uniqueId: number;
  20149. /**
  20150. * Width of the texture to apply the post process on
  20151. */
  20152. width: number;
  20153. /**
  20154. * Height of the texture to apply the post process on
  20155. */
  20156. height: number;
  20157. /**
  20158. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20159. * @hidden
  20160. */
  20161. _outputTexture: Nullable<InternalTexture>;
  20162. /**
  20163. * Sampling mode used by the shader
  20164. * See https://doc.babylonjs.com/classes/3.1/texture
  20165. */
  20166. renderTargetSamplingMode: number;
  20167. /**
  20168. * Clear color to use when screen clearing
  20169. */
  20170. clearColor: Color4;
  20171. /**
  20172. * If the buffer needs to be cleared before applying the post process. (default: true)
  20173. * Should be set to false if shader will overwrite all previous pixels.
  20174. */
  20175. autoClear: boolean;
  20176. /**
  20177. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20178. */
  20179. alphaMode: number;
  20180. /**
  20181. * Sets the setAlphaBlendConstants of the babylon engine
  20182. */
  20183. alphaConstants: Color4;
  20184. /**
  20185. * Animations to be used for the post processing
  20186. */
  20187. animations: import("babylonjs/Animations/animation").Animation[];
  20188. /**
  20189. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20190. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20191. */
  20192. enablePixelPerfectMode: boolean;
  20193. /**
  20194. * Force the postprocess to be applied without taking in account viewport
  20195. */
  20196. forceFullscreenViewport: boolean;
  20197. /**
  20198. * List of inspectable custom properties (used by the Inspector)
  20199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20200. */
  20201. inspectableCustomProperties: IInspectable[];
  20202. /**
  20203. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20204. *
  20205. * | Value | Type | Description |
  20206. * | ----- | ----------------------------------- | ----------- |
  20207. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20208. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20209. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20210. *
  20211. */
  20212. scaleMode: number;
  20213. /**
  20214. * Force textures to be a power of two (default: false)
  20215. */
  20216. alwaysForcePOT: boolean;
  20217. private _samples;
  20218. /**
  20219. * Number of sample textures (default: 1)
  20220. */
  20221. get samples(): number;
  20222. set samples(n: number);
  20223. /**
  20224. * Modify the scale of the post process to be the same as the viewport (default: false)
  20225. */
  20226. adaptScaleToCurrentViewport: boolean;
  20227. private _camera;
  20228. private _scene;
  20229. private _engine;
  20230. private _options;
  20231. private _reusable;
  20232. private _textureType;
  20233. private _textureFormat;
  20234. /**
  20235. * Smart array of input and output textures for the post process.
  20236. * @hidden
  20237. */
  20238. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20239. /**
  20240. * The index in _textures that corresponds to the output texture.
  20241. * @hidden
  20242. */
  20243. _currentRenderTextureInd: number;
  20244. private _effect;
  20245. private _samplers;
  20246. private _fragmentUrl;
  20247. private _vertexUrl;
  20248. private _parameters;
  20249. private _scaleRatio;
  20250. protected _indexParameters: any;
  20251. private _shareOutputWithPostProcess;
  20252. private _texelSize;
  20253. private _forcedOutputTexture;
  20254. /**
  20255. * Returns the fragment url or shader name used in the post process.
  20256. * @returns the fragment url or name in the shader store.
  20257. */
  20258. getEffectName(): string;
  20259. /**
  20260. * An event triggered when the postprocess is activated.
  20261. */
  20262. onActivateObservable: Observable<Camera>;
  20263. private _onActivateObserver;
  20264. /**
  20265. * A function that is added to the onActivateObservable
  20266. */
  20267. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20268. /**
  20269. * An event triggered when the postprocess changes its size.
  20270. */
  20271. onSizeChangedObservable: Observable<PostProcess>;
  20272. private _onSizeChangedObserver;
  20273. /**
  20274. * A function that is added to the onSizeChangedObservable
  20275. */
  20276. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20277. /**
  20278. * An event triggered when the postprocess applies its effect.
  20279. */
  20280. onApplyObservable: Observable<Effect>;
  20281. private _onApplyObserver;
  20282. /**
  20283. * A function that is added to the onApplyObservable
  20284. */
  20285. set onApply(callback: (effect: Effect) => void);
  20286. /**
  20287. * An event triggered before rendering the postprocess
  20288. */
  20289. onBeforeRenderObservable: Observable<Effect>;
  20290. private _onBeforeRenderObserver;
  20291. /**
  20292. * A function that is added to the onBeforeRenderObservable
  20293. */
  20294. set onBeforeRender(callback: (effect: Effect) => void);
  20295. /**
  20296. * An event triggered after rendering the postprocess
  20297. */
  20298. onAfterRenderObservable: Observable<Effect>;
  20299. private _onAfterRenderObserver;
  20300. /**
  20301. * A function that is added to the onAfterRenderObservable
  20302. */
  20303. set onAfterRender(callback: (efect: Effect) => void);
  20304. /**
  20305. * 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
  20306. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20307. */
  20308. get inputTexture(): InternalTexture;
  20309. set inputTexture(value: InternalTexture);
  20310. /**
  20311. * Gets the camera which post process is applied to.
  20312. * @returns The camera the post process is applied to.
  20313. */
  20314. getCamera(): Camera;
  20315. /**
  20316. * Gets the texel size of the postprocess.
  20317. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20318. */
  20319. get texelSize(): Vector2;
  20320. /**
  20321. * Creates a new instance PostProcess
  20322. * @param name The name of the PostProcess.
  20323. * @param fragmentUrl The url of the fragment shader to be used.
  20324. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20325. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20326. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20327. * @param camera The camera to apply the render pass to.
  20328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20329. * @param engine The engine which the post process will be applied. (default: current engine)
  20330. * @param reusable If the post process can be reused on the same frame. (default: false)
  20331. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20332. * @param textureType Type of textures used when performing the post process. (default: 0)
  20333. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20334. * @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
  20335. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20336. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20337. */
  20338. constructor(
  20339. /** Name of the PostProcess. */
  20340. 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);
  20341. /**
  20342. * Gets a string idenfifying the name of the class
  20343. * @returns "PostProcess" string
  20344. */
  20345. getClassName(): string;
  20346. /**
  20347. * Gets the engine which this post process belongs to.
  20348. * @returns The engine the post process was enabled with.
  20349. */
  20350. getEngine(): Engine;
  20351. /**
  20352. * The effect that is created when initializing the post process.
  20353. * @returns The created effect corresponding the the postprocess.
  20354. */
  20355. getEffect(): Effect;
  20356. /**
  20357. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20358. * @param postProcess The post process to share the output with.
  20359. * @returns This post process.
  20360. */
  20361. shareOutputWith(postProcess: PostProcess): PostProcess;
  20362. /**
  20363. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20364. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20365. */
  20366. useOwnOutput(): void;
  20367. /**
  20368. * Updates the effect with the current post process compile time values and recompiles the shader.
  20369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20372. * @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
  20373. * @param onCompiled Called when the shader has been compiled.
  20374. * @param onError Called if there is an error when compiling a shader.
  20375. */
  20376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20377. /**
  20378. * The post process is reusable if it can be used multiple times within one frame.
  20379. * @returns If the post process is reusable
  20380. */
  20381. isReusable(): boolean;
  20382. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20383. markTextureDirty(): void;
  20384. /**
  20385. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20386. * 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.
  20387. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20388. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20389. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20390. * @returns The target texture that was bound to be written to.
  20391. */
  20392. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20393. /**
  20394. * If the post process is supported.
  20395. */
  20396. get isSupported(): boolean;
  20397. /**
  20398. * The aspect ratio of the output texture.
  20399. */
  20400. get aspectRatio(): number;
  20401. /**
  20402. * Get a value indicating if the post-process is ready to be used
  20403. * @returns true if the post-process is ready (shader is compiled)
  20404. */
  20405. isReady(): boolean;
  20406. /**
  20407. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20408. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20409. */
  20410. apply(): Nullable<Effect>;
  20411. private _disposeTextures;
  20412. /**
  20413. * Disposes the post process.
  20414. * @param camera The camera to dispose the post process on.
  20415. */
  20416. dispose(camera?: Camera): void;
  20417. }
  20418. }
  20419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20420. /** @hidden */
  20421. export var kernelBlurVaryingDeclaration: {
  20422. name: string;
  20423. shader: string;
  20424. };
  20425. }
  20426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20427. /** @hidden */
  20428. export var kernelBlurFragment: {
  20429. name: string;
  20430. shader: string;
  20431. };
  20432. }
  20433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20434. /** @hidden */
  20435. export var kernelBlurFragment2: {
  20436. name: string;
  20437. shader: string;
  20438. };
  20439. }
  20440. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20442. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20443. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20444. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20445. /** @hidden */
  20446. export var kernelBlurPixelShader: {
  20447. name: string;
  20448. shader: string;
  20449. };
  20450. }
  20451. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20452. /** @hidden */
  20453. export var kernelBlurVertex: {
  20454. name: string;
  20455. shader: string;
  20456. };
  20457. }
  20458. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20459. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20460. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20461. /** @hidden */
  20462. export var kernelBlurVertexShader: {
  20463. name: string;
  20464. shader: string;
  20465. };
  20466. }
  20467. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20468. import { Vector2 } from "babylonjs/Maths/math.vector";
  20469. import { Nullable } from "babylonjs/types";
  20470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { Effect } from "babylonjs/Materials/effect";
  20473. import { Engine } from "babylonjs/Engines/engine";
  20474. import "babylonjs/Shaders/kernelBlur.fragment";
  20475. import "babylonjs/Shaders/kernelBlur.vertex";
  20476. /**
  20477. * The Blur Post Process which blurs an image based on a kernel and direction.
  20478. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20479. */
  20480. export class BlurPostProcess extends PostProcess {
  20481. /** The direction in which to blur the image. */
  20482. direction: Vector2;
  20483. private blockCompilation;
  20484. protected _kernel: number;
  20485. protected _idealKernel: number;
  20486. protected _packedFloat: boolean;
  20487. private _staticDefines;
  20488. /**
  20489. * Sets the length in pixels of the blur sample region
  20490. */
  20491. set kernel(v: number);
  20492. /**
  20493. * Gets the length in pixels of the blur sample region
  20494. */
  20495. get kernel(): number;
  20496. /**
  20497. * Sets wether or not the blur needs to unpack/repack floats
  20498. */
  20499. set packedFloat(v: boolean);
  20500. /**
  20501. * Gets wether or not the blur is unpacking/repacking floats
  20502. */
  20503. get packedFloat(): boolean;
  20504. /**
  20505. * Creates a new instance BlurPostProcess
  20506. * @param name The name of the effect.
  20507. * @param direction The direction in which to blur the image.
  20508. * @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.
  20509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20510. * @param camera The camera to apply the render pass to.
  20511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20512. * @param engine The engine which the post process will be applied. (default: current engine)
  20513. * @param reusable If the post process can be reused on the same frame. (default: false)
  20514. * @param textureType Type of textures used when performing the post process. (default: 0)
  20515. * @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)
  20516. */
  20517. constructor(name: string,
  20518. /** The direction in which to blur the image. */
  20519. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20520. /**
  20521. * Updates the effect with the current post process compile time values and recompiles the shader.
  20522. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20523. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20524. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20525. * @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
  20526. * @param onCompiled Called when the shader has been compiled.
  20527. * @param onError Called if there is an error when compiling a shader.
  20528. */
  20529. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20530. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20531. /**
  20532. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20533. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20534. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20535. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20536. * The gaps between physical kernels are compensated for in the weighting of the samples
  20537. * @param idealKernel Ideal blur kernel.
  20538. * @return Nearest best kernel.
  20539. */
  20540. protected _nearestBestKernel(idealKernel: number): number;
  20541. /**
  20542. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20543. * @param x The point on the Gaussian distribution to sample.
  20544. * @return the value of the Gaussian function at x.
  20545. */
  20546. protected _gaussianWeight(x: number): number;
  20547. /**
  20548. * Generates a string that can be used as a floating point number in GLSL.
  20549. * @param x Value to print.
  20550. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20551. * @return GLSL float string.
  20552. */
  20553. protected _glslFloat(x: number, decimalFigures?: number): string;
  20554. }
  20555. }
  20556. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20557. import { Scene } from "babylonjs/scene";
  20558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20559. import { Plane } from "babylonjs/Maths/math.plane";
  20560. /**
  20561. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20562. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20563. * You can then easily use it as a reflectionTexture on a flat surface.
  20564. * In case the surface is not a plane, please consider relying on reflection probes.
  20565. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20566. */
  20567. export class MirrorTexture extends RenderTargetTexture {
  20568. private scene;
  20569. /**
  20570. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20571. * 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.
  20572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20573. */
  20574. mirrorPlane: Plane;
  20575. /**
  20576. * Define the blur ratio used to blur the reflection if needed.
  20577. */
  20578. set blurRatio(value: number);
  20579. get blurRatio(): number;
  20580. /**
  20581. * Define the adaptive blur kernel used to blur the reflection if needed.
  20582. * This will autocompute the closest best match for the `blurKernel`
  20583. */
  20584. set adaptiveBlurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernel(value: number);
  20590. /**
  20591. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20593. */
  20594. set blurKernelX(value: number);
  20595. get blurKernelX(): number;
  20596. /**
  20597. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20599. */
  20600. set blurKernelY(value: number);
  20601. get blurKernelY(): number;
  20602. private _autoComputeBlurKernel;
  20603. protected _onRatioRescale(): void;
  20604. private _updateGammaSpace;
  20605. private _imageProcessingConfigChangeObserver;
  20606. private _transformMatrix;
  20607. private _mirrorMatrix;
  20608. private _savedViewMatrix;
  20609. private _blurX;
  20610. private _blurY;
  20611. private _adaptiveBlurKernel;
  20612. private _blurKernelX;
  20613. private _blurKernelY;
  20614. private _blurRatio;
  20615. /**
  20616. * Instantiates a Mirror Texture.
  20617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20619. * You can then easily use it as a reflectionTexture on a flat surface.
  20620. * In case the surface is not a plane, please consider relying on reflection probes.
  20621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20622. * @param name
  20623. * @param size
  20624. * @param scene
  20625. * @param generateMipMaps
  20626. * @param type
  20627. * @param samplingMode
  20628. * @param generateDepthBuffer
  20629. */
  20630. constructor(name: string, size: number | {
  20631. width: number;
  20632. height: number;
  20633. } | {
  20634. ratio: number;
  20635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20636. private _preparePostProcesses;
  20637. /**
  20638. * Clone the mirror texture.
  20639. * @returns the cloned texture
  20640. */
  20641. clone(): MirrorTexture;
  20642. /**
  20643. * Serialize the texture to a JSON representation you could use in Parse later on
  20644. * @returns the serialized JSON representation
  20645. */
  20646. serialize(): any;
  20647. /**
  20648. * Dispose the texture and release its associated resources.
  20649. */
  20650. dispose(): void;
  20651. }
  20652. }
  20653. declare module "babylonjs/Materials/Textures/texture" {
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { Nullable } from "babylonjs/types";
  20656. import { Matrix } from "babylonjs/Maths/math.vector";
  20657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20659. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20660. import { Scene } from "babylonjs/scene";
  20661. /**
  20662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20664. */
  20665. export class Texture extends BaseTexture {
  20666. /**
  20667. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20668. */
  20669. static SerializeBuffers: boolean;
  20670. /** @hidden */
  20671. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20672. /** @hidden */
  20673. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20674. /** @hidden */
  20675. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20676. /** nearest is mag = nearest and min = nearest and mip = linear */
  20677. static readonly NEAREST_SAMPLINGMODE: number;
  20678. /** nearest is mag = nearest and min = nearest and mip = linear */
  20679. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20681. static readonly BILINEAR_SAMPLINGMODE: number;
  20682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20683. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20684. /** Trilinear is mag = linear and min = linear and mip = linear */
  20685. static readonly TRILINEAR_SAMPLINGMODE: number;
  20686. /** Trilinear is mag = linear and min = linear and mip = linear */
  20687. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20688. /** mag = nearest and min = nearest and mip = nearest */
  20689. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20690. /** mag = nearest and min = linear and mip = nearest */
  20691. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20692. /** mag = nearest and min = linear and mip = linear */
  20693. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20694. /** mag = nearest and min = linear and mip = none */
  20695. static readonly NEAREST_LINEAR: number;
  20696. /** mag = nearest and min = nearest and mip = none */
  20697. static readonly NEAREST_NEAREST: number;
  20698. /** mag = linear and min = nearest and mip = nearest */
  20699. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20700. /** mag = linear and min = nearest and mip = linear */
  20701. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20702. /** mag = linear and min = linear and mip = none */
  20703. static readonly LINEAR_LINEAR: number;
  20704. /** mag = linear and min = nearest and mip = none */
  20705. static readonly LINEAR_NEAREST: number;
  20706. /** Explicit coordinates mode */
  20707. static readonly EXPLICIT_MODE: number;
  20708. /** Spherical coordinates mode */
  20709. static readonly SPHERICAL_MODE: number;
  20710. /** Planar coordinates mode */
  20711. static readonly PLANAR_MODE: number;
  20712. /** Cubic coordinates mode */
  20713. static readonly CUBIC_MODE: number;
  20714. /** Projection coordinates mode */
  20715. static readonly PROJECTION_MODE: number;
  20716. /** Inverse Cubic coordinates mode */
  20717. static readonly SKYBOX_MODE: number;
  20718. /** Inverse Cubic coordinates mode */
  20719. static readonly INVCUBIC_MODE: number;
  20720. /** Equirectangular coordinates mode */
  20721. static readonly EQUIRECTANGULAR_MODE: number;
  20722. /** Equirectangular Fixed coordinates mode */
  20723. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20724. /** Equirectangular Fixed Mirrored coordinates mode */
  20725. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20726. /** Texture is not repeating outside of 0..1 UVs */
  20727. static readonly CLAMP_ADDRESSMODE: number;
  20728. /** Texture is repeating outside of 0..1 UVs */
  20729. static readonly WRAP_ADDRESSMODE: number;
  20730. /** Texture is repeating and mirrored */
  20731. static readonly MIRROR_ADDRESSMODE: number;
  20732. /**
  20733. * 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
  20734. */
  20735. static UseSerializedUrlIfAny: boolean;
  20736. /**
  20737. * Define the url of the texture.
  20738. */
  20739. url: Nullable<string>;
  20740. /**
  20741. * Define an offset on the texture to offset the u coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. uOffset: number;
  20745. /**
  20746. * Define an offset on the texture to offset the v coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20748. */
  20749. vOffset: number;
  20750. /**
  20751. * Define an offset on the texture to scale the u coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. uScale: number;
  20755. /**
  20756. * Define an offset on the texture to scale the v coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20758. */
  20759. vScale: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. uAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. vAng: number;
  20770. /**
  20771. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20772. * @see http://doc.babylonjs.com/how_to/more_materials
  20773. */
  20774. wAng: number;
  20775. /**
  20776. * Defines the center of rotation (U)
  20777. */
  20778. uRotationCenter: number;
  20779. /**
  20780. * Defines the center of rotation (V)
  20781. */
  20782. vRotationCenter: number;
  20783. /**
  20784. * Defines the center of rotation (W)
  20785. */
  20786. wRotationCenter: number;
  20787. /**
  20788. * Are mip maps generated for this texture or not.
  20789. */
  20790. get noMipmap(): boolean;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: Nullable<IInspectable[]>;
  20796. private _noMipmap;
  20797. /** @hidden */
  20798. _invertY: boolean;
  20799. private _rowGenerationMatrix;
  20800. private _cachedTextureMatrix;
  20801. private _projectionModeMatrix;
  20802. private _t0;
  20803. private _t1;
  20804. private _t2;
  20805. private _cachedUOffset;
  20806. private _cachedVOffset;
  20807. private _cachedUScale;
  20808. private _cachedVScale;
  20809. private _cachedUAng;
  20810. private _cachedVAng;
  20811. private _cachedWAng;
  20812. private _cachedProjectionMatrixId;
  20813. private _cachedCoordinatesMode;
  20814. /** @hidden */
  20815. protected _initialSamplingMode: number;
  20816. /** @hidden */
  20817. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20818. private _deleteBuffer;
  20819. protected _format: Nullable<number>;
  20820. private _delayedOnLoad;
  20821. private _delayedOnError;
  20822. private _mimeType?;
  20823. /**
  20824. * Observable triggered once the texture has been loaded.
  20825. */
  20826. onLoadObservable: Observable<Texture>;
  20827. protected _isBlocking: boolean;
  20828. /**
  20829. * Is the texture preventing material to render while loading.
  20830. * If false, a default texture will be used instead of the loading one during the preparation step.
  20831. */
  20832. set isBlocking(value: boolean);
  20833. get isBlocking(): boolean;
  20834. /**
  20835. * Get the current sampling mode associated with the texture.
  20836. */
  20837. get samplingMode(): number;
  20838. /**
  20839. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20840. */
  20841. get invertY(): boolean;
  20842. /**
  20843. * Instantiates a new texture.
  20844. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20845. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20846. * @param url defines the url of the picture to load as a texture
  20847. * @param scene defines the scene or engine the texture will belong to
  20848. * @param noMipmap defines if the texture will require mip maps or not
  20849. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20850. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20851. * @param onLoad defines a callback triggered when the texture has been loaded
  20852. * @param onError defines a callback triggered when an error occurred during the loading session
  20853. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20854. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20855. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20856. * @param mimeType defines an optional mime type information
  20857. */
  20858. 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);
  20859. /**
  20860. * Update the url (and optional buffer) of this texture if url was null during construction.
  20861. * @param url the url of the texture
  20862. * @param buffer the buffer of the texture (defaults to null)
  20863. * @param onLoad callback called when the texture is loaded (defaults to null)
  20864. */
  20865. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20866. /**
  20867. * Finish the loading sequence of a texture flagged as delayed load.
  20868. * @hidden
  20869. */
  20870. delayLoad(): void;
  20871. private _prepareRowForTextureGeneration;
  20872. /**
  20873. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20874. * @returns the transform matrix of the texture.
  20875. */
  20876. getTextureMatrix(uBase?: number): Matrix;
  20877. /**
  20878. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20879. * @returns The reflection texture transform
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Clones the texture.
  20884. * @returns the cloned texture
  20885. */
  20886. clone(): Texture;
  20887. /**
  20888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20889. * @returns The JSON representation of the texture
  20890. */
  20891. serialize(): any;
  20892. /**
  20893. * Get the current class name of the texture useful for serialization or dynamic coding.
  20894. * @returns "Texture"
  20895. */
  20896. getClassName(): string;
  20897. /**
  20898. * Dispose the texture and release its associated resources.
  20899. */
  20900. dispose(): void;
  20901. /**
  20902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20903. * @param parsedTexture Define the JSON representation of the texture
  20904. * @param scene Define the scene the parsed texture should be instantiated in
  20905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20906. * @returns The parsed texture if successful
  20907. */
  20908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20909. /**
  20910. * Creates a texture from its base 64 representation.
  20911. * @param data Define the base64 payload without the data: prefix
  20912. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20913. * @param scene Define the scene the texture should belong to
  20914. * @param noMipmap Forces the texture to not create mip map information if true
  20915. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20916. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20917. * @param onLoad define a callback triggered when the texture has been loaded
  20918. * @param onError define a callback triggered when an error occurred during the loading session
  20919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20920. * @returns the created texture
  20921. */
  20922. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20923. /**
  20924. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20925. * @param data Define the base64 payload without the data: prefix
  20926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20928. * @param scene Define the scene the texture should belong to
  20929. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20930. * @param noMipmap Forces the texture to not create mip map information if true
  20931. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20932. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20933. * @param onLoad define a callback triggered when the texture has been loaded
  20934. * @param onError define a callback triggered when an error occurred during the loading session
  20935. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20936. * @returns the created texture
  20937. */
  20938. 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;
  20939. }
  20940. }
  20941. declare module "babylonjs/PostProcesses/postProcessManager" {
  20942. import { Nullable } from "babylonjs/types";
  20943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20945. import { Scene } from "babylonjs/scene";
  20946. /**
  20947. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20948. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20949. */
  20950. export class PostProcessManager {
  20951. private _scene;
  20952. private _indexBuffer;
  20953. private _vertexBuffers;
  20954. /**
  20955. * Creates a new instance PostProcess
  20956. * @param scene The scene that the post process is associated with.
  20957. */
  20958. constructor(scene: Scene);
  20959. private _prepareBuffers;
  20960. private _buildIndexBuffer;
  20961. /**
  20962. * Rebuilds the vertex buffers of the manager.
  20963. * @hidden
  20964. */
  20965. _rebuild(): void;
  20966. /**
  20967. * Prepares a frame to be run through a post process.
  20968. * @param sourceTexture The input texture to the post procesess. (default: null)
  20969. * @param postProcesses An array of post processes to be run. (default: null)
  20970. * @returns True if the post processes were able to be run.
  20971. * @hidden
  20972. */
  20973. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20974. /**
  20975. * Manually render a set of post processes to a texture.
  20976. * @param postProcesses An array of post processes to be run.
  20977. * @param targetTexture The target texture to render to.
  20978. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20979. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20980. * @param lodLevel defines which lod of the texture to render to
  20981. */
  20982. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20983. /**
  20984. * Finalize the result of the output of the postprocesses.
  20985. * @param doNotPresent If true the result will not be displayed to the screen.
  20986. * @param targetTexture The target texture to render to.
  20987. * @param faceIndex The index of the face to bind the target texture to.
  20988. * @param postProcesses The array of post processes to render.
  20989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20990. * @hidden
  20991. */
  20992. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20993. /**
  20994. * Disposes of the post process manager.
  20995. */
  20996. dispose(): void;
  20997. }
  20998. }
  20999. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { SmartArray } from "babylonjs/Misc/smartArray";
  21002. import { Nullable, Immutable } from "babylonjs/types";
  21003. import { Camera } from "babylonjs/Cameras/camera";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21006. import { Color4 } from "babylonjs/Maths/math.color";
  21007. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21011. import { Texture } from "babylonjs/Materials/Textures/texture";
  21012. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21013. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21014. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21015. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21016. import { Engine } from "babylonjs/Engines/engine";
  21017. /**
  21018. * This Helps creating a texture that will be created from a camera in your scene.
  21019. * It is basically a dynamic texture that could be used to create special effects for instance.
  21020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21021. */
  21022. export class RenderTargetTexture extends Texture {
  21023. isCube: boolean;
  21024. /**
  21025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21026. */
  21027. static readonly REFRESHRATE_RENDER_ONCE: number;
  21028. /**
  21029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21032. /**
  21033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21034. * the central point of your effect and can save a lot of performances.
  21035. */
  21036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21037. /**
  21038. * Use this predicate to dynamically define the list of mesh you want to render.
  21039. * If set, the renderList property will be overwritten.
  21040. */
  21041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21042. private _renderList;
  21043. /**
  21044. * Use this list to define the list of mesh you want to render.
  21045. */
  21046. get renderList(): Nullable<Array<AbstractMesh>>;
  21047. set renderList(value: Nullable<Array<AbstractMesh>>);
  21048. /**
  21049. * Use this function to overload the renderList array at rendering time.
  21050. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21051. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21052. * the cube (if the RTT is a cube, else layerOrFace=0).
  21053. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21054. */
  21055. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21056. private _hookArray;
  21057. /**
  21058. * Define if particles should be rendered in your texture.
  21059. */
  21060. renderParticles: boolean;
  21061. /**
  21062. * Define if sprites should be rendered in your texture.
  21063. */
  21064. renderSprites: boolean;
  21065. /**
  21066. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21067. */
  21068. coordinatesMode: number;
  21069. /**
  21070. * Define the camera used to render the texture.
  21071. */
  21072. activeCamera: Nullable<Camera>;
  21073. /**
  21074. * Override the render function of the texture with your own one.
  21075. */
  21076. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21077. /**
  21078. * Define if camera post processes should be use while rendering the texture.
  21079. */
  21080. useCameraPostProcesses: boolean;
  21081. /**
  21082. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21083. */
  21084. ignoreCameraViewport: boolean;
  21085. private _postProcessManager;
  21086. private _postProcesses;
  21087. private _resizeObserver;
  21088. /**
  21089. * An event triggered when the texture is unbind.
  21090. */
  21091. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21092. /**
  21093. * An event triggered when the texture is unbind.
  21094. */
  21095. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21096. private _onAfterUnbindObserver;
  21097. /**
  21098. * Set a after unbind callback in the texture.
  21099. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21100. */
  21101. set onAfterUnbind(callback: () => void);
  21102. /**
  21103. * An event triggered before rendering the texture
  21104. */
  21105. onBeforeRenderObservable: Observable<number>;
  21106. private _onBeforeRenderObserver;
  21107. /**
  21108. * Set a before render callback in the texture.
  21109. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21110. */
  21111. set onBeforeRender(callback: (faceIndex: number) => void);
  21112. /**
  21113. * An event triggered after rendering the texture
  21114. */
  21115. onAfterRenderObservable: Observable<number>;
  21116. private _onAfterRenderObserver;
  21117. /**
  21118. * Set a after render callback in the texture.
  21119. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21120. */
  21121. set onAfterRender(callback: (faceIndex: number) => void);
  21122. /**
  21123. * An event triggered after the texture clear
  21124. */
  21125. onClearObservable: Observable<Engine>;
  21126. private _onClearObserver;
  21127. /**
  21128. * Set a clear callback in the texture.
  21129. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21130. */
  21131. set onClear(callback: (Engine: Engine) => void);
  21132. /**
  21133. * An event triggered when the texture is resized.
  21134. */
  21135. onResizeObservable: Observable<RenderTargetTexture>;
  21136. /**
  21137. * Define the clear color of the Render Target if it should be different from the scene.
  21138. */
  21139. clearColor: Color4;
  21140. protected _size: number | {
  21141. width: number;
  21142. height: number;
  21143. layers?: number;
  21144. };
  21145. protected _initialSizeParameter: number | {
  21146. width: number;
  21147. height: number;
  21148. } | {
  21149. ratio: number;
  21150. };
  21151. protected _sizeRatio: Nullable<number>;
  21152. /** @hidden */
  21153. _generateMipMaps: boolean;
  21154. protected _renderingManager: RenderingManager;
  21155. /** @hidden */
  21156. _waitingRenderList: string[];
  21157. protected _doNotChangeAspectRatio: boolean;
  21158. protected _currentRefreshId: number;
  21159. protected _refreshRate: number;
  21160. protected _textureMatrix: Matrix;
  21161. protected _samples: number;
  21162. protected _renderTargetOptions: RenderTargetCreationOptions;
  21163. /**
  21164. * Gets render target creation options that were used.
  21165. */
  21166. get renderTargetOptions(): RenderTargetCreationOptions;
  21167. protected _engine: Engine;
  21168. protected _onRatioRescale(): void;
  21169. /**
  21170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21171. * It must define where the camera used to render the texture is set
  21172. */
  21173. boundingBoxPosition: Vector3;
  21174. private _boundingBoxSize;
  21175. /**
  21176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21177. * When defined, the cubemap will switch to local mode
  21178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21179. * @example https://www.babylonjs-playground.com/#RNASML
  21180. */
  21181. set boundingBoxSize(value: Vector3);
  21182. get boundingBoxSize(): Vector3;
  21183. /**
  21184. * In case the RTT has been created with a depth texture, get the associated
  21185. * depth texture.
  21186. * Otherwise, return null.
  21187. */
  21188. get depthStencilTexture(): Nullable<InternalTexture>;
  21189. /**
  21190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21191. * or used a shadow, depth texture...
  21192. * @param name The friendly name of the texture
  21193. * @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)
  21194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21195. * @param generateMipMaps True if mip maps need to be generated after render.
  21196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21197. * @param type The type of the buffer in the RTT (int, half float, float...)
  21198. * @param isCube True if a cube texture needs to be created
  21199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21200. * @param generateDepthBuffer True to generate a depth buffer
  21201. * @param generateStencilBuffer True to generate a stencil buffer
  21202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21205. */
  21206. constructor(name: string, size: number | {
  21207. width: number;
  21208. height: number;
  21209. layers?: number;
  21210. } | {
  21211. ratio: number;
  21212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21213. /**
  21214. * Creates a depth stencil texture.
  21215. * This is only available in WebGL 2 or with the depth texture extension available.
  21216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21219. */
  21220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21221. private _processSizeParameter;
  21222. /**
  21223. * Define the number of samples to use in case of MSAA.
  21224. * It defaults to one meaning no MSAA has been enabled.
  21225. */
  21226. get samples(): number;
  21227. set samples(value: number);
  21228. /**
  21229. * Resets the refresh counter of the texture and start bak from scratch.
  21230. * Could be useful to regenerate the texture if it is setup to render only once.
  21231. */
  21232. resetRefreshCounter(): void;
  21233. /**
  21234. * Define the refresh rate of the texture or the rendering frequency.
  21235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21236. */
  21237. get refreshRate(): number;
  21238. set refreshRate(value: number);
  21239. /**
  21240. * Adds a post process to the render target rendering passes.
  21241. * @param postProcess define the post process to add
  21242. */
  21243. addPostProcess(postProcess: PostProcess): void;
  21244. /**
  21245. * Clear all the post processes attached to the render target
  21246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21247. */
  21248. clearPostProcesses(dispose?: boolean): void;
  21249. /**
  21250. * Remove one of the post process from the list of attached post processes to the texture
  21251. * @param postProcess define the post process to remove from the list
  21252. */
  21253. removePostProcess(postProcess: PostProcess): void;
  21254. /** @hidden */
  21255. _shouldRender(): boolean;
  21256. /**
  21257. * Gets the actual render size of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderSize(): number;
  21261. /**
  21262. * Gets the actual render width of the texture.
  21263. * @returns the width of the render size
  21264. */
  21265. getRenderWidth(): number;
  21266. /**
  21267. * Gets the actual render height of the texture.
  21268. * @returns the height of the render size
  21269. */
  21270. getRenderHeight(): number;
  21271. /**
  21272. * Gets the actual number of layers of the texture.
  21273. * @returns the number of layers
  21274. */
  21275. getRenderLayers(): number;
  21276. /**
  21277. * Get if the texture can be rescaled or not.
  21278. */
  21279. get canRescale(): boolean;
  21280. /**
  21281. * Resize the texture using a ratio.
  21282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21283. */
  21284. scale(ratio: number): void;
  21285. /**
  21286. * Get the texture reflection matrix used to rotate/transform the reflection.
  21287. * @returns the reflection matrix
  21288. */
  21289. getReflectionTextureMatrix(): Matrix;
  21290. /**
  21291. * Resize the texture to a new desired size.
  21292. * Be carrefull as it will recreate all the data in the new texture.
  21293. * @param size Define the new size. It can be:
  21294. * - a number for squared texture,
  21295. * - an object containing { width: number, height: number }
  21296. * - or an object containing a ratio { ratio: number }
  21297. */
  21298. resize(size: number | {
  21299. width: number;
  21300. height: number;
  21301. } | {
  21302. ratio: number;
  21303. }): void;
  21304. private _defaultRenderListPrepared;
  21305. /**
  21306. * Renders all the objects from the render list into the texture.
  21307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21309. */
  21310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21311. private _bestReflectionRenderTargetDimension;
  21312. private _prepareRenderingManager;
  21313. /**
  21314. * @hidden
  21315. * @param faceIndex face index to bind to if this is a cubetexture
  21316. * @param layer defines the index of the texture to bind in the array
  21317. */
  21318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21320. private renderToTarget;
  21321. /**
  21322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21323. * This allowed control for front to back rendering or reversly depending of the special needs.
  21324. *
  21325. * @param renderingGroupId The rendering group id corresponding to its index
  21326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21329. */
  21330. 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;
  21331. /**
  21332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21333. *
  21334. * @param renderingGroupId The rendering group id corresponding to its index
  21335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21336. */
  21337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21338. /**
  21339. * Clones the texture.
  21340. * @returns the cloned texture
  21341. */
  21342. clone(): RenderTargetTexture;
  21343. /**
  21344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21345. * @returns The JSON representation of the texture
  21346. */
  21347. serialize(): any;
  21348. /**
  21349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21350. */
  21351. disposeFramebufferObjects(): void;
  21352. /**
  21353. * Dispose the texture and release its associated resources.
  21354. */
  21355. dispose(): void;
  21356. /** @hidden */
  21357. _rebuild(): void;
  21358. /**
  21359. * Clear the info related to rendering groups preventing retention point in material dispose.
  21360. */
  21361. freeRenderingGroups(): void;
  21362. /**
  21363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21364. * @returns the view count
  21365. */
  21366. getViewCount(): number;
  21367. }
  21368. }
  21369. declare module "babylonjs/Materials/material" {
  21370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21371. import { SmartArray } from "babylonjs/Misc/smartArray";
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import { Matrix } from "babylonjs/Maths/math.vector";
  21376. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21379. import { Effect } from "babylonjs/Materials/effect";
  21380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21382. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21383. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21384. import { Mesh } from "babylonjs/Meshes/mesh";
  21385. import { Animation } from "babylonjs/Animations/animation";
  21386. /**
  21387. * Options for compiling materials.
  21388. */
  21389. export interface IMaterialCompilationOptions {
  21390. /**
  21391. * Defines whether clip planes are enabled.
  21392. */
  21393. clipPlane: boolean;
  21394. /**
  21395. * Defines whether instances are enabled.
  21396. */
  21397. useInstances: boolean;
  21398. }
  21399. /**
  21400. * Base class for the main features of a material in Babylon.js
  21401. */
  21402. export class Material implements IAnimatable {
  21403. /**
  21404. * Returns the triangle fill mode
  21405. */
  21406. static readonly TriangleFillMode: number;
  21407. /**
  21408. * Returns the wireframe mode
  21409. */
  21410. static readonly WireFrameFillMode: number;
  21411. /**
  21412. * Returns the point fill mode
  21413. */
  21414. static readonly PointFillMode: number;
  21415. /**
  21416. * Returns the point list draw mode
  21417. */
  21418. static readonly PointListDrawMode: number;
  21419. /**
  21420. * Returns the line list draw mode
  21421. */
  21422. static readonly LineListDrawMode: number;
  21423. /**
  21424. * Returns the line loop draw mode
  21425. */
  21426. static readonly LineLoopDrawMode: number;
  21427. /**
  21428. * Returns the line strip draw mode
  21429. */
  21430. static readonly LineStripDrawMode: number;
  21431. /**
  21432. * Returns the triangle strip draw mode
  21433. */
  21434. static readonly TriangleStripDrawMode: number;
  21435. /**
  21436. * Returns the triangle fan draw mode
  21437. */
  21438. static readonly TriangleFanDrawMode: number;
  21439. /**
  21440. * Stores the clock-wise side orientation
  21441. */
  21442. static readonly ClockWiseSideOrientation: number;
  21443. /**
  21444. * Stores the counter clock-wise side orientation
  21445. */
  21446. static readonly CounterClockWiseSideOrientation: number;
  21447. /**
  21448. * The dirty texture flag value
  21449. */
  21450. static readonly TextureDirtyFlag: number;
  21451. /**
  21452. * The dirty light flag value
  21453. */
  21454. static readonly LightDirtyFlag: number;
  21455. /**
  21456. * The dirty fresnel flag value
  21457. */
  21458. static readonly FresnelDirtyFlag: number;
  21459. /**
  21460. * The dirty attribute flag value
  21461. */
  21462. static readonly AttributesDirtyFlag: number;
  21463. /**
  21464. * The dirty misc flag value
  21465. */
  21466. static readonly MiscDirtyFlag: number;
  21467. /**
  21468. * The all dirty flag value
  21469. */
  21470. static readonly AllDirtyFlag: number;
  21471. /**
  21472. * The ID of the material
  21473. */
  21474. id: string;
  21475. /**
  21476. * Gets or sets the unique id of the material
  21477. */
  21478. uniqueId: number;
  21479. /**
  21480. * The name of the material
  21481. */
  21482. name: string;
  21483. /**
  21484. * Gets or sets user defined metadata
  21485. */
  21486. metadata: any;
  21487. /**
  21488. * For internal use only. Please do not use.
  21489. */
  21490. reservedDataStore: any;
  21491. /**
  21492. * Specifies if the ready state should be checked on each call
  21493. */
  21494. checkReadyOnEveryCall: boolean;
  21495. /**
  21496. * Specifies if the ready state should be checked once
  21497. */
  21498. checkReadyOnlyOnce: boolean;
  21499. /**
  21500. * The state of the material
  21501. */
  21502. state: string;
  21503. /**
  21504. * The alpha value of the material
  21505. */
  21506. protected _alpha: number;
  21507. /**
  21508. * List of inspectable custom properties (used by the Inspector)
  21509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21510. */
  21511. inspectableCustomProperties: IInspectable[];
  21512. /**
  21513. * Sets the alpha value of the material
  21514. */
  21515. set alpha(value: number);
  21516. /**
  21517. * Gets the alpha value of the material
  21518. */
  21519. get alpha(): number;
  21520. /**
  21521. * Specifies if back face culling is enabled
  21522. */
  21523. protected _backFaceCulling: boolean;
  21524. /**
  21525. * Sets the back-face culling state
  21526. */
  21527. set backFaceCulling(value: boolean);
  21528. /**
  21529. * Gets the back-face culling state
  21530. */
  21531. get backFaceCulling(): boolean;
  21532. /**
  21533. * Stores the value for side orientation
  21534. */
  21535. sideOrientation: number;
  21536. /**
  21537. * Callback triggered when the material is compiled
  21538. */
  21539. onCompiled: Nullable<(effect: Effect) => void>;
  21540. /**
  21541. * Callback triggered when an error occurs
  21542. */
  21543. onError: Nullable<(effect: Effect, errors: string) => void>;
  21544. /**
  21545. * Callback triggered to get the render target textures
  21546. */
  21547. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21548. /**
  21549. * Gets a boolean indicating that current material needs to register RTT
  21550. */
  21551. get hasRenderTargetTextures(): boolean;
  21552. /**
  21553. * Specifies if the material should be serialized
  21554. */
  21555. doNotSerialize: boolean;
  21556. /**
  21557. * @hidden
  21558. */
  21559. _storeEffectOnSubMeshes: boolean;
  21560. /**
  21561. * Stores the animations for the material
  21562. */
  21563. animations: Nullable<Array<Animation>>;
  21564. /**
  21565. * An event triggered when the material is disposed
  21566. */
  21567. onDisposeObservable: Observable<Material>;
  21568. /**
  21569. * An observer which watches for dispose events
  21570. */
  21571. private _onDisposeObserver;
  21572. private _onUnBindObservable;
  21573. /**
  21574. * Called during a dispose event
  21575. */
  21576. set onDispose(callback: () => void);
  21577. private _onBindObservable;
  21578. /**
  21579. * An event triggered when the material is bound
  21580. */
  21581. get onBindObservable(): Observable<AbstractMesh>;
  21582. /**
  21583. * An observer which watches for bind events
  21584. */
  21585. private _onBindObserver;
  21586. /**
  21587. * Called during a bind event
  21588. */
  21589. set onBind(callback: (Mesh: AbstractMesh) => void);
  21590. /**
  21591. * An event triggered when the material is unbound
  21592. */
  21593. get onUnBindObservable(): Observable<Material>;
  21594. /**
  21595. * Stores the value of the alpha mode
  21596. */
  21597. private _alphaMode;
  21598. /**
  21599. * Sets the value of the alpha mode.
  21600. *
  21601. * | Value | Type | Description |
  21602. * | --- | --- | --- |
  21603. * | 0 | ALPHA_DISABLE | |
  21604. * | 1 | ALPHA_ADD | |
  21605. * | 2 | ALPHA_COMBINE | |
  21606. * | 3 | ALPHA_SUBTRACT | |
  21607. * | 4 | ALPHA_MULTIPLY | |
  21608. * | 5 | ALPHA_MAXIMIZED | |
  21609. * | 6 | ALPHA_ONEONE | |
  21610. * | 7 | ALPHA_PREMULTIPLIED | |
  21611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21612. * | 9 | ALPHA_INTERPOLATE | |
  21613. * | 10 | ALPHA_SCREENMODE | |
  21614. *
  21615. */
  21616. set alphaMode(value: number);
  21617. /**
  21618. * Gets the value of the alpha mode
  21619. */
  21620. get alphaMode(): number;
  21621. /**
  21622. * Stores the state of the need depth pre-pass value
  21623. */
  21624. private _needDepthPrePass;
  21625. /**
  21626. * Sets the need depth pre-pass value
  21627. */
  21628. set needDepthPrePass(value: boolean);
  21629. /**
  21630. * Gets the depth pre-pass value
  21631. */
  21632. get needDepthPrePass(): boolean;
  21633. /**
  21634. * Specifies if depth writing should be disabled
  21635. */
  21636. disableDepthWrite: boolean;
  21637. /**
  21638. * Specifies if depth writing should be forced
  21639. */
  21640. forceDepthWrite: boolean;
  21641. /**
  21642. * Specifies the depth function that should be used. 0 means the default engine function
  21643. */
  21644. depthFunction: number;
  21645. /**
  21646. * Specifies if there should be a separate pass for culling
  21647. */
  21648. separateCullingPass: boolean;
  21649. /**
  21650. * Stores the state specifing if fog should be enabled
  21651. */
  21652. private _fogEnabled;
  21653. /**
  21654. * Sets the state for enabling fog
  21655. */
  21656. set fogEnabled(value: boolean);
  21657. /**
  21658. * Gets the value of the fog enabled state
  21659. */
  21660. get fogEnabled(): boolean;
  21661. /**
  21662. * Stores the size of points
  21663. */
  21664. pointSize: number;
  21665. /**
  21666. * Stores the z offset value
  21667. */
  21668. zOffset: number;
  21669. /**
  21670. * Gets a value specifying if wireframe mode is enabled
  21671. */
  21672. get wireframe(): boolean;
  21673. /**
  21674. * Sets the state of wireframe mode
  21675. */
  21676. set wireframe(value: boolean);
  21677. /**
  21678. * Gets the value specifying if point clouds are enabled
  21679. */
  21680. get pointsCloud(): boolean;
  21681. /**
  21682. * Sets the state of point cloud mode
  21683. */
  21684. set pointsCloud(value: boolean);
  21685. /**
  21686. * Gets the material fill mode
  21687. */
  21688. get fillMode(): number;
  21689. /**
  21690. * Sets the material fill mode
  21691. */
  21692. set fillMode(value: number);
  21693. /**
  21694. * @hidden
  21695. * Stores the effects for the material
  21696. */
  21697. _effect: Nullable<Effect>;
  21698. /**
  21699. * Specifies if uniform buffers should be used
  21700. */
  21701. private _useUBO;
  21702. /**
  21703. * Stores a reference to the scene
  21704. */
  21705. private _scene;
  21706. /**
  21707. * Stores the fill mode state
  21708. */
  21709. private _fillMode;
  21710. /**
  21711. * Specifies if the depth write state should be cached
  21712. */
  21713. private _cachedDepthWriteState;
  21714. /**
  21715. * Specifies if the depth function state should be cached
  21716. */
  21717. private _cachedDepthFunctionState;
  21718. /**
  21719. * Stores the uniform buffer
  21720. */
  21721. protected _uniformBuffer: UniformBuffer;
  21722. /** @hidden */
  21723. _indexInSceneMaterialArray: number;
  21724. /** @hidden */
  21725. meshMap: Nullable<{
  21726. [id: string]: AbstractMesh | undefined;
  21727. }>;
  21728. /**
  21729. * Creates a material instance
  21730. * @param name defines the name of the material
  21731. * @param scene defines the scene to reference
  21732. * @param doNotAdd specifies if the material should be added to the scene
  21733. */
  21734. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21735. /**
  21736. * Returns a string representation of the current material
  21737. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21738. * @returns a string with material information
  21739. */
  21740. toString(fullDetails?: boolean): string;
  21741. /**
  21742. * Gets the class name of the material
  21743. * @returns a string with the class name of the material
  21744. */
  21745. getClassName(): string;
  21746. /**
  21747. * Specifies if updates for the material been locked
  21748. */
  21749. get isFrozen(): boolean;
  21750. /**
  21751. * Locks updates for the material
  21752. */
  21753. freeze(): void;
  21754. /**
  21755. * Unlocks updates for the material
  21756. */
  21757. unfreeze(): void;
  21758. /**
  21759. * Specifies if the material is ready to be used
  21760. * @param mesh defines the mesh to check
  21761. * @param useInstances specifies if instances should be used
  21762. * @returns a boolean indicating if the material is ready to be used
  21763. */
  21764. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21765. /**
  21766. * Specifies that the submesh is ready to be used
  21767. * @param mesh defines the mesh to check
  21768. * @param subMesh defines which submesh to check
  21769. * @param useInstances specifies that instances should be used
  21770. * @returns a boolean indicating that the submesh is ready or not
  21771. */
  21772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21773. /**
  21774. * Returns the material effect
  21775. * @returns the effect associated with the material
  21776. */
  21777. getEffect(): Nullable<Effect>;
  21778. /**
  21779. * Returns the current scene
  21780. * @returns a Scene
  21781. */
  21782. getScene(): Scene;
  21783. /**
  21784. * Specifies if the material will require alpha blending
  21785. * @returns a boolean specifying if alpha blending is needed
  21786. */
  21787. needAlphaBlending(): boolean;
  21788. /**
  21789. * Specifies if the mesh will require alpha blending
  21790. * @param mesh defines the mesh to check
  21791. * @returns a boolean specifying if alpha blending is needed for the mesh
  21792. */
  21793. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21794. /**
  21795. * Specifies if this material should be rendered in alpha test mode
  21796. * @returns a boolean specifying if an alpha test is needed.
  21797. */
  21798. needAlphaTesting(): boolean;
  21799. /**
  21800. * Gets the texture used for the alpha test
  21801. * @returns the texture to use for alpha testing
  21802. */
  21803. getAlphaTestTexture(): Nullable<BaseTexture>;
  21804. /**
  21805. * Marks the material to indicate that it needs to be re-calculated
  21806. */
  21807. markDirty(): void;
  21808. /** @hidden */
  21809. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21810. /**
  21811. * Binds the material to the mesh
  21812. * @param world defines the world transformation matrix
  21813. * @param mesh defines the mesh to bind the material to
  21814. */
  21815. bind(world: Matrix, mesh?: Mesh): void;
  21816. /**
  21817. * Binds the submesh to the material
  21818. * @param world defines the world transformation matrix
  21819. * @param mesh defines the mesh containing the submesh
  21820. * @param subMesh defines the submesh to bind the material to
  21821. */
  21822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21823. /**
  21824. * Binds the world matrix to the material
  21825. * @param world defines the world transformation matrix
  21826. */
  21827. bindOnlyWorldMatrix(world: Matrix): void;
  21828. /**
  21829. * Binds the scene's uniform buffer to the effect.
  21830. * @param effect defines the effect to bind to the scene uniform buffer
  21831. * @param sceneUbo defines the uniform buffer storing scene data
  21832. */
  21833. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21834. /**
  21835. * Binds the view matrix to the effect
  21836. * @param effect defines the effect to bind the view matrix to
  21837. */
  21838. bindView(effect: Effect): void;
  21839. /**
  21840. * Binds the view projection matrix to the effect
  21841. * @param effect defines the effect to bind the view projection matrix to
  21842. */
  21843. bindViewProjection(effect: Effect): void;
  21844. /**
  21845. * Specifies if material alpha testing should be turned on for the mesh
  21846. * @param mesh defines the mesh to check
  21847. */
  21848. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21849. /**
  21850. * Processes to execute after binding the material to a mesh
  21851. * @param mesh defines the rendered mesh
  21852. */
  21853. protected _afterBind(mesh?: Mesh): void;
  21854. /**
  21855. * Unbinds the material from the mesh
  21856. */
  21857. unbind(): void;
  21858. /**
  21859. * Gets the active textures from the material
  21860. * @returns an array of textures
  21861. */
  21862. getActiveTextures(): BaseTexture[];
  21863. /**
  21864. * Specifies if the material uses a texture
  21865. * @param texture defines the texture to check against the material
  21866. * @returns a boolean specifying if the material uses the texture
  21867. */
  21868. hasTexture(texture: BaseTexture): boolean;
  21869. /**
  21870. * Makes a duplicate of the material, and gives it a new name
  21871. * @param name defines the new name for the duplicated material
  21872. * @returns the cloned material
  21873. */
  21874. clone(name: string): Nullable<Material>;
  21875. /**
  21876. * Gets the meshes bound to the material
  21877. * @returns an array of meshes bound to the material
  21878. */
  21879. getBindedMeshes(): AbstractMesh[];
  21880. /**
  21881. * Force shader compilation
  21882. * @param mesh defines the mesh associated with this material
  21883. * @param onCompiled defines a function to execute once the material is compiled
  21884. * @param options defines the options to configure the compilation
  21885. * @param onError defines a function to execute if the material fails compiling
  21886. */
  21887. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21888. /**
  21889. * Force shader compilation
  21890. * @param mesh defines the mesh that will use this material
  21891. * @param options defines additional options for compiling the shaders
  21892. * @returns a promise that resolves when the compilation completes
  21893. */
  21894. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21895. private static readonly _AllDirtyCallBack;
  21896. private static readonly _ImageProcessingDirtyCallBack;
  21897. private static readonly _TextureDirtyCallBack;
  21898. private static readonly _FresnelDirtyCallBack;
  21899. private static readonly _MiscDirtyCallBack;
  21900. private static readonly _LightsDirtyCallBack;
  21901. private static readonly _AttributeDirtyCallBack;
  21902. private static _FresnelAndMiscDirtyCallBack;
  21903. private static _TextureAndMiscDirtyCallBack;
  21904. private static readonly _DirtyCallbackArray;
  21905. private static readonly _RunDirtyCallBacks;
  21906. /**
  21907. * Marks a define in the material to indicate that it needs to be re-computed
  21908. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21909. */
  21910. markAsDirty(flag: number): void;
  21911. /**
  21912. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21913. * @param func defines a function which checks material defines against the submeshes
  21914. */
  21915. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21916. /**
  21917. * Indicates that we need to re-calculated for all submeshes
  21918. */
  21919. protected _markAllSubMeshesAsAllDirty(): void;
  21920. /**
  21921. * Indicates that image processing needs to be re-calculated for all submeshes
  21922. */
  21923. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21924. /**
  21925. * Indicates that textures need to be re-calculated for all submeshes
  21926. */
  21927. protected _markAllSubMeshesAsTexturesDirty(): void;
  21928. /**
  21929. * Indicates that fresnel needs to be re-calculated for all submeshes
  21930. */
  21931. protected _markAllSubMeshesAsFresnelDirty(): void;
  21932. /**
  21933. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21934. */
  21935. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21936. /**
  21937. * Indicates that lights need to be re-calculated for all submeshes
  21938. */
  21939. protected _markAllSubMeshesAsLightsDirty(): void;
  21940. /**
  21941. * Indicates that attributes need to be re-calculated for all submeshes
  21942. */
  21943. protected _markAllSubMeshesAsAttributesDirty(): void;
  21944. /**
  21945. * Indicates that misc needs to be re-calculated for all submeshes
  21946. */
  21947. protected _markAllSubMeshesAsMiscDirty(): void;
  21948. /**
  21949. * Indicates that textures and misc need to be re-calculated for all submeshes
  21950. */
  21951. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21952. /**
  21953. * Disposes the material
  21954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21957. */
  21958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21959. /** @hidden */
  21960. private releaseVertexArrayObject;
  21961. /**
  21962. * Serializes this material
  21963. * @returns the serialized material object
  21964. */
  21965. serialize(): any;
  21966. /**
  21967. * Creates a material from parsed material data
  21968. * @param parsedMaterial defines parsed material data
  21969. * @param scene defines the hosting scene
  21970. * @param rootUrl defines the root URL to use to load textures
  21971. * @returns a new material
  21972. */
  21973. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21974. }
  21975. }
  21976. declare module "babylonjs/Materials/multiMaterial" {
  21977. import { Nullable } from "babylonjs/types";
  21978. import { Scene } from "babylonjs/scene";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Material } from "babylonjs/Materials/material";
  21983. /**
  21984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21985. * separate meshes. This can be use to improve performances.
  21986. * @see http://doc.babylonjs.com/how_to/multi_materials
  21987. */
  21988. export class MultiMaterial extends Material {
  21989. private _subMaterials;
  21990. /**
  21991. * Gets or Sets the list of Materials used within the multi material.
  21992. * They need to be ordered according to the submeshes order in the associated mesh
  21993. */
  21994. get subMaterials(): Nullable<Material>[];
  21995. set subMaterials(value: Nullable<Material>[]);
  21996. /**
  21997. * Function used to align with Node.getChildren()
  21998. * @returns the list of Materials used within the multi material
  21999. */
  22000. getChildren(): Nullable<Material>[];
  22001. /**
  22002. * Instantiates a new Multi Material
  22003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22004. * separate meshes. This can be use to improve performances.
  22005. * @see http://doc.babylonjs.com/how_to/multi_materials
  22006. * @param name Define the name in the scene
  22007. * @param scene Define the scene the material belongs to
  22008. */
  22009. constructor(name: string, scene: Scene);
  22010. private _hookArray;
  22011. /**
  22012. * Get one of the submaterial by its index in the submaterials array
  22013. * @param index The index to look the sub material at
  22014. * @returns The Material if the index has been defined
  22015. */
  22016. getSubMaterial(index: number): Nullable<Material>;
  22017. /**
  22018. * Get the list of active textures for the whole sub materials list.
  22019. * @returns All the textures that will be used during the rendering
  22020. */
  22021. getActiveTextures(): BaseTexture[];
  22022. /**
  22023. * Gets the current class name of the material e.g. "MultiMaterial"
  22024. * Mainly use in serialization.
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Checks if the material is ready to render the requested sub mesh
  22030. * @param mesh Define the mesh the submesh belongs to
  22031. * @param subMesh Define the sub mesh to look readyness for
  22032. * @param useInstances Define whether or not the material is used with instances
  22033. * @returns true if ready, otherwise false
  22034. */
  22035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22036. /**
  22037. * Clones the current material and its related sub materials
  22038. * @param name Define the name of the newly cloned material
  22039. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22040. * @returns the cloned material
  22041. */
  22042. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22043. /**
  22044. * Serializes the materials into a JSON representation.
  22045. * @returns the JSON representation
  22046. */
  22047. serialize(): any;
  22048. /**
  22049. * Dispose the material and release its associated resources
  22050. * @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)
  22051. * @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)
  22052. * @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)
  22053. */
  22054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22055. /**
  22056. * Creates a MultiMaterial from parsed MultiMaterial data.
  22057. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22058. * @param scene defines the hosting scene
  22059. * @returns a new MultiMaterial
  22060. */
  22061. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22062. }
  22063. }
  22064. declare module "babylonjs/Meshes/subMesh" {
  22065. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22067. import { Engine } from "babylonjs/Engines/engine";
  22068. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22069. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22072. import { Plane } from "babylonjs/Maths/math.plane";
  22073. import { Collider } from "babylonjs/Collisions/collider";
  22074. import { Material } from "babylonjs/Materials/material";
  22075. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22077. import { Mesh } from "babylonjs/Meshes/mesh";
  22078. import { Ray } from "babylonjs/Culling/ray";
  22079. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22080. /**
  22081. * Base class for submeshes
  22082. */
  22083. export class BaseSubMesh {
  22084. /** @hidden */
  22085. _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */
  22087. _materialEffect: Nullable<Effect>;
  22088. /**
  22089. * Gets material defines used by the effect associated to the sub mesh
  22090. */
  22091. get materialDefines(): Nullable<MaterialDefines>;
  22092. /**
  22093. * Sets material defines used by the effect associated to the sub mesh
  22094. */
  22095. set materialDefines(defines: Nullable<MaterialDefines>);
  22096. /**
  22097. * Gets associated effect
  22098. */
  22099. get effect(): Nullable<Effect>;
  22100. /**
  22101. * Sets associated effect (effect used to render this submesh)
  22102. * @param effect defines the effect to associate with
  22103. * @param defines defines the set of defines used to compile this effect
  22104. */
  22105. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22106. }
  22107. /**
  22108. * Defines a subdivision inside a mesh
  22109. */
  22110. export class SubMesh extends BaseSubMesh implements ICullable {
  22111. /** the material index to use */
  22112. materialIndex: number;
  22113. /** vertex index start */
  22114. verticesStart: number;
  22115. /** vertices count */
  22116. verticesCount: number;
  22117. /** index start */
  22118. indexStart: number;
  22119. /** indices count */
  22120. indexCount: number;
  22121. /** @hidden */
  22122. _linesIndexCount: number;
  22123. private _mesh;
  22124. private _renderingMesh;
  22125. private _boundingInfo;
  22126. private _linesIndexBuffer;
  22127. /** @hidden */
  22128. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22129. /** @hidden */
  22130. _trianglePlanes: Plane[];
  22131. /** @hidden */
  22132. _lastColliderTransformMatrix: Nullable<Matrix>;
  22133. /** @hidden */
  22134. _renderId: number;
  22135. /** @hidden */
  22136. _alphaIndex: number;
  22137. /** @hidden */
  22138. _distanceToCamera: number;
  22139. /** @hidden */
  22140. _id: number;
  22141. private _currentMaterial;
  22142. /**
  22143. * Add a new submesh to a mesh
  22144. * @param materialIndex defines the material index to use
  22145. * @param verticesStart defines vertex index start
  22146. * @param verticesCount defines vertices count
  22147. * @param indexStart defines index start
  22148. * @param indexCount defines indices count
  22149. * @param mesh defines the parent mesh
  22150. * @param renderingMesh defines an optional rendering mesh
  22151. * @param createBoundingBox defines if bounding box should be created for this submesh
  22152. * @returns the new submesh
  22153. */
  22154. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22155. /**
  22156. * Creates a new submesh
  22157. * @param materialIndex defines the material index to use
  22158. * @param verticesStart defines vertex index start
  22159. * @param verticesCount defines vertices count
  22160. * @param indexStart defines index start
  22161. * @param indexCount defines indices count
  22162. * @param mesh defines the parent mesh
  22163. * @param renderingMesh defines an optional rendering mesh
  22164. * @param createBoundingBox defines if bounding box should be created for this submesh
  22165. */
  22166. constructor(
  22167. /** the material index to use */
  22168. materialIndex: number,
  22169. /** vertex index start */
  22170. verticesStart: number,
  22171. /** vertices count */
  22172. verticesCount: number,
  22173. /** index start */
  22174. indexStart: number,
  22175. /** indices count */
  22176. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22177. /**
  22178. * Returns true if this submesh covers the entire parent mesh
  22179. * @ignorenaming
  22180. */
  22181. get IsGlobal(): boolean;
  22182. /**
  22183. * Returns the submesh BoudingInfo object
  22184. * @returns current bounding info (or mesh's one if the submesh is global)
  22185. */
  22186. getBoundingInfo(): BoundingInfo;
  22187. /**
  22188. * Sets the submesh BoundingInfo
  22189. * @param boundingInfo defines the new bounding info to use
  22190. * @returns the SubMesh
  22191. */
  22192. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22193. /**
  22194. * Returns the mesh of the current submesh
  22195. * @return the parent mesh
  22196. */
  22197. getMesh(): AbstractMesh;
  22198. /**
  22199. * Returns the rendering mesh of the submesh
  22200. * @returns the rendering mesh (could be different from parent mesh)
  22201. */
  22202. getRenderingMesh(): Mesh;
  22203. /**
  22204. * Returns the submesh material
  22205. * @returns null or the current material
  22206. */
  22207. getMaterial(): Nullable<Material>;
  22208. /**
  22209. * Sets a new updated BoundingInfo object to the submesh
  22210. * @param data defines an optional position array to use to determine the bounding info
  22211. * @returns the SubMesh
  22212. */
  22213. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22214. /** @hidden */
  22215. _checkCollision(collider: Collider): boolean;
  22216. /**
  22217. * Updates the submesh BoundingInfo
  22218. * @param world defines the world matrix to use to update the bounding info
  22219. * @returns the submesh
  22220. */
  22221. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22222. /**
  22223. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22224. * @param frustumPlanes defines the frustum planes
  22225. * @returns true if the submesh is intersecting with the frustum
  22226. */
  22227. isInFrustum(frustumPlanes: Plane[]): boolean;
  22228. /**
  22229. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22230. * @param frustumPlanes defines the frustum planes
  22231. * @returns true if the submesh is inside the frustum
  22232. */
  22233. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22234. /**
  22235. * Renders the submesh
  22236. * @param enableAlphaMode defines if alpha needs to be used
  22237. * @returns the submesh
  22238. */
  22239. render(enableAlphaMode: boolean): SubMesh;
  22240. /**
  22241. * @hidden
  22242. */
  22243. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22244. /**
  22245. * Checks if the submesh intersects with a ray
  22246. * @param ray defines the ray to test
  22247. * @returns true is the passed ray intersects the submesh bounding box
  22248. */
  22249. canIntersects(ray: Ray): boolean;
  22250. /**
  22251. * Intersects current submesh with a ray
  22252. * @param ray defines the ray to test
  22253. * @param positions defines mesh's positions array
  22254. * @param indices defines mesh's indices array
  22255. * @param fastCheck defines if only bounding info should be used
  22256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22257. * @returns intersection info or null if no intersection
  22258. */
  22259. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22260. /** @hidden */
  22261. private _intersectLines;
  22262. /** @hidden */
  22263. private _intersectUnIndexedLines;
  22264. /** @hidden */
  22265. private _intersectTriangles;
  22266. /** @hidden */
  22267. private _intersectUnIndexedTriangles;
  22268. /** @hidden */
  22269. _rebuild(): void;
  22270. /**
  22271. * Creates a new submesh from the passed mesh
  22272. * @param newMesh defines the new hosting mesh
  22273. * @param newRenderingMesh defines an optional rendering mesh
  22274. * @returns the new submesh
  22275. */
  22276. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22277. /**
  22278. * Release associated resources
  22279. */
  22280. dispose(): void;
  22281. /**
  22282. * Gets the class name
  22283. * @returns the string "SubMesh".
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Creates a new submesh from indices data
  22288. * @param materialIndex the index of the main mesh material
  22289. * @param startIndex the index where to start the copy in the mesh indices array
  22290. * @param indexCount the number of indices to copy then from the startIndex
  22291. * @param mesh the main mesh to create the submesh from
  22292. * @param renderingMesh the optional rendering mesh
  22293. * @returns a new submesh
  22294. */
  22295. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22296. }
  22297. }
  22298. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22299. /**
  22300. * Class used to represent data loading progression
  22301. */
  22302. export class SceneLoaderFlags {
  22303. private static _ForceFullSceneLoadingForIncremental;
  22304. private static _ShowLoadingScreen;
  22305. private static _CleanBoneMatrixWeights;
  22306. private static _loggingLevel;
  22307. /**
  22308. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22309. */
  22310. static get ForceFullSceneLoadingForIncremental(): boolean;
  22311. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22312. /**
  22313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22314. */
  22315. static get ShowLoadingScreen(): boolean;
  22316. static set ShowLoadingScreen(value: boolean);
  22317. /**
  22318. * Defines the current logging level (while loading the scene)
  22319. * @ignorenaming
  22320. */
  22321. static get loggingLevel(): number;
  22322. static set loggingLevel(value: number);
  22323. /**
  22324. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22325. */
  22326. static get CleanBoneMatrixWeights(): boolean;
  22327. static set CleanBoneMatrixWeights(value: boolean);
  22328. }
  22329. }
  22330. declare module "babylonjs/Meshes/geometry" {
  22331. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22334. import { Engine } from "babylonjs/Engines/engine";
  22335. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22336. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22337. import { Effect } from "babylonjs/Materials/effect";
  22338. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22340. import { Mesh } from "babylonjs/Meshes/mesh";
  22341. /**
  22342. * Class used to store geometry data (vertex buffers + index buffer)
  22343. */
  22344. export class Geometry implements IGetSetVerticesData {
  22345. /**
  22346. * Gets or sets the ID of the geometry
  22347. */
  22348. id: string;
  22349. /**
  22350. * Gets or sets the unique ID of the geometry
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22355. */
  22356. delayLoadState: number;
  22357. /**
  22358. * Gets the file containing the data to load when running in delay load state
  22359. */
  22360. delayLoadingFile: Nullable<string>;
  22361. /**
  22362. * Callback called when the geometry is updated
  22363. */
  22364. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22365. private _scene;
  22366. private _engine;
  22367. private _meshes;
  22368. private _totalVertices;
  22369. /** @hidden */
  22370. _indices: IndicesArray;
  22371. /** @hidden */
  22372. _vertexBuffers: {
  22373. [key: string]: VertexBuffer;
  22374. };
  22375. private _isDisposed;
  22376. private _extend;
  22377. private _boundingBias;
  22378. /** @hidden */
  22379. _delayInfo: Array<string>;
  22380. private _indexBuffer;
  22381. private _indexBufferIsUpdatable;
  22382. /** @hidden */
  22383. _boundingInfo: Nullable<BoundingInfo>;
  22384. /** @hidden */
  22385. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22386. /** @hidden */
  22387. _softwareSkinningFrameId: number;
  22388. private _vertexArrayObjects;
  22389. private _updatable;
  22390. /** @hidden */
  22391. _positions: Nullable<Vector3[]>;
  22392. /**
  22393. * 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
  22394. */
  22395. get boundingBias(): Vector2;
  22396. /**
  22397. * 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
  22398. */
  22399. set boundingBias(value: Vector2);
  22400. /**
  22401. * Static function used to attach a new empty geometry to a mesh
  22402. * @param mesh defines the mesh to attach the geometry to
  22403. * @returns the new Geometry
  22404. */
  22405. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22406. /**
  22407. * Creates a new geometry
  22408. * @param id defines the unique ID
  22409. * @param scene defines the hosting scene
  22410. * @param vertexData defines the VertexData used to get geometry data
  22411. * @param updatable defines if geometry must be updatable (false by default)
  22412. * @param mesh defines the mesh that will be associated with the geometry
  22413. */
  22414. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22415. /**
  22416. * Gets the current extend of the geometry
  22417. */
  22418. get extend(): {
  22419. minimum: Vector3;
  22420. maximum: Vector3;
  22421. };
  22422. /**
  22423. * Gets the hosting scene
  22424. * @returns the hosting Scene
  22425. */
  22426. getScene(): Scene;
  22427. /**
  22428. * Gets the hosting engine
  22429. * @returns the hosting Engine
  22430. */
  22431. getEngine(): Engine;
  22432. /**
  22433. * Defines if the geometry is ready to use
  22434. * @returns true if the geometry is ready to be used
  22435. */
  22436. isReady(): boolean;
  22437. /**
  22438. * Gets a value indicating that the geometry should not be serialized
  22439. */
  22440. get doNotSerialize(): boolean;
  22441. /** @hidden */
  22442. _rebuild(): void;
  22443. /**
  22444. * Affects all geometry data in one call
  22445. * @param vertexData defines the geometry data
  22446. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22447. */
  22448. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22449. /**
  22450. * Set specific vertex data
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @param data defines the vertex data to use
  22453. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22454. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22455. */
  22456. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22457. /**
  22458. * Removes a specific vertex data
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. */
  22461. removeVerticesData(kind: string): void;
  22462. /**
  22463. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22464. * @param buffer defines the vertex buffer to use
  22465. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22466. */
  22467. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22468. /**
  22469. * Update a specific vertex buffer
  22470. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22471. * It will do nothing if the buffer is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param offset defines the offset in the target buffer where to store the data
  22475. * @param useBytes set to true if the offset is in bytes
  22476. */
  22477. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22478. /**
  22479. * Update a specific vertex buffer
  22480. * This function will create a new buffer if the current one is not updatable
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @param data defines the data to use
  22483. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22484. */
  22485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22486. private _updateBoundingInfo;
  22487. /** @hidden */
  22488. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22489. /**
  22490. * Gets total number of vertices
  22491. * @returns the total number of vertices
  22492. */
  22493. getTotalVertices(): number;
  22494. /**
  22495. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22496. * @param kind defines the data kind (Position, normal, etc...)
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns a float array containing vertex data
  22500. */
  22501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22502. /**
  22503. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if the vertex buffer with the specified kind is updatable
  22506. */
  22507. isVertexBufferUpdatable(kind: string): boolean;
  22508. /**
  22509. * Gets a specific vertex buffer
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @returns a VertexBuffer
  22512. */
  22513. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22514. /**
  22515. * Returns all vertex buffers
  22516. * @return an object holding all vertex buffers indexed by kind
  22517. */
  22518. getVertexBuffers(): Nullable<{
  22519. [key: string]: VertexBuffer;
  22520. }>;
  22521. /**
  22522. * Gets a boolean indicating if specific vertex buffer is present
  22523. * @param kind defines the data kind (Position, normal, etc...)
  22524. * @returns true if data is present
  22525. */
  22526. isVerticesDataPresent(kind: string): boolean;
  22527. /**
  22528. * Gets a list of all attached data kinds (Position, normal, etc...)
  22529. * @returns a list of string containing all kinds
  22530. */
  22531. getVerticesDataKinds(): string[];
  22532. /**
  22533. * Update index buffer
  22534. * @param indices defines the indices to store in the index buffer
  22535. * @param offset defines the offset in the target buffer where to store the data
  22536. * @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)
  22537. */
  22538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22539. /**
  22540. * Creates a new index buffer
  22541. * @param indices defines the indices to store in the index buffer
  22542. * @param totalVertices defines the total number of vertices (could be null)
  22543. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22546. /**
  22547. * Return the total number of indices
  22548. * @returns the total number of indices
  22549. */
  22550. getTotalIndices(): number;
  22551. /**
  22552. * Gets the index buffer array
  22553. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22555. * @returns the index buffer array
  22556. */
  22557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22558. /**
  22559. * Gets the index buffer
  22560. * @return the index buffer
  22561. */
  22562. getIndexBuffer(): Nullable<DataBuffer>;
  22563. /** @hidden */
  22564. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22565. /**
  22566. * Release the associated resources for a specific mesh
  22567. * @param mesh defines the source mesh
  22568. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22569. */
  22570. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22571. /**
  22572. * Apply current geometry to a given mesh
  22573. * @param mesh defines the mesh to apply geometry to
  22574. */
  22575. applyToMesh(mesh: Mesh): void;
  22576. private _updateExtend;
  22577. private _applyToMesh;
  22578. private notifyUpdate;
  22579. /**
  22580. * Load the geometry if it was flagged as delay loaded
  22581. * @param scene defines the hosting scene
  22582. * @param onLoaded defines a callback called when the geometry is loaded
  22583. */
  22584. load(scene: Scene, onLoaded?: () => void): void;
  22585. private _queueLoad;
  22586. /**
  22587. * Invert the geometry to move from a right handed system to a left handed one.
  22588. */
  22589. toLeftHanded(): void;
  22590. /** @hidden */
  22591. _resetPointsArrayCache(): void;
  22592. /** @hidden */
  22593. _generatePointsArray(): boolean;
  22594. /**
  22595. * Gets a value indicating if the geometry is disposed
  22596. * @returns true if the geometry was disposed
  22597. */
  22598. isDisposed(): boolean;
  22599. private _disposeVertexArrayObjects;
  22600. /**
  22601. * Free all associated resources
  22602. */
  22603. dispose(): void;
  22604. /**
  22605. * Clone the current geometry into a new geometry
  22606. * @param id defines the unique ID of the new geometry
  22607. * @returns a new geometry object
  22608. */
  22609. copy(id: string): Geometry;
  22610. /**
  22611. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22612. * @return a JSON representation of the current geometry data (without the vertices data)
  22613. */
  22614. serialize(): any;
  22615. private toNumberArray;
  22616. /**
  22617. * Serialize all vertices data into a JSON oject
  22618. * @returns a JSON representation of the current geometry data
  22619. */
  22620. serializeVerticeData(): any;
  22621. /**
  22622. * Extracts a clone of a mesh geometry
  22623. * @param mesh defines the source mesh
  22624. * @param id defines the unique ID of the new geometry object
  22625. * @returns the new geometry object
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22628. /**
  22629. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22630. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22631. * Be aware Math.random() could cause collisions, but:
  22632. * "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"
  22633. * @returns a string containing a new GUID
  22634. */
  22635. static RandomId(): string;
  22636. /** @hidden */
  22637. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22638. private static _CleanMatricesWeights;
  22639. /**
  22640. * Create a new geometry from persisted data (Using .babylon file format)
  22641. * @param parsedVertexData defines the persisted data
  22642. * @param scene defines the hosting scene
  22643. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22644. * @returns the new geometry object
  22645. */
  22646. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22647. }
  22648. }
  22649. declare module "babylonjs/Meshes/mesh.vertexData" {
  22650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22651. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22652. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22653. import { Geometry } from "babylonjs/Meshes/geometry";
  22654. import { Mesh } from "babylonjs/Meshes/mesh";
  22655. /**
  22656. * Define an interface for all classes that will get and set the data on vertices
  22657. */
  22658. export interface IGetSetVerticesData {
  22659. /**
  22660. * Gets a boolean indicating if specific vertex data is present
  22661. * @param kind defines the vertex data kind to use
  22662. * @returns true is data kind is present
  22663. */
  22664. isVerticesDataPresent(kind: string): boolean;
  22665. /**
  22666. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22667. * @param kind defines the data kind (Position, normal, etc...)
  22668. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22670. * @returns a float array containing vertex data
  22671. */
  22672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22673. /**
  22674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22675. * @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.
  22676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22677. * @returns the indices array or an empty array if the mesh has no geometry
  22678. */
  22679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22680. /**
  22681. * Set specific vertex data
  22682. * @param kind defines the data kind (Position, normal, etc...)
  22683. * @param data defines the vertex data to use
  22684. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22685. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22686. */
  22687. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22688. /**
  22689. * Update a specific associated vertex buffer
  22690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22691. * - VertexBuffer.PositionKind
  22692. * - VertexBuffer.UVKind
  22693. * - VertexBuffer.UV2Kind
  22694. * - VertexBuffer.UV3Kind
  22695. * - VertexBuffer.UV4Kind
  22696. * - VertexBuffer.UV5Kind
  22697. * - VertexBuffer.UV6Kind
  22698. * - VertexBuffer.ColorKind
  22699. * - VertexBuffer.MatricesIndicesKind
  22700. * - VertexBuffer.MatricesIndicesExtraKind
  22701. * - VertexBuffer.MatricesWeightsKind
  22702. * - VertexBuffer.MatricesWeightsExtraKind
  22703. * @param data defines the data source
  22704. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22705. * @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)
  22706. */
  22707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22708. /**
  22709. * Creates a new index buffer
  22710. * @param indices defines the indices to store in the index buffer
  22711. * @param totalVertices defines the total number of vertices (could be null)
  22712. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22713. */
  22714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22715. }
  22716. /**
  22717. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22718. */
  22719. export class VertexData {
  22720. /**
  22721. * Mesh side orientation : usually the external or front surface
  22722. */
  22723. static readonly FRONTSIDE: number;
  22724. /**
  22725. * Mesh side orientation : usually the internal or back surface
  22726. */
  22727. static readonly BACKSIDE: number;
  22728. /**
  22729. * Mesh side orientation : both internal and external or front and back surfaces
  22730. */
  22731. static readonly DOUBLESIDE: number;
  22732. /**
  22733. * Mesh side orientation : by default, `FRONTSIDE`
  22734. */
  22735. static readonly DEFAULTSIDE: number;
  22736. /**
  22737. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22738. */
  22739. positions: Nullable<FloatArray>;
  22740. /**
  22741. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22742. */
  22743. normals: Nullable<FloatArray>;
  22744. /**
  22745. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22746. */
  22747. tangents: Nullable<FloatArray>;
  22748. /**
  22749. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22750. */
  22751. uvs: Nullable<FloatArray>;
  22752. /**
  22753. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22754. */
  22755. uvs2: Nullable<FloatArray>;
  22756. /**
  22757. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22758. */
  22759. uvs3: Nullable<FloatArray>;
  22760. /**
  22761. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22762. */
  22763. uvs4: Nullable<FloatArray>;
  22764. /**
  22765. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs5: Nullable<FloatArray>;
  22768. /**
  22769. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs6: Nullable<FloatArray>;
  22772. /**
  22773. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22774. */
  22775. colors: Nullable<FloatArray>;
  22776. /**
  22777. * 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).
  22778. */
  22779. matricesIndices: Nullable<FloatArray>;
  22780. /**
  22781. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22782. */
  22783. matricesWeights: Nullable<FloatArray>;
  22784. /**
  22785. * An array extending the number of possible indices
  22786. */
  22787. matricesIndicesExtra: Nullable<FloatArray>;
  22788. /**
  22789. * An array extending the number of possible weights when the number of indices is extended
  22790. */
  22791. matricesWeightsExtra: Nullable<FloatArray>;
  22792. /**
  22793. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22794. */
  22795. indices: Nullable<IndicesArray>;
  22796. /**
  22797. * Uses the passed data array to set the set the values for the specified kind of data
  22798. * @param data a linear array of floating numbers
  22799. * @param kind the type of data that is being set, eg positions, colors etc
  22800. */
  22801. set(data: FloatArray, kind: string): void;
  22802. /**
  22803. * Associates the vertexData to the passed Mesh.
  22804. * Sets it as updatable or not (default `false`)
  22805. * @param mesh the mesh the vertexData is applied to
  22806. * @param updatable when used and having the value true allows new data to update the vertexData
  22807. * @returns the VertexData
  22808. */
  22809. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22810. /**
  22811. * Associates the vertexData to the passed Geometry.
  22812. * Sets it as updatable or not (default `false`)
  22813. * @param geometry the geometry the vertexData is applied to
  22814. * @param updatable when used and having the value true allows new data to update the vertexData
  22815. * @returns VertexData
  22816. */
  22817. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22818. /**
  22819. * Updates the associated mesh
  22820. * @param mesh the mesh to be updated
  22821. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22822. * @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
  22823. * @returns VertexData
  22824. */
  22825. updateMesh(mesh: Mesh): VertexData;
  22826. /**
  22827. * Updates the associated geometry
  22828. * @param geometry the geometry to be updated
  22829. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22830. * @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
  22831. * @returns VertexData.
  22832. */
  22833. updateGeometry(geometry: Geometry): VertexData;
  22834. private _applyTo;
  22835. private _update;
  22836. /**
  22837. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22838. * @param matrix the transforming matrix
  22839. * @returns the VertexData
  22840. */
  22841. transform(matrix: Matrix): VertexData;
  22842. /**
  22843. * Merges the passed VertexData into the current one
  22844. * @param other the VertexData to be merged into the current one
  22845. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22846. * @returns the modified VertexData
  22847. */
  22848. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22849. private _mergeElement;
  22850. private _validate;
  22851. /**
  22852. * Serializes the VertexData
  22853. * @returns a serialized object
  22854. */
  22855. serialize(): any;
  22856. /**
  22857. * Extracts the vertexData from a mesh
  22858. * @param mesh the mesh from which to extract the VertexData
  22859. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22861. * @returns the object VertexData associated to the passed mesh
  22862. */
  22863. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22864. /**
  22865. * Extracts the vertexData from the geometry
  22866. * @param geometry the geometry from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22868. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22869. * @returns the object VertexData associated to the passed mesh
  22870. */
  22871. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. private static _ExtractFrom;
  22873. /**
  22874. * Creates the VertexData for a Ribbon
  22875. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22876. * * pathArray array of paths, each of which an array of successive Vector3
  22877. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22878. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22879. * * 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
  22880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22881. * * 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)
  22882. * * 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)
  22883. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22884. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22885. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22886. * @returns the VertexData of the ribbon
  22887. */
  22888. static CreateRibbon(options: {
  22889. pathArray: Vector3[][];
  22890. closeArray?: boolean;
  22891. closePath?: boolean;
  22892. offset?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. invertUV?: boolean;
  22897. uvs?: Vector2[];
  22898. colors?: Color4[];
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a box
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22906. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22907. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22908. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * 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)
  22911. * * 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)
  22912. * @returns the VertexData of the box
  22913. */
  22914. static CreateBox(options: {
  22915. size?: number;
  22916. width?: number;
  22917. height?: number;
  22918. depth?: number;
  22919. faceUV?: Vector4[];
  22920. faceColors?: Color4[];
  22921. sideOrientation?: number;
  22922. frontUVs?: Vector4;
  22923. backUVs?: Vector4;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a tiled box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22929. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22930. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22932. * @returns the VertexData of the box
  22933. */
  22934. static CreateTiledBox(options: {
  22935. pattern?: number;
  22936. width?: number;
  22937. height?: number;
  22938. depth?: number;
  22939. tileSize?: number;
  22940. tileWidth?: number;
  22941. tileHeight?: number;
  22942. alignHorizontal?: number;
  22943. alignVertical?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. }): VertexData;
  22948. /**
  22949. * Creates the VertexData for a tiled plane
  22950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22951. * * pattern a limited pattern arrangement depending on the number
  22952. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22953. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22954. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22956. * * 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)
  22957. * * 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)
  22958. * @returns the VertexData of the tiled plane
  22959. */
  22960. static CreateTiledPlane(options: {
  22961. pattern?: number;
  22962. tileSize?: number;
  22963. tileWidth?: number;
  22964. tileHeight?: number;
  22965. size?: number;
  22966. width?: number;
  22967. height?: number;
  22968. alignHorizontal?: number;
  22969. alignVertical?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22977. * * segments sets the number of horizontal strips optional, default 32
  22978. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22979. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22980. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22981. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22982. * * 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
  22983. * * 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
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * 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)
  22986. * * 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)
  22987. * @returns the VertexData of the ellipsoid
  22988. */
  22989. static CreateSphere(options: {
  22990. segments?: number;
  22991. diameter?: number;
  22992. diameterX?: number;
  22993. diameterY?: number;
  22994. diameterZ?: number;
  22995. arc?: number;
  22996. slice?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a cylinder, cone or prism
  23003. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23004. * * height sets the height (y direction) of the cylinder, optional, default 2
  23005. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23006. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23007. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23008. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23009. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23010. * * 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
  23011. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23012. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23013. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23014. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23016. * * 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)
  23017. * * 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)
  23018. * @returns the VertexData of the cylinder, cone or prism
  23019. */
  23020. static CreateCylinder(options: {
  23021. height?: number;
  23022. diameterTop?: number;
  23023. diameterBottom?: number;
  23024. diameter?: number;
  23025. tessellation?: number;
  23026. subdivisions?: number;
  23027. arc?: number;
  23028. faceColors?: Color4[];
  23029. faceUV?: Vector4[];
  23030. hasRings?: boolean;
  23031. enclose?: boolean;
  23032. sideOrientation?: number;
  23033. frontUVs?: Vector4;
  23034. backUVs?: Vector4;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a torus
  23038. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23039. * * diameter the diameter of the torus, optional default 1
  23040. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23041. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * 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)
  23044. * * 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)
  23045. * @returns the VertexData of the torus
  23046. */
  23047. static CreateTorus(options: {
  23048. diameter?: number;
  23049. thickness?: number;
  23050. tessellation?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData of the LineSystem
  23057. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23058. * - lines an array of lines, each line being an array of successive Vector3
  23059. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23060. * @returns the VertexData of the LineSystem
  23061. */
  23062. static CreateLineSystem(options: {
  23063. lines: Vector3[][];
  23064. colors?: Nullable<Color4[][]>;
  23065. }): VertexData;
  23066. /**
  23067. * Create the VertexData for a DashedLines
  23068. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23069. * - points an array successive Vector3
  23070. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23071. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23072. * - dashNb the intended total number of dashes, optional, default 200
  23073. * @returns the VertexData for the DashedLines
  23074. */
  23075. static CreateDashedLines(options: {
  23076. points: Vector3[];
  23077. dashSize?: number;
  23078. gapSize?: number;
  23079. dashNb?: number;
  23080. }): VertexData;
  23081. /**
  23082. * Creates the VertexData for a Ground
  23083. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23084. * - width the width (x direction) of the ground, optional, default 1
  23085. * - height the height (z direction) of the ground, optional, default 1
  23086. * - subdivisions the number of subdivisions per side, optional, default 1
  23087. * @returns the VertexData of the Ground
  23088. */
  23089. static CreateGround(options: {
  23090. width?: number;
  23091. height?: number;
  23092. subdivisions?: number;
  23093. subdivisionsX?: number;
  23094. subdivisionsY?: number;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23098. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23099. * * xmin the ground minimum X coordinate, optional, default -1
  23100. * * zmin the ground minimum Z coordinate, optional, default -1
  23101. * * xmax the ground maximum X coordinate, optional, default 1
  23102. * * zmax the ground maximum Z coordinate, optional, default 1
  23103. * * 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}
  23104. * * 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}
  23105. * @returns the VertexData of the TiledGround
  23106. */
  23107. static CreateTiledGround(options: {
  23108. xmin: number;
  23109. zmin: number;
  23110. xmax: number;
  23111. zmax: number;
  23112. subdivisions?: {
  23113. w: number;
  23114. h: number;
  23115. };
  23116. precision?: {
  23117. w: number;
  23118. h: number;
  23119. };
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData of the Ground designed from a heightmap
  23123. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23124. * * width the width (x direction) of the ground
  23125. * * height the height (z direction) of the ground
  23126. * * subdivisions the number of subdivisions per side
  23127. * * minHeight the minimum altitude on the ground, optional, default 0
  23128. * * maxHeight the maximum altitude on the ground, optional default 1
  23129. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23130. * * buffer the array holding the image color data
  23131. * * bufferWidth the width of image
  23132. * * bufferHeight the height of image
  23133. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23134. * @returns the VertexData of the Ground designed from a heightmap
  23135. */
  23136. static CreateGroundFromHeightMap(options: {
  23137. width: number;
  23138. height: number;
  23139. subdivisions: number;
  23140. minHeight: number;
  23141. maxHeight: number;
  23142. colorFilter: Color3;
  23143. buffer: Uint8Array;
  23144. bufferWidth: number;
  23145. bufferHeight: number;
  23146. alphaFilter: number;
  23147. }): VertexData;
  23148. /**
  23149. * Creates the VertexData for a Plane
  23150. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23151. * * size sets the width and height of the plane to the value of size, optional default 1
  23152. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23153. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23155. * * 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)
  23156. * * 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)
  23157. * @returns the VertexData of the box
  23158. */
  23159. static CreatePlane(options: {
  23160. size?: number;
  23161. width?: number;
  23162. height?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData of the Disc or regular Polygon
  23169. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23170. * * radius the radius of the disc, optional default 0.5
  23171. * * tessellation the number of polygon sides, optional, default 64
  23172. * * 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
  23173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23174. * * 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)
  23175. * * 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)
  23176. * @returns the VertexData of the box
  23177. */
  23178. static CreateDisc(options: {
  23179. radius?: number;
  23180. tessellation?: number;
  23181. arc?: number;
  23182. sideOrientation?: number;
  23183. frontUVs?: Vector4;
  23184. backUVs?: Vector4;
  23185. }): VertexData;
  23186. /**
  23187. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23188. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23189. * @param polygon a mesh built from polygonTriangulation.build()
  23190. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23191. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23192. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23193. * @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)
  23194. * @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)
  23195. * @returns the VertexData of the Polygon
  23196. */
  23197. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23198. /**
  23199. * Creates the VertexData of the IcoSphere
  23200. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23201. * * radius the radius of the IcoSphere, optional default 1
  23202. * * radiusX allows stretching in the x direction, optional, default radius
  23203. * * radiusY allows stretching in the y direction, optional, default radius
  23204. * * radiusZ allows stretching in the z direction, optional, default radius
  23205. * * flat when true creates a flat shaded mesh, optional, default true
  23206. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * 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)
  23209. * * 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)
  23210. * @returns the VertexData of the IcoSphere
  23211. */
  23212. static CreateIcoSphere(options: {
  23213. radius?: number;
  23214. radiusX?: number;
  23215. radiusY?: number;
  23216. radiusZ?: number;
  23217. flat?: boolean;
  23218. subdivisions?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a Polyhedron
  23225. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23226. * * type provided types are:
  23227. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23228. * * 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)
  23229. * * size the size of the IcoSphere, optional default 1
  23230. * * sizeX allows stretching in the x direction, optional, default size
  23231. * * sizeY allows stretching in the y direction, optional, default size
  23232. * * sizeZ allows stretching in the z direction, optional, default size
  23233. * * 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
  23234. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23235. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23236. * * flat when true creates a flat shaded mesh, optional, default true
  23237. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * @returns the VertexData of the Polyhedron
  23242. */
  23243. static CreatePolyhedron(options: {
  23244. type?: number;
  23245. size?: number;
  23246. sizeX?: number;
  23247. sizeY?: number;
  23248. sizeZ?: number;
  23249. custom?: any;
  23250. faceUV?: Vector4[];
  23251. faceColors?: Color4[];
  23252. flat?: boolean;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. }): VertexData;
  23257. /**
  23258. * Creates the VertexData for a TorusKnot
  23259. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23260. * * radius the radius of the torus knot, optional, default 2
  23261. * * tube the thickness of the tube, optional, default 0.5
  23262. * * radialSegments the number of sides on each tube segments, optional, default 32
  23263. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23264. * * p the number of windings around the z axis, optional, default 2
  23265. * * q the number of windings around the x axis, optional, default 3
  23266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23267. * * 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)
  23268. * * 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)
  23269. * @returns the VertexData of the Torus Knot
  23270. */
  23271. static CreateTorusKnot(options: {
  23272. radius?: number;
  23273. tube?: number;
  23274. radialSegments?: number;
  23275. tubularSegments?: number;
  23276. p?: number;
  23277. q?: number;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Compute normals for given positions and indices
  23284. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23285. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23286. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23287. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23288. * * facetNormals : optional array of facet normals (vector3)
  23289. * * facetPositions : optional array of facet positions (vector3)
  23290. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23291. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23292. * * bInfo : optional bounding info, required for facetPartitioning computation
  23293. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23294. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23295. * * useRightHandedSystem: optional boolean to for right handed system computation
  23296. * * depthSort : optional boolean to enable the facet depth sort computation
  23297. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23298. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23299. */
  23300. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23301. facetNormals?: any;
  23302. facetPositions?: any;
  23303. facetPartitioning?: any;
  23304. ratio?: number;
  23305. bInfo?: any;
  23306. bbSize?: Vector3;
  23307. subDiv?: any;
  23308. useRightHandedSystem?: boolean;
  23309. depthSort?: boolean;
  23310. distanceTo?: Vector3;
  23311. depthSortedFacets?: any;
  23312. }): void;
  23313. /** @hidden */
  23314. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23315. /**
  23316. * Applies VertexData created from the imported parameters to the geometry
  23317. * @param parsedVertexData the parsed data from an imported file
  23318. * @param geometry the geometry to apply the VertexData to
  23319. */
  23320. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23321. }
  23322. }
  23323. declare module "babylonjs/Morph/morphTarget" {
  23324. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23325. import { Observable } from "babylonjs/Misc/observable";
  23326. import { Nullable, FloatArray } from "babylonjs/types";
  23327. import { Scene } from "babylonjs/scene";
  23328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23329. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23330. /**
  23331. * Defines a target to use with MorphTargetManager
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23333. */
  23334. export class MorphTarget implements IAnimatable {
  23335. /** defines the name of the target */
  23336. name: string;
  23337. /**
  23338. * Gets or sets the list of animations
  23339. */
  23340. animations: import("babylonjs/Animations/animation").Animation[];
  23341. private _scene;
  23342. private _positions;
  23343. private _normals;
  23344. private _tangents;
  23345. private _uvs;
  23346. private _influence;
  23347. private _uniqueId;
  23348. /**
  23349. * Observable raised when the influence changes
  23350. */
  23351. onInfluenceChanged: Observable<boolean>;
  23352. /** @hidden */
  23353. _onDataLayoutChanged: Observable<void>;
  23354. /**
  23355. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23356. */
  23357. get influence(): number;
  23358. set influence(influence: number);
  23359. /**
  23360. * Gets or sets the id of the morph Target
  23361. */
  23362. id: string;
  23363. private _animationPropertiesOverride;
  23364. /**
  23365. * Gets or sets the animation properties override
  23366. */
  23367. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23368. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23369. /**
  23370. * Creates a new MorphTarget
  23371. * @param name defines the name of the target
  23372. * @param influence defines the influence to use
  23373. * @param scene defines the scene the morphtarget belongs to
  23374. */
  23375. constructor(
  23376. /** defines the name of the target */
  23377. name: string, influence?: number, scene?: Nullable<Scene>);
  23378. /**
  23379. * Gets the unique ID of this manager
  23380. */
  23381. get uniqueId(): number;
  23382. /**
  23383. * Gets a boolean defining if the target contains position data
  23384. */
  23385. get hasPositions(): boolean;
  23386. /**
  23387. * Gets a boolean defining if the target contains normal data
  23388. */
  23389. get hasNormals(): boolean;
  23390. /**
  23391. * Gets a boolean defining if the target contains tangent data
  23392. */
  23393. get hasTangents(): boolean;
  23394. /**
  23395. * Gets a boolean defining if the target contains texture coordinates data
  23396. */
  23397. get hasUVs(): boolean;
  23398. /**
  23399. * Affects position data to this target
  23400. * @param data defines the position data to use
  23401. */
  23402. setPositions(data: Nullable<FloatArray>): void;
  23403. /**
  23404. * Gets the position data stored in this target
  23405. * @returns a FloatArray containing the position data (or null if not present)
  23406. */
  23407. getPositions(): Nullable<FloatArray>;
  23408. /**
  23409. * Affects normal data to this target
  23410. * @param data defines the normal data to use
  23411. */
  23412. setNormals(data: Nullable<FloatArray>): void;
  23413. /**
  23414. * Gets the normal data stored in this target
  23415. * @returns a FloatArray containing the normal data (or null if not present)
  23416. */
  23417. getNormals(): Nullable<FloatArray>;
  23418. /**
  23419. * Affects tangent data to this target
  23420. * @param data defines the tangent data to use
  23421. */
  23422. setTangents(data: Nullable<FloatArray>): void;
  23423. /**
  23424. * Gets the tangent data stored in this target
  23425. * @returns a FloatArray containing the tangent data (or null if not present)
  23426. */
  23427. getTangents(): Nullable<FloatArray>;
  23428. /**
  23429. * Affects texture coordinates data to this target
  23430. * @param data defines the texture coordinates data to use
  23431. */
  23432. setUVs(data: Nullable<FloatArray>): void;
  23433. /**
  23434. * Gets the texture coordinates data stored in this target
  23435. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23436. */
  23437. getUVs(): Nullable<FloatArray>;
  23438. /**
  23439. * Clone the current target
  23440. * @returns a new MorphTarget
  23441. */
  23442. clone(): MorphTarget;
  23443. /**
  23444. * Serializes the current target into a Serialization object
  23445. * @returns the serialized object
  23446. */
  23447. serialize(): any;
  23448. /**
  23449. * Returns the string "MorphTarget"
  23450. * @returns "MorphTarget"
  23451. */
  23452. getClassName(): string;
  23453. /**
  23454. * Creates a new target from serialized data
  23455. * @param serializationObject defines the serialized data to use
  23456. * @returns a new MorphTarget
  23457. */
  23458. static Parse(serializationObject: any): MorphTarget;
  23459. /**
  23460. * Creates a MorphTarget from mesh data
  23461. * @param mesh defines the source mesh
  23462. * @param name defines the name to use for the new target
  23463. * @param influence defines the influence to attach to the target
  23464. * @returns a new MorphTarget
  23465. */
  23466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23467. }
  23468. }
  23469. declare module "babylonjs/Morph/morphTargetManager" {
  23470. import { Nullable } from "babylonjs/types";
  23471. import { Scene } from "babylonjs/scene";
  23472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23473. /**
  23474. * This class is used to deform meshes using morphing between different targets
  23475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23476. */
  23477. export class MorphTargetManager {
  23478. private _targets;
  23479. private _targetInfluenceChangedObservers;
  23480. private _targetDataLayoutChangedObservers;
  23481. private _activeTargets;
  23482. private _scene;
  23483. private _influences;
  23484. private _supportsNormals;
  23485. private _supportsTangents;
  23486. private _supportsUVs;
  23487. private _vertexCount;
  23488. private _uniqueId;
  23489. private _tempInfluences;
  23490. /**
  23491. * Gets or sets a boolean indicating if normals must be morphed
  23492. */
  23493. enableNormalMorphing: boolean;
  23494. /**
  23495. * Gets or sets a boolean indicating if tangents must be morphed
  23496. */
  23497. enableTangentMorphing: boolean;
  23498. /**
  23499. * Gets or sets a boolean indicating if UV must be morphed
  23500. */
  23501. enableUVMorphing: boolean;
  23502. /**
  23503. * Creates a new MorphTargetManager
  23504. * @param scene defines the current scene
  23505. */
  23506. constructor(scene?: Nullable<Scene>);
  23507. /**
  23508. * Gets the unique ID of this manager
  23509. */
  23510. get uniqueId(): number;
  23511. /**
  23512. * Gets the number of vertices handled by this manager
  23513. */
  23514. get vertexCount(): number;
  23515. /**
  23516. * Gets a boolean indicating if this manager supports morphing of normals
  23517. */
  23518. get supportsNormals(): boolean;
  23519. /**
  23520. * Gets a boolean indicating if this manager supports morphing of tangents
  23521. */
  23522. get supportsTangents(): boolean;
  23523. /**
  23524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23525. */
  23526. get supportsUVs(): boolean;
  23527. /**
  23528. * Gets the number of targets stored in this manager
  23529. */
  23530. get numTargets(): number;
  23531. /**
  23532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23533. */
  23534. get numInfluencers(): number;
  23535. /**
  23536. * Gets the list of influences (one per target)
  23537. */
  23538. get influences(): Float32Array;
  23539. /**
  23540. * Gets the active target at specified index. An active target is a target with an influence > 0
  23541. * @param index defines the index to check
  23542. * @returns the requested target
  23543. */
  23544. getActiveTarget(index: number): MorphTarget;
  23545. /**
  23546. * Gets the target at specified index
  23547. * @param index defines the index to check
  23548. * @returns the requested target
  23549. */
  23550. getTarget(index: number): MorphTarget;
  23551. /**
  23552. * Add a new target to this manager
  23553. * @param target defines the target to add
  23554. */
  23555. addTarget(target: MorphTarget): void;
  23556. /**
  23557. * Removes a target from the manager
  23558. * @param target defines the target to remove
  23559. */
  23560. removeTarget(target: MorphTarget): void;
  23561. /**
  23562. * Clone the current manager
  23563. * @returns a new MorphTargetManager
  23564. */
  23565. clone(): MorphTargetManager;
  23566. /**
  23567. * Serializes the current manager into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. private _syncActiveTargets;
  23572. /**
  23573. * Syncrhonize the targets with all the meshes using this morph target manager
  23574. */
  23575. synchronize(): void;
  23576. /**
  23577. * Creates a new MorphTargetManager from serialized data
  23578. * @param serializationObject defines the serialized data
  23579. * @param scene defines the hosting scene
  23580. * @returns the new MorphTargetManager
  23581. */
  23582. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23583. }
  23584. }
  23585. declare module "babylonjs/Meshes/meshLODLevel" {
  23586. import { Mesh } from "babylonjs/Meshes/mesh";
  23587. import { Nullable } from "babylonjs/types";
  23588. /**
  23589. * Class used to represent a specific level of detail of a mesh
  23590. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23591. */
  23592. export class MeshLODLevel {
  23593. /** Defines the distance where this level should start being displayed */
  23594. distance: number;
  23595. /** Defines the mesh to use to render this level */
  23596. mesh: Nullable<Mesh>;
  23597. /**
  23598. * Creates a new LOD level
  23599. * @param distance defines the distance where this level should star being displayed
  23600. * @param mesh defines the mesh to use to render this level
  23601. */
  23602. constructor(
  23603. /** Defines the distance where this level should start being displayed */
  23604. distance: number,
  23605. /** Defines the mesh to use to render this level */
  23606. mesh: Nullable<Mesh>);
  23607. }
  23608. }
  23609. declare module "babylonjs/Meshes/groundMesh" {
  23610. import { Scene } from "babylonjs/scene";
  23611. import { Vector3 } from "babylonjs/Maths/math.vector";
  23612. import { Mesh } from "babylonjs/Meshes/mesh";
  23613. /**
  23614. * Mesh representing the gorund
  23615. */
  23616. export class GroundMesh extends Mesh {
  23617. /** If octree should be generated */
  23618. generateOctree: boolean;
  23619. private _heightQuads;
  23620. /** @hidden */
  23621. _subdivisionsX: number;
  23622. /** @hidden */
  23623. _subdivisionsY: number;
  23624. /** @hidden */
  23625. _width: number;
  23626. /** @hidden */
  23627. _height: number;
  23628. /** @hidden */
  23629. _minX: number;
  23630. /** @hidden */
  23631. _maxX: number;
  23632. /** @hidden */
  23633. _minZ: number;
  23634. /** @hidden */
  23635. _maxZ: number;
  23636. constructor(name: string, scene: Scene);
  23637. /**
  23638. * "GroundMesh"
  23639. * @returns "GroundMesh"
  23640. */
  23641. getClassName(): string;
  23642. /**
  23643. * The minimum of x and y subdivisions
  23644. */
  23645. get subdivisions(): number;
  23646. /**
  23647. * X subdivisions
  23648. */
  23649. get subdivisionsX(): number;
  23650. /**
  23651. * Y subdivisions
  23652. */
  23653. get subdivisionsY(): number;
  23654. /**
  23655. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23656. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23657. * @param chunksCount the number of subdivisions for x and y
  23658. * @param octreeBlocksSize (Default: 32)
  23659. */
  23660. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23661. /**
  23662. * Returns a height (y) value in the Worl system :
  23663. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23664. * @param x x coordinate
  23665. * @param z z coordinate
  23666. * @returns the ground y position if (x, z) are outside the ground surface.
  23667. */
  23668. getHeightAtCoordinates(x: number, z: number): number;
  23669. /**
  23670. * Returns a normalized vector (Vector3) orthogonal to the ground
  23671. * at the ground coordinates (x, z) expressed in the World system.
  23672. * @param x x coordinate
  23673. * @param z z coordinate
  23674. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23675. */
  23676. getNormalAtCoordinates(x: number, z: number): Vector3;
  23677. /**
  23678. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23679. * at the ground coordinates (x, z) expressed in the World system.
  23680. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23681. * @param x x coordinate
  23682. * @param z z coordinate
  23683. * @param ref vector to store the result
  23684. * @returns the GroundMesh.
  23685. */
  23686. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23687. /**
  23688. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23689. * if the ground has been updated.
  23690. * This can be used in the render loop.
  23691. * @returns the GroundMesh.
  23692. */
  23693. updateCoordinateHeights(): GroundMesh;
  23694. private _getFacetAt;
  23695. private _initHeightQuads;
  23696. private _computeHeightQuads;
  23697. /**
  23698. * Serializes this ground mesh
  23699. * @param serializationObject object to write serialization to
  23700. */
  23701. serialize(serializationObject: any): void;
  23702. /**
  23703. * Parses a serialized ground mesh
  23704. * @param parsedMesh the serialized mesh
  23705. * @param scene the scene to create the ground mesh in
  23706. * @returns the created ground mesh
  23707. */
  23708. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23709. }
  23710. }
  23711. declare module "babylonjs/Physics/physicsJoint" {
  23712. import { Vector3 } from "babylonjs/Maths/math.vector";
  23713. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23714. /**
  23715. * Interface for Physics-Joint data
  23716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23717. */
  23718. export interface PhysicsJointData {
  23719. /**
  23720. * The main pivot of the joint
  23721. */
  23722. mainPivot?: Vector3;
  23723. /**
  23724. * The connected pivot of the joint
  23725. */
  23726. connectedPivot?: Vector3;
  23727. /**
  23728. * The main axis of the joint
  23729. */
  23730. mainAxis?: Vector3;
  23731. /**
  23732. * The connected axis of the joint
  23733. */
  23734. connectedAxis?: Vector3;
  23735. /**
  23736. * The collision of the joint
  23737. */
  23738. collision?: boolean;
  23739. /**
  23740. * Native Oimo/Cannon/Energy data
  23741. */
  23742. nativeParams?: any;
  23743. }
  23744. /**
  23745. * This is a holder class for the physics joint created by the physics plugin
  23746. * It holds a set of functions to control the underlying joint
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export class PhysicsJoint {
  23750. /**
  23751. * The type of the physics joint
  23752. */
  23753. type: number;
  23754. /**
  23755. * The data for the physics joint
  23756. */
  23757. jointData: PhysicsJointData;
  23758. private _physicsJoint;
  23759. protected _physicsPlugin: IPhysicsEnginePlugin;
  23760. /**
  23761. * Initializes the physics joint
  23762. * @param type The type of the physics joint
  23763. * @param jointData The data for the physics joint
  23764. */
  23765. constructor(
  23766. /**
  23767. * The type of the physics joint
  23768. */
  23769. type: number,
  23770. /**
  23771. * The data for the physics joint
  23772. */
  23773. jointData: PhysicsJointData);
  23774. /**
  23775. * Gets the physics joint
  23776. */
  23777. get physicsJoint(): any;
  23778. /**
  23779. * Sets the physics joint
  23780. */
  23781. set physicsJoint(newJoint: any);
  23782. /**
  23783. * Sets the physics plugin
  23784. */
  23785. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23786. /**
  23787. * Execute a function that is physics-plugin specific.
  23788. * @param {Function} func the function that will be executed.
  23789. * It accepts two parameters: the physics world and the physics joint
  23790. */
  23791. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23792. /**
  23793. * Distance-Joint type
  23794. */
  23795. static DistanceJoint: number;
  23796. /**
  23797. * Hinge-Joint type
  23798. */
  23799. static HingeJoint: number;
  23800. /**
  23801. * Ball-and-Socket joint type
  23802. */
  23803. static BallAndSocketJoint: number;
  23804. /**
  23805. * Wheel-Joint type
  23806. */
  23807. static WheelJoint: number;
  23808. /**
  23809. * Slider-Joint type
  23810. */
  23811. static SliderJoint: number;
  23812. /**
  23813. * Prismatic-Joint type
  23814. */
  23815. static PrismaticJoint: number;
  23816. /**
  23817. * Universal-Joint type
  23818. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23819. */
  23820. static UniversalJoint: number;
  23821. /**
  23822. * Hinge-Joint 2 type
  23823. */
  23824. static Hinge2Joint: number;
  23825. /**
  23826. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23827. */
  23828. static PointToPointJoint: number;
  23829. /**
  23830. * Spring-Joint type
  23831. */
  23832. static SpringJoint: number;
  23833. /**
  23834. * Lock-Joint type
  23835. */
  23836. static LockJoint: number;
  23837. }
  23838. /**
  23839. * A class representing a physics distance joint
  23840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23841. */
  23842. export class DistanceJoint extends PhysicsJoint {
  23843. /**
  23844. *
  23845. * @param jointData The data for the Distance-Joint
  23846. */
  23847. constructor(jointData: DistanceJointData);
  23848. /**
  23849. * Update the predefined distance.
  23850. * @param maxDistance The maximum preferred distance
  23851. * @param minDistance The minimum preferred distance
  23852. */
  23853. updateDistance(maxDistance: number, minDistance?: number): void;
  23854. }
  23855. /**
  23856. * Represents a Motor-Enabled Joint
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23860. /**
  23861. * Initializes the Motor-Enabled Joint
  23862. * @param type The type of the joint
  23863. * @param jointData The physica joint data for the joint
  23864. */
  23865. constructor(type: number, jointData: PhysicsJointData);
  23866. /**
  23867. * Set the motor values.
  23868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23869. * @param force the force to apply
  23870. * @param maxForce max force for this motor.
  23871. */
  23872. setMotor(force?: number, maxForce?: number): void;
  23873. /**
  23874. * Set the motor's limits.
  23875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23876. * @param upperLimit The upper limit of the motor
  23877. * @param lowerLimit The lower limit of the motor
  23878. */
  23879. setLimit(upperLimit: number, lowerLimit?: number): void;
  23880. }
  23881. /**
  23882. * This class represents a single physics Hinge-Joint
  23883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23884. */
  23885. export class HingeJoint extends MotorEnabledJoint {
  23886. /**
  23887. * Initializes the Hinge-Joint
  23888. * @param jointData The joint data for the Hinge-Joint
  23889. */
  23890. constructor(jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param {number} force the force to apply
  23895. * @param {number} maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a dual hinge physics joint (same as wheel joint)
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class Hinge2Joint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge2-Joint
  23913. * @param jointData The joint data for the Hinge2-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} targetSpeed the speed the motor is to reach
  23920. * @param {number} maxForce max force for this motor.
  23921. * @param {motorIndex} the motor's index, 0 or 1.
  23922. */
  23923. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23924. /**
  23925. * Set the motor limits.
  23926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23927. * @param {number} upperLimit the upper limit
  23928. * @param {number} lowerLimit lower limit
  23929. * @param {motorIndex} the motor's index, 0 or 1.
  23930. */
  23931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23932. }
  23933. /**
  23934. * Interface for a motor enabled joint
  23935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23936. */
  23937. export interface IMotorEnabledJoint {
  23938. /**
  23939. * Physics joint
  23940. */
  23941. physicsJoint: any;
  23942. /**
  23943. * Sets the motor of the motor-enabled joint
  23944. * @param force The force of the motor
  23945. * @param maxForce The maximum force of the motor
  23946. * @param motorIndex The index of the motor
  23947. */
  23948. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Sets the limit of the motor
  23951. * @param upperLimit The upper limit of the motor
  23952. * @param lowerLimit The lower limit of the motor
  23953. * @param motorIndex The index of the motor
  23954. */
  23955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23956. }
  23957. /**
  23958. * Joint data for a Distance-Joint
  23959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23960. */
  23961. export interface DistanceJointData extends PhysicsJointData {
  23962. /**
  23963. * Max distance the 2 joint objects can be apart
  23964. */
  23965. maxDistance: number;
  23966. }
  23967. /**
  23968. * Joint data from a spring joint
  23969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23970. */
  23971. export interface SpringJointData extends PhysicsJointData {
  23972. /**
  23973. * Length of the spring
  23974. */
  23975. length: number;
  23976. /**
  23977. * Stiffness of the spring
  23978. */
  23979. stiffness: number;
  23980. /**
  23981. * Damping of the spring
  23982. */
  23983. damping: number;
  23984. /** this callback will be called when applying the force to the impostors. */
  23985. forceApplicationCallback: () => void;
  23986. }
  23987. }
  23988. declare module "babylonjs/Physics/physicsRaycastResult" {
  23989. import { Vector3 } from "babylonjs/Maths/math.vector";
  23990. /**
  23991. * Holds the data for the raycast result
  23992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23993. */
  23994. export class PhysicsRaycastResult {
  23995. private _hasHit;
  23996. private _hitDistance;
  23997. private _hitNormalWorld;
  23998. private _hitPointWorld;
  23999. private _rayFromWorld;
  24000. private _rayToWorld;
  24001. /**
  24002. * Gets if there was a hit
  24003. */
  24004. get hasHit(): boolean;
  24005. /**
  24006. * Gets the distance from the hit
  24007. */
  24008. get hitDistance(): number;
  24009. /**
  24010. * Gets the hit normal/direction in the world
  24011. */
  24012. get hitNormalWorld(): Vector3;
  24013. /**
  24014. * Gets the hit point in the world
  24015. */
  24016. get hitPointWorld(): Vector3;
  24017. /**
  24018. * Gets the ray "start point" of the ray in the world
  24019. */
  24020. get rayFromWorld(): Vector3;
  24021. /**
  24022. * Gets the ray "end point" of the ray in the world
  24023. */
  24024. get rayToWorld(): Vector3;
  24025. /**
  24026. * Sets the hit data (normal & point in world space)
  24027. * @param hitNormalWorld defines the normal in world space
  24028. * @param hitPointWorld defines the point in world space
  24029. */
  24030. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24031. /**
  24032. * Sets the distance from the start point to the hit point
  24033. * @param distance
  24034. */
  24035. setHitDistance(distance: number): void;
  24036. /**
  24037. * Calculates the distance manually
  24038. */
  24039. calculateHitDistance(): void;
  24040. /**
  24041. * Resets all the values to default
  24042. * @param from The from point on world space
  24043. * @param to The to point on world space
  24044. */
  24045. reset(from?: Vector3, to?: Vector3): void;
  24046. }
  24047. /**
  24048. * Interface for the size containing width and height
  24049. */
  24050. interface IXYZ {
  24051. /**
  24052. * X
  24053. */
  24054. x: number;
  24055. /**
  24056. * Y
  24057. */
  24058. y: number;
  24059. /**
  24060. * Z
  24061. */
  24062. z: number;
  24063. }
  24064. }
  24065. declare module "babylonjs/Physics/IPhysicsEngine" {
  24066. import { Nullable } from "babylonjs/types";
  24067. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24069. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24070. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24071. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24072. /**
  24073. * Interface used to describe a physics joint
  24074. */
  24075. export interface PhysicsImpostorJoint {
  24076. /** Defines the main impostor to which the joint is linked */
  24077. mainImpostor: PhysicsImpostor;
  24078. /** Defines the impostor that is connected to the main impostor using this joint */
  24079. connectedImpostor: PhysicsImpostor;
  24080. /** Defines the joint itself */
  24081. joint: PhysicsJoint;
  24082. }
  24083. /** @hidden */
  24084. export interface IPhysicsEnginePlugin {
  24085. world: any;
  24086. name: string;
  24087. setGravity(gravity: Vector3): void;
  24088. setTimeStep(timeStep: number): void;
  24089. getTimeStep(): number;
  24090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24094. removePhysicsBody(impostor: PhysicsImpostor): void;
  24095. generateJoint(joint: PhysicsImpostorJoint): void;
  24096. removeJoint(joint: PhysicsImpostorJoint): void;
  24097. isSupported(): boolean;
  24098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24105. getBodyMass(impostor: PhysicsImpostor): number;
  24106. getBodyFriction(impostor: PhysicsImpostor): number;
  24107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24108. getBodyRestitution(impostor: PhysicsImpostor): number;
  24109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24110. getBodyPressure?(impostor: PhysicsImpostor): number;
  24111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24120. sleepBody(impostor: PhysicsImpostor): void;
  24121. wakeUpBody(impostor: PhysicsImpostor): void;
  24122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24126. getRadius(impostor: PhysicsImpostor): number;
  24127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24129. dispose(): void;
  24130. }
  24131. /**
  24132. * Interface used to define a physics engine
  24133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24134. */
  24135. export interface IPhysicsEngine {
  24136. /**
  24137. * Gets the gravity vector used by the simulation
  24138. */
  24139. gravity: Vector3;
  24140. /**
  24141. * Sets the gravity vector used by the simulation
  24142. * @param gravity defines the gravity vector to use
  24143. */
  24144. setGravity(gravity: Vector3): void;
  24145. /**
  24146. * Set the time step of the physics engine.
  24147. * Default is 1/60.
  24148. * To slow it down, enter 1/600 for example.
  24149. * To speed it up, 1/30
  24150. * @param newTimeStep the new timestep to apply to this world.
  24151. */
  24152. setTimeStep(newTimeStep: number): void;
  24153. /**
  24154. * Get the time step of the physics engine.
  24155. * @returns the current time step
  24156. */
  24157. getTimeStep(): number;
  24158. /**
  24159. * Set the sub time step of the physics engine.
  24160. * Default is 0 meaning there is no sub steps
  24161. * To increase physics resolution precision, set a small value (like 1 ms)
  24162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24163. */
  24164. setSubTimeStep(subTimeStep: number): void;
  24165. /**
  24166. * Get the sub time step of the physics engine.
  24167. * @returns the current sub time step
  24168. */
  24169. getSubTimeStep(): number;
  24170. /**
  24171. * Release all resources
  24172. */
  24173. dispose(): void;
  24174. /**
  24175. * Gets the name of the current physics plugin
  24176. * @returns the name of the plugin
  24177. */
  24178. getPhysicsPluginName(): string;
  24179. /**
  24180. * Adding a new impostor for the impostor tracking.
  24181. * This will be done by the impostor itself.
  24182. * @param impostor the impostor to add
  24183. */
  24184. addImpostor(impostor: PhysicsImpostor): void;
  24185. /**
  24186. * Remove an impostor from the engine.
  24187. * This impostor and its mesh will not longer be updated by the physics engine.
  24188. * @param impostor the impostor to remove
  24189. */
  24190. removeImpostor(impostor: PhysicsImpostor): void;
  24191. /**
  24192. * Add a joint to the physics engine
  24193. * @param mainImpostor defines the main impostor to which the joint is added.
  24194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24195. * @param joint defines the joint that will connect both impostors.
  24196. */
  24197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24198. /**
  24199. * Removes a joint from the simulation
  24200. * @param mainImpostor defines the impostor used with the joint
  24201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24202. * @param joint defines the joint to remove
  24203. */
  24204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24205. /**
  24206. * Gets the current plugin used to run the simulation
  24207. * @returns current plugin
  24208. */
  24209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24210. /**
  24211. * Gets the list of physic impostors
  24212. * @returns an array of PhysicsImpostor
  24213. */
  24214. getImpostors(): Array<PhysicsImpostor>;
  24215. /**
  24216. * Gets the impostor for a physics enabled object
  24217. * @param object defines the object impersonated by the impostor
  24218. * @returns the PhysicsImpostor or null if not found
  24219. */
  24220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24221. /**
  24222. * Gets the impostor for a physics body object
  24223. * @param body defines physics body used by the impostor
  24224. * @returns the PhysicsImpostor or null if not found
  24225. */
  24226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24227. /**
  24228. * Does a raycast in the physics world
  24229. * @param from when should the ray start?
  24230. * @param to when should the ray end?
  24231. * @returns PhysicsRaycastResult
  24232. */
  24233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24234. /**
  24235. * Called by the scene. No need to call it.
  24236. * @param delta defines the timespam between frames
  24237. */
  24238. _step(delta: number): void;
  24239. }
  24240. }
  24241. declare module "babylonjs/Physics/physicsImpostor" {
  24242. import { Nullable, IndicesArray } from "babylonjs/types";
  24243. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24246. import { Scene } from "babylonjs/scene";
  24247. import { Bone } from "babylonjs/Bones/bone";
  24248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24249. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24250. import { Space } from "babylonjs/Maths/math.axis";
  24251. /**
  24252. * The interface for the physics imposter parameters
  24253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24254. */
  24255. export interface PhysicsImpostorParameters {
  24256. /**
  24257. * The mass of the physics imposter
  24258. */
  24259. mass: number;
  24260. /**
  24261. * The friction of the physics imposter
  24262. */
  24263. friction?: number;
  24264. /**
  24265. * The coefficient of restitution of the physics imposter
  24266. */
  24267. restitution?: number;
  24268. /**
  24269. * The native options of the physics imposter
  24270. */
  24271. nativeOptions?: any;
  24272. /**
  24273. * Specifies if the parent should be ignored
  24274. */
  24275. ignoreParent?: boolean;
  24276. /**
  24277. * Specifies if bi-directional transformations should be disabled
  24278. */
  24279. disableBidirectionalTransformation?: boolean;
  24280. /**
  24281. * The pressure inside the physics imposter, soft object only
  24282. */
  24283. pressure?: number;
  24284. /**
  24285. * The stiffness the physics imposter, soft object only
  24286. */
  24287. stiffness?: number;
  24288. /**
  24289. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24290. */
  24291. velocityIterations?: number;
  24292. /**
  24293. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24294. */
  24295. positionIterations?: number;
  24296. /**
  24297. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24298. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24299. * Add to fix multiple points
  24300. */
  24301. fixedPoints?: number;
  24302. /**
  24303. * The collision margin around a soft object
  24304. */
  24305. margin?: number;
  24306. /**
  24307. * The collision margin around a soft object
  24308. */
  24309. damping?: number;
  24310. /**
  24311. * The path for a rope based on an extrusion
  24312. */
  24313. path?: any;
  24314. /**
  24315. * The shape of an extrusion used for a rope based on an extrusion
  24316. */
  24317. shape?: any;
  24318. }
  24319. /**
  24320. * Interface for a physics-enabled object
  24321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24322. */
  24323. export interface IPhysicsEnabledObject {
  24324. /**
  24325. * The position of the physics-enabled object
  24326. */
  24327. position: Vector3;
  24328. /**
  24329. * The rotation of the physics-enabled object
  24330. */
  24331. rotationQuaternion: Nullable<Quaternion>;
  24332. /**
  24333. * The scale of the physics-enabled object
  24334. */
  24335. scaling: Vector3;
  24336. /**
  24337. * The rotation of the physics-enabled object
  24338. */
  24339. rotation?: Vector3;
  24340. /**
  24341. * The parent of the physics-enabled object
  24342. */
  24343. parent?: any;
  24344. /**
  24345. * The bounding info of the physics-enabled object
  24346. * @returns The bounding info of the physics-enabled object
  24347. */
  24348. getBoundingInfo(): BoundingInfo;
  24349. /**
  24350. * Computes the world matrix
  24351. * @param force Specifies if the world matrix should be computed by force
  24352. * @returns A world matrix
  24353. */
  24354. computeWorldMatrix(force: boolean): Matrix;
  24355. /**
  24356. * Gets the world matrix
  24357. * @returns A world matrix
  24358. */
  24359. getWorldMatrix?(): Matrix;
  24360. /**
  24361. * Gets the child meshes
  24362. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24363. * @returns An array of abstract meshes
  24364. */
  24365. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24366. /**
  24367. * Gets the vertex data
  24368. * @param kind The type of vertex data
  24369. * @returns A nullable array of numbers, or a float32 array
  24370. */
  24371. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24372. /**
  24373. * Gets the indices from the mesh
  24374. * @returns A nullable array of index arrays
  24375. */
  24376. getIndices?(): Nullable<IndicesArray>;
  24377. /**
  24378. * Gets the scene from the mesh
  24379. * @returns the indices array or null
  24380. */
  24381. getScene?(): Scene;
  24382. /**
  24383. * Gets the absolute position from the mesh
  24384. * @returns the absolute position
  24385. */
  24386. getAbsolutePosition(): Vector3;
  24387. /**
  24388. * Gets the absolute pivot point from the mesh
  24389. * @returns the absolute pivot point
  24390. */
  24391. getAbsolutePivotPoint(): Vector3;
  24392. /**
  24393. * Rotates the mesh
  24394. * @param axis The axis of rotation
  24395. * @param amount The amount of rotation
  24396. * @param space The space of the rotation
  24397. * @returns The rotation transform node
  24398. */
  24399. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24400. /**
  24401. * Translates the mesh
  24402. * @param axis The axis of translation
  24403. * @param distance The distance of translation
  24404. * @param space The space of the translation
  24405. * @returns The transform node
  24406. */
  24407. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24408. /**
  24409. * Sets the absolute position of the mesh
  24410. * @param absolutePosition The absolute position of the mesh
  24411. * @returns The transform node
  24412. */
  24413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24414. /**
  24415. * Gets the class name of the mesh
  24416. * @returns The class name
  24417. */
  24418. getClassName(): string;
  24419. }
  24420. /**
  24421. * Represents a physics imposter
  24422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24423. */
  24424. export class PhysicsImpostor {
  24425. /**
  24426. * The physics-enabled object used as the physics imposter
  24427. */
  24428. object: IPhysicsEnabledObject;
  24429. /**
  24430. * The type of the physics imposter
  24431. */
  24432. type: number;
  24433. private _options;
  24434. private _scene?;
  24435. /**
  24436. * The default object size of the imposter
  24437. */
  24438. static DEFAULT_OBJECT_SIZE: Vector3;
  24439. /**
  24440. * The identity quaternion of the imposter
  24441. */
  24442. static IDENTITY_QUATERNION: Quaternion;
  24443. /** @hidden */
  24444. _pluginData: any;
  24445. private _physicsEngine;
  24446. private _physicsBody;
  24447. private _bodyUpdateRequired;
  24448. private _onBeforePhysicsStepCallbacks;
  24449. private _onAfterPhysicsStepCallbacks;
  24450. /** @hidden */
  24451. _onPhysicsCollideCallbacks: Array<{
  24452. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24453. otherImpostors: Array<PhysicsImpostor>;
  24454. }>;
  24455. private _deltaPosition;
  24456. private _deltaRotation;
  24457. private _deltaRotationConjugated;
  24458. /** @hidden */
  24459. _isFromLine: boolean;
  24460. private _parent;
  24461. private _isDisposed;
  24462. private static _tmpVecs;
  24463. private static _tmpQuat;
  24464. /**
  24465. * Specifies if the physics imposter is disposed
  24466. */
  24467. get isDisposed(): boolean;
  24468. /**
  24469. * Gets the mass of the physics imposter
  24470. */
  24471. get mass(): number;
  24472. set mass(value: number);
  24473. /**
  24474. * Gets the coefficient of friction
  24475. */
  24476. get friction(): number;
  24477. /**
  24478. * Sets the coefficient of friction
  24479. */
  24480. set friction(value: number);
  24481. /**
  24482. * Gets the coefficient of restitution
  24483. */
  24484. get restitution(): number;
  24485. /**
  24486. * Sets the coefficient of restitution
  24487. */
  24488. set restitution(value: number);
  24489. /**
  24490. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24491. */
  24492. get pressure(): number;
  24493. /**
  24494. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24495. */
  24496. set pressure(value: number);
  24497. /**
  24498. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24499. */
  24500. get stiffness(): number;
  24501. /**
  24502. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24503. */
  24504. set stiffness(value: number);
  24505. /**
  24506. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24507. */
  24508. get velocityIterations(): number;
  24509. /**
  24510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24511. */
  24512. set velocityIterations(value: number);
  24513. /**
  24514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24515. */
  24516. get positionIterations(): number;
  24517. /**
  24518. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24519. */
  24520. set positionIterations(value: number);
  24521. /**
  24522. * The unique id of the physics imposter
  24523. * set by the physics engine when adding this impostor to the array
  24524. */
  24525. uniqueId: number;
  24526. /**
  24527. * @hidden
  24528. */
  24529. soft: boolean;
  24530. /**
  24531. * @hidden
  24532. */
  24533. segments: number;
  24534. private _joints;
  24535. /**
  24536. * Initializes the physics imposter
  24537. * @param object The physics-enabled object used as the physics imposter
  24538. * @param type The type of the physics imposter
  24539. * @param _options The options for the physics imposter
  24540. * @param _scene The Babylon scene
  24541. */
  24542. constructor(
  24543. /**
  24544. * The physics-enabled object used as the physics imposter
  24545. */
  24546. object: IPhysicsEnabledObject,
  24547. /**
  24548. * The type of the physics imposter
  24549. */
  24550. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24551. /**
  24552. * This function will completly initialize this impostor.
  24553. * It will create a new body - but only if this mesh has no parent.
  24554. * If it has, this impostor will not be used other than to define the impostor
  24555. * of the child mesh.
  24556. * @hidden
  24557. */
  24558. _init(): void;
  24559. private _getPhysicsParent;
  24560. /**
  24561. * Should a new body be generated.
  24562. * @returns boolean specifying if body initialization is required
  24563. */
  24564. isBodyInitRequired(): boolean;
  24565. /**
  24566. * Sets the updated scaling
  24567. * @param updated Specifies if the scaling is updated
  24568. */
  24569. setScalingUpdated(): void;
  24570. /**
  24571. * Force a regeneration of this or the parent's impostor's body.
  24572. * Use under cautious - This will remove all joints already implemented.
  24573. */
  24574. forceUpdate(): void;
  24575. /**
  24576. * Gets the body that holds this impostor. Either its own, or its parent.
  24577. */
  24578. get physicsBody(): any;
  24579. /**
  24580. * Get the parent of the physics imposter
  24581. * @returns Physics imposter or null
  24582. */
  24583. get parent(): Nullable<PhysicsImpostor>;
  24584. /**
  24585. * Sets the parent of the physics imposter
  24586. */
  24587. set parent(value: Nullable<PhysicsImpostor>);
  24588. /**
  24589. * Set the physics body. Used mainly by the physics engine/plugin
  24590. */
  24591. set physicsBody(physicsBody: any);
  24592. /**
  24593. * Resets the update flags
  24594. */
  24595. resetUpdateFlags(): void;
  24596. /**
  24597. * Gets the object extend size
  24598. * @returns the object extend size
  24599. */
  24600. getObjectExtendSize(): Vector3;
  24601. /**
  24602. * Gets the object center
  24603. * @returns The object center
  24604. */
  24605. getObjectCenter(): Vector3;
  24606. /**
  24607. * Get a specific parameter from the options parameters
  24608. * @param paramName The object parameter name
  24609. * @returns The object parameter
  24610. */
  24611. getParam(paramName: string): any;
  24612. /**
  24613. * Sets a specific parameter in the options given to the physics plugin
  24614. * @param paramName The parameter name
  24615. * @param value The value of the parameter
  24616. */
  24617. setParam(paramName: string, value: number): void;
  24618. /**
  24619. * Specifically change the body's mass option. Won't recreate the physics body object
  24620. * @param mass The mass of the physics imposter
  24621. */
  24622. setMass(mass: number): void;
  24623. /**
  24624. * Gets the linear velocity
  24625. * @returns linear velocity or null
  24626. */
  24627. getLinearVelocity(): Nullable<Vector3>;
  24628. /**
  24629. * Sets the linear velocity
  24630. * @param velocity linear velocity or null
  24631. */
  24632. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24633. /**
  24634. * Gets the angular velocity
  24635. * @returns angular velocity or null
  24636. */
  24637. getAngularVelocity(): Nullable<Vector3>;
  24638. /**
  24639. * Sets the angular velocity
  24640. * @param velocity The velocity or null
  24641. */
  24642. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24643. /**
  24644. * Execute a function with the physics plugin native code
  24645. * Provide a function the will have two variables - the world object and the physics body object
  24646. * @param func The function to execute with the physics plugin native code
  24647. */
  24648. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24649. /**
  24650. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Unregister a function that will be executed before the physics world is stepping forward
  24656. * @param func The function to execute before the physics world is stepped forward
  24657. */
  24658. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Register a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * Unregisters a function that will be executed after the physics step
  24666. * @param func The function to execute after physics step
  24667. */
  24668. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24669. /**
  24670. * register a function that will be executed when this impostor collides against a different body
  24671. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24672. * @param func Callback that is executed on collision
  24673. */
  24674. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24675. /**
  24676. * Unregisters the physics imposter on contact
  24677. * @param collideAgainst The physics object to collide against
  24678. * @param func Callback to execute on collision
  24679. */
  24680. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24681. private _tmpQuat;
  24682. private _tmpQuat2;
  24683. /**
  24684. * Get the parent rotation
  24685. * @returns The parent rotation
  24686. */
  24687. getParentsRotation(): Quaternion;
  24688. /**
  24689. * this function is executed by the physics engine.
  24690. */
  24691. beforeStep: () => void;
  24692. /**
  24693. * this function is executed by the physics engine
  24694. */
  24695. afterStep: () => void;
  24696. /**
  24697. * Legacy collision detection event support
  24698. */
  24699. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24700. /**
  24701. * event and body object due to cannon's event-based architecture.
  24702. */
  24703. onCollide: (e: {
  24704. body: any;
  24705. }) => void;
  24706. /**
  24707. * Apply a force
  24708. * @param force The force to apply
  24709. * @param contactPoint The contact point for the force
  24710. * @returns The physics imposter
  24711. */
  24712. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24713. /**
  24714. * Apply an impulse
  24715. * @param force The impulse force
  24716. * @param contactPoint The contact point for the impulse force
  24717. * @returns The physics imposter
  24718. */
  24719. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24720. /**
  24721. * A help function to create a joint
  24722. * @param otherImpostor A physics imposter used to create a joint
  24723. * @param jointType The type of joint
  24724. * @param jointData The data for the joint
  24725. * @returns The physics imposter
  24726. */
  24727. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24728. /**
  24729. * Add a joint to this impostor with a different impostor
  24730. * @param otherImpostor A physics imposter used to add a joint
  24731. * @param joint The joint to add
  24732. * @returns The physics imposter
  24733. */
  24734. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24735. /**
  24736. * Add an anchor to a cloth impostor
  24737. * @param otherImpostor rigid impostor to anchor to
  24738. * @param width ratio across width from 0 to 1
  24739. * @param height ratio up height from 0 to 1
  24740. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24741. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24742. * @returns impostor the soft imposter
  24743. */
  24744. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24745. /**
  24746. * Add a hook to a rope impostor
  24747. * @param otherImpostor rigid impostor to anchor to
  24748. * @param length ratio across rope from 0 to 1
  24749. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24750. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24751. * @returns impostor the rope imposter
  24752. */
  24753. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24754. /**
  24755. * Will keep this body still, in a sleep mode.
  24756. * @returns the physics imposter
  24757. */
  24758. sleep(): PhysicsImpostor;
  24759. /**
  24760. * Wake the body up.
  24761. * @returns The physics imposter
  24762. */
  24763. wakeUp(): PhysicsImpostor;
  24764. /**
  24765. * Clones the physics imposter
  24766. * @param newObject The physics imposter clones to this physics-enabled object
  24767. * @returns A nullable physics imposter
  24768. */
  24769. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24770. /**
  24771. * Disposes the physics imposter
  24772. */
  24773. dispose(): void;
  24774. /**
  24775. * Sets the delta position
  24776. * @param position The delta position amount
  24777. */
  24778. setDeltaPosition(position: Vector3): void;
  24779. /**
  24780. * Sets the delta rotation
  24781. * @param rotation The delta rotation amount
  24782. */
  24783. setDeltaRotation(rotation: Quaternion): void;
  24784. /**
  24785. * Gets the box size of the physics imposter and stores the result in the input parameter
  24786. * @param result Stores the box size
  24787. * @returns The physics imposter
  24788. */
  24789. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24790. /**
  24791. * Gets the radius of the physics imposter
  24792. * @returns Radius of the physics imposter
  24793. */
  24794. getRadius(): number;
  24795. /**
  24796. * Sync a bone with this impostor
  24797. * @param bone The bone to sync to the impostor.
  24798. * @param boneMesh The mesh that the bone is influencing.
  24799. * @param jointPivot The pivot of the joint / bone in local space.
  24800. * @param distToJoint Optional distance from the impostor to the joint.
  24801. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24802. */
  24803. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24804. /**
  24805. * Sync impostor to a bone
  24806. * @param bone The bone that the impostor will be synced to.
  24807. * @param boneMesh The mesh that the bone is influencing.
  24808. * @param jointPivot The pivot of the joint / bone in local space.
  24809. * @param distToJoint Optional distance from the impostor to the joint.
  24810. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24811. * @param boneAxis Optional vector3 axis the bone is aligned with
  24812. */
  24813. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24814. /**
  24815. * No-Imposter type
  24816. */
  24817. static NoImpostor: number;
  24818. /**
  24819. * Sphere-Imposter type
  24820. */
  24821. static SphereImpostor: number;
  24822. /**
  24823. * Box-Imposter type
  24824. */
  24825. static BoxImpostor: number;
  24826. /**
  24827. * Plane-Imposter type
  24828. */
  24829. static PlaneImpostor: number;
  24830. /**
  24831. * Mesh-imposter type
  24832. */
  24833. static MeshImpostor: number;
  24834. /**
  24835. * Capsule-Impostor type (Ammo.js plugin only)
  24836. */
  24837. static CapsuleImpostor: number;
  24838. /**
  24839. * Cylinder-Imposter type
  24840. */
  24841. static CylinderImpostor: number;
  24842. /**
  24843. * Particle-Imposter type
  24844. */
  24845. static ParticleImpostor: number;
  24846. /**
  24847. * Heightmap-Imposter type
  24848. */
  24849. static HeightmapImpostor: number;
  24850. /**
  24851. * ConvexHull-Impostor type (Ammo.js plugin only)
  24852. */
  24853. static ConvexHullImpostor: number;
  24854. /**
  24855. * Custom-Imposter type (Ammo.js plugin only)
  24856. */
  24857. static CustomImpostor: number;
  24858. /**
  24859. * Rope-Imposter type
  24860. */
  24861. static RopeImpostor: number;
  24862. /**
  24863. * Cloth-Imposter type
  24864. */
  24865. static ClothImpostor: number;
  24866. /**
  24867. * Softbody-Imposter type
  24868. */
  24869. static SoftbodyImpostor: number;
  24870. }
  24871. }
  24872. declare module "babylonjs/Meshes/mesh" {
  24873. import { Observable } from "babylonjs/Misc/observable";
  24874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24876. import { Camera } from "babylonjs/Cameras/camera";
  24877. import { Scene } from "babylonjs/scene";
  24878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24879. import { Color4 } from "babylonjs/Maths/math.color";
  24880. import { Engine } from "babylonjs/Engines/engine";
  24881. import { Node } from "babylonjs/node";
  24882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24883. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24884. import { Buffer } from "babylonjs/Meshes/buffer";
  24885. import { Geometry } from "babylonjs/Meshes/geometry";
  24886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24888. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24889. import { Effect } from "babylonjs/Materials/effect";
  24890. import { Material } from "babylonjs/Materials/material";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24893. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24894. import { Path3D } from "babylonjs/Maths/math.path";
  24895. import { Plane } from "babylonjs/Maths/math.plane";
  24896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24897. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24898. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24899. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24900. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24902. /**
  24903. * @hidden
  24904. **/
  24905. export class _CreationDataStorage {
  24906. closePath?: boolean;
  24907. closeArray?: boolean;
  24908. idx: number[];
  24909. dashSize: number;
  24910. gapSize: number;
  24911. path3D: Path3D;
  24912. pathArray: Vector3[][];
  24913. arc: number;
  24914. radius: number;
  24915. cap: number;
  24916. tessellation: number;
  24917. }
  24918. /**
  24919. * @hidden
  24920. **/
  24921. class _InstanceDataStorage {
  24922. visibleInstances: any;
  24923. batchCache: _InstancesBatch;
  24924. instancesBufferSize: number;
  24925. instancesBuffer: Nullable<Buffer>;
  24926. instancesData: Float32Array;
  24927. overridenInstanceCount: number;
  24928. isFrozen: boolean;
  24929. previousBatch: Nullable<_InstancesBatch>;
  24930. hardwareInstancedRendering: boolean;
  24931. sideOrientation: number;
  24932. manualUpdate: boolean;
  24933. }
  24934. /**
  24935. * @hidden
  24936. **/
  24937. export class _InstancesBatch {
  24938. mustReturn: boolean;
  24939. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24940. renderSelf: boolean[];
  24941. hardwareInstancedRendering: boolean[];
  24942. }
  24943. /**
  24944. * Class used to represent renderable models
  24945. */
  24946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24947. /**
  24948. * Mesh side orientation : usually the external or front surface
  24949. */
  24950. static readonly FRONTSIDE: number;
  24951. /**
  24952. * Mesh side orientation : usually the internal or back surface
  24953. */
  24954. static readonly BACKSIDE: number;
  24955. /**
  24956. * Mesh side orientation : both internal and external or front and back surfaces
  24957. */
  24958. static readonly DOUBLESIDE: number;
  24959. /**
  24960. * Mesh side orientation : by default, `FRONTSIDE`
  24961. */
  24962. static readonly DEFAULTSIDE: number;
  24963. /**
  24964. * Mesh cap setting : no cap
  24965. */
  24966. static readonly NO_CAP: number;
  24967. /**
  24968. * Mesh cap setting : one cap at the beginning of the mesh
  24969. */
  24970. static readonly CAP_START: number;
  24971. /**
  24972. * Mesh cap setting : one cap at the end of the mesh
  24973. */
  24974. static readonly CAP_END: number;
  24975. /**
  24976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24977. */
  24978. static readonly CAP_ALL: number;
  24979. /**
  24980. * Mesh pattern setting : no flip or rotate
  24981. */
  24982. static readonly NO_FLIP: number;
  24983. /**
  24984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24985. */
  24986. static readonly FLIP_TILE: number;
  24987. /**
  24988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24989. */
  24990. static readonly ROTATE_TILE: number;
  24991. /**
  24992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24993. */
  24994. static readonly FLIP_ROW: number;
  24995. /**
  24996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24997. */
  24998. static readonly ROTATE_ROW: number;
  24999. /**
  25000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25001. */
  25002. static readonly FLIP_N_ROTATE_TILE: number;
  25003. /**
  25004. * Mesh pattern setting : rotate pattern and rotate
  25005. */
  25006. static readonly FLIP_N_ROTATE_ROW: number;
  25007. /**
  25008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25009. */
  25010. static readonly CENTER: number;
  25011. /**
  25012. * Mesh tile positioning : part tiles on left
  25013. */
  25014. static readonly LEFT: number;
  25015. /**
  25016. * Mesh tile positioning : part tiles on right
  25017. */
  25018. static readonly RIGHT: number;
  25019. /**
  25020. * Mesh tile positioning : part tiles on top
  25021. */
  25022. static readonly TOP: number;
  25023. /**
  25024. * Mesh tile positioning : part tiles on bottom
  25025. */
  25026. static readonly BOTTOM: number;
  25027. /**
  25028. * Gets the default side orientation.
  25029. * @param orientation the orientation to value to attempt to get
  25030. * @returns the default orientation
  25031. * @hidden
  25032. */
  25033. static _GetDefaultSideOrientation(orientation?: number): number;
  25034. private _internalMeshDataInfo;
  25035. /**
  25036. * An event triggered before rendering the mesh
  25037. */
  25038. get onBeforeRenderObservable(): Observable<Mesh>;
  25039. /**
  25040. * An event triggered before binding the mesh
  25041. */
  25042. get onBeforeBindObservable(): Observable<Mesh>;
  25043. /**
  25044. * An event triggered after rendering the mesh
  25045. */
  25046. get onAfterRenderObservable(): Observable<Mesh>;
  25047. /**
  25048. * An event triggered before drawing the mesh
  25049. */
  25050. get onBeforeDrawObservable(): Observable<Mesh>;
  25051. private _onBeforeDrawObserver;
  25052. /**
  25053. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25054. */
  25055. set onBeforeDraw(callback: () => void);
  25056. get hasInstances(): boolean;
  25057. /**
  25058. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25059. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25060. */
  25061. delayLoadState: number;
  25062. /**
  25063. * Gets the list of instances created from this mesh
  25064. * it is not supposed to be modified manually.
  25065. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25067. */
  25068. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25069. /**
  25070. * Gets the file containing delay loading data for this mesh
  25071. */
  25072. delayLoadingFile: string;
  25073. /** @hidden */
  25074. _binaryInfo: any;
  25075. /**
  25076. * User defined function used to change how LOD level selection is done
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25078. */
  25079. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25080. /**
  25081. * Gets or sets the morph target manager
  25082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25083. */
  25084. get morphTargetManager(): Nullable<MorphTargetManager>;
  25085. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25086. /** @hidden */
  25087. _creationDataStorage: Nullable<_CreationDataStorage>;
  25088. /** @hidden */
  25089. _geometry: Nullable<Geometry>;
  25090. /** @hidden */
  25091. _delayInfo: Array<string>;
  25092. /** @hidden */
  25093. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25094. /** @hidden */
  25095. _instanceDataStorage: _InstanceDataStorage;
  25096. private _effectiveMaterial;
  25097. /** @hidden */
  25098. _shouldGenerateFlatShading: boolean;
  25099. /** @hidden */
  25100. _originalBuilderSideOrientation: number;
  25101. /**
  25102. * Use this property to change the original side orientation defined at construction time
  25103. */
  25104. overrideMaterialSideOrientation: Nullable<number>;
  25105. /**
  25106. * Gets the source mesh (the one used to clone this one from)
  25107. */
  25108. get source(): Nullable<Mesh>;
  25109. /**
  25110. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25111. */
  25112. get isUnIndexed(): boolean;
  25113. set isUnIndexed(value: boolean);
  25114. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25115. get worldMatrixInstancedBuffer(): Float32Array;
  25116. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25117. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25118. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25119. /**
  25120. * @constructor
  25121. * @param name The value used by scene.getMeshByName() to do a lookup.
  25122. * @param scene The scene to add this mesh to.
  25123. * @param parent The parent of this mesh, if it has one
  25124. * @param source An optional Mesh from which geometry is shared, cloned.
  25125. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25126. * When false, achieved by calling a clone(), also passing False.
  25127. * This will make creation of children, recursive.
  25128. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25129. */
  25130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25131. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25132. doNotInstantiate: boolean;
  25133. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25134. /**
  25135. * Gets the class name
  25136. * @returns the string "Mesh".
  25137. */
  25138. getClassName(): string;
  25139. /** @hidden */
  25140. get _isMesh(): boolean;
  25141. /**
  25142. * Returns a description of this mesh
  25143. * @param fullDetails define if full details about this mesh must be used
  25144. * @returns a descriptive string representing this mesh
  25145. */
  25146. toString(fullDetails?: boolean): string;
  25147. /** @hidden */
  25148. _unBindEffect(): void;
  25149. /**
  25150. * Gets a boolean indicating if this mesh has LOD
  25151. */
  25152. get hasLODLevels(): boolean;
  25153. /**
  25154. * Gets the list of MeshLODLevel associated with the current mesh
  25155. * @returns an array of MeshLODLevel
  25156. */
  25157. getLODLevels(): MeshLODLevel[];
  25158. private _sortLODLevels;
  25159. /**
  25160. * Add a mesh as LOD level triggered at the given distance.
  25161. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25162. * @param distance The distance from the center of the object to show this level
  25163. * @param mesh The mesh to be added as LOD level (can be null)
  25164. * @return This mesh (for chaining)
  25165. */
  25166. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25167. /**
  25168. * Returns the LOD level mesh at the passed distance or null if not found.
  25169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25170. * @param distance The distance from the center of the object to show this level
  25171. * @returns a Mesh or `null`
  25172. */
  25173. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25174. /**
  25175. * Remove a mesh from the LOD array
  25176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25177. * @param mesh defines the mesh to be removed
  25178. * @return This mesh (for chaining)
  25179. */
  25180. removeLODLevel(mesh: Mesh): Mesh;
  25181. /**
  25182. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25184. * @param camera defines the camera to use to compute distance
  25185. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25186. * @return This mesh (for chaining)
  25187. */
  25188. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25189. /**
  25190. * Gets the mesh internal Geometry object
  25191. */
  25192. get geometry(): Nullable<Geometry>;
  25193. /**
  25194. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25195. * @returns the total number of vertices
  25196. */
  25197. getTotalVertices(): number;
  25198. /**
  25199. * Returns the content of an associated vertex buffer
  25200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @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
  25214. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25215. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25216. */
  25217. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25218. /**
  25219. * Returns the mesh VertexBuffer object from the requested `kind`
  25220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25221. * - VertexBuffer.PositionKind
  25222. * - VertexBuffer.NormalKind
  25223. * - VertexBuffer.UVKind
  25224. * - VertexBuffer.UV2Kind
  25225. * - VertexBuffer.UV3Kind
  25226. * - VertexBuffer.UV4Kind
  25227. * - VertexBuffer.UV5Kind
  25228. * - VertexBuffer.UV6Kind
  25229. * - VertexBuffer.ColorKind
  25230. * - VertexBuffer.MatricesIndicesKind
  25231. * - VertexBuffer.MatricesIndicesExtraKind
  25232. * - VertexBuffer.MatricesWeightsKind
  25233. * - VertexBuffer.MatricesWeightsExtraKind
  25234. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25235. */
  25236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25237. /**
  25238. * Tests if a specific vertex buffer is associated with this mesh
  25239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25240. * - VertexBuffer.PositionKind
  25241. * - VertexBuffer.NormalKind
  25242. * - VertexBuffer.UVKind
  25243. * - VertexBuffer.UV2Kind
  25244. * - VertexBuffer.UV3Kind
  25245. * - VertexBuffer.UV4Kind
  25246. * - VertexBuffer.UV5Kind
  25247. * - VertexBuffer.UV6Kind
  25248. * - VertexBuffer.ColorKind
  25249. * - VertexBuffer.MatricesIndicesKind
  25250. * - VertexBuffer.MatricesIndicesExtraKind
  25251. * - VertexBuffer.MatricesWeightsKind
  25252. * - VertexBuffer.MatricesWeightsExtraKind
  25253. * @returns a boolean
  25254. */
  25255. isVerticesDataPresent(kind: string): boolean;
  25256. /**
  25257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25259. * - VertexBuffer.PositionKind
  25260. * - VertexBuffer.UVKind
  25261. * - VertexBuffer.UV2Kind
  25262. * - VertexBuffer.UV3Kind
  25263. * - VertexBuffer.UV4Kind
  25264. * - VertexBuffer.UV5Kind
  25265. * - VertexBuffer.UV6Kind
  25266. * - VertexBuffer.ColorKind
  25267. * - VertexBuffer.MatricesIndicesKind
  25268. * - VertexBuffer.MatricesIndicesExtraKind
  25269. * - VertexBuffer.MatricesWeightsKind
  25270. * - VertexBuffer.MatricesWeightsExtraKind
  25271. * @returns a boolean
  25272. */
  25273. isVertexBufferUpdatable(kind: string): boolean;
  25274. /**
  25275. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25277. * - VertexBuffer.PositionKind
  25278. * - VertexBuffer.NormalKind
  25279. * - VertexBuffer.UVKind
  25280. * - VertexBuffer.UV2Kind
  25281. * - VertexBuffer.UV3Kind
  25282. * - VertexBuffer.UV4Kind
  25283. * - VertexBuffer.UV5Kind
  25284. * - VertexBuffer.UV6Kind
  25285. * - VertexBuffer.ColorKind
  25286. * - VertexBuffer.MatricesIndicesKind
  25287. * - VertexBuffer.MatricesIndicesExtraKind
  25288. * - VertexBuffer.MatricesWeightsKind
  25289. * - VertexBuffer.MatricesWeightsExtraKind
  25290. * @returns an array of strings
  25291. */
  25292. getVerticesDataKinds(): string[];
  25293. /**
  25294. * Returns a positive integer : the total number of indices in this mesh geometry.
  25295. * @returns the numner of indices or zero if the mesh has no geometry.
  25296. */
  25297. getTotalIndices(): number;
  25298. /**
  25299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25300. * @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.
  25301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25302. * @returns the indices array or an empty array if the mesh has no geometry
  25303. */
  25304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25305. get isBlocked(): boolean;
  25306. /**
  25307. * Determine if the current mesh is ready to be rendered
  25308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25310. * @returns true if all associated assets are ready (material, textures, shaders)
  25311. */
  25312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25313. /**
  25314. * 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.
  25315. */
  25316. get areNormalsFrozen(): boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  25319. * @returns the current mesh
  25320. */
  25321. freezeNormals(): Mesh;
  25322. /**
  25323. * 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
  25324. * @returns the current mesh
  25325. */
  25326. unfreezeNormals(): Mesh;
  25327. /**
  25328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25329. */
  25330. set overridenInstanceCount(count: number);
  25331. /** @hidden */
  25332. _preActivate(): Mesh;
  25333. /** @hidden */
  25334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25335. /** @hidden */
  25336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25337. /**
  25338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25339. * This means the mesh underlying bounding box and sphere are recomputed.
  25340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25341. * @returns the current mesh
  25342. */
  25343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25344. /** @hidden */
  25345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25346. /**
  25347. * This function will subdivide the mesh into multiple submeshes
  25348. * @param count defines the expected number of submeshes
  25349. */
  25350. subdivide(count: number): void;
  25351. /**
  25352. * Copy a FloatArray into a specific associated vertex buffer
  25353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25354. * - VertexBuffer.PositionKind
  25355. * - VertexBuffer.UVKind
  25356. * - VertexBuffer.UV2Kind
  25357. * - VertexBuffer.UV3Kind
  25358. * - VertexBuffer.UV4Kind
  25359. * - VertexBuffer.UV5Kind
  25360. * - VertexBuffer.UV6Kind
  25361. * - VertexBuffer.ColorKind
  25362. * - VertexBuffer.MatricesIndicesKind
  25363. * - VertexBuffer.MatricesIndicesExtraKind
  25364. * - VertexBuffer.MatricesWeightsKind
  25365. * - VertexBuffer.MatricesWeightsExtraKind
  25366. * @param data defines the data source
  25367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25368. * @param stride defines the data stride size (can be null)
  25369. * @returns the current mesh
  25370. */
  25371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25372. /**
  25373. * Delete a vertex buffer associated with this mesh
  25374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25375. * - VertexBuffer.PositionKind
  25376. * - VertexBuffer.UVKind
  25377. * - VertexBuffer.UV2Kind
  25378. * - VertexBuffer.UV3Kind
  25379. * - VertexBuffer.UV4Kind
  25380. * - VertexBuffer.UV5Kind
  25381. * - VertexBuffer.UV6Kind
  25382. * - VertexBuffer.ColorKind
  25383. * - VertexBuffer.MatricesIndicesKind
  25384. * - VertexBuffer.MatricesIndicesExtraKind
  25385. * - VertexBuffer.MatricesWeightsKind
  25386. * - VertexBuffer.MatricesWeightsExtraKind
  25387. */
  25388. removeVerticesData(kind: string): void;
  25389. /**
  25390. * Flags an associated vertex buffer as updatable
  25391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25392. * - VertexBuffer.PositionKind
  25393. * - VertexBuffer.UVKind
  25394. * - VertexBuffer.UV2Kind
  25395. * - VertexBuffer.UV3Kind
  25396. * - VertexBuffer.UV4Kind
  25397. * - VertexBuffer.UV5Kind
  25398. * - VertexBuffer.UV6Kind
  25399. * - VertexBuffer.ColorKind
  25400. * - VertexBuffer.MatricesIndicesKind
  25401. * - VertexBuffer.MatricesIndicesExtraKind
  25402. * - VertexBuffer.MatricesWeightsKind
  25403. * - VertexBuffer.MatricesWeightsExtraKind
  25404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25405. */
  25406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25407. /**
  25408. * Sets the mesh global Vertex Buffer
  25409. * @param buffer defines the buffer to use
  25410. * @returns the current mesh
  25411. */
  25412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25413. /**
  25414. * Update a specific associated vertex buffer
  25415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25416. * - VertexBuffer.PositionKind
  25417. * - VertexBuffer.UVKind
  25418. * - VertexBuffer.UV2Kind
  25419. * - VertexBuffer.UV3Kind
  25420. * - VertexBuffer.UV4Kind
  25421. * - VertexBuffer.UV5Kind
  25422. * - VertexBuffer.UV6Kind
  25423. * - VertexBuffer.ColorKind
  25424. * - VertexBuffer.MatricesIndicesKind
  25425. * - VertexBuffer.MatricesIndicesExtraKind
  25426. * - VertexBuffer.MatricesWeightsKind
  25427. * - VertexBuffer.MatricesWeightsExtraKind
  25428. * @param data defines the data source
  25429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25430. * @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)
  25431. * @returns the current mesh
  25432. */
  25433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25434. /**
  25435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25439. * @returns the current mesh
  25440. */
  25441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25442. /**
  25443. * Creates a un-shared specific occurence of the geometry for the mesh.
  25444. * @returns the current mesh
  25445. */
  25446. makeGeometryUnique(): Mesh;
  25447. /**
  25448. * Set the index buffer of this mesh
  25449. * @param indices defines the source data
  25450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25452. * @returns the current mesh
  25453. */
  25454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25455. /**
  25456. * Update the current index buffer
  25457. * @param indices defines the source data
  25458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25459. * @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)
  25460. * @returns the current mesh
  25461. */
  25462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25463. /**
  25464. * Invert the geometry to move from a right handed system to a left handed one.
  25465. * @returns the current mesh
  25466. */
  25467. toLeftHanded(): Mesh;
  25468. /** @hidden */
  25469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25470. /** @hidden */
  25471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25472. /**
  25473. * Registers for this mesh a javascript function called just before the rendering process
  25474. * @param func defines the function to call before rendering this mesh
  25475. * @returns the current mesh
  25476. */
  25477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25478. /**
  25479. * Disposes a previously registered javascript function called before the rendering
  25480. * @param func defines the function to remove
  25481. * @returns the current mesh
  25482. */
  25483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25484. /**
  25485. * Registers for this mesh a javascript function called just after the rendering is complete
  25486. * @param func defines the function to call after rendering this mesh
  25487. * @returns the current mesh
  25488. */
  25489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25490. /**
  25491. * Disposes a previously registered javascript function called after the rendering.
  25492. * @param func defines the function to remove
  25493. * @returns the current mesh
  25494. */
  25495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25496. /** @hidden */
  25497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25498. /** @hidden */
  25499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25500. /** @hidden */
  25501. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25502. /** @hidden */
  25503. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25504. /** @hidden */
  25505. _rebuild(): void;
  25506. /** @hidden */
  25507. _freeze(): void;
  25508. /** @hidden */
  25509. _unFreeze(): void;
  25510. /**
  25511. * 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
  25512. * @param subMesh defines the subMesh to render
  25513. * @param enableAlphaMode defines if alpha mode can be changed
  25514. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25515. * @returns the current mesh
  25516. */
  25517. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25518. private _onBeforeDraw;
  25519. /**
  25520. * Renormalize the mesh and patch it up if there are no weights
  25521. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25522. * However in the case of zero weights then we set just a single influence to 1.
  25523. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25524. */
  25525. cleanMatrixWeights(): void;
  25526. private normalizeSkinFourWeights;
  25527. private normalizeSkinWeightsAndExtra;
  25528. /**
  25529. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25530. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25531. * the user know there was an issue with importing the mesh
  25532. * @returns a validation object with skinned, valid and report string
  25533. */
  25534. validateSkinning(): {
  25535. skinned: boolean;
  25536. valid: boolean;
  25537. report: string;
  25538. };
  25539. /** @hidden */
  25540. _checkDelayState(): Mesh;
  25541. private _queueLoad;
  25542. /**
  25543. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25544. * A mesh is in the frustum if its bounding box intersects the frustum
  25545. * @param frustumPlanes defines the frustum to test
  25546. * @returns true if the mesh is in the frustum planes
  25547. */
  25548. isInFrustum(frustumPlanes: Plane[]): boolean;
  25549. /**
  25550. * Sets the mesh material by the material or multiMaterial `id` property
  25551. * @param id is a string identifying the material or the multiMaterial
  25552. * @returns the current mesh
  25553. */
  25554. setMaterialByID(id: string): Mesh;
  25555. /**
  25556. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25557. * @returns an array of IAnimatable
  25558. */
  25559. getAnimatables(): IAnimatable[];
  25560. /**
  25561. * Modifies the mesh geometry according to the passed transformation matrix.
  25562. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25563. * The mesh normals are modified using the same transformation.
  25564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25565. * @param transform defines the transform matrix to use
  25566. * @see http://doc.babylonjs.com/resources/baking_transformations
  25567. * @returns the current mesh
  25568. */
  25569. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25570. /**
  25571. * Modifies the mesh geometry according to its own current World Matrix.
  25572. * The mesh World Matrix is then reset.
  25573. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25575. * @see http://doc.babylonjs.com/resources/baking_transformations
  25576. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25577. * @returns the current mesh
  25578. */
  25579. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25580. /** @hidden */
  25581. get _positions(): Nullable<Vector3[]>;
  25582. /** @hidden */
  25583. _resetPointsArrayCache(): Mesh;
  25584. /** @hidden */
  25585. _generatePointsArray(): boolean;
  25586. /**
  25587. * Returns a new Mesh object generated from the current mesh properties.
  25588. * This method must not get confused with createInstance()
  25589. * @param name is a string, the name given to the new mesh
  25590. * @param newParent can be any Node object (default `null`)
  25591. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25592. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25593. * @returns a new mesh
  25594. */
  25595. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25596. /**
  25597. * Releases resources associated with this mesh.
  25598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25600. */
  25601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25602. /** @hidden */
  25603. _disposeInstanceSpecificData(): void;
  25604. /**
  25605. * Modifies the mesh geometry according to a displacement map.
  25606. * 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.
  25607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25608. * @param url is a string, the URL from the image file is to be downloaded.
  25609. * @param minHeight is the lower limit of the displacement.
  25610. * @param maxHeight is the upper limit of the displacement.
  25611. * @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.
  25612. * @param uvOffset is an optional vector2 used to offset UV.
  25613. * @param uvScale is an optional vector2 used to scale UV.
  25614. * @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.
  25615. * @returns the Mesh.
  25616. */
  25617. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25618. /**
  25619. * Modifies the mesh geometry according to a displacementMap buffer.
  25620. * 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.
  25621. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25622. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25623. * @param heightMapWidth is the width of the buffer image.
  25624. * @param heightMapHeight is the height of the buffer image.
  25625. * @param minHeight is the lower limit of the displacement.
  25626. * @param maxHeight is the upper limit of the displacement.
  25627. * @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.
  25628. * @param uvOffset is an optional vector2 used to offset UV.
  25629. * @param uvScale is an optional vector2 used to scale UV.
  25630. * @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.
  25631. * @returns the Mesh.
  25632. */
  25633. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25634. /**
  25635. * Modify the mesh to get a flat shading rendering.
  25636. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25637. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25638. * @returns current mesh
  25639. */
  25640. convertToFlatShadedMesh(): Mesh;
  25641. /**
  25642. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25643. * In other words, more vertices, no more indices and a single bigger VBO.
  25644. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25645. * @returns current mesh
  25646. */
  25647. convertToUnIndexedMesh(): Mesh;
  25648. /**
  25649. * Inverses facet orientations.
  25650. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25651. * @param flipNormals will also inverts the normals
  25652. * @returns current mesh
  25653. */
  25654. flipFaces(flipNormals?: boolean): Mesh;
  25655. /**
  25656. * Increase the number of facets and hence vertices in a mesh
  25657. * Vertex normals are interpolated from existing vertex normals
  25658. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25659. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25660. */
  25661. increaseVertices(numberPerEdge: number): void;
  25662. /**
  25663. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25664. * This will undo any application of covertToFlatShadedMesh
  25665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25666. */
  25667. forceSharedVertices(): void;
  25668. /** @hidden */
  25669. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25670. /** @hidden */
  25671. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25672. /**
  25673. * Creates a new InstancedMesh object from the mesh model.
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25675. * @param name defines the name of the new instance
  25676. * @returns a new InstancedMesh
  25677. */
  25678. createInstance(name: string): InstancedMesh;
  25679. /**
  25680. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25681. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25682. * @returns the current mesh
  25683. */
  25684. synchronizeInstances(): Mesh;
  25685. /**
  25686. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25687. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25688. * This should be used together with the simplification to avoid disappearing triangles.
  25689. * @param successCallback an optional success callback to be called after the optimization finished.
  25690. * @returns the current mesh
  25691. */
  25692. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25693. /**
  25694. * Serialize current mesh
  25695. * @param serializationObject defines the object which will receive the serialization data
  25696. */
  25697. serialize(serializationObject: any): void;
  25698. /** @hidden */
  25699. _syncGeometryWithMorphTargetManager(): void;
  25700. /** @hidden */
  25701. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25702. /**
  25703. * Returns a new Mesh object parsed from the source provided.
  25704. * @param parsedMesh is the source
  25705. * @param scene defines the hosting scene
  25706. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25707. * @returns a new Mesh
  25708. */
  25709. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25710. /**
  25711. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25713. * @param name defines the name of the mesh to create
  25714. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25715. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25716. * @param closePath creates a seam between the first and the last points of each path of the path array
  25717. * @param offset is taken in account only if the `pathArray` is containing a single path
  25718. * @param scene defines the hosting scene
  25719. * @param updatable defines if the mesh must be flagged as updatable
  25720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25721. * @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)
  25722. * @returns a new Mesh
  25723. */
  25724. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25725. /**
  25726. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25727. * @param name defines the name of the mesh to create
  25728. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25729. * @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
  25730. * @param scene defines the hosting scene
  25731. * @param updatable defines if the mesh must be flagged as updatable
  25732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25736. /**
  25737. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25738. * @param name defines the name of the mesh to create
  25739. * @param size sets the size (float) of each box side (default 1)
  25740. * @param scene defines the hosting scene
  25741. * @param updatable defines if the mesh must be flagged as updatable
  25742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25743. * @returns a new Mesh
  25744. */
  25745. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25746. /**
  25747. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25748. * @param name defines the name of the mesh to create
  25749. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25750. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25757. /**
  25758. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25759. * @param name defines the name of the mesh to create
  25760. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25761. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25762. * @param scene defines the hosting scene
  25763. * @returns a new Mesh
  25764. */
  25765. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25766. /**
  25767. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25768. * @param name defines the name of the mesh to create
  25769. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25770. * @param diameterTop set the top cap diameter (floats, default 1)
  25771. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25772. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25773. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25774. * @param scene defines the hosting scene
  25775. * @param updatable defines if the mesh must be flagged as updatable
  25776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25777. * @returns a new Mesh
  25778. */
  25779. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25780. /**
  25781. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25782. * @param name defines the name of the mesh to create
  25783. * @param diameter sets the diameter size (float) of the torus (default 1)
  25784. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25785. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25786. * @param scene defines the hosting scene
  25787. * @param updatable defines if the mesh must be flagged as updatable
  25788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25789. * @returns a new Mesh
  25790. */
  25791. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25792. /**
  25793. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25794. * @param name defines the name of the mesh to create
  25795. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25796. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25797. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25798. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25799. * @param p the number of windings on X axis (positive integers, default 2)
  25800. * @param q the number of windings on Y axis (positive integers, default 3)
  25801. * @param scene defines the hosting scene
  25802. * @param updatable defines if the mesh must be flagged as updatable
  25803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25804. * @returns a new Mesh
  25805. */
  25806. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25807. /**
  25808. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25809. * @param name defines the name of the mesh to create
  25810. * @param points is an array successive Vector3
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @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).
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25817. /**
  25818. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param points is an array successive Vector3
  25821. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25822. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25823. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25824. * @param scene defines the hosting scene
  25825. * @param updatable defines if the mesh must be flagged as updatable
  25826. * @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)
  25827. * @returns a new Mesh
  25828. */
  25829. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25830. /**
  25831. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25832. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25833. * 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.
  25834. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25835. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25836. * Remember you can only change the shape positions, not their number when updating a polygon.
  25837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25838. * @param name defines the name of the mesh to create
  25839. * @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
  25840. * @param scene defines the hosting scene
  25841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @param earcutInjection can be used to inject your own earcut reference
  25845. * @returns a new Mesh
  25846. */
  25847. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25848. /**
  25849. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25850. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25851. * @param name defines the name of the mesh to create
  25852. * @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
  25853. * @param depth defines the height of extrusion
  25854. * @param scene defines the hosting scene
  25855. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25856. * @param updatable defines if the mesh must be flagged as updatable
  25857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25858. * @param earcutInjection can be used to inject your own earcut reference
  25859. * @returns a new Mesh
  25860. */
  25861. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25862. /**
  25863. * Creates an extruded shape mesh.
  25864. * 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
  25865. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25866. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25867. * @param name defines the name of the mesh to create
  25868. * @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
  25869. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25870. * @param scale is the value to scale the shape
  25871. * @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
  25872. * @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
  25873. * @param scene defines the hosting scene
  25874. * @param updatable defines if the mesh must be flagged as updatable
  25875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25876. * @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)
  25877. * @returns a new Mesh
  25878. */
  25879. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25880. /**
  25881. * Creates an custom extruded shape mesh.
  25882. * The custom extrusion is a parametric shape.
  25883. * It has no predefined shape. Its final shape will depend on the input parameters.
  25884. * Please consider using the same method from the MeshBuilder class instead
  25885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25886. * @param name defines the name of the mesh to create
  25887. * @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
  25888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25889. * @param scaleFunction is a custom Javascript function called on each path point
  25890. * @param rotationFunction is a custom Javascript function called on each path point
  25891. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25892. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25893. * @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
  25894. * @param scene defines the hosting scene
  25895. * @param updatable defines if the mesh must be flagged as updatable
  25896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25897. * @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)
  25898. * @returns a new Mesh
  25899. */
  25900. 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;
  25901. /**
  25902. * Creates lathe mesh.
  25903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25904. * Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @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
  25907. * @param radius is the radius value of the lathe
  25908. * @param tessellation is the side number of the lathe.
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @returns a new Mesh
  25923. */
  25924. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25925. /**
  25926. * Creates a ground mesh.
  25927. * Please consider using the same method from the MeshBuilder class instead
  25928. * @param name defines the name of the mesh to create
  25929. * @param width set the width of the ground
  25930. * @param height set the height of the ground
  25931. * @param subdivisions sets the number of subdivisions per side
  25932. * @param scene defines the hosting scene
  25933. * @param updatable defines if the mesh must be flagged as updatable
  25934. * @returns a new Mesh
  25935. */
  25936. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25937. /**
  25938. * Creates a tiled ground mesh.
  25939. * Please consider using the same method from the MeshBuilder class instead
  25940. * @param name defines the name of the mesh to create
  25941. * @param xmin set the ground minimum X coordinate
  25942. * @param zmin set the ground minimum Y coordinate
  25943. * @param xmax set the ground maximum X coordinate
  25944. * @param zmax set the ground maximum Z coordinate
  25945. * @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
  25946. * @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
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @returns a new Mesh
  25950. */
  25951. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25952. w: number;
  25953. h: number;
  25954. }, precision: {
  25955. w: number;
  25956. h: number;
  25957. }, scene: Scene, updatable?: boolean): Mesh;
  25958. /**
  25959. * Creates a ground mesh from a height map.
  25960. * Please consider using the same method from the MeshBuilder class instead
  25961. * @see http://doc.babylonjs.com/babylon101/height_map
  25962. * @param name defines the name of the mesh to create
  25963. * @param url sets the URL of the height map image resource
  25964. * @param width set the ground width size
  25965. * @param height set the ground height size
  25966. * @param subdivisions sets the number of subdivision per side
  25967. * @param minHeight is the minimum altitude on the ground
  25968. * @param maxHeight is the maximum altitude on the ground
  25969. * @param scene defines the hosting scene
  25970. * @param updatable defines if the mesh must be flagged as updatable
  25971. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25972. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25973. * @returns a new Mesh
  25974. */
  25975. 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;
  25976. /**
  25977. * Creates a tube mesh.
  25978. * The tube is a parametric shape.
  25979. * It has no predefined shape. Its final shape will depend on the input parameters.
  25980. * Please consider using the same method from the MeshBuilder class instead
  25981. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25982. * @param name defines the name of the mesh to create
  25983. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25984. * @param radius sets the tube radius size
  25985. * @param tessellation is the number of sides on the tubular surface
  25986. * @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
  25987. * @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
  25988. * @param scene defines the hosting scene
  25989. * @param updatable defines if the mesh must be flagged as updatable
  25990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25991. * @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)
  25992. * @returns a new Mesh
  25993. */
  25994. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25995. (i: number, distance: number): number;
  25996. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25997. /**
  25998. * Creates a polyhedron mesh.
  25999. * Please consider using the same method from the MeshBuilder class instead.
  26000. * * 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
  26001. * * The parameter `size` (positive float, default 1) sets the polygon size
  26002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26003. * * 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`
  26004. * * 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
  26005. * * 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)`)
  26006. * * 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
  26007. * * 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
  26008. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26009. * * If you create a double-sided mesh, you can choose what parts of 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
  26010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26011. * @param name defines the name of the mesh to create
  26012. * @param options defines the options used to create the mesh
  26013. * @param scene defines the hosting scene
  26014. * @returns a new Mesh
  26015. */
  26016. static CreatePolyhedron(name: string, options: {
  26017. type?: number;
  26018. size?: number;
  26019. sizeX?: number;
  26020. sizeY?: number;
  26021. sizeZ?: number;
  26022. custom?: any;
  26023. faceUV?: Vector4[];
  26024. faceColors?: Color4[];
  26025. updatable?: boolean;
  26026. sideOrientation?: number;
  26027. }, scene: Scene): Mesh;
  26028. /**
  26029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26031. * * 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`)
  26032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26033. * * 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
  26034. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26035. * * If you create a double-sided mesh, you can choose what parts of 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
  26036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26037. * @param name defines the name of the mesh
  26038. * @param options defines the options used to create the mesh
  26039. * @param scene defines the hosting scene
  26040. * @returns a new Mesh
  26041. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26042. */
  26043. static CreateIcoSphere(name: string, options: {
  26044. radius?: number;
  26045. flat?: boolean;
  26046. subdivisions?: number;
  26047. sideOrientation?: number;
  26048. updatable?: boolean;
  26049. }, scene: Scene): Mesh;
  26050. /**
  26051. * Creates a decal mesh.
  26052. * Please consider using the same method from the MeshBuilder class instead.
  26053. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26054. * @param name defines the name of the mesh
  26055. * @param sourceMesh defines the mesh receiving the decal
  26056. * @param position sets the position of the decal in world coordinates
  26057. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26058. * @param size sets the decal scaling
  26059. * @param angle sets the angle to rotate the decal
  26060. * @returns a new Mesh
  26061. */
  26062. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26063. /**
  26064. * Prepare internal position array for software CPU skinning
  26065. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26066. */
  26067. setPositionsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Prepare internal normal array for software CPU skinning
  26070. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26071. */
  26072. setNormalsForCPUSkinning(): Float32Array;
  26073. /**
  26074. * Updates the vertex buffer by applying transformation from the bones
  26075. * @param skeleton defines the skeleton to apply to current mesh
  26076. * @returns the current mesh
  26077. */
  26078. applySkeleton(skeleton: Skeleton): Mesh;
  26079. /**
  26080. * 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
  26081. * @param meshes defines the list of meshes to scan
  26082. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26083. */
  26084. static MinMax(meshes: AbstractMesh[]): {
  26085. min: Vector3;
  26086. max: Vector3;
  26087. };
  26088. /**
  26089. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26090. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26091. * @returns a vector3
  26092. */
  26093. static Center(meshesOrMinMaxVector: {
  26094. min: Vector3;
  26095. max: Vector3;
  26096. } | AbstractMesh[]): Vector3;
  26097. /**
  26098. * Merge the array of meshes into a single mesh for performance reasons.
  26099. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26100. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26101. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26102. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26103. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26104. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26105. * @returns a new mesh
  26106. */
  26107. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26108. /** @hidden */
  26109. addInstance(instance: InstancedMesh): void;
  26110. /** @hidden */
  26111. removeInstance(instance: InstancedMesh): void;
  26112. }
  26113. }
  26114. declare module "babylonjs/Cameras/camera" {
  26115. import { SmartArray } from "babylonjs/Misc/smartArray";
  26116. import { Observable } from "babylonjs/Misc/observable";
  26117. import { Nullable } from "babylonjs/types";
  26118. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26119. import { Scene } from "babylonjs/scene";
  26120. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26121. import { Node } from "babylonjs/node";
  26122. import { Mesh } from "babylonjs/Meshes/mesh";
  26123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26124. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26125. import { Viewport } from "babylonjs/Maths/math.viewport";
  26126. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26129. import { Ray } from "babylonjs/Culling/ray";
  26130. /**
  26131. * This is the base class of all the camera used in the application.
  26132. * @see http://doc.babylonjs.com/features/cameras
  26133. */
  26134. export class Camera extends Node {
  26135. /** @hidden */
  26136. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26137. /**
  26138. * This is the default projection mode used by the cameras.
  26139. * It helps recreating a feeling of perspective and better appreciate depth.
  26140. * This is the best way to simulate real life cameras.
  26141. */
  26142. static readonly PERSPECTIVE_CAMERA: number;
  26143. /**
  26144. * This helps creating camera with an orthographic mode.
  26145. * 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.
  26146. */
  26147. static readonly ORTHOGRAPHIC_CAMERA: number;
  26148. /**
  26149. * This is the default FOV mode for perspective cameras.
  26150. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26151. */
  26152. static readonly FOVMODE_VERTICAL_FIXED: number;
  26153. /**
  26154. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26155. */
  26156. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26157. /**
  26158. * This specifies ther is no need for a camera rig.
  26159. * Basically only one eye is rendered corresponding to the camera.
  26160. */
  26161. static readonly RIG_MODE_NONE: number;
  26162. /**
  26163. * Simulates a camera Rig with one blue eye and one red eye.
  26164. * This can be use with 3d blue and red glasses.
  26165. */
  26166. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26167. /**
  26168. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26169. */
  26170. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26171. /**
  26172. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26173. */
  26174. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26175. /**
  26176. * Defines that both eyes of the camera will be rendered over under each other.
  26177. */
  26178. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26179. /**
  26180. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26181. */
  26182. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26183. /**
  26184. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26185. */
  26186. static readonly RIG_MODE_VR: number;
  26187. /**
  26188. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26189. */
  26190. static readonly RIG_MODE_WEBVR: number;
  26191. /**
  26192. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26193. */
  26194. static readonly RIG_MODE_CUSTOM: number;
  26195. /**
  26196. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26197. */
  26198. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26199. /**
  26200. * Define the input manager associated with the camera.
  26201. */
  26202. inputs: CameraInputsManager<Camera>;
  26203. /** @hidden */
  26204. _position: Vector3;
  26205. /**
  26206. * Define the current local position of the camera in the scene
  26207. */
  26208. get position(): Vector3;
  26209. set position(newPosition: Vector3);
  26210. /**
  26211. * The vector the camera should consider as up.
  26212. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26213. */
  26214. upVector: Vector3;
  26215. /**
  26216. * Define the current limit on the left side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoLeft: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the right side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoRight: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the bottom side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoBottom: Nullable<number>;
  26230. /**
  26231. * Define the current limit on the top side for an orthographic camera
  26232. * In scene unit
  26233. */
  26234. orthoTop: Nullable<number>;
  26235. /**
  26236. * Field Of View is set in Radians. (default is 0.8)
  26237. */
  26238. fov: number;
  26239. /**
  26240. * Define the minimum distance the camera can see from.
  26241. * This is important to note that the depth buffer are not infinite and the closer it starts
  26242. * the more your scene might encounter depth fighting issue.
  26243. */
  26244. minZ: number;
  26245. /**
  26246. * Define the maximum distance the camera can see to.
  26247. * This is important to note that the depth buffer are not infinite and the further it end
  26248. * the more your scene might encounter depth fighting issue.
  26249. */
  26250. maxZ: number;
  26251. /**
  26252. * Define the default inertia of the camera.
  26253. * This helps giving a smooth feeling to the camera movement.
  26254. */
  26255. inertia: number;
  26256. /**
  26257. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26258. */
  26259. mode: number;
  26260. /**
  26261. * Define whether the camera is intermediate.
  26262. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26263. */
  26264. isIntermediate: boolean;
  26265. /**
  26266. * Define the viewport of the camera.
  26267. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26268. */
  26269. viewport: Viewport;
  26270. /**
  26271. * Restricts the camera to viewing objects with the same layerMask.
  26272. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26273. */
  26274. layerMask: number;
  26275. /**
  26276. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26277. */
  26278. fovMode: number;
  26279. /**
  26280. * Rig mode of the camera.
  26281. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26282. * This is normally controlled byt the camera themselves as internal use.
  26283. */
  26284. cameraRigMode: number;
  26285. /**
  26286. * Defines the distance between both "eyes" in case of a RIG
  26287. */
  26288. interaxialDistance: number;
  26289. /**
  26290. * Defines if stereoscopic rendering is done side by side or over under.
  26291. */
  26292. isStereoscopicSideBySide: boolean;
  26293. /**
  26294. * 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
  26295. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26296. * else in the scene. (Eg. security camera)
  26297. *
  26298. * 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)
  26299. */
  26300. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26301. /**
  26302. * When set, the camera will render to this render target instead of the default canvas
  26303. *
  26304. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26305. */
  26306. outputRenderTarget: Nullable<RenderTargetTexture>;
  26307. /**
  26308. * Observable triggered when the camera view matrix has changed.
  26309. */
  26310. onViewMatrixChangedObservable: Observable<Camera>;
  26311. /**
  26312. * Observable triggered when the camera Projection matrix has changed.
  26313. */
  26314. onProjectionMatrixChangedObservable: Observable<Camera>;
  26315. /**
  26316. * Observable triggered when the inputs have been processed.
  26317. */
  26318. onAfterCheckInputsObservable: Observable<Camera>;
  26319. /**
  26320. * Observable triggered when reset has been called and applied to the camera.
  26321. */
  26322. onRestoreStateObservable: Observable<Camera>;
  26323. /**
  26324. * Is this camera a part of a rig system?
  26325. */
  26326. isRigCamera: boolean;
  26327. /**
  26328. * If isRigCamera set to true this will be set with the parent camera.
  26329. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26330. */
  26331. rigParent?: Camera;
  26332. /** @hidden */
  26333. _cameraRigParams: any;
  26334. /** @hidden */
  26335. _rigCameras: Camera[];
  26336. /** @hidden */
  26337. _rigPostProcess: Nullable<PostProcess>;
  26338. protected _webvrViewMatrix: Matrix;
  26339. /** @hidden */
  26340. _skipRendering: boolean;
  26341. /** @hidden */
  26342. _projectionMatrix: Matrix;
  26343. /** @hidden */
  26344. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26345. /** @hidden */
  26346. _activeMeshes: SmartArray<AbstractMesh>;
  26347. protected _globalPosition: Vector3;
  26348. /** @hidden */
  26349. _computedViewMatrix: Matrix;
  26350. private _doNotComputeProjectionMatrix;
  26351. private _transformMatrix;
  26352. private _frustumPlanes;
  26353. private _refreshFrustumPlanes;
  26354. private _storedFov;
  26355. private _stateStored;
  26356. /**
  26357. * Instantiates a new camera object.
  26358. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26359. * @see http://doc.babylonjs.com/features/cameras
  26360. * @param name Defines the name of the camera in the scene
  26361. * @param position Defines the position of the camera
  26362. * @param scene Defines the scene the camera belongs too
  26363. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26364. */
  26365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26366. /**
  26367. * Store current camera state (fov, position, etc..)
  26368. * @returns the camera
  26369. */
  26370. storeState(): Camera;
  26371. /**
  26372. * Restores the camera state values if it has been stored. You must call storeState() first
  26373. */
  26374. protected _restoreStateValues(): boolean;
  26375. /**
  26376. * Restored camera state. You must call storeState() first.
  26377. * @returns true if restored and false otherwise
  26378. */
  26379. restoreState(): boolean;
  26380. /**
  26381. * Gets the class name of the camera.
  26382. * @returns the class name
  26383. */
  26384. getClassName(): string;
  26385. /** @hidden */
  26386. readonly _isCamera: boolean;
  26387. /**
  26388. * Gets a string representation of the camera useful for debug purpose.
  26389. * @param fullDetails Defines that a more verboe level of logging is required
  26390. * @returns the string representation
  26391. */
  26392. toString(fullDetails?: boolean): string;
  26393. /**
  26394. * Gets the current world space position of the camera.
  26395. */
  26396. get globalPosition(): Vector3;
  26397. /**
  26398. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26399. * @returns the active meshe list
  26400. */
  26401. getActiveMeshes(): SmartArray<AbstractMesh>;
  26402. /**
  26403. * Check whether a mesh is part of the current active mesh list of the camera
  26404. * @param mesh Defines the mesh to check
  26405. * @returns true if active, false otherwise
  26406. */
  26407. isActiveMesh(mesh: Mesh): boolean;
  26408. /**
  26409. * Is this camera ready to be used/rendered
  26410. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26411. * @return true if the camera is ready
  26412. */
  26413. isReady(completeCheck?: boolean): boolean;
  26414. /** @hidden */
  26415. _initCache(): void;
  26416. /** @hidden */
  26417. _updateCache(ignoreParentClass?: boolean): void;
  26418. /** @hidden */
  26419. _isSynchronized(): boolean;
  26420. /** @hidden */
  26421. _isSynchronizedViewMatrix(): boolean;
  26422. /** @hidden */
  26423. _isSynchronizedProjectionMatrix(): boolean;
  26424. /**
  26425. * Attach the input controls to a specific dom element to get the input from.
  26426. * @param element Defines the element the controls should be listened from
  26427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26428. */
  26429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26430. /**
  26431. * Detach the current controls from the specified dom element.
  26432. * @param element Defines the element to stop listening the inputs from
  26433. */
  26434. detachControl(element: HTMLElement): void;
  26435. /**
  26436. * Update the camera state according to the different inputs gathered during the frame.
  26437. */
  26438. update(): void;
  26439. /** @hidden */
  26440. _checkInputs(): void;
  26441. /** @hidden */
  26442. get rigCameras(): Camera[];
  26443. /**
  26444. * Gets the post process used by the rig cameras
  26445. */
  26446. get rigPostProcess(): Nullable<PostProcess>;
  26447. /**
  26448. * Internal, gets the first post proces.
  26449. * @returns the first post process to be run on this camera.
  26450. */
  26451. _getFirstPostProcess(): Nullable<PostProcess>;
  26452. private _cascadePostProcessesToRigCams;
  26453. /**
  26454. * Attach a post process to the camera.
  26455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26456. * @param postProcess The post process to attach to the camera
  26457. * @param insertAt The position of the post process in case several of them are in use in the scene
  26458. * @returns the position the post process has been inserted at
  26459. */
  26460. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26461. /**
  26462. * Detach a post process to the camera.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26464. * @param postProcess The post process to detach from the camera
  26465. */
  26466. detachPostProcess(postProcess: PostProcess): void;
  26467. /**
  26468. * Gets the current world matrix of the camera
  26469. */
  26470. getWorldMatrix(): Matrix;
  26471. /** @hidden */
  26472. _getViewMatrix(): Matrix;
  26473. /**
  26474. * Gets the current view matrix of the camera.
  26475. * @param force forces the camera to recompute the matrix without looking at the cached state
  26476. * @returns the view matrix
  26477. */
  26478. getViewMatrix(force?: boolean): Matrix;
  26479. /**
  26480. * Freeze the projection matrix.
  26481. * It will prevent the cache check of the camera projection compute and can speed up perf
  26482. * if no parameter of the camera are meant to change
  26483. * @param projection Defines manually a projection if necessary
  26484. */
  26485. freezeProjectionMatrix(projection?: Matrix): void;
  26486. /**
  26487. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26488. */
  26489. unfreezeProjectionMatrix(): void;
  26490. /**
  26491. * Gets the current projection matrix of the camera.
  26492. * @param force forces the camera to recompute the matrix without looking at the cached state
  26493. * @returns the projection matrix
  26494. */
  26495. getProjectionMatrix(force?: boolean): Matrix;
  26496. /**
  26497. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26498. * @returns a Matrix
  26499. */
  26500. getTransformationMatrix(): Matrix;
  26501. private _updateFrustumPlanes;
  26502. /**
  26503. * Checks if a cullable object (mesh...) is in the camera frustum
  26504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26505. * @param target The object to check
  26506. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26507. * @returns true if the object is in frustum otherwise false
  26508. */
  26509. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26510. /**
  26511. * Checks if a cullable object (mesh...) is in the camera frustum
  26512. * Unlike isInFrustum this cheks the full bounding box
  26513. * @param target The object to check
  26514. * @returns true if the object is in frustum otherwise false
  26515. */
  26516. isCompletelyInFrustum(target: ICullable): boolean;
  26517. /**
  26518. * Gets a ray in the forward direction from the camera.
  26519. * @param length Defines the length of the ray to create
  26520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26521. * @param origin Defines the start point of the ray which defaults to the camera position
  26522. * @returns the forward ray
  26523. */
  26524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26525. /**
  26526. * Releases resources associated with this node.
  26527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26529. */
  26530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26531. /** @hidden */
  26532. _isLeftCamera: boolean;
  26533. /**
  26534. * Gets the left camera of a rig setup in case of Rigged Camera
  26535. */
  26536. get isLeftCamera(): boolean;
  26537. /** @hidden */
  26538. _isRightCamera: boolean;
  26539. /**
  26540. * Gets the right camera of a rig setup in case of Rigged Camera
  26541. */
  26542. get isRightCamera(): boolean;
  26543. /**
  26544. * Gets the left camera of a rig setup in case of Rigged Camera
  26545. */
  26546. get leftCamera(): Nullable<FreeCamera>;
  26547. /**
  26548. * Gets the right camera of a rig setup in case of Rigged Camera
  26549. */
  26550. get rightCamera(): Nullable<FreeCamera>;
  26551. /**
  26552. * Gets the left camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getLeftTarget(): Nullable<Vector3>;
  26556. /**
  26557. * Gets the right camera target of a rig setup in case of Rigged Camera
  26558. * @returns the target position
  26559. */
  26560. getRightTarget(): Nullable<Vector3>;
  26561. /**
  26562. * @hidden
  26563. */
  26564. setCameraRigMode(mode: number, rigParams: any): void;
  26565. /** @hidden */
  26566. static _setStereoscopicRigMode(camera: Camera): void;
  26567. /** @hidden */
  26568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26569. /** @hidden */
  26570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26571. /** @hidden */
  26572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26573. /** @hidden */
  26574. _getVRProjectionMatrix(): Matrix;
  26575. protected _updateCameraRotationMatrix(): void;
  26576. protected _updateWebVRCameraRotationMatrix(): void;
  26577. /**
  26578. * This function MUST be overwritten by the different WebVR cameras available.
  26579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26580. * @hidden
  26581. */
  26582. _getWebVRProjectionMatrix(): Matrix;
  26583. /**
  26584. * This function MUST be overwritten by the different WebVR cameras available.
  26585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26586. * @hidden
  26587. */
  26588. _getWebVRViewMatrix(): Matrix;
  26589. /** @hidden */
  26590. setCameraRigParameter(name: string, value: any): void;
  26591. /**
  26592. * needs to be overridden by children so sub has required properties to be copied
  26593. * @hidden
  26594. */
  26595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26596. /**
  26597. * May need to be overridden by children
  26598. * @hidden
  26599. */
  26600. _updateRigCameras(): void;
  26601. /** @hidden */
  26602. _setupInputs(): void;
  26603. /**
  26604. * Serialiaze the camera setup to a json represention
  26605. * @returns the JSON representation
  26606. */
  26607. serialize(): any;
  26608. /**
  26609. * Clones the current camera.
  26610. * @param name The cloned camera name
  26611. * @returns the cloned camera
  26612. */
  26613. clone(name: string): Camera;
  26614. /**
  26615. * Gets the direction of the camera relative to a given local axis.
  26616. * @param localAxis Defines the reference axis to provide a relative direction.
  26617. * @return the direction
  26618. */
  26619. getDirection(localAxis: Vector3): Vector3;
  26620. /**
  26621. * Returns the current camera absolute rotation
  26622. */
  26623. get absoluteRotation(): Quaternion;
  26624. /**
  26625. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26626. * @param localAxis Defines the reference axis to provide a relative direction.
  26627. * @param result Defines the vector to store the result in
  26628. */
  26629. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26630. /**
  26631. * Gets a camera constructor for a given camera type
  26632. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26633. * @param name The name of the camera the result will be able to instantiate
  26634. * @param scene The scene the result will construct the camera in
  26635. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26636. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26637. * @returns a factory method to construc the camera
  26638. */
  26639. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26640. /**
  26641. * Compute the world matrix of the camera.
  26642. * @returns the camera world matrix
  26643. */
  26644. computeWorldMatrix(): Matrix;
  26645. /**
  26646. * Parse a JSON and creates the camera from the parsed information
  26647. * @param parsedCamera The JSON to parse
  26648. * @param scene The scene to instantiate the camera in
  26649. * @returns the newly constructed camera
  26650. */
  26651. static Parse(parsedCamera: any, scene: Scene): Camera;
  26652. }
  26653. }
  26654. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26655. import { Nullable } from "babylonjs/types";
  26656. import { Scene } from "babylonjs/scene";
  26657. import { Vector4 } from "babylonjs/Maths/math.vector";
  26658. import { Mesh } from "babylonjs/Meshes/mesh";
  26659. /**
  26660. * Class containing static functions to help procedurally build meshes
  26661. */
  26662. export class DiscBuilder {
  26663. /**
  26664. * Creates a plane polygonal mesh. By default, this is a disc
  26665. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26666. * * 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
  26667. * * 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
  26668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26671. * @param name defines the name of the mesh
  26672. * @param options defines the options used to create the mesh
  26673. * @param scene defines the hosting scene
  26674. * @returns the plane polygonal mesh
  26675. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26676. */
  26677. static CreateDisc(name: string, options: {
  26678. radius?: number;
  26679. tessellation?: number;
  26680. arc?: number;
  26681. updatable?: boolean;
  26682. sideOrientation?: number;
  26683. frontUVs?: Vector4;
  26684. backUVs?: Vector4;
  26685. }, scene?: Nullable<Scene>): Mesh;
  26686. }
  26687. }
  26688. declare module "babylonjs/Materials/fresnelParameters" {
  26689. import { Color3 } from "babylonjs/Maths/math.color";
  26690. /**
  26691. * This represents all the required information to add a fresnel effect on a material:
  26692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26693. */
  26694. export class FresnelParameters {
  26695. private _isEnabled;
  26696. /**
  26697. * Define if the fresnel effect is enable or not.
  26698. */
  26699. get isEnabled(): boolean;
  26700. set isEnabled(value: boolean);
  26701. /**
  26702. * Define the color used on edges (grazing angle)
  26703. */
  26704. leftColor: Color3;
  26705. /**
  26706. * Define the color used on center
  26707. */
  26708. rightColor: Color3;
  26709. /**
  26710. * Define bias applied to computed fresnel term
  26711. */
  26712. bias: number;
  26713. /**
  26714. * Defined the power exponent applied to fresnel term
  26715. */
  26716. power: number;
  26717. /**
  26718. * Clones the current fresnel and its valuues
  26719. * @returns a clone fresnel configuration
  26720. */
  26721. clone(): FresnelParameters;
  26722. /**
  26723. * Serializes the current fresnel parameters to a JSON representation.
  26724. * @return the JSON serialization
  26725. */
  26726. serialize(): any;
  26727. /**
  26728. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26729. * @param parsedFresnelParameters Define the JSON representation
  26730. * @returns the parsed parameters
  26731. */
  26732. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26733. }
  26734. }
  26735. declare module "babylonjs/Materials/pushMaterial" {
  26736. import { Nullable } from "babylonjs/types";
  26737. import { Scene } from "babylonjs/scene";
  26738. import { Matrix } from "babylonjs/Maths/math.vector";
  26739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26740. import { Mesh } from "babylonjs/Meshes/mesh";
  26741. import { Material } from "babylonjs/Materials/material";
  26742. import { Effect } from "babylonjs/Materials/effect";
  26743. /**
  26744. * Base class of materials working in push mode in babylon JS
  26745. * @hidden
  26746. */
  26747. export class PushMaterial extends Material {
  26748. protected _activeEffect: Effect;
  26749. protected _normalMatrix: Matrix;
  26750. /**
  26751. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26752. * This means that the material can keep using a previous shader while a new one is being compiled.
  26753. * This is mostly used when shader parallel compilation is supported (true by default)
  26754. */
  26755. allowShaderHotSwapping: boolean;
  26756. constructor(name: string, scene: Scene);
  26757. getEffect(): Effect;
  26758. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26759. /**
  26760. * Binds the given world matrix to the active effect
  26761. *
  26762. * @param world the matrix to bind
  26763. */
  26764. bindOnlyWorldMatrix(world: Matrix): void;
  26765. /**
  26766. * Binds the given normal matrix to the active effect
  26767. *
  26768. * @param normalMatrix the matrix to bind
  26769. */
  26770. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26771. bind(world: Matrix, mesh?: Mesh): void;
  26772. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26773. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26774. }
  26775. }
  26776. declare module "babylonjs/Materials/materialFlags" {
  26777. /**
  26778. * This groups all the flags used to control the materials channel.
  26779. */
  26780. export class MaterialFlags {
  26781. private static _DiffuseTextureEnabled;
  26782. /**
  26783. * Are diffuse textures enabled in the application.
  26784. */
  26785. static get DiffuseTextureEnabled(): boolean;
  26786. static set DiffuseTextureEnabled(value: boolean);
  26787. private static _AmbientTextureEnabled;
  26788. /**
  26789. * Are ambient textures enabled in the application.
  26790. */
  26791. static get AmbientTextureEnabled(): boolean;
  26792. static set AmbientTextureEnabled(value: boolean);
  26793. private static _OpacityTextureEnabled;
  26794. /**
  26795. * Are opacity textures enabled in the application.
  26796. */
  26797. static get OpacityTextureEnabled(): boolean;
  26798. static set OpacityTextureEnabled(value: boolean);
  26799. private static _ReflectionTextureEnabled;
  26800. /**
  26801. * Are reflection textures enabled in the application.
  26802. */
  26803. static get ReflectionTextureEnabled(): boolean;
  26804. static set ReflectionTextureEnabled(value: boolean);
  26805. private static _EmissiveTextureEnabled;
  26806. /**
  26807. * Are emissive textures enabled in the application.
  26808. */
  26809. static get EmissiveTextureEnabled(): boolean;
  26810. static set EmissiveTextureEnabled(value: boolean);
  26811. private static _SpecularTextureEnabled;
  26812. /**
  26813. * Are specular textures enabled in the application.
  26814. */
  26815. static get SpecularTextureEnabled(): boolean;
  26816. static set SpecularTextureEnabled(value: boolean);
  26817. private static _BumpTextureEnabled;
  26818. /**
  26819. * Are bump textures enabled in the application.
  26820. */
  26821. static get BumpTextureEnabled(): boolean;
  26822. static set BumpTextureEnabled(value: boolean);
  26823. private static _LightmapTextureEnabled;
  26824. /**
  26825. * Are lightmap textures enabled in the application.
  26826. */
  26827. static get LightmapTextureEnabled(): boolean;
  26828. static set LightmapTextureEnabled(value: boolean);
  26829. private static _RefractionTextureEnabled;
  26830. /**
  26831. * Are refraction textures enabled in the application.
  26832. */
  26833. static get RefractionTextureEnabled(): boolean;
  26834. static set RefractionTextureEnabled(value: boolean);
  26835. private static _ColorGradingTextureEnabled;
  26836. /**
  26837. * Are color grading textures enabled in the application.
  26838. */
  26839. static get ColorGradingTextureEnabled(): boolean;
  26840. static set ColorGradingTextureEnabled(value: boolean);
  26841. private static _FresnelEnabled;
  26842. /**
  26843. * Are fresnels enabled in the application.
  26844. */
  26845. static get FresnelEnabled(): boolean;
  26846. static set FresnelEnabled(value: boolean);
  26847. private static _ClearCoatTextureEnabled;
  26848. /**
  26849. * Are clear coat textures enabled in the application.
  26850. */
  26851. static get ClearCoatTextureEnabled(): boolean;
  26852. static set ClearCoatTextureEnabled(value: boolean);
  26853. private static _ClearCoatBumpTextureEnabled;
  26854. /**
  26855. * Are clear coat bump textures enabled in the application.
  26856. */
  26857. static get ClearCoatBumpTextureEnabled(): boolean;
  26858. static set ClearCoatBumpTextureEnabled(value: boolean);
  26859. private static _ClearCoatTintTextureEnabled;
  26860. /**
  26861. * Are clear coat tint textures enabled in the application.
  26862. */
  26863. static get ClearCoatTintTextureEnabled(): boolean;
  26864. static set ClearCoatTintTextureEnabled(value: boolean);
  26865. private static _SheenTextureEnabled;
  26866. /**
  26867. * Are sheen textures enabled in the application.
  26868. */
  26869. static get SheenTextureEnabled(): boolean;
  26870. static set SheenTextureEnabled(value: boolean);
  26871. private static _AnisotropicTextureEnabled;
  26872. /**
  26873. * Are anisotropic textures enabled in the application.
  26874. */
  26875. static get AnisotropicTextureEnabled(): boolean;
  26876. static set AnisotropicTextureEnabled(value: boolean);
  26877. private static _ThicknessTextureEnabled;
  26878. /**
  26879. * Are thickness textures enabled in the application.
  26880. */
  26881. static get ThicknessTextureEnabled(): boolean;
  26882. static set ThicknessTextureEnabled(value: boolean);
  26883. }
  26884. }
  26885. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26886. /** @hidden */
  26887. export var defaultFragmentDeclaration: {
  26888. name: string;
  26889. shader: string;
  26890. };
  26891. }
  26892. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26893. /** @hidden */
  26894. export var defaultUboDeclaration: {
  26895. name: string;
  26896. shader: string;
  26897. };
  26898. }
  26899. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26900. /** @hidden */
  26901. export var lightFragmentDeclaration: {
  26902. name: string;
  26903. shader: string;
  26904. };
  26905. }
  26906. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26907. /** @hidden */
  26908. export var lightUboDeclaration: {
  26909. name: string;
  26910. shader: string;
  26911. };
  26912. }
  26913. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26914. /** @hidden */
  26915. export var lightsFragmentFunctions: {
  26916. name: string;
  26917. shader: string;
  26918. };
  26919. }
  26920. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26921. /** @hidden */
  26922. export var shadowsFragmentFunctions: {
  26923. name: string;
  26924. shader: string;
  26925. };
  26926. }
  26927. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26928. /** @hidden */
  26929. export var fresnelFunction: {
  26930. name: string;
  26931. shader: string;
  26932. };
  26933. }
  26934. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26935. /** @hidden */
  26936. export var reflectionFunction: {
  26937. name: string;
  26938. shader: string;
  26939. };
  26940. }
  26941. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26942. /** @hidden */
  26943. export var bumpFragmentFunctions: {
  26944. name: string;
  26945. shader: string;
  26946. };
  26947. }
  26948. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26949. /** @hidden */
  26950. export var logDepthDeclaration: {
  26951. name: string;
  26952. shader: string;
  26953. };
  26954. }
  26955. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26956. /** @hidden */
  26957. export var bumpFragment: {
  26958. name: string;
  26959. shader: string;
  26960. };
  26961. }
  26962. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26963. /** @hidden */
  26964. export var depthPrePass: {
  26965. name: string;
  26966. shader: string;
  26967. };
  26968. }
  26969. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26970. /** @hidden */
  26971. export var lightFragment: {
  26972. name: string;
  26973. shader: string;
  26974. };
  26975. }
  26976. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26977. /** @hidden */
  26978. export var logDepthFragment: {
  26979. name: string;
  26980. shader: string;
  26981. };
  26982. }
  26983. declare module "babylonjs/Shaders/default.fragment" {
  26984. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26992. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26993. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26997. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27002. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27003. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27004. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27005. /** @hidden */
  27006. export var defaultPixelShader: {
  27007. name: string;
  27008. shader: string;
  27009. };
  27010. }
  27011. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27012. /** @hidden */
  27013. export var defaultVertexDeclaration: {
  27014. name: string;
  27015. shader: string;
  27016. };
  27017. }
  27018. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27019. /** @hidden */
  27020. export var bumpVertexDeclaration: {
  27021. name: string;
  27022. shader: string;
  27023. };
  27024. }
  27025. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27026. /** @hidden */
  27027. export var bumpVertex: {
  27028. name: string;
  27029. shader: string;
  27030. };
  27031. }
  27032. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27033. /** @hidden */
  27034. export var fogVertex: {
  27035. name: string;
  27036. shader: string;
  27037. };
  27038. }
  27039. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27040. /** @hidden */
  27041. export var shadowsVertex: {
  27042. name: string;
  27043. shader: string;
  27044. };
  27045. }
  27046. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27047. /** @hidden */
  27048. export var pointCloudVertex: {
  27049. name: string;
  27050. shader: string;
  27051. };
  27052. }
  27053. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27054. /** @hidden */
  27055. export var logDepthVertex: {
  27056. name: string;
  27057. shader: string;
  27058. };
  27059. }
  27060. declare module "babylonjs/Shaders/default.vertex" {
  27061. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27064. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27073. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27080. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27081. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27082. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27083. /** @hidden */
  27084. export var defaultVertexShader: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Materials/standardMaterial" {
  27090. import { SmartArray } from "babylonjs/Misc/smartArray";
  27091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27092. import { Nullable } from "babylonjs/types";
  27093. import { Scene } from "babylonjs/scene";
  27094. import { Matrix } from "babylonjs/Maths/math.vector";
  27095. import { Color3 } from "babylonjs/Maths/math.color";
  27096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27098. import { Mesh } from "babylonjs/Meshes/mesh";
  27099. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27100. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27101. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27103. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27106. import "babylonjs/Shaders/default.fragment";
  27107. import "babylonjs/Shaders/default.vertex";
  27108. /** @hidden */
  27109. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27110. MAINUV1: boolean;
  27111. MAINUV2: boolean;
  27112. DIFFUSE: boolean;
  27113. DIFFUSEDIRECTUV: number;
  27114. AMBIENT: boolean;
  27115. AMBIENTDIRECTUV: number;
  27116. OPACITY: boolean;
  27117. OPACITYDIRECTUV: number;
  27118. OPACITYRGB: boolean;
  27119. REFLECTION: boolean;
  27120. EMISSIVE: boolean;
  27121. EMISSIVEDIRECTUV: number;
  27122. SPECULAR: boolean;
  27123. SPECULARDIRECTUV: number;
  27124. BUMP: boolean;
  27125. BUMPDIRECTUV: number;
  27126. PARALLAX: boolean;
  27127. PARALLAXOCCLUSION: boolean;
  27128. SPECULAROVERALPHA: boolean;
  27129. CLIPPLANE: boolean;
  27130. CLIPPLANE2: boolean;
  27131. CLIPPLANE3: boolean;
  27132. CLIPPLANE4: boolean;
  27133. CLIPPLANE5: boolean;
  27134. CLIPPLANE6: boolean;
  27135. ALPHATEST: boolean;
  27136. DEPTHPREPASS: boolean;
  27137. ALPHAFROMDIFFUSE: boolean;
  27138. POINTSIZE: boolean;
  27139. FOG: boolean;
  27140. SPECULARTERM: boolean;
  27141. DIFFUSEFRESNEL: boolean;
  27142. OPACITYFRESNEL: boolean;
  27143. REFLECTIONFRESNEL: boolean;
  27144. REFRACTIONFRESNEL: boolean;
  27145. EMISSIVEFRESNEL: boolean;
  27146. FRESNEL: boolean;
  27147. NORMAL: boolean;
  27148. UV1: boolean;
  27149. UV2: boolean;
  27150. VERTEXCOLOR: boolean;
  27151. VERTEXALPHA: boolean;
  27152. NUM_BONE_INFLUENCERS: number;
  27153. BonesPerMesh: number;
  27154. BONETEXTURE: boolean;
  27155. INSTANCES: boolean;
  27156. GLOSSINESS: boolean;
  27157. ROUGHNESS: boolean;
  27158. EMISSIVEASILLUMINATION: boolean;
  27159. LINKEMISSIVEWITHDIFFUSE: boolean;
  27160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27161. LIGHTMAP: boolean;
  27162. LIGHTMAPDIRECTUV: number;
  27163. OBJECTSPACE_NORMALMAP: boolean;
  27164. USELIGHTMAPASSHADOWMAP: boolean;
  27165. REFLECTIONMAP_3D: boolean;
  27166. REFLECTIONMAP_SPHERICAL: boolean;
  27167. REFLECTIONMAP_PLANAR: boolean;
  27168. REFLECTIONMAP_CUBIC: boolean;
  27169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27170. REFLECTIONMAP_PROJECTION: boolean;
  27171. REFLECTIONMAP_SKYBOX: boolean;
  27172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27173. REFLECTIONMAP_EXPLICIT: boolean;
  27174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27177. INVERTCUBICMAP: boolean;
  27178. LOGARITHMICDEPTH: boolean;
  27179. REFRACTION: boolean;
  27180. REFRACTIONMAP_3D: boolean;
  27181. REFLECTIONOVERALPHA: boolean;
  27182. TWOSIDEDLIGHTING: boolean;
  27183. SHADOWFLOAT: boolean;
  27184. MORPHTARGETS: boolean;
  27185. MORPHTARGETS_NORMAL: boolean;
  27186. MORPHTARGETS_TANGENT: boolean;
  27187. MORPHTARGETS_UV: boolean;
  27188. NUM_MORPH_INFLUENCERS: number;
  27189. NONUNIFORMSCALING: boolean;
  27190. PREMULTIPLYALPHA: boolean;
  27191. IMAGEPROCESSING: boolean;
  27192. VIGNETTE: boolean;
  27193. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27194. VIGNETTEBLENDMODEOPAQUE: boolean;
  27195. TONEMAPPING: boolean;
  27196. TONEMAPPING_ACES: boolean;
  27197. CONTRAST: boolean;
  27198. COLORCURVES: boolean;
  27199. COLORGRADING: boolean;
  27200. COLORGRADING3D: boolean;
  27201. SAMPLER3DGREENDEPTH: boolean;
  27202. SAMPLER3DBGRMAP: boolean;
  27203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27204. MULTIVIEW: boolean;
  27205. /**
  27206. * If the reflection texture on this material is in linear color space
  27207. * @hidden
  27208. */
  27209. IS_REFLECTION_LINEAR: boolean;
  27210. /**
  27211. * If the refraction texture on this material is in linear color space
  27212. * @hidden
  27213. */
  27214. IS_REFRACTION_LINEAR: boolean;
  27215. EXPOSURE: boolean;
  27216. constructor();
  27217. setReflectionMode(modeToEnable: string): void;
  27218. }
  27219. /**
  27220. * This is the default material used in Babylon. It is the best trade off between quality
  27221. * and performances.
  27222. * @see http://doc.babylonjs.com/babylon101/materials
  27223. */
  27224. export class StandardMaterial extends PushMaterial {
  27225. private _diffuseTexture;
  27226. /**
  27227. * The basic texture of the material as viewed under a light.
  27228. */
  27229. diffuseTexture: Nullable<BaseTexture>;
  27230. private _ambientTexture;
  27231. /**
  27232. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27233. */
  27234. ambientTexture: Nullable<BaseTexture>;
  27235. private _opacityTexture;
  27236. /**
  27237. * Define the transparency of the material from a texture.
  27238. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27239. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27240. */
  27241. opacityTexture: Nullable<BaseTexture>;
  27242. private _reflectionTexture;
  27243. /**
  27244. * Define the texture used to display the reflection.
  27245. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27246. */
  27247. reflectionTexture: Nullable<BaseTexture>;
  27248. private _emissiveTexture;
  27249. /**
  27250. * Define texture of the material as if self lit.
  27251. * This will be mixed in the final result even in the absence of light.
  27252. */
  27253. emissiveTexture: Nullable<BaseTexture>;
  27254. private _specularTexture;
  27255. /**
  27256. * Define how the color and intensity of the highlight given by the light in the material.
  27257. */
  27258. specularTexture: Nullable<BaseTexture>;
  27259. private _bumpTexture;
  27260. /**
  27261. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27262. * 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.
  27263. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27264. */
  27265. bumpTexture: Nullable<BaseTexture>;
  27266. private _lightmapTexture;
  27267. /**
  27268. * Complex lighting can be computationally expensive to compute at runtime.
  27269. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27270. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27271. */
  27272. lightmapTexture: Nullable<BaseTexture>;
  27273. private _refractionTexture;
  27274. /**
  27275. * Define the texture used to display the refraction.
  27276. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27277. */
  27278. refractionTexture: Nullable<BaseTexture>;
  27279. /**
  27280. * The color of the material lit by the environmental background lighting.
  27281. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27282. */
  27283. ambientColor: Color3;
  27284. /**
  27285. * The basic color of the material as viewed under a light.
  27286. */
  27287. diffuseColor: Color3;
  27288. /**
  27289. * Define how the color and intensity of the highlight given by the light in the material.
  27290. */
  27291. specularColor: Color3;
  27292. /**
  27293. * Define the color of the material as if self lit.
  27294. * This will be mixed in the final result even in the absence of light.
  27295. */
  27296. emissiveColor: Color3;
  27297. /**
  27298. * Defines how sharp are the highlights in the material.
  27299. * The bigger the value the sharper giving a more glossy feeling to the result.
  27300. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27301. */
  27302. specularPower: number;
  27303. private _useAlphaFromDiffuseTexture;
  27304. /**
  27305. * Does the transparency come from the diffuse texture alpha channel.
  27306. */
  27307. useAlphaFromDiffuseTexture: boolean;
  27308. private _useEmissiveAsIllumination;
  27309. /**
  27310. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27311. */
  27312. useEmissiveAsIllumination: boolean;
  27313. private _linkEmissiveWithDiffuse;
  27314. /**
  27315. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27316. * the emissive level when the final color is close to one.
  27317. */
  27318. linkEmissiveWithDiffuse: boolean;
  27319. private _useSpecularOverAlpha;
  27320. /**
  27321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27323. */
  27324. useSpecularOverAlpha: boolean;
  27325. private _useReflectionOverAlpha;
  27326. /**
  27327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27329. */
  27330. useReflectionOverAlpha: boolean;
  27331. private _disableLighting;
  27332. /**
  27333. * Does lights from the scene impacts this material.
  27334. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27335. */
  27336. disableLighting: boolean;
  27337. private _useObjectSpaceNormalMap;
  27338. /**
  27339. * Allows using an object space normal map (instead of tangent space).
  27340. */
  27341. useObjectSpaceNormalMap: boolean;
  27342. private _useParallax;
  27343. /**
  27344. * Is parallax enabled or not.
  27345. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27346. */
  27347. useParallax: boolean;
  27348. private _useParallaxOcclusion;
  27349. /**
  27350. * Is parallax occlusion enabled or not.
  27351. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27352. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27353. */
  27354. useParallaxOcclusion: boolean;
  27355. /**
  27356. * 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.
  27357. */
  27358. parallaxScaleBias: number;
  27359. private _roughness;
  27360. /**
  27361. * Helps to define how blurry the reflections should appears in the material.
  27362. */
  27363. roughness: number;
  27364. /**
  27365. * In case of refraction, define the value of the index of refraction.
  27366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27367. */
  27368. indexOfRefraction: number;
  27369. /**
  27370. * Invert the refraction texture alongside the y axis.
  27371. * It can be useful with procedural textures or probe for instance.
  27372. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27373. */
  27374. invertRefractionY: boolean;
  27375. /**
  27376. * Defines the alpha limits in alpha test mode.
  27377. */
  27378. alphaCutOff: number;
  27379. private _useLightmapAsShadowmap;
  27380. /**
  27381. * In case of light mapping, define whether the map contains light or shadow informations.
  27382. */
  27383. useLightmapAsShadowmap: boolean;
  27384. private _diffuseFresnelParameters;
  27385. /**
  27386. * Define the diffuse fresnel parameters of the material.
  27387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27388. */
  27389. diffuseFresnelParameters: FresnelParameters;
  27390. private _opacityFresnelParameters;
  27391. /**
  27392. * Define the opacity fresnel parameters of the material.
  27393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27394. */
  27395. opacityFresnelParameters: FresnelParameters;
  27396. private _reflectionFresnelParameters;
  27397. /**
  27398. * Define the reflection fresnel parameters of the material.
  27399. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27400. */
  27401. reflectionFresnelParameters: FresnelParameters;
  27402. private _refractionFresnelParameters;
  27403. /**
  27404. * Define the refraction fresnel parameters of the material.
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27406. */
  27407. refractionFresnelParameters: FresnelParameters;
  27408. private _emissiveFresnelParameters;
  27409. /**
  27410. * Define the emissive fresnel parameters of the material.
  27411. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27412. */
  27413. emissiveFresnelParameters: FresnelParameters;
  27414. private _useReflectionFresnelFromSpecular;
  27415. /**
  27416. * If true automatically deducts the fresnels values from the material specularity.
  27417. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27418. */
  27419. useReflectionFresnelFromSpecular: boolean;
  27420. private _useGlossinessFromSpecularMapAlpha;
  27421. /**
  27422. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27423. */
  27424. useGlossinessFromSpecularMapAlpha: boolean;
  27425. private _maxSimultaneousLights;
  27426. /**
  27427. * Defines the maximum number of lights that can be used in the material
  27428. */
  27429. maxSimultaneousLights: number;
  27430. private _invertNormalMapX;
  27431. /**
  27432. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27433. */
  27434. invertNormalMapX: boolean;
  27435. private _invertNormalMapY;
  27436. /**
  27437. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27438. */
  27439. invertNormalMapY: boolean;
  27440. private _twoSidedLighting;
  27441. /**
  27442. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27443. */
  27444. twoSidedLighting: boolean;
  27445. /**
  27446. * Default configuration related to image processing available in the standard Material.
  27447. */
  27448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27449. /**
  27450. * Gets the image processing configuration used either in this material.
  27451. */
  27452. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27453. /**
  27454. * Sets the Default image processing configuration used either in the this material.
  27455. *
  27456. * If sets to null, the scene one is in use.
  27457. */
  27458. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27459. /**
  27460. * Keep track of the image processing observer to allow dispose and replace.
  27461. */
  27462. private _imageProcessingObserver;
  27463. /**
  27464. * Attaches a new image processing configuration to the Standard Material.
  27465. * @param configuration
  27466. */
  27467. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27468. /**
  27469. * Gets wether the color curves effect is enabled.
  27470. */
  27471. get cameraColorCurvesEnabled(): boolean;
  27472. /**
  27473. * Sets wether the color curves effect is enabled.
  27474. */
  27475. set cameraColorCurvesEnabled(value: boolean);
  27476. /**
  27477. * Gets wether the color grading effect is enabled.
  27478. */
  27479. get cameraColorGradingEnabled(): boolean;
  27480. /**
  27481. * Gets wether the color grading effect is enabled.
  27482. */
  27483. set cameraColorGradingEnabled(value: boolean);
  27484. /**
  27485. * Gets wether tonemapping is enabled or not.
  27486. */
  27487. get cameraToneMappingEnabled(): boolean;
  27488. /**
  27489. * Sets wether tonemapping is enabled or not
  27490. */
  27491. set cameraToneMappingEnabled(value: boolean);
  27492. /**
  27493. * The camera exposure used on this material.
  27494. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27495. * This corresponds to a photographic exposure.
  27496. */
  27497. get cameraExposure(): number;
  27498. /**
  27499. * The camera exposure used on this material.
  27500. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27501. * This corresponds to a photographic exposure.
  27502. */
  27503. set cameraExposure(value: number);
  27504. /**
  27505. * Gets The camera contrast used on this material.
  27506. */
  27507. get cameraContrast(): number;
  27508. /**
  27509. * Sets The camera contrast used on this material.
  27510. */
  27511. set cameraContrast(value: number);
  27512. /**
  27513. * Gets the Color Grading 2D Lookup Texture.
  27514. */
  27515. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27516. /**
  27517. * Sets the Color Grading 2D Lookup Texture.
  27518. */
  27519. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27520. /**
  27521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27523. * 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;
  27524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27525. */
  27526. get cameraColorCurves(): Nullable<ColorCurves>;
  27527. /**
  27528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27530. * 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;
  27531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27532. */
  27533. set cameraColorCurves(value: Nullable<ColorCurves>);
  27534. /**
  27535. * Custom callback helping to override the default shader used in the material.
  27536. */
  27537. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27538. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27539. protected _worldViewProjectionMatrix: Matrix;
  27540. protected _globalAmbientColor: Color3;
  27541. protected _useLogarithmicDepth: boolean;
  27542. protected _rebuildInParallel: boolean;
  27543. /**
  27544. * Instantiates a new standard material.
  27545. * This is the default material used in Babylon. It is the best trade off between quality
  27546. * and performances.
  27547. * @see http://doc.babylonjs.com/babylon101/materials
  27548. * @param name Define the name of the material in the scene
  27549. * @param scene Define the scene the material belong to
  27550. */
  27551. constructor(name: string, scene: Scene);
  27552. /**
  27553. * Gets a boolean indicating that current material needs to register RTT
  27554. */
  27555. get hasRenderTargetTextures(): boolean;
  27556. /**
  27557. * Gets the current class name of the material e.g. "StandardMaterial"
  27558. * Mainly use in serialization.
  27559. * @returns the class name
  27560. */
  27561. getClassName(): string;
  27562. /**
  27563. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27564. * You can try switching to logarithmic depth.
  27565. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27566. */
  27567. get useLogarithmicDepth(): boolean;
  27568. set useLogarithmicDepth(value: boolean);
  27569. /**
  27570. * Specifies if the material will require alpha blending
  27571. * @returns a boolean specifying if alpha blending is needed
  27572. */
  27573. needAlphaBlending(): boolean;
  27574. /**
  27575. * Specifies if this material should be rendered in alpha test mode
  27576. * @returns a boolean specifying if an alpha test is needed.
  27577. */
  27578. needAlphaTesting(): boolean;
  27579. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27580. /**
  27581. * Get the texture used for alpha test purpose.
  27582. * @returns the diffuse texture in case of the standard material.
  27583. */
  27584. getAlphaTestTexture(): Nullable<BaseTexture>;
  27585. /**
  27586. * Get if the submesh is ready to be used and all its information available.
  27587. * Child classes can use it to update shaders
  27588. * @param mesh defines the mesh to check
  27589. * @param subMesh defines which submesh to check
  27590. * @param useInstances specifies that instances should be used
  27591. * @returns a boolean indicating that the submesh is ready or not
  27592. */
  27593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27594. /**
  27595. * Builds the material UBO layouts.
  27596. * Used internally during the effect preparation.
  27597. */
  27598. buildUniformLayout(): void;
  27599. /**
  27600. * Unbinds the material from the mesh
  27601. */
  27602. unbind(): void;
  27603. /**
  27604. * Binds the submesh to this material by preparing the effect and shader to draw
  27605. * @param world defines the world transformation matrix
  27606. * @param mesh defines the mesh containing the submesh
  27607. * @param subMesh defines the submesh to bind the material to
  27608. */
  27609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27610. /**
  27611. * Get the list of animatables in the material.
  27612. * @returns the list of animatables object used in the material
  27613. */
  27614. getAnimatables(): IAnimatable[];
  27615. /**
  27616. * Gets the active textures from the material
  27617. * @returns an array of textures
  27618. */
  27619. getActiveTextures(): BaseTexture[];
  27620. /**
  27621. * Specifies if the material uses a texture
  27622. * @param texture defines the texture to check against the material
  27623. * @returns a boolean specifying if the material uses the texture
  27624. */
  27625. hasTexture(texture: BaseTexture): boolean;
  27626. /**
  27627. * Disposes the material
  27628. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27629. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27630. */
  27631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27632. /**
  27633. * Makes a duplicate of the material, and gives it a new name
  27634. * @param name defines the new name for the duplicated material
  27635. * @returns the cloned material
  27636. */
  27637. clone(name: string): StandardMaterial;
  27638. /**
  27639. * Serializes this material in a JSON representation
  27640. * @returns the serialized material object
  27641. */
  27642. serialize(): any;
  27643. /**
  27644. * Creates a standard material from parsed material data
  27645. * @param source defines the JSON representation of the material
  27646. * @param scene defines the hosting scene
  27647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27648. * @returns a new standard material
  27649. */
  27650. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27651. /**
  27652. * Are diffuse textures enabled in the application.
  27653. */
  27654. static get DiffuseTextureEnabled(): boolean;
  27655. static set DiffuseTextureEnabled(value: boolean);
  27656. /**
  27657. * Are ambient textures enabled in the application.
  27658. */
  27659. static get AmbientTextureEnabled(): boolean;
  27660. static set AmbientTextureEnabled(value: boolean);
  27661. /**
  27662. * Are opacity textures enabled in the application.
  27663. */
  27664. static get OpacityTextureEnabled(): boolean;
  27665. static set OpacityTextureEnabled(value: boolean);
  27666. /**
  27667. * Are reflection textures enabled in the application.
  27668. */
  27669. static get ReflectionTextureEnabled(): boolean;
  27670. static set ReflectionTextureEnabled(value: boolean);
  27671. /**
  27672. * Are emissive textures enabled in the application.
  27673. */
  27674. static get EmissiveTextureEnabled(): boolean;
  27675. static set EmissiveTextureEnabled(value: boolean);
  27676. /**
  27677. * Are specular textures enabled in the application.
  27678. */
  27679. static get SpecularTextureEnabled(): boolean;
  27680. static set SpecularTextureEnabled(value: boolean);
  27681. /**
  27682. * Are bump textures enabled in the application.
  27683. */
  27684. static get BumpTextureEnabled(): boolean;
  27685. static set BumpTextureEnabled(value: boolean);
  27686. /**
  27687. * Are lightmap textures enabled in the application.
  27688. */
  27689. static get LightmapTextureEnabled(): boolean;
  27690. static set LightmapTextureEnabled(value: boolean);
  27691. /**
  27692. * Are refraction textures enabled in the application.
  27693. */
  27694. static get RefractionTextureEnabled(): boolean;
  27695. static set RefractionTextureEnabled(value: boolean);
  27696. /**
  27697. * Are color grading textures enabled in the application.
  27698. */
  27699. static get ColorGradingTextureEnabled(): boolean;
  27700. static set ColorGradingTextureEnabled(value: boolean);
  27701. /**
  27702. * Are fresnels enabled in the application.
  27703. */
  27704. static get FresnelEnabled(): boolean;
  27705. static set FresnelEnabled(value: boolean);
  27706. }
  27707. }
  27708. declare module "babylonjs/Particles/solidParticleSystem" {
  27709. import { Nullable } from "babylonjs/types";
  27710. import { Vector3 } from "babylonjs/Maths/math.vector";
  27711. import { Mesh } from "babylonjs/Meshes/mesh";
  27712. import { Scene, IDisposable } from "babylonjs/scene";
  27713. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27714. import { Material } from "babylonjs/Materials/material";
  27715. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27716. /**
  27717. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27718. *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.
  27719. * The SPS is also a particle system. It provides some methods to manage the particles.
  27720. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27721. *
  27722. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27723. */
  27724. export class SolidParticleSystem implements IDisposable {
  27725. /**
  27726. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27727. * Example : var p = SPS.particles[i];
  27728. */
  27729. particles: SolidParticle[];
  27730. /**
  27731. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27732. */
  27733. nbParticles: number;
  27734. /**
  27735. * If the particles must ever face the camera (default false). Useful for planar particles.
  27736. */
  27737. billboard: boolean;
  27738. /**
  27739. * Recompute normals when adding a shape
  27740. */
  27741. recomputeNormals: boolean;
  27742. /**
  27743. * This a counter ofr your own usage. It's not set by any SPS functions.
  27744. */
  27745. counter: number;
  27746. /**
  27747. * The SPS name. This name is also given to the underlying mesh.
  27748. */
  27749. name: string;
  27750. /**
  27751. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27752. */
  27753. mesh: Mesh;
  27754. /**
  27755. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27756. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27757. */
  27758. vars: any;
  27759. /**
  27760. * This array is populated when the SPS is set as 'pickable'.
  27761. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27762. * Each element of this array is an object `{idx: int, faceId: int}`.
  27763. * `idx` is the picked particle index in the `SPS.particles` array
  27764. * `faceId` is the picked face index counted within this particle.
  27765. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27766. */
  27767. pickedParticles: {
  27768. idx: number;
  27769. faceId: number;
  27770. }[];
  27771. /**
  27772. * This array is populated when `enableDepthSort` is set to true.
  27773. * Each element of this array is an instance of the class DepthSortedParticle.
  27774. */
  27775. depthSortedParticles: DepthSortedParticle[];
  27776. /**
  27777. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27778. * @hidden
  27779. */
  27780. _bSphereOnly: boolean;
  27781. /**
  27782. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27783. * @hidden
  27784. */
  27785. _bSphereRadiusFactor: number;
  27786. private _scene;
  27787. private _positions;
  27788. private _indices;
  27789. private _normals;
  27790. private _colors;
  27791. private _uvs;
  27792. private _indices32;
  27793. private _positions32;
  27794. private _normals32;
  27795. private _fixedNormal32;
  27796. private _colors32;
  27797. private _uvs32;
  27798. private _index;
  27799. private _updatable;
  27800. private _pickable;
  27801. private _isVisibilityBoxLocked;
  27802. private _alwaysVisible;
  27803. private _depthSort;
  27804. private _expandable;
  27805. private _shapeCounter;
  27806. private _copy;
  27807. private _color;
  27808. private _computeParticleColor;
  27809. private _computeParticleTexture;
  27810. private _computeParticleRotation;
  27811. private _computeParticleVertex;
  27812. private _computeBoundingBox;
  27813. private _depthSortParticles;
  27814. private _camera;
  27815. private _mustUnrotateFixedNormals;
  27816. private _particlesIntersect;
  27817. private _needs32Bits;
  27818. private _isNotBuilt;
  27819. private _lastParticleId;
  27820. private _idxOfId;
  27821. private _multimaterialEnabled;
  27822. private _useModelMaterial;
  27823. private _indicesByMaterial;
  27824. private _materialIndexes;
  27825. private _depthSortFunction;
  27826. private _materialSortFunction;
  27827. private _materials;
  27828. private _multimaterial;
  27829. private _materialIndexesById;
  27830. private _defaultMaterial;
  27831. private _autoUpdateSubMeshes;
  27832. /**
  27833. * Creates a SPS (Solid Particle System) object.
  27834. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27835. * @param scene (Scene) is the scene in which the SPS is added.
  27836. * @param options defines the options of the sps e.g.
  27837. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27838. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27839. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27840. * * 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.
  27841. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27842. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27843. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27844. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27845. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27846. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27847. */
  27848. constructor(name: string, scene: Scene, options?: {
  27849. updatable?: boolean;
  27850. isPickable?: boolean;
  27851. enableDepthSort?: boolean;
  27852. particleIntersection?: boolean;
  27853. boundingSphereOnly?: boolean;
  27854. bSphereRadiusFactor?: number;
  27855. expandable?: boolean;
  27856. useModelMaterial?: boolean;
  27857. enableMultiMaterial?: boolean;
  27858. });
  27859. /**
  27860. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27861. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27862. * @returns the created mesh
  27863. */
  27864. buildMesh(): Mesh;
  27865. /**
  27866. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27867. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27868. * Thus the particles generated from `digest()` have their property `position` set yet.
  27869. * @param mesh ( Mesh ) is the mesh to be digested
  27870. * @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
  27871. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27872. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27873. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27874. * @returns the current SPS
  27875. */
  27876. digest(mesh: Mesh, options?: {
  27877. facetNb?: number;
  27878. number?: number;
  27879. delta?: number;
  27880. storage?: [];
  27881. }): SolidParticleSystem;
  27882. /**
  27883. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27884. * @hidden
  27885. */
  27886. private _unrotateFixedNormals;
  27887. /**
  27888. * Resets the temporary working copy particle
  27889. * @hidden
  27890. */
  27891. private _resetCopy;
  27892. /**
  27893. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27894. * @param p the current index in the positions array to be updated
  27895. * @param ind the current index in the indices array
  27896. * @param shape a Vector3 array, the shape geometry
  27897. * @param positions the positions array to be updated
  27898. * @param meshInd the shape indices array
  27899. * @param indices the indices array to be updated
  27900. * @param meshUV the shape uv array
  27901. * @param uvs the uv array to be updated
  27902. * @param meshCol the shape color array
  27903. * @param colors the color array to be updated
  27904. * @param meshNor the shape normals array
  27905. * @param normals the normals array to be updated
  27906. * @param idx the particle index
  27907. * @param idxInShape the particle index in its shape
  27908. * @param options the addShape() method passed options
  27909. * @model the particle model
  27910. * @hidden
  27911. */
  27912. private _meshBuilder;
  27913. /**
  27914. * Returns a shape Vector3 array from positions float array
  27915. * @param positions float array
  27916. * @returns a vector3 array
  27917. * @hidden
  27918. */
  27919. private _posToShape;
  27920. /**
  27921. * Returns a shapeUV array from a float uvs (array deep copy)
  27922. * @param uvs as a float array
  27923. * @returns a shapeUV array
  27924. * @hidden
  27925. */
  27926. private _uvsToShapeUV;
  27927. /**
  27928. * Adds a new particle object in the particles array
  27929. * @param idx particle index in particles array
  27930. * @param id particle id
  27931. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27932. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27933. * @param model particle ModelShape object
  27934. * @param shapeId model shape identifier
  27935. * @param idxInShape index of the particle in the current model
  27936. * @param bInfo model bounding info object
  27937. * @param storage target storage array, if any
  27938. * @hidden
  27939. */
  27940. private _addParticle;
  27941. /**
  27942. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27943. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27944. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27945. * @param nb (positive integer) the number of particles to be created from this model
  27946. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27947. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27948. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27949. * @returns the number of shapes in the system
  27950. */
  27951. addShape(mesh: Mesh, nb: number, options?: {
  27952. positionFunction?: any;
  27953. vertexFunction?: any;
  27954. storage?: [];
  27955. }): number;
  27956. /**
  27957. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27958. * @hidden
  27959. */
  27960. private _rebuildParticle;
  27961. /**
  27962. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27963. * @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.
  27964. * @returns the SPS.
  27965. */
  27966. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27967. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27968. * Returns an array with the removed particles.
  27969. * 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.
  27970. * The SPS can't be empty so at least one particle needs to remain in place.
  27971. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27972. * @param start index of the first particle to remove
  27973. * @param end index of the last particle to remove (included)
  27974. * @returns an array populated with the removed particles
  27975. */
  27976. removeParticles(start: number, end: number): SolidParticle[];
  27977. /**
  27978. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27979. * @param solidParticleArray an array populated with Solid Particles objects
  27980. * @returns the SPS
  27981. */
  27982. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27983. /**
  27984. * Creates a new particle and modifies the SPS mesh geometry :
  27985. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27986. * - calls _addParticle() to populate the particle array
  27987. * factorized code from addShape() and insertParticlesFromArray()
  27988. * @param idx particle index in the particles array
  27989. * @param i particle index in its shape
  27990. * @param modelShape particle ModelShape object
  27991. * @param shape shape vertex array
  27992. * @param meshInd shape indices array
  27993. * @param meshUV shape uv array
  27994. * @param meshCol shape color array
  27995. * @param meshNor shape normals array
  27996. * @param bbInfo shape bounding info
  27997. * @param storage target particle storage
  27998. * @options addShape() passed options
  27999. * @hidden
  28000. */
  28001. private _insertNewParticle;
  28002. /**
  28003. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28004. * This method calls `updateParticle()` for each particle of the SPS.
  28005. * For an animated SPS, it is usually called within the render loop.
  28006. * 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.
  28007. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28008. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28009. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28010. * @returns the SPS.
  28011. */
  28012. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28013. /**
  28014. * Disposes the SPS.
  28015. */
  28016. dispose(): void;
  28017. /**
  28018. * Returns a SolidParticle object from its identifier : particle.id
  28019. * @param id (integer) the particle Id
  28020. * @returns the searched particle or null if not found in the SPS.
  28021. */
  28022. getParticleById(id: number): Nullable<SolidParticle>;
  28023. /**
  28024. * Returns a new array populated with the particles having the passed shapeId.
  28025. * @param shapeId (integer) the shape identifier
  28026. * @returns a new solid particle array
  28027. */
  28028. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28029. /**
  28030. * Populates the passed array "ref" with the particles having the passed shapeId.
  28031. * @param shapeId the shape identifier
  28032. * @returns the SPS
  28033. * @param ref
  28034. */
  28035. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28036. /**
  28037. * Computes the required SubMeshes according the materials assigned to the particles.
  28038. * @returns the solid particle system.
  28039. * Does nothing if called before the SPS mesh is built.
  28040. */
  28041. computeSubMeshes(): SolidParticleSystem;
  28042. /**
  28043. * Sorts the solid particles by material when MultiMaterial is enabled.
  28044. * Updates the indices32 array.
  28045. * Updates the indicesByMaterial array.
  28046. * Updates the mesh indices array.
  28047. * @returns the SPS
  28048. * @hidden
  28049. */
  28050. private _sortParticlesByMaterial;
  28051. /**
  28052. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28053. * @hidden
  28054. */
  28055. private _setMaterialIndexesById;
  28056. /**
  28057. * Returns an array with unique values of Materials from the passed array
  28058. * @param array the material array to be checked and filtered
  28059. * @hidden
  28060. */
  28061. private _filterUniqueMaterialId;
  28062. /**
  28063. * Sets a new Standard Material as _defaultMaterial if not already set.
  28064. * @hidden
  28065. */
  28066. private _setDefaultMaterial;
  28067. /**
  28068. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28069. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28070. * @returns the SPS.
  28071. */
  28072. refreshVisibleSize(): SolidParticleSystem;
  28073. /**
  28074. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28075. * @param size the size (float) of the visibility box
  28076. * note : this doesn't lock the SPS mesh bounding box.
  28077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28078. */
  28079. setVisibilityBox(size: number): void;
  28080. /**
  28081. * Gets whether the SPS as always visible or not
  28082. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28083. */
  28084. get isAlwaysVisible(): boolean;
  28085. /**
  28086. * Sets the SPS as always visible or not
  28087. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28088. */
  28089. set isAlwaysVisible(val: boolean);
  28090. /**
  28091. * Sets 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. set isVisibilityBoxLocked(val: boolean);
  28095. /**
  28096. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28098. */
  28099. get isVisibilityBoxLocked(): boolean;
  28100. /**
  28101. * Tells to `setParticles()` to compute the particle rotations or not.
  28102. * Default value : true. The SPS is faster when it's set to false.
  28103. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28104. */
  28105. set computeParticleRotation(val: boolean);
  28106. /**
  28107. * Tells to `setParticles()` to compute the particle colors or not.
  28108. * Default value : true. The SPS is faster when it's set to false.
  28109. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28110. */
  28111. set computeParticleColor(val: boolean);
  28112. set computeParticleTexture(val: boolean);
  28113. /**
  28114. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28115. * Default value : false. The SPS is faster when it's set to false.
  28116. * Note : the particle custom vertex positions aren't stored values.
  28117. */
  28118. set computeParticleVertex(val: boolean);
  28119. /**
  28120. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28121. */
  28122. set computeBoundingBox(val: boolean);
  28123. /**
  28124. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28125. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28126. * Default : `true`
  28127. */
  28128. set depthSortParticles(val: boolean);
  28129. /**
  28130. * Gets if `setParticles()` computes the particle rotations or not.
  28131. * Default value : true. The SPS is faster when it's set to false.
  28132. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28133. */
  28134. get computeParticleRotation(): boolean;
  28135. /**
  28136. * Gets if `setParticles()` computes the particle colors or not.
  28137. * Default value : true. The SPS is faster when it's set to false.
  28138. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28139. */
  28140. get computeParticleColor(): boolean;
  28141. /**
  28142. * Gets if `setParticles()` computes the particle textures or not.
  28143. * Default value : true. The SPS is faster when it's set to false.
  28144. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28145. */
  28146. get computeParticleTexture(): boolean;
  28147. /**
  28148. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28149. * Default value : false. The SPS is faster when it's set to false.
  28150. * Note : the particle custom vertex positions aren't stored values.
  28151. */
  28152. get computeParticleVertex(): boolean;
  28153. /**
  28154. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28155. */
  28156. get computeBoundingBox(): boolean;
  28157. /**
  28158. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28160. * Default : `true`
  28161. */
  28162. get depthSortParticles(): boolean;
  28163. /**
  28164. * Gets if the SPS is created as expandable at construction time.
  28165. * Default : `false`
  28166. */
  28167. get expandable(): boolean;
  28168. /**
  28169. * Gets if the SPS supports the Multi Materials
  28170. */
  28171. get multimaterialEnabled(): boolean;
  28172. /**
  28173. * Gets if the SPS uses the model materials for its own multimaterial.
  28174. */
  28175. get useModelMaterial(): boolean;
  28176. /**
  28177. * The SPS used material array.
  28178. */
  28179. get materials(): Material[];
  28180. /**
  28181. * Sets the SPS MultiMaterial from the passed materials.
  28182. * Note : the passed array is internally copied and not used then by reference.
  28183. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28184. */
  28185. setMultiMaterial(materials: Material[]): void;
  28186. /**
  28187. * The SPS computed multimaterial object
  28188. */
  28189. get multimaterial(): MultiMaterial;
  28190. set multimaterial(mm: MultiMaterial);
  28191. /**
  28192. * If the subMeshes must be updated on the next call to setParticles()
  28193. */
  28194. get autoUpdateSubMeshes(): boolean;
  28195. set autoUpdateSubMeshes(val: boolean);
  28196. /**
  28197. * This function does nothing. It may be overwritten to set all the particle first values.
  28198. * The SPS doesn't call this function, you may have to call it by your own.
  28199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28200. */
  28201. initParticles(): void;
  28202. /**
  28203. * This function does nothing. It may be overwritten to recycle a particle.
  28204. * The SPS doesn't call this function, you may have to call it by your own.
  28205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28206. * @param particle The particle to recycle
  28207. * @returns the recycled particle
  28208. */
  28209. recycleParticle(particle: SolidParticle): SolidParticle;
  28210. /**
  28211. * Updates a particle : this function should be overwritten by the user.
  28212. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28213. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28214. * @example : just set a particle position or velocity and recycle conditions
  28215. * @param particle The particle to update
  28216. * @returns the updated particle
  28217. */
  28218. updateParticle(particle: SolidParticle): SolidParticle;
  28219. /**
  28220. * Updates a vertex of a particle : it can be overwritten by the user.
  28221. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28222. * @param particle the current particle
  28223. * @param vertex the current index of the current particle
  28224. * @param pt the index of the current vertex in the particle shape
  28225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28226. * @example : just set a vertex particle position
  28227. * @returns the updated vertex
  28228. */
  28229. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28230. /**
  28231. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28232. * This does nothing and may be overwritten by the user.
  28233. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28234. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28235. * @param update the boolean update value actually passed to setParticles()
  28236. */
  28237. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28238. /**
  28239. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28240. * This will be passed three parameters.
  28241. * This does nothing and may be overwritten by the user.
  28242. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28243. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28244. * @param update the boolean update value actually passed to setParticles()
  28245. */
  28246. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28247. }
  28248. }
  28249. declare module "babylonjs/Particles/solidParticle" {
  28250. import { Nullable } from "babylonjs/types";
  28251. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28252. import { Color4 } from "babylonjs/Maths/math.color";
  28253. import { Mesh } from "babylonjs/Meshes/mesh";
  28254. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28255. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28256. import { Plane } from "babylonjs/Maths/math.plane";
  28257. import { Material } from "babylonjs/Materials/material";
  28258. /**
  28259. * Represents one particle of a solid particle system.
  28260. */
  28261. export class SolidParticle {
  28262. /**
  28263. * particle global index
  28264. */
  28265. idx: number;
  28266. /**
  28267. * particle identifier
  28268. */
  28269. id: number;
  28270. /**
  28271. * The color of the particle
  28272. */
  28273. color: Nullable<Color4>;
  28274. /**
  28275. * The world space position of the particle.
  28276. */
  28277. position: Vector3;
  28278. /**
  28279. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28280. */
  28281. rotation: Vector3;
  28282. /**
  28283. * The world space rotation quaternion of the particle.
  28284. */
  28285. rotationQuaternion: Nullable<Quaternion>;
  28286. /**
  28287. * The scaling of the particle.
  28288. */
  28289. scaling: Vector3;
  28290. /**
  28291. * The uvs of the particle.
  28292. */
  28293. uvs: Vector4;
  28294. /**
  28295. * The current speed of the particle.
  28296. */
  28297. velocity: Vector3;
  28298. /**
  28299. * The pivot point in the particle local space.
  28300. */
  28301. pivot: Vector3;
  28302. /**
  28303. * Must the particle be translated from its pivot point in its local space ?
  28304. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28305. * Default : false
  28306. */
  28307. translateFromPivot: boolean;
  28308. /**
  28309. * Is the particle active or not ?
  28310. */
  28311. alive: boolean;
  28312. /**
  28313. * Is the particle visible or not ?
  28314. */
  28315. isVisible: boolean;
  28316. /**
  28317. * Index of this particle in the global "positions" array (Internal use)
  28318. * @hidden
  28319. */
  28320. _pos: number;
  28321. /**
  28322. * @hidden Index of this particle in the global "indices" array (Internal use)
  28323. */
  28324. _ind: number;
  28325. /**
  28326. * @hidden ModelShape of this particle (Internal use)
  28327. */
  28328. _model: ModelShape;
  28329. /**
  28330. * ModelShape id of this particle
  28331. */
  28332. shapeId: number;
  28333. /**
  28334. * Index of the particle in its shape id
  28335. */
  28336. idxInShape: number;
  28337. /**
  28338. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28339. */
  28340. _modelBoundingInfo: BoundingInfo;
  28341. /**
  28342. * @hidden Particle BoundingInfo object (Internal use)
  28343. */
  28344. _boundingInfo: BoundingInfo;
  28345. /**
  28346. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28347. */
  28348. _sps: SolidParticleSystem;
  28349. /**
  28350. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28351. */
  28352. _stillInvisible: boolean;
  28353. /**
  28354. * @hidden Last computed particle rotation matrix
  28355. */
  28356. _rotationMatrix: number[];
  28357. /**
  28358. * Parent particle Id, if any.
  28359. * Default null.
  28360. */
  28361. parentId: Nullable<number>;
  28362. /**
  28363. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28364. */
  28365. materialIndex: Nullable<number>;
  28366. /**
  28367. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28368. * The possible values are :
  28369. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28370. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28372. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28373. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28374. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28375. * */
  28376. cullingStrategy: number;
  28377. /**
  28378. * @hidden Internal global position in the SPS.
  28379. */
  28380. _globalPosition: Vector3;
  28381. /**
  28382. * Creates a Solid Particle object.
  28383. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28384. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28385. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28386. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28387. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28388. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28389. * @param shapeId (integer) is the model shape identifier in the SPS.
  28390. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28391. * @param sps defines the sps it is associated to
  28392. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28393. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28394. */
  28395. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28396. /**
  28397. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28398. * @param target the particle target
  28399. * @returns the current particle
  28400. */
  28401. copyToRef(target: SolidParticle): SolidParticle;
  28402. /**
  28403. * Legacy support, changed scale to scaling
  28404. */
  28405. get scale(): Vector3;
  28406. /**
  28407. * Legacy support, changed scale to scaling
  28408. */
  28409. set scale(scale: Vector3);
  28410. /**
  28411. * Legacy support, changed quaternion to rotationQuaternion
  28412. */
  28413. get quaternion(): Nullable<Quaternion>;
  28414. /**
  28415. * Legacy support, changed quaternion to rotationQuaternion
  28416. */
  28417. set quaternion(q: Nullable<Quaternion>);
  28418. /**
  28419. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28420. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28421. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28422. * @returns true if it intersects
  28423. */
  28424. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28425. /**
  28426. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28427. * A particle is in the frustum if its bounding box intersects the frustum
  28428. * @param frustumPlanes defines the frustum to test
  28429. * @returns true if the particle is in the frustum planes
  28430. */
  28431. isInFrustum(frustumPlanes: Plane[]): boolean;
  28432. /**
  28433. * get the rotation matrix of the particle
  28434. * @hidden
  28435. */
  28436. getRotationMatrix(m: Matrix): void;
  28437. }
  28438. /**
  28439. * Represents the shape of the model used by one particle of a solid particle system.
  28440. * SPS internal tool, don't use it manually.
  28441. */
  28442. export class ModelShape {
  28443. /**
  28444. * The shape id
  28445. * @hidden
  28446. */
  28447. shapeID: number;
  28448. /**
  28449. * flat array of model positions (internal use)
  28450. * @hidden
  28451. */
  28452. _shape: Vector3[];
  28453. /**
  28454. * flat array of model UVs (internal use)
  28455. * @hidden
  28456. */
  28457. _shapeUV: number[];
  28458. /**
  28459. * color array of the model
  28460. * @hidden
  28461. */
  28462. _shapeColors: number[];
  28463. /**
  28464. * indices array of the model
  28465. * @hidden
  28466. */
  28467. _indices: number[];
  28468. /**
  28469. * normals array of the model
  28470. * @hidden
  28471. */
  28472. _normals: number[];
  28473. /**
  28474. * length of the shape in the model indices array (internal use)
  28475. * @hidden
  28476. */
  28477. _indicesLength: number;
  28478. /**
  28479. * Custom position function (internal use)
  28480. * @hidden
  28481. */
  28482. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28483. /**
  28484. * Custom vertex function (internal use)
  28485. * @hidden
  28486. */
  28487. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28488. /**
  28489. * Model material (internal use)
  28490. * @hidden
  28491. */
  28492. _material: Nullable<Material>;
  28493. /**
  28494. * 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.
  28495. * SPS internal tool, don't use it manually.
  28496. * @hidden
  28497. */
  28498. 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>);
  28499. }
  28500. /**
  28501. * Represents a Depth Sorted Particle in the solid particle system.
  28502. * @hidden
  28503. */
  28504. export class DepthSortedParticle {
  28505. /**
  28506. * Index of the particle in the "indices" array
  28507. */
  28508. ind: number;
  28509. /**
  28510. * Length of the particle shape in the "indices" array
  28511. */
  28512. indicesLength: number;
  28513. /**
  28514. * Squared distance from the particle to the camera
  28515. */
  28516. sqDistance: number;
  28517. /**
  28518. * Material index when used with MultiMaterials
  28519. */
  28520. materialIndex: number;
  28521. /**
  28522. * Creates a new sorted particle
  28523. * @param materialIndex
  28524. */
  28525. constructor(ind: number, indLength: number, materialIndex: number);
  28526. }
  28527. }
  28528. declare module "babylonjs/Collisions/meshCollisionData" {
  28529. import { Collider } from "babylonjs/Collisions/collider";
  28530. import { Vector3 } from "babylonjs/Maths/math.vector";
  28531. import { Nullable } from "babylonjs/types";
  28532. import { Observer } from "babylonjs/Misc/observable";
  28533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28534. /**
  28535. * @hidden
  28536. */
  28537. export class _MeshCollisionData {
  28538. _checkCollisions: boolean;
  28539. _collisionMask: number;
  28540. _collisionGroup: number;
  28541. _collider: Nullable<Collider>;
  28542. _oldPositionForCollisions: Vector3;
  28543. _diffPositionForCollisions: Vector3;
  28544. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28545. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28546. }
  28547. }
  28548. declare module "babylonjs/Meshes/abstractMesh" {
  28549. import { Observable } from "babylonjs/Misc/observable";
  28550. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28551. import { Camera } from "babylonjs/Cameras/camera";
  28552. import { Scene, IDisposable } from "babylonjs/scene";
  28553. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28554. import { Node } from "babylonjs/node";
  28555. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28558. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28559. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28560. import { Material } from "babylonjs/Materials/material";
  28561. import { Light } from "babylonjs/Lights/light";
  28562. import { Skeleton } from "babylonjs/Bones/skeleton";
  28563. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28564. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28565. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28566. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28567. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28568. import { Plane } from "babylonjs/Maths/math.plane";
  28569. import { Ray } from "babylonjs/Culling/ray";
  28570. import { Collider } from "babylonjs/Collisions/collider";
  28571. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28572. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28573. /** @hidden */
  28574. class _FacetDataStorage {
  28575. facetPositions: Vector3[];
  28576. facetNormals: Vector3[];
  28577. facetPartitioning: number[][];
  28578. facetNb: number;
  28579. partitioningSubdivisions: number;
  28580. partitioningBBoxRatio: number;
  28581. facetDataEnabled: boolean;
  28582. facetParameters: any;
  28583. bbSize: Vector3;
  28584. subDiv: {
  28585. max: number;
  28586. X: number;
  28587. Y: number;
  28588. Z: number;
  28589. };
  28590. facetDepthSort: boolean;
  28591. facetDepthSortEnabled: boolean;
  28592. depthSortedIndices: IndicesArray;
  28593. depthSortedFacets: {
  28594. ind: number;
  28595. sqDistance: number;
  28596. }[];
  28597. facetDepthSortFunction: (f1: {
  28598. ind: number;
  28599. sqDistance: number;
  28600. }, f2: {
  28601. ind: number;
  28602. sqDistance: number;
  28603. }) => number;
  28604. facetDepthSortFrom: Vector3;
  28605. facetDepthSortOrigin: Vector3;
  28606. invertedMatrix: Matrix;
  28607. }
  28608. /**
  28609. * @hidden
  28610. **/
  28611. class _InternalAbstractMeshDataInfo {
  28612. _hasVertexAlpha: boolean;
  28613. _useVertexColors: boolean;
  28614. _numBoneInfluencers: number;
  28615. _applyFog: boolean;
  28616. _receiveShadows: boolean;
  28617. _facetData: _FacetDataStorage;
  28618. _visibility: number;
  28619. _skeleton: Nullable<Skeleton>;
  28620. _layerMask: number;
  28621. _computeBonesUsingShaders: boolean;
  28622. _isActive: boolean;
  28623. _onlyForInstances: boolean;
  28624. _isActiveIntermediate: boolean;
  28625. _onlyForInstancesIntermediate: boolean;
  28626. _actAsRegularMesh: boolean;
  28627. }
  28628. /**
  28629. * Class used to store all common mesh properties
  28630. */
  28631. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28632. /** No occlusion */
  28633. static OCCLUSION_TYPE_NONE: number;
  28634. /** Occlusion set to optimisitic */
  28635. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28636. /** Occlusion set to strict */
  28637. static OCCLUSION_TYPE_STRICT: number;
  28638. /** Use an accurante occlusion algorithm */
  28639. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28640. /** Use a conservative occlusion algorithm */
  28641. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28642. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28643. * Test order :
  28644. * Is the bounding sphere outside the frustum ?
  28645. * If not, are the bounding box vertices outside the frustum ?
  28646. * It not, then the cullable object is in the frustum.
  28647. */
  28648. static readonly CULLINGSTRATEGY_STANDARD: number;
  28649. /** Culling strategy : Bounding Sphere Only.
  28650. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28651. * It's also less accurate than the standard because some not visible objects can still be selected.
  28652. * Test : is the bounding sphere outside the frustum ?
  28653. * If not, then the cullable object is in the frustum.
  28654. */
  28655. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28656. /** Culling strategy : Optimistic Inclusion.
  28657. * This in an inclusion test first, then the standard exclusion test.
  28658. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28659. * 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.
  28660. * Anyway, it's as accurate as the standard strategy.
  28661. * Test :
  28662. * Is the cullable object bounding sphere center in the frustum ?
  28663. * If not, apply the default culling strategy.
  28664. */
  28665. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28666. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28667. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28668. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28669. * 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.
  28670. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28671. * Test :
  28672. * Is the cullable object bounding sphere center in the frustum ?
  28673. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28674. */
  28675. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28676. /**
  28677. * No billboard
  28678. */
  28679. static get BILLBOARDMODE_NONE(): number;
  28680. /** Billboard on X axis */
  28681. static get BILLBOARDMODE_X(): number;
  28682. /** Billboard on Y axis */
  28683. static get BILLBOARDMODE_Y(): number;
  28684. /** Billboard on Z axis */
  28685. static get BILLBOARDMODE_Z(): number;
  28686. /** Billboard on all axes */
  28687. static get BILLBOARDMODE_ALL(): number;
  28688. /** Billboard on using position instead of orientation */
  28689. static get BILLBOARDMODE_USE_POSITION(): number;
  28690. /** @hidden */
  28691. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28692. /**
  28693. * The culling strategy to use to check whether the mesh must be rendered or not.
  28694. * This value can be changed at any time and will be used on the next render mesh selection.
  28695. * The possible values are :
  28696. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28697. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28700. * Please read each static variable documentation to get details about the culling process.
  28701. * */
  28702. cullingStrategy: number;
  28703. /**
  28704. * Gets the number of facets in the mesh
  28705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28706. */
  28707. get facetNb(): number;
  28708. /**
  28709. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28711. */
  28712. get partitioningSubdivisions(): number;
  28713. set partitioningSubdivisions(nb: number);
  28714. /**
  28715. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28716. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28718. */
  28719. get partitioningBBoxRatio(): number;
  28720. set partitioningBBoxRatio(ratio: number);
  28721. /**
  28722. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28723. * Works only for updatable meshes.
  28724. * Doesn't work with multi-materials
  28725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28726. */
  28727. get mustDepthSortFacets(): boolean;
  28728. set mustDepthSortFacets(sort: boolean);
  28729. /**
  28730. * The location (Vector3) where the facet depth sort must be computed from.
  28731. * By default, the active camera position.
  28732. * Used only when facet depth sort is enabled
  28733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28734. */
  28735. get facetDepthSortFrom(): Vector3;
  28736. set facetDepthSortFrom(location: Vector3);
  28737. /**
  28738. * gets a boolean indicating if facetData is enabled
  28739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28740. */
  28741. get isFacetDataEnabled(): boolean;
  28742. /** @hidden */
  28743. _updateNonUniformScalingState(value: boolean): boolean;
  28744. /**
  28745. * An event triggered when this mesh collides with another one
  28746. */
  28747. onCollideObservable: Observable<AbstractMesh>;
  28748. /** Set a function to call when this mesh collides with another one */
  28749. set onCollide(callback: () => void);
  28750. /**
  28751. * An event triggered when the collision's position changes
  28752. */
  28753. onCollisionPositionChangeObservable: Observable<Vector3>;
  28754. /** Set a function to call when the collision's position changes */
  28755. set onCollisionPositionChange(callback: () => void);
  28756. /**
  28757. * An event triggered when material is changed
  28758. */
  28759. onMaterialChangedObservable: Observable<AbstractMesh>;
  28760. /**
  28761. * Gets or sets the orientation for POV movement & rotation
  28762. */
  28763. definedFacingForward: boolean;
  28764. /** @hidden */
  28765. _occlusionQuery: Nullable<WebGLQuery>;
  28766. /** @hidden */
  28767. _renderingGroup: Nullable<RenderingGroup>;
  28768. /**
  28769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28770. */
  28771. get visibility(): number;
  28772. /**
  28773. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28774. */
  28775. set visibility(value: number);
  28776. /** Gets or sets the alpha index used to sort transparent meshes
  28777. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28778. */
  28779. alphaIndex: number;
  28780. /**
  28781. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28782. */
  28783. isVisible: boolean;
  28784. /**
  28785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28786. */
  28787. isPickable: boolean;
  28788. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28789. showSubMeshesBoundingBox: boolean;
  28790. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28792. */
  28793. isBlocker: boolean;
  28794. /**
  28795. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28796. */
  28797. enablePointerMoveEvents: boolean;
  28798. /**
  28799. * Specifies the rendering group id for this mesh (0 by default)
  28800. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28801. */
  28802. renderingGroupId: number;
  28803. private _material;
  28804. /** Gets or sets current material */
  28805. get material(): Nullable<Material>;
  28806. set material(value: Nullable<Material>);
  28807. /**
  28808. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28809. * @see http://doc.babylonjs.com/babylon101/shadows
  28810. */
  28811. get receiveShadows(): boolean;
  28812. set receiveShadows(value: boolean);
  28813. /** Defines color to use when rendering outline */
  28814. outlineColor: Color3;
  28815. /** Define width to use when rendering outline */
  28816. outlineWidth: number;
  28817. /** Defines color to use when rendering overlay */
  28818. overlayColor: Color3;
  28819. /** Defines alpha to use when rendering overlay */
  28820. overlayAlpha: number;
  28821. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28822. get hasVertexAlpha(): boolean;
  28823. set hasVertexAlpha(value: boolean);
  28824. /** 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) */
  28825. get useVertexColors(): boolean;
  28826. set useVertexColors(value: boolean);
  28827. /**
  28828. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28829. */
  28830. get computeBonesUsingShaders(): boolean;
  28831. set computeBonesUsingShaders(value: boolean);
  28832. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28833. get numBoneInfluencers(): number;
  28834. set numBoneInfluencers(value: number);
  28835. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28836. get applyFog(): boolean;
  28837. set applyFog(value: boolean);
  28838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28839. useOctreeForRenderingSelection: boolean;
  28840. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28841. useOctreeForPicking: boolean;
  28842. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28843. useOctreeForCollisions: boolean;
  28844. /**
  28845. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28846. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28847. */
  28848. get layerMask(): number;
  28849. set layerMask(value: number);
  28850. /**
  28851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28852. */
  28853. alwaysSelectAsActiveMesh: boolean;
  28854. /**
  28855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28856. */
  28857. doNotSyncBoundingInfo: boolean;
  28858. /**
  28859. * Gets or sets the current action manager
  28860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28861. */
  28862. actionManager: Nullable<AbstractActionManager>;
  28863. private _meshCollisionData;
  28864. /**
  28865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28867. */
  28868. ellipsoid: Vector3;
  28869. /**
  28870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28872. */
  28873. ellipsoidOffset: Vector3;
  28874. /**
  28875. * Gets or sets a collision mask used to mask collisions (default is -1).
  28876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28877. */
  28878. get collisionMask(): number;
  28879. set collisionMask(mask: number);
  28880. /**
  28881. * Gets or sets the current collision group mask (-1 by default).
  28882. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28883. */
  28884. get collisionGroup(): number;
  28885. set collisionGroup(mask: number);
  28886. /**
  28887. * Defines edge width used when edgesRenderer is enabled
  28888. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28889. */
  28890. edgesWidth: number;
  28891. /**
  28892. * Defines edge color used when edgesRenderer is enabled
  28893. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28894. */
  28895. edgesColor: Color4;
  28896. /** @hidden */
  28897. _edgesRenderer: Nullable<IEdgesRenderer>;
  28898. /** @hidden */
  28899. _masterMesh: Nullable<AbstractMesh>;
  28900. /** @hidden */
  28901. _boundingInfo: Nullable<BoundingInfo>;
  28902. /** @hidden */
  28903. _renderId: number;
  28904. /**
  28905. * Gets or sets the list of subMeshes
  28906. * @see http://doc.babylonjs.com/how_to/multi_materials
  28907. */
  28908. subMeshes: SubMesh[];
  28909. /** @hidden */
  28910. _intersectionsInProgress: AbstractMesh[];
  28911. /** @hidden */
  28912. _unIndexed: boolean;
  28913. /** @hidden */
  28914. _lightSources: Light[];
  28915. /** Gets the list of lights affecting that mesh */
  28916. get lightSources(): Light[];
  28917. /** @hidden */
  28918. get _positions(): Nullable<Vector3[]>;
  28919. /** @hidden */
  28920. _waitingData: {
  28921. lods: Nullable<any>;
  28922. actions: Nullable<any>;
  28923. freezeWorldMatrix: Nullable<boolean>;
  28924. };
  28925. /** @hidden */
  28926. _bonesTransformMatrices: Nullable<Float32Array>;
  28927. /** @hidden */
  28928. _transformMatrixTexture: Nullable<RawTexture>;
  28929. /**
  28930. * Gets or sets a skeleton to apply skining transformations
  28931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28932. */
  28933. set skeleton(value: Nullable<Skeleton>);
  28934. get skeleton(): Nullable<Skeleton>;
  28935. /**
  28936. * An event triggered when the mesh is rebuilt.
  28937. */
  28938. onRebuildObservable: Observable<AbstractMesh>;
  28939. /**
  28940. * Creates a new AbstractMesh
  28941. * @param name defines the name of the mesh
  28942. * @param scene defines the hosting scene
  28943. */
  28944. constructor(name: string, scene?: Nullable<Scene>);
  28945. /**
  28946. * Returns the string "AbstractMesh"
  28947. * @returns "AbstractMesh"
  28948. */
  28949. getClassName(): string;
  28950. /**
  28951. * Gets a string representation of the current mesh
  28952. * @param fullDetails defines a boolean indicating if full details must be included
  28953. * @returns a string representation of the current mesh
  28954. */
  28955. toString(fullDetails?: boolean): string;
  28956. /**
  28957. * @hidden
  28958. */
  28959. protected _getEffectiveParent(): Nullable<Node>;
  28960. /** @hidden */
  28961. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28962. /** @hidden */
  28963. _rebuild(): void;
  28964. /** @hidden */
  28965. _resyncLightSources(): void;
  28966. /** @hidden */
  28967. _resyncLightSource(light: Light): void;
  28968. /** @hidden */
  28969. _unBindEffect(): void;
  28970. /** @hidden */
  28971. _removeLightSource(light: Light, dispose: boolean): void;
  28972. private _markSubMeshesAsDirty;
  28973. /** @hidden */
  28974. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28975. /** @hidden */
  28976. _markSubMeshesAsAttributesDirty(): void;
  28977. /** @hidden */
  28978. _markSubMeshesAsMiscDirty(): void;
  28979. /**
  28980. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28981. */
  28982. get scaling(): Vector3;
  28983. set scaling(newScaling: Vector3);
  28984. /**
  28985. * Returns true if the mesh is blocked. Implemented by child classes
  28986. */
  28987. get isBlocked(): boolean;
  28988. /**
  28989. * Returns the mesh itself by default. Implemented by child classes
  28990. * @param camera defines the camera to use to pick the right LOD level
  28991. * @returns the currentAbstractMesh
  28992. */
  28993. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28994. /**
  28995. * Returns 0 by default. Implemented by child classes
  28996. * @returns an integer
  28997. */
  28998. getTotalVertices(): number;
  28999. /**
  29000. * Returns a positive integer : the total number of indices in this mesh geometry.
  29001. * @returns the numner of indices or zero if the mesh has no geometry.
  29002. */
  29003. getTotalIndices(): number;
  29004. /**
  29005. * Returns null by default. Implemented by child classes
  29006. * @returns null
  29007. */
  29008. getIndices(): Nullable<IndicesArray>;
  29009. /**
  29010. * Returns the array of the requested vertex data kind. Implemented by child classes
  29011. * @param kind defines the vertex data kind to use
  29012. * @returns null
  29013. */
  29014. getVerticesData(kind: string): Nullable<FloatArray>;
  29015. /**
  29016. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29017. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29018. * Note that a new underlying VertexBuffer object is created each call.
  29019. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29020. * @param kind defines vertex data kind:
  29021. * * VertexBuffer.PositionKind
  29022. * * VertexBuffer.UVKind
  29023. * * VertexBuffer.UV2Kind
  29024. * * VertexBuffer.UV3Kind
  29025. * * VertexBuffer.UV4Kind
  29026. * * VertexBuffer.UV5Kind
  29027. * * VertexBuffer.UV6Kind
  29028. * * VertexBuffer.ColorKind
  29029. * * VertexBuffer.MatricesIndicesKind
  29030. * * VertexBuffer.MatricesIndicesExtraKind
  29031. * * VertexBuffer.MatricesWeightsKind
  29032. * * VertexBuffer.MatricesWeightsExtraKind
  29033. * @param data defines the data source
  29034. * @param updatable defines if the data must be flagged as updatable (or static)
  29035. * @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
  29036. * @returns the current mesh
  29037. */
  29038. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29039. /**
  29040. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29041. * If the mesh has no geometry, it is simply returned as it is.
  29042. * @param kind defines vertex data kind:
  29043. * * VertexBuffer.PositionKind
  29044. * * VertexBuffer.UVKind
  29045. * * VertexBuffer.UV2Kind
  29046. * * VertexBuffer.UV3Kind
  29047. * * VertexBuffer.UV4Kind
  29048. * * VertexBuffer.UV5Kind
  29049. * * VertexBuffer.UV6Kind
  29050. * * VertexBuffer.ColorKind
  29051. * * VertexBuffer.MatricesIndicesKind
  29052. * * VertexBuffer.MatricesIndicesExtraKind
  29053. * * VertexBuffer.MatricesWeightsKind
  29054. * * VertexBuffer.MatricesWeightsExtraKind
  29055. * @param data defines the data source
  29056. * @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
  29057. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29058. * @returns the current mesh
  29059. */
  29060. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29061. /**
  29062. * Sets the mesh indices,
  29063. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29064. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29065. * @param totalVertices Defines the total number of vertices
  29066. * @returns the current mesh
  29067. */
  29068. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29069. /**
  29070. * Gets a boolean indicating if specific vertex data is present
  29071. * @param kind defines the vertex data kind to use
  29072. * @returns true is data kind is present
  29073. */
  29074. isVerticesDataPresent(kind: string): boolean;
  29075. /**
  29076. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29077. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29078. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29079. * @returns a BoundingInfo
  29080. */
  29081. getBoundingInfo(): BoundingInfo;
  29082. /**
  29083. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29084. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29085. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29086. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29087. * @returns the current mesh
  29088. */
  29089. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29090. /**
  29091. * Overwrite the current bounding info
  29092. * @param boundingInfo defines the new bounding info
  29093. * @returns the current mesh
  29094. */
  29095. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29096. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29097. get useBones(): boolean;
  29098. /** @hidden */
  29099. _preActivate(): void;
  29100. /** @hidden */
  29101. _preActivateForIntermediateRendering(renderId: number): void;
  29102. /** @hidden */
  29103. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29104. /** @hidden */
  29105. _postActivate(): void;
  29106. /** @hidden */
  29107. _freeze(): void;
  29108. /** @hidden */
  29109. _unFreeze(): void;
  29110. /**
  29111. * Gets the current world matrix
  29112. * @returns a Matrix
  29113. */
  29114. getWorldMatrix(): Matrix;
  29115. /** @hidden */
  29116. _getWorldMatrixDeterminant(): number;
  29117. /**
  29118. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29119. */
  29120. get isAnInstance(): boolean;
  29121. /**
  29122. * Gets a boolean indicating if this mesh has instances
  29123. */
  29124. get hasInstances(): boolean;
  29125. /**
  29126. * Perform relative position change from the point of view of behind the front of the mesh.
  29127. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29128. * Supports definition of mesh facing forward or backward
  29129. * @param amountRight defines the distance on the right axis
  29130. * @param amountUp defines the distance on the up axis
  29131. * @param amountForward defines the distance on the forward axis
  29132. * @returns the current mesh
  29133. */
  29134. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29135. /**
  29136. * Calculate relative position change from the point of view of behind the front of the mesh.
  29137. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29138. * Supports definition of mesh facing forward or backward
  29139. * @param amountRight defines the distance on the right axis
  29140. * @param amountUp defines the distance on the up axis
  29141. * @param amountForward defines the distance on the forward axis
  29142. * @returns the new displacement vector
  29143. */
  29144. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29145. /**
  29146. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29147. * Supports definition of mesh facing forward or backward
  29148. * @param flipBack defines the flip
  29149. * @param twirlClockwise defines the twirl
  29150. * @param tiltRight defines the tilt
  29151. * @returns the current mesh
  29152. */
  29153. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29154. /**
  29155. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29156. * Supports definition of mesh facing forward or backward.
  29157. * @param flipBack defines the flip
  29158. * @param twirlClockwise defines the twirl
  29159. * @param tiltRight defines the tilt
  29160. * @returns the new rotation vector
  29161. */
  29162. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29163. /**
  29164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29165. * This means the mesh underlying bounding box and sphere are recomputed.
  29166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29167. * @returns the current mesh
  29168. */
  29169. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29170. /** @hidden */
  29171. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29172. /** @hidden */
  29173. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29174. /** @hidden */
  29175. _updateBoundingInfo(): AbstractMesh;
  29176. /** @hidden */
  29177. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29178. /** @hidden */
  29179. protected _afterComputeWorldMatrix(): void;
  29180. /** @hidden */
  29181. get _effectiveMesh(): AbstractMesh;
  29182. /**
  29183. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29184. * A mesh is in the frustum if its bounding box intersects the frustum
  29185. * @param frustumPlanes defines the frustum to test
  29186. * @returns true if the mesh is in the frustum planes
  29187. */
  29188. isInFrustum(frustumPlanes: Plane[]): boolean;
  29189. /**
  29190. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29191. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29192. * @param frustumPlanes defines the frustum to test
  29193. * @returns true if the mesh is completely in the frustum planes
  29194. */
  29195. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29196. /**
  29197. * True if the mesh intersects another mesh or a SolidParticle object
  29198. * @param mesh defines a target mesh or SolidParticle to test
  29199. * @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)
  29200. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29201. * @returns true if there is an intersection
  29202. */
  29203. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29204. /**
  29205. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29206. * @param point defines the point to test
  29207. * @returns true if there is an intersection
  29208. */
  29209. intersectsPoint(point: Vector3): boolean;
  29210. /**
  29211. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29213. */
  29214. get checkCollisions(): boolean;
  29215. set checkCollisions(collisionEnabled: boolean);
  29216. /**
  29217. * Gets Collider object used to compute collisions (not physics)
  29218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29219. */
  29220. get collider(): Nullable<Collider>;
  29221. /**
  29222. * Move the mesh using collision engine
  29223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29224. * @param displacement defines the requested displacement vector
  29225. * @returns the current mesh
  29226. */
  29227. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29228. private _onCollisionPositionChange;
  29229. /** @hidden */
  29230. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29231. /** @hidden */
  29232. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29233. /** @hidden */
  29234. _checkCollision(collider: Collider): AbstractMesh;
  29235. /** @hidden */
  29236. _generatePointsArray(): boolean;
  29237. /**
  29238. * Checks if the passed Ray intersects with the mesh
  29239. * @param ray defines the ray to use
  29240. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29242. * @returns the picking info
  29243. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29244. */
  29245. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29246. /**
  29247. * Clones the current mesh
  29248. * @param name defines the mesh name
  29249. * @param newParent defines the new mesh parent
  29250. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29251. * @returns the new mesh
  29252. */
  29253. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29254. /**
  29255. * Disposes all the submeshes of the current meshnp
  29256. * @returns the current mesh
  29257. */
  29258. releaseSubMeshes(): AbstractMesh;
  29259. /**
  29260. * Releases resources associated with this abstract mesh.
  29261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29263. */
  29264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29265. /**
  29266. * Adds the passed mesh as a child to the current mesh
  29267. * @param mesh defines the child mesh
  29268. * @returns the current mesh
  29269. */
  29270. addChild(mesh: AbstractMesh): AbstractMesh;
  29271. /**
  29272. * Removes the passed mesh from the current mesh children list
  29273. * @param mesh defines the child mesh
  29274. * @returns the current mesh
  29275. */
  29276. removeChild(mesh: AbstractMesh): AbstractMesh;
  29277. /** @hidden */
  29278. private _initFacetData;
  29279. /**
  29280. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29281. * This method can be called within the render loop.
  29282. * 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
  29283. * @returns the current mesh
  29284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29285. */
  29286. updateFacetData(): AbstractMesh;
  29287. /**
  29288. * Returns the facetLocalNormals array.
  29289. * The normals are expressed in the mesh local spac
  29290. * @returns an array of Vector3
  29291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29292. */
  29293. getFacetLocalNormals(): Vector3[];
  29294. /**
  29295. * Returns the facetLocalPositions array.
  29296. * The facet positions are expressed in the mesh local space
  29297. * @returns an array of Vector3
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29299. */
  29300. getFacetLocalPositions(): Vector3[];
  29301. /**
  29302. * Returns the facetLocalPartioning array
  29303. * @returns an array of array of numbers
  29304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29305. */
  29306. getFacetLocalPartitioning(): number[][];
  29307. /**
  29308. * Returns the i-th facet position in the world system.
  29309. * This method allocates a new Vector3 per call
  29310. * @param i defines the facet index
  29311. * @returns a new Vector3
  29312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29313. */
  29314. getFacetPosition(i: number): Vector3;
  29315. /**
  29316. * Sets the reference Vector3 with the i-th facet position in the world system
  29317. * @param i defines the facet index
  29318. * @param ref defines the target vector
  29319. * @returns the current mesh
  29320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29321. */
  29322. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29323. /**
  29324. * Returns the i-th facet normal in the world system.
  29325. * This method allocates a new Vector3 per call
  29326. * @param i defines the facet index
  29327. * @returns a new Vector3
  29328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29329. */
  29330. getFacetNormal(i: number): Vector3;
  29331. /**
  29332. * Sets the reference Vector3 with the i-th facet normal in the world system
  29333. * @param i defines the facet index
  29334. * @param ref defines the target vector
  29335. * @returns the current mesh
  29336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29337. */
  29338. getFacetNormalToRef(i: number, ref: Vector3): this;
  29339. /**
  29340. * 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)
  29341. * @param x defines x coordinate
  29342. * @param y defines y coordinate
  29343. * @param z defines z coordinate
  29344. * @returns the array of facet indexes
  29345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29346. */
  29347. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29348. /**
  29349. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29350. * @param projected sets as the (x,y,z) world projection on the facet
  29351. * @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
  29352. * @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
  29353. * @param x defines x coordinate
  29354. * @param y defines y coordinate
  29355. * @param z defines z coordinate
  29356. * @returns the face index if found (or null instead)
  29357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29358. */
  29359. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29360. /**
  29361. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29362. * @param projected sets as the (x,y,z) local projection on the facet
  29363. * @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
  29364. * @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
  29365. * @param x defines x coordinate
  29366. * @param y defines y coordinate
  29367. * @param z defines z coordinate
  29368. * @returns the face index if found (or null instead)
  29369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29370. */
  29371. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29372. /**
  29373. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29374. * @returns the parameters
  29375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29376. */
  29377. getFacetDataParameters(): any;
  29378. /**
  29379. * Disables the feature FacetData and frees the related memory
  29380. * @returns the current mesh
  29381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29382. */
  29383. disableFacetData(): AbstractMesh;
  29384. /**
  29385. * Updates the AbstractMesh indices array
  29386. * @param indices defines the data source
  29387. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29388. * @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)
  29389. * @returns the current mesh
  29390. */
  29391. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29392. /**
  29393. * Creates new normals data for the mesh
  29394. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29395. * @returns the current mesh
  29396. */
  29397. createNormals(updatable: boolean): AbstractMesh;
  29398. /**
  29399. * Align the mesh with a normal
  29400. * @param normal defines the normal to use
  29401. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29402. * @returns the current mesh
  29403. */
  29404. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29405. /** @hidden */
  29406. _checkOcclusionQuery(): boolean;
  29407. /**
  29408. * Disables the mesh edge rendering mode
  29409. * @returns the currentAbstractMesh
  29410. */
  29411. disableEdgesRendering(): AbstractMesh;
  29412. /**
  29413. * Enables the edge rendering mode on the mesh.
  29414. * This mode makes the mesh edges visible
  29415. * @param epsilon defines the maximal distance between two angles to detect a face
  29416. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29417. * @returns the currentAbstractMesh
  29418. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29419. */
  29420. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29421. }
  29422. }
  29423. declare module "babylonjs/Actions/actionEvent" {
  29424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29425. import { Nullable } from "babylonjs/types";
  29426. import { Sprite } from "babylonjs/Sprites/sprite";
  29427. import { Scene } from "babylonjs/scene";
  29428. import { Vector2 } from "babylonjs/Maths/math.vector";
  29429. /**
  29430. * Interface used to define ActionEvent
  29431. */
  29432. export interface IActionEvent {
  29433. /** The mesh or sprite that triggered the action */
  29434. source: any;
  29435. /** The X mouse cursor position at the time of the event */
  29436. pointerX: number;
  29437. /** The Y mouse cursor position at the time of the event */
  29438. pointerY: number;
  29439. /** The mesh that is currently pointed at (can be null) */
  29440. meshUnderPointer: Nullable<AbstractMesh>;
  29441. /** the original (browser) event that triggered the ActionEvent */
  29442. sourceEvent?: any;
  29443. /** additional data for the event */
  29444. additionalData?: any;
  29445. }
  29446. /**
  29447. * ActionEvent is the event being sent when an action is triggered.
  29448. */
  29449. export class ActionEvent implements IActionEvent {
  29450. /** The mesh or sprite that triggered the action */
  29451. source: any;
  29452. /** The X mouse cursor position at the time of the event */
  29453. pointerX: number;
  29454. /** The Y mouse cursor position at the time of the event */
  29455. pointerY: number;
  29456. /** The mesh that is currently pointed at (can be null) */
  29457. meshUnderPointer: Nullable<AbstractMesh>;
  29458. /** the original (browser) event that triggered the ActionEvent */
  29459. sourceEvent?: any;
  29460. /** additional data for the event */
  29461. additionalData?: any;
  29462. /**
  29463. * Creates a new ActionEvent
  29464. * @param source The mesh or sprite that triggered the action
  29465. * @param pointerX The X mouse cursor position at the time of the event
  29466. * @param pointerY The Y mouse cursor position at the time of the event
  29467. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29468. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29469. * @param additionalData additional data for the event
  29470. */
  29471. constructor(
  29472. /** The mesh or sprite that triggered the action */
  29473. source: any,
  29474. /** The X mouse cursor position at the time of the event */
  29475. pointerX: number,
  29476. /** The Y mouse cursor position at the time of the event */
  29477. pointerY: number,
  29478. /** The mesh that is currently pointed at (can be null) */
  29479. meshUnderPointer: Nullable<AbstractMesh>,
  29480. /** the original (browser) event that triggered the ActionEvent */
  29481. sourceEvent?: any,
  29482. /** additional data for the event */
  29483. additionalData?: any);
  29484. /**
  29485. * Helper function to auto-create an ActionEvent from a source mesh.
  29486. * @param source The source mesh that triggered the event
  29487. * @param evt The original (browser) event
  29488. * @param additionalData additional data for the event
  29489. * @returns the new ActionEvent
  29490. */
  29491. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29492. /**
  29493. * Helper function to auto-create an ActionEvent from a source sprite
  29494. * @param source The source sprite that triggered the event
  29495. * @param scene Scene associated with the sprite
  29496. * @param evt The original (browser) event
  29497. * @param additionalData additional data for the event
  29498. * @returns the new ActionEvent
  29499. */
  29500. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29501. /**
  29502. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29503. * @param scene the scene where the event occurred
  29504. * @param evt The original (browser) event
  29505. * @returns the new ActionEvent
  29506. */
  29507. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29508. /**
  29509. * Helper function to auto-create an ActionEvent from a primitive
  29510. * @param prim defines the target primitive
  29511. * @param pointerPos defines the pointer position
  29512. * @param evt The original (browser) event
  29513. * @param additionalData additional data for the event
  29514. * @returns the new ActionEvent
  29515. */
  29516. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29517. }
  29518. }
  29519. declare module "babylonjs/Actions/abstractActionManager" {
  29520. import { IDisposable } from "babylonjs/scene";
  29521. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29522. import { IAction } from "babylonjs/Actions/action";
  29523. import { Nullable } from "babylonjs/types";
  29524. /**
  29525. * Abstract class used to decouple action Manager from scene and meshes.
  29526. * Do not instantiate.
  29527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29528. */
  29529. export abstract class AbstractActionManager implements IDisposable {
  29530. /** Gets the list of active triggers */
  29531. static Triggers: {
  29532. [key: string]: number;
  29533. };
  29534. /** Gets the cursor to use when hovering items */
  29535. hoverCursor: string;
  29536. /** Gets the list of actions */
  29537. actions: IAction[];
  29538. /**
  29539. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29540. */
  29541. isRecursive: boolean;
  29542. /**
  29543. * Releases all associated resources
  29544. */
  29545. abstract dispose(): void;
  29546. /**
  29547. * Does this action manager has pointer triggers
  29548. */
  29549. abstract get hasPointerTriggers(): boolean;
  29550. /**
  29551. * Does this action manager has pick triggers
  29552. */
  29553. abstract get hasPickTriggers(): boolean;
  29554. /**
  29555. * Process a specific trigger
  29556. * @param trigger defines the trigger to process
  29557. * @param evt defines the event details to be processed
  29558. */
  29559. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29560. /**
  29561. * Does this action manager handles actions of any of the given triggers
  29562. * @param triggers defines the triggers to be tested
  29563. * @return a boolean indicating whether one (or more) of the triggers is handled
  29564. */
  29565. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29566. /**
  29567. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29568. * speed.
  29569. * @param triggerA defines the trigger to be tested
  29570. * @param triggerB defines the trigger to be tested
  29571. * @return a boolean indicating whether one (or more) of the triggers is handled
  29572. */
  29573. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29574. /**
  29575. * Does this action manager handles actions of a given trigger
  29576. * @param trigger defines the trigger to be tested
  29577. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29578. * @return whether the trigger is handled
  29579. */
  29580. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29581. /**
  29582. * Serialize this manager to a JSON object
  29583. * @param name defines the property name to store this manager
  29584. * @returns a JSON representation of this manager
  29585. */
  29586. abstract serialize(name: string): any;
  29587. /**
  29588. * Registers an action to this action manager
  29589. * @param action defines the action to be registered
  29590. * @return the action amended (prepared) after registration
  29591. */
  29592. abstract registerAction(action: IAction): Nullable<IAction>;
  29593. /**
  29594. * Unregisters an action to this action manager
  29595. * @param action defines the action to be unregistered
  29596. * @return a boolean indicating whether the action has been unregistered
  29597. */
  29598. abstract unregisterAction(action: IAction): Boolean;
  29599. /**
  29600. * Does exist one action manager with at least one trigger
  29601. **/
  29602. static get HasTriggers(): boolean;
  29603. /**
  29604. * Does exist one action manager with at least one pick trigger
  29605. **/
  29606. static get HasPickTriggers(): boolean;
  29607. /**
  29608. * Does exist one action manager that handles actions of a given trigger
  29609. * @param trigger defines the trigger to be tested
  29610. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29611. **/
  29612. static HasSpecificTrigger(trigger: number): boolean;
  29613. }
  29614. }
  29615. declare module "babylonjs/node" {
  29616. import { Scene } from "babylonjs/scene";
  29617. import { Nullable } from "babylonjs/types";
  29618. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29619. import { Engine } from "babylonjs/Engines/engine";
  29620. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29621. import { Observable } from "babylonjs/Misc/observable";
  29622. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29623. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29624. import { Animatable } from "babylonjs/Animations/animatable";
  29625. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29626. import { Animation } from "babylonjs/Animations/animation";
  29627. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29629. /**
  29630. * Defines how a node can be built from a string name.
  29631. */
  29632. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29633. /**
  29634. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29635. */
  29636. export class Node implements IBehaviorAware<Node> {
  29637. /** @hidden */
  29638. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29639. private static _NodeConstructors;
  29640. /**
  29641. * Add a new node constructor
  29642. * @param type defines the type name of the node to construct
  29643. * @param constructorFunc defines the constructor function
  29644. */
  29645. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29646. /**
  29647. * Returns a node constructor based on type name
  29648. * @param type defines the type name
  29649. * @param name defines the new node name
  29650. * @param scene defines the hosting scene
  29651. * @param options defines optional options to transmit to constructors
  29652. * @returns the new constructor or null
  29653. */
  29654. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29655. /**
  29656. * Gets or sets the name of the node
  29657. */
  29658. name: string;
  29659. /**
  29660. * Gets or sets the id of the node
  29661. */
  29662. id: string;
  29663. /**
  29664. * Gets or sets the unique id of the node
  29665. */
  29666. uniqueId: number;
  29667. /**
  29668. * Gets or sets a string used to store user defined state for the node
  29669. */
  29670. state: string;
  29671. /**
  29672. * Gets or sets an object used to store user defined information for the node
  29673. */
  29674. metadata: any;
  29675. /**
  29676. * For internal use only. Please do not use.
  29677. */
  29678. reservedDataStore: any;
  29679. /**
  29680. * List of inspectable custom properties (used by the Inspector)
  29681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29682. */
  29683. inspectableCustomProperties: IInspectable[];
  29684. private _doNotSerialize;
  29685. /**
  29686. * Gets or sets a boolean used to define if the node must be serialized
  29687. */
  29688. get doNotSerialize(): boolean;
  29689. set doNotSerialize(value: boolean);
  29690. /** @hidden */
  29691. _isDisposed: boolean;
  29692. /**
  29693. * Gets a list of Animations associated with the node
  29694. */
  29695. animations: import("babylonjs/Animations/animation").Animation[];
  29696. protected _ranges: {
  29697. [name: string]: Nullable<AnimationRange>;
  29698. };
  29699. /**
  29700. * Callback raised when the node is ready to be used
  29701. */
  29702. onReady: Nullable<(node: Node) => void>;
  29703. private _isEnabled;
  29704. private _isParentEnabled;
  29705. private _isReady;
  29706. /** @hidden */
  29707. _currentRenderId: number;
  29708. private _parentUpdateId;
  29709. /** @hidden */
  29710. _childUpdateId: number;
  29711. /** @hidden */
  29712. _waitingParentId: Nullable<string>;
  29713. /** @hidden */
  29714. _scene: Scene;
  29715. /** @hidden */
  29716. _cache: any;
  29717. private _parentNode;
  29718. private _children;
  29719. /** @hidden */
  29720. _worldMatrix: Matrix;
  29721. /** @hidden */
  29722. _worldMatrixDeterminant: number;
  29723. /** @hidden */
  29724. _worldMatrixDeterminantIsDirty: boolean;
  29725. /** @hidden */
  29726. private _sceneRootNodesIndex;
  29727. /**
  29728. * Gets a boolean indicating if the node has been disposed
  29729. * @returns true if the node was disposed
  29730. */
  29731. isDisposed(): boolean;
  29732. /**
  29733. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29734. * @see https://doc.babylonjs.com/how_to/parenting
  29735. */
  29736. set parent(parent: Nullable<Node>);
  29737. get parent(): Nullable<Node>;
  29738. /** @hidden */
  29739. _addToSceneRootNodes(): void;
  29740. /** @hidden */
  29741. _removeFromSceneRootNodes(): void;
  29742. private _animationPropertiesOverride;
  29743. /**
  29744. * Gets or sets the animation properties override
  29745. */
  29746. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29747. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29748. /**
  29749. * Gets a string idenfifying the name of the class
  29750. * @returns "Node" string
  29751. */
  29752. getClassName(): string;
  29753. /** @hidden */
  29754. readonly _isNode: boolean;
  29755. /**
  29756. * An event triggered when the mesh is disposed
  29757. */
  29758. onDisposeObservable: Observable<Node>;
  29759. private _onDisposeObserver;
  29760. /**
  29761. * Sets a callback that will be raised when the node will be disposed
  29762. */
  29763. set onDispose(callback: () => void);
  29764. /**
  29765. * Creates a new Node
  29766. * @param name the name and id to be given to this node
  29767. * @param scene the scene this node will be added to
  29768. */
  29769. constructor(name: string, scene?: Nullable<Scene>);
  29770. /**
  29771. * Gets the scene of the node
  29772. * @returns a scene
  29773. */
  29774. getScene(): Scene;
  29775. /**
  29776. * Gets the engine of the node
  29777. * @returns a Engine
  29778. */
  29779. getEngine(): Engine;
  29780. private _behaviors;
  29781. /**
  29782. * Attach a behavior to the node
  29783. * @see http://doc.babylonjs.com/features/behaviour
  29784. * @param behavior defines the behavior to attach
  29785. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29786. * @returns the current Node
  29787. */
  29788. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29789. /**
  29790. * Remove an attached behavior
  29791. * @see http://doc.babylonjs.com/features/behaviour
  29792. * @param behavior defines the behavior to attach
  29793. * @returns the current Node
  29794. */
  29795. removeBehavior(behavior: Behavior<Node>): Node;
  29796. /**
  29797. * Gets the list of attached behaviors
  29798. * @see http://doc.babylonjs.com/features/behaviour
  29799. */
  29800. get behaviors(): Behavior<Node>[];
  29801. /**
  29802. * Gets an attached behavior by name
  29803. * @param name defines the name of the behavior to look for
  29804. * @see http://doc.babylonjs.com/features/behaviour
  29805. * @returns null if behavior was not found else the requested behavior
  29806. */
  29807. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29808. /**
  29809. * Returns the latest update of the World matrix
  29810. * @returns a Matrix
  29811. */
  29812. getWorldMatrix(): Matrix;
  29813. /** @hidden */
  29814. _getWorldMatrixDeterminant(): number;
  29815. /**
  29816. * Returns directly the latest state of the mesh World matrix.
  29817. * A Matrix is returned.
  29818. */
  29819. get worldMatrixFromCache(): Matrix;
  29820. /** @hidden */
  29821. _initCache(): void;
  29822. /** @hidden */
  29823. updateCache(force?: boolean): void;
  29824. /** @hidden */
  29825. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29826. /** @hidden */
  29827. _updateCache(ignoreParentClass?: boolean): void;
  29828. /** @hidden */
  29829. _isSynchronized(): boolean;
  29830. /** @hidden */
  29831. _markSyncedWithParent(): void;
  29832. /** @hidden */
  29833. isSynchronizedWithParent(): boolean;
  29834. /** @hidden */
  29835. isSynchronized(): boolean;
  29836. /**
  29837. * Is this node ready to be used/rendered
  29838. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29839. * @return true if the node is ready
  29840. */
  29841. isReady(completeCheck?: boolean): boolean;
  29842. /**
  29843. * Is this node enabled?
  29844. * 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
  29845. * @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
  29846. * @return whether this node (and its parent) is enabled
  29847. */
  29848. isEnabled(checkAncestors?: boolean): boolean;
  29849. /** @hidden */
  29850. protected _syncParentEnabledState(): void;
  29851. /**
  29852. * Set the enabled state of this node
  29853. * @param value defines the new enabled state
  29854. */
  29855. setEnabled(value: boolean): void;
  29856. /**
  29857. * Is this node a descendant of the given node?
  29858. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29859. * @param ancestor defines the parent node to inspect
  29860. * @returns a boolean indicating if this node is a descendant of the given node
  29861. */
  29862. isDescendantOf(ancestor: Node): boolean;
  29863. /** @hidden */
  29864. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29865. /**
  29866. * Will return all nodes that have this node as ascendant
  29867. * @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
  29868. * @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
  29869. * @return all children nodes of all types
  29870. */
  29871. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29872. /**
  29873. * Get all child-meshes of this node
  29874. * @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)
  29875. * @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
  29876. * @returns an array of AbstractMesh
  29877. */
  29878. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29879. /**
  29880. * Get all direct children of this node
  29881. * @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
  29882. * @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)
  29883. * @returns an array of Node
  29884. */
  29885. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29886. /** @hidden */
  29887. _setReady(state: boolean): void;
  29888. /**
  29889. * Get an animation by name
  29890. * @param name defines the name of the animation to look for
  29891. * @returns null if not found else the requested animation
  29892. */
  29893. getAnimationByName(name: string): Nullable<Animation>;
  29894. /**
  29895. * Creates an animation range for this node
  29896. * @param name defines the name of the range
  29897. * @param from defines the starting key
  29898. * @param to defines the end key
  29899. */
  29900. createAnimationRange(name: string, from: number, to: number): void;
  29901. /**
  29902. * Delete a specific animation range
  29903. * @param name defines the name of the range to delete
  29904. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29905. */
  29906. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29907. /**
  29908. * Get an animation range by name
  29909. * @param name defines the name of the animation range to look for
  29910. * @returns null if not found else the requested animation range
  29911. */
  29912. getAnimationRange(name: string): Nullable<AnimationRange>;
  29913. /**
  29914. * Gets the list of all animation ranges defined on this node
  29915. * @returns an array
  29916. */
  29917. getAnimationRanges(): Nullable<AnimationRange>[];
  29918. /**
  29919. * Will start the animation sequence
  29920. * @param name defines the range frames for animation sequence
  29921. * @param loop defines if the animation should loop (false by default)
  29922. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29923. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29924. * @returns the object created for this animation. If range does not exist, it will return null
  29925. */
  29926. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29927. /**
  29928. * Serialize animation ranges into a JSON compatible object
  29929. * @returns serialization object
  29930. */
  29931. serializeAnimationRanges(): any;
  29932. /**
  29933. * Computes the world matrix of the node
  29934. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29935. * @returns the world matrix
  29936. */
  29937. computeWorldMatrix(force?: boolean): Matrix;
  29938. /**
  29939. * Releases resources associated with this node.
  29940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29942. */
  29943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29944. /**
  29945. * Parse animation range data from a serialization object and store them into a given node
  29946. * @param node defines where to store the animation ranges
  29947. * @param parsedNode defines the serialization object to read data from
  29948. * @param scene defines the hosting scene
  29949. */
  29950. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29951. /**
  29952. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29953. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29954. * @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
  29955. * @returns the new bounding vectors
  29956. */
  29957. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29958. min: Vector3;
  29959. max: Vector3;
  29960. };
  29961. }
  29962. }
  29963. declare module "babylonjs/Animations/animation" {
  29964. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29965. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29966. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29967. import { Nullable } from "babylonjs/types";
  29968. import { Scene } from "babylonjs/scene";
  29969. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29970. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29971. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29972. import { Node } from "babylonjs/node";
  29973. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29974. import { Size } from "babylonjs/Maths/math.size";
  29975. import { Animatable } from "babylonjs/Animations/animatable";
  29976. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29977. /**
  29978. * @hidden
  29979. */
  29980. export class _IAnimationState {
  29981. key: number;
  29982. repeatCount: number;
  29983. workValue?: any;
  29984. loopMode?: number;
  29985. offsetValue?: any;
  29986. highLimitValue?: any;
  29987. }
  29988. /**
  29989. * Class used to store any kind of animation
  29990. */
  29991. export class Animation {
  29992. /**Name of the animation */
  29993. name: string;
  29994. /**Property to animate */
  29995. targetProperty: string;
  29996. /**The frames per second of the animation */
  29997. framePerSecond: number;
  29998. /**The data type of the animation */
  29999. dataType: number;
  30000. /**The loop mode of the animation */
  30001. loopMode?: number | undefined;
  30002. /**Specifies if blending should be enabled */
  30003. enableBlending?: boolean | undefined;
  30004. /**
  30005. * Use matrix interpolation instead of using direct key value when animating matrices
  30006. */
  30007. static AllowMatricesInterpolation: boolean;
  30008. /**
  30009. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30010. */
  30011. static AllowMatrixDecomposeForInterpolation: boolean;
  30012. /**
  30013. * Stores the key frames of the animation
  30014. */
  30015. private _keys;
  30016. /**
  30017. * Stores the easing function of the animation
  30018. */
  30019. private _easingFunction;
  30020. /**
  30021. * @hidden Internal use only
  30022. */
  30023. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30024. /**
  30025. * The set of event that will be linked to this animation
  30026. */
  30027. private _events;
  30028. /**
  30029. * Stores an array of target property paths
  30030. */
  30031. targetPropertyPath: string[];
  30032. /**
  30033. * Stores the blending speed of the animation
  30034. */
  30035. blendingSpeed: number;
  30036. /**
  30037. * Stores the animation ranges for the animation
  30038. */
  30039. private _ranges;
  30040. /**
  30041. * @hidden Internal use
  30042. */
  30043. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30044. /**
  30045. * Sets up an animation
  30046. * @param property The property to animate
  30047. * @param animationType The animation type to apply
  30048. * @param framePerSecond The frames per second of the animation
  30049. * @param easingFunction The easing function used in the animation
  30050. * @returns The created animation
  30051. */
  30052. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30053. /**
  30054. * Create and start an animation on a node
  30055. * @param name defines the name of the global animation that will be run on all nodes
  30056. * @param node defines the root node where the animation will take place
  30057. * @param targetProperty defines property to animate
  30058. * @param framePerSecond defines the number of frame per second yo use
  30059. * @param totalFrame defines the number of frames in total
  30060. * @param from defines the initial value
  30061. * @param to defines the final value
  30062. * @param loopMode defines which loop mode you want to use (off by default)
  30063. * @param easingFunction defines the easing function to use (linear by default)
  30064. * @param onAnimationEnd defines the callback to call when animation end
  30065. * @returns the animatable created for this animation
  30066. */
  30067. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30068. /**
  30069. * Create and start an animation on a node and its descendants
  30070. * @param name defines the name of the global animation that will be run on all nodes
  30071. * @param node defines the root node where the animation will take place
  30072. * @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
  30073. * @param targetProperty defines property to animate
  30074. * @param framePerSecond defines the number of frame per second to use
  30075. * @param totalFrame defines the number of frames in total
  30076. * @param from defines the initial value
  30077. * @param to defines the final value
  30078. * @param loopMode defines which loop mode you want to use (off by default)
  30079. * @param easingFunction defines the easing function to use (linear by default)
  30080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30081. * @returns the list of animatables created for all nodes
  30082. * @example https://www.babylonjs-playground.com/#MH0VLI
  30083. */
  30084. 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[]>;
  30085. /**
  30086. * Creates a new animation, merges it with the existing animations and starts it
  30087. * @param name Name of the animation
  30088. * @param node Node which contains the scene that begins the animations
  30089. * @param targetProperty Specifies which property to animate
  30090. * @param framePerSecond The frames per second of the animation
  30091. * @param totalFrame The total number of frames
  30092. * @param from The frame at the beginning of the animation
  30093. * @param to The frame at the end of the animation
  30094. * @param loopMode Specifies the loop mode of the animation
  30095. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30096. * @param onAnimationEnd Callback to run once the animation is complete
  30097. * @returns Nullable animation
  30098. */
  30099. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30100. /**
  30101. * Transition property of an host to the target Value
  30102. * @param property The property to transition
  30103. * @param targetValue The target Value of the property
  30104. * @param host The object where the property to animate belongs
  30105. * @param scene Scene used to run the animation
  30106. * @param frameRate Framerate (in frame/s) to use
  30107. * @param transition The transition type we want to use
  30108. * @param duration The duration of the animation, in milliseconds
  30109. * @param onAnimationEnd Callback trigger at the end of the animation
  30110. * @returns Nullable animation
  30111. */
  30112. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30113. /**
  30114. * Return the array of runtime animations currently using this animation
  30115. */
  30116. get runtimeAnimations(): RuntimeAnimation[];
  30117. /**
  30118. * Specifies if any of the runtime animations are currently running
  30119. */
  30120. get hasRunningRuntimeAnimations(): boolean;
  30121. /**
  30122. * Initializes the animation
  30123. * @param name Name of the animation
  30124. * @param targetProperty Property to animate
  30125. * @param framePerSecond The frames per second of the animation
  30126. * @param dataType The data type of the animation
  30127. * @param loopMode The loop mode of the animation
  30128. * @param enableBlending Specifies if blending should be enabled
  30129. */
  30130. constructor(
  30131. /**Name of the animation */
  30132. name: string,
  30133. /**Property to animate */
  30134. targetProperty: string,
  30135. /**The frames per second of the animation */
  30136. framePerSecond: number,
  30137. /**The data type of the animation */
  30138. dataType: number,
  30139. /**The loop mode of the animation */
  30140. loopMode?: number | undefined,
  30141. /**Specifies if blending should be enabled */
  30142. enableBlending?: boolean | undefined);
  30143. /**
  30144. * Converts the animation to a string
  30145. * @param fullDetails support for multiple levels of logging within scene loading
  30146. * @returns String form of the animation
  30147. */
  30148. toString(fullDetails?: boolean): string;
  30149. /**
  30150. * Add an event to this animation
  30151. * @param event Event to add
  30152. */
  30153. addEvent(event: AnimationEvent): void;
  30154. /**
  30155. * Remove all events found at the given frame
  30156. * @param frame The frame to remove events from
  30157. */
  30158. removeEvents(frame: number): void;
  30159. /**
  30160. * Retrieves all the events from the animation
  30161. * @returns Events from the animation
  30162. */
  30163. getEvents(): AnimationEvent[];
  30164. /**
  30165. * Creates an animation range
  30166. * @param name Name of the animation range
  30167. * @param from Starting frame of the animation range
  30168. * @param to Ending frame of the animation
  30169. */
  30170. createRange(name: string, from: number, to: number): void;
  30171. /**
  30172. * Deletes an animation range by name
  30173. * @param name Name of the animation range to delete
  30174. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30175. */
  30176. deleteRange(name: string, deleteFrames?: boolean): void;
  30177. /**
  30178. * Gets the animation range by name, or null if not defined
  30179. * @param name Name of the animation range
  30180. * @returns Nullable animation range
  30181. */
  30182. getRange(name: string): Nullable<AnimationRange>;
  30183. /**
  30184. * Gets the key frames from the animation
  30185. * @returns The key frames of the animation
  30186. */
  30187. getKeys(): Array<IAnimationKey>;
  30188. /**
  30189. * Gets the highest frame rate of the animation
  30190. * @returns Highest frame rate of the animation
  30191. */
  30192. getHighestFrame(): number;
  30193. /**
  30194. * Gets the easing function of the animation
  30195. * @returns Easing function of the animation
  30196. */
  30197. getEasingFunction(): IEasingFunction;
  30198. /**
  30199. * Sets the easing function of the animation
  30200. * @param easingFunction A custom mathematical formula for animation
  30201. */
  30202. setEasingFunction(easingFunction: EasingFunction): void;
  30203. /**
  30204. * Interpolates a scalar linearly
  30205. * @param startValue Start value of the animation curve
  30206. * @param endValue End value of the animation curve
  30207. * @param gradient Scalar amount to interpolate
  30208. * @returns Interpolated scalar value
  30209. */
  30210. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30211. /**
  30212. * Interpolates a scalar cubically
  30213. * @param startValue Start value of the animation curve
  30214. * @param outTangent End tangent of the animation
  30215. * @param endValue End value of the animation curve
  30216. * @param inTangent Start tangent of the animation curve
  30217. * @param gradient Scalar amount to interpolate
  30218. * @returns Interpolated scalar value
  30219. */
  30220. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30221. /**
  30222. * Interpolates a quaternion using a spherical linear interpolation
  30223. * @param startValue Start value of the animation curve
  30224. * @param endValue End value of the animation curve
  30225. * @param gradient Scalar amount to interpolate
  30226. * @returns Interpolated quaternion value
  30227. */
  30228. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30229. /**
  30230. * Interpolates a quaternion cubically
  30231. * @param startValue Start value of the animation curve
  30232. * @param outTangent End tangent of the animation curve
  30233. * @param endValue End value of the animation curve
  30234. * @param inTangent Start tangent of the animation curve
  30235. * @param gradient Scalar amount to interpolate
  30236. * @returns Interpolated quaternion value
  30237. */
  30238. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30239. /**
  30240. * Interpolates a Vector3 linearl
  30241. * @param startValue Start value of the animation curve
  30242. * @param endValue End value of the animation curve
  30243. * @param gradient Scalar amount to interpolate
  30244. * @returns Interpolated scalar value
  30245. */
  30246. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30247. /**
  30248. * Interpolates a Vector3 cubically
  30249. * @param startValue Start value of the animation curve
  30250. * @param outTangent End tangent of the animation
  30251. * @param endValue End value of the animation curve
  30252. * @param inTangent Start tangent of the animation curve
  30253. * @param gradient Scalar amount to interpolate
  30254. * @returns InterpolatedVector3 value
  30255. */
  30256. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30257. /**
  30258. * Interpolates a Vector2 linearly
  30259. * @param startValue Start value of the animation curve
  30260. * @param endValue End value of the animation curve
  30261. * @param gradient Scalar amount to interpolate
  30262. * @returns Interpolated Vector2 value
  30263. */
  30264. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30265. /**
  30266. * Interpolates a Vector2 cubically
  30267. * @param startValue Start value of the animation curve
  30268. * @param outTangent End tangent of the animation
  30269. * @param endValue End value of the animation curve
  30270. * @param inTangent Start tangent of the animation curve
  30271. * @param gradient Scalar amount to interpolate
  30272. * @returns Interpolated Vector2 value
  30273. */
  30274. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30275. /**
  30276. * Interpolates a size linearly
  30277. * @param startValue Start value of the animation curve
  30278. * @param endValue End value of the animation curve
  30279. * @param gradient Scalar amount to interpolate
  30280. * @returns Interpolated Size value
  30281. */
  30282. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30283. /**
  30284. * Interpolates a Color3 linearly
  30285. * @param startValue Start value of the animation curve
  30286. * @param endValue End value of the animation curve
  30287. * @param gradient Scalar amount to interpolate
  30288. * @returns Interpolated Color3 value
  30289. */
  30290. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30291. /**
  30292. * Interpolates a Color4 linearly
  30293. * @param startValue Start value of the animation curve
  30294. * @param endValue End value of the animation curve
  30295. * @param gradient Scalar amount to interpolate
  30296. * @returns Interpolated Color3 value
  30297. */
  30298. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30299. /**
  30300. * @hidden Internal use only
  30301. */
  30302. _getKeyValue(value: any): any;
  30303. /**
  30304. * @hidden Internal use only
  30305. */
  30306. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30307. /**
  30308. * Defines the function to use to interpolate matrices
  30309. * @param startValue defines the start matrix
  30310. * @param endValue defines the end matrix
  30311. * @param gradient defines the gradient between both matrices
  30312. * @param result defines an optional target matrix where to store the interpolation
  30313. * @returns the interpolated matrix
  30314. */
  30315. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30316. /**
  30317. * Makes a copy of the animation
  30318. * @returns Cloned animation
  30319. */
  30320. clone(): Animation;
  30321. /**
  30322. * Sets the key frames of the animation
  30323. * @param values The animation key frames to set
  30324. */
  30325. setKeys(values: Array<IAnimationKey>): void;
  30326. /**
  30327. * Serializes the animation to an object
  30328. * @returns Serialized object
  30329. */
  30330. serialize(): any;
  30331. /**
  30332. * Float animation type
  30333. */
  30334. static readonly ANIMATIONTYPE_FLOAT: number;
  30335. /**
  30336. * Vector3 animation type
  30337. */
  30338. static readonly ANIMATIONTYPE_VECTOR3: number;
  30339. /**
  30340. * Quaternion animation type
  30341. */
  30342. static readonly ANIMATIONTYPE_QUATERNION: number;
  30343. /**
  30344. * Matrix animation type
  30345. */
  30346. static readonly ANIMATIONTYPE_MATRIX: number;
  30347. /**
  30348. * Color3 animation type
  30349. */
  30350. static readonly ANIMATIONTYPE_COLOR3: number;
  30351. /**
  30352. * Color3 animation type
  30353. */
  30354. static readonly ANIMATIONTYPE_COLOR4: number;
  30355. /**
  30356. * Vector2 animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_VECTOR2: number;
  30359. /**
  30360. * Size animation type
  30361. */
  30362. static readonly ANIMATIONTYPE_SIZE: number;
  30363. /**
  30364. * Relative Loop Mode
  30365. */
  30366. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30367. /**
  30368. * Cycle Loop Mode
  30369. */
  30370. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30371. /**
  30372. * Constant Loop Mode
  30373. */
  30374. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30375. /** @hidden */
  30376. static _UniversalLerp(left: any, right: any, amount: number): any;
  30377. /**
  30378. * Parses an animation object and creates an animation
  30379. * @param parsedAnimation Parsed animation object
  30380. * @returns Animation object
  30381. */
  30382. static Parse(parsedAnimation: any): Animation;
  30383. /**
  30384. * Appends the serialized animations from the source animations
  30385. * @param source Source containing the animations
  30386. * @param destination Target to store the animations
  30387. */
  30388. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30389. }
  30390. }
  30391. declare module "babylonjs/Animations/animatable.interface" {
  30392. import { Nullable } from "babylonjs/types";
  30393. import { Animation } from "babylonjs/Animations/animation";
  30394. /**
  30395. * Interface containing an array of animations
  30396. */
  30397. export interface IAnimatable {
  30398. /**
  30399. * Array of animations
  30400. */
  30401. animations: Nullable<Array<Animation>>;
  30402. }
  30403. }
  30404. declare module "babylonjs/Misc/decorators" {
  30405. import { Nullable } from "babylonjs/types";
  30406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30407. import { Scene } from "babylonjs/scene";
  30408. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30409. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30421. /**
  30422. * Decorator used to define property that can be serialized as reference to a camera
  30423. * @param sourceName defines the name of the property to decorate
  30424. */
  30425. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30426. /**
  30427. * Class used to help serialization objects
  30428. */
  30429. export class SerializationHelper {
  30430. /** @hidden */
  30431. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30432. /** @hidden */
  30433. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30434. /** @hidden */
  30435. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30436. /** @hidden */
  30437. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30438. /**
  30439. * Appends the serialized animations from the source animations
  30440. * @param source Source containing the animations
  30441. * @param destination Target to store the animations
  30442. */
  30443. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30444. /**
  30445. * Static function used to serialized a specific entity
  30446. * @param entity defines the entity to serialize
  30447. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30448. * @returns a JSON compatible object representing the serialization of the entity
  30449. */
  30450. static Serialize<T>(entity: T, serializationObject?: any): any;
  30451. /**
  30452. * Creates a new entity from a serialization data object
  30453. * @param creationFunction defines a function used to instanciated the new entity
  30454. * @param source defines the source serialization data
  30455. * @param scene defines the hosting scene
  30456. * @param rootUrl defines the root url for resources
  30457. * @returns a new entity
  30458. */
  30459. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30460. /**
  30461. * Clones an object
  30462. * @param creationFunction defines the function used to instanciate the new object
  30463. * @param source defines the source object
  30464. * @returns the cloned object
  30465. */
  30466. static Clone<T>(creationFunction: () => T, source: T): T;
  30467. /**
  30468. * Instanciates a new object based on a source one (some data will be shared between both object)
  30469. * @param creationFunction defines the function used to instanciate the new object
  30470. * @param source defines the source object
  30471. * @returns the new object
  30472. */
  30473. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30474. }
  30475. }
  30476. declare module "babylonjs/Misc/guid" {
  30477. /**
  30478. * Class used to manipulate GUIDs
  30479. */
  30480. export class GUID {
  30481. /**
  30482. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30483. * Be aware Math.random() could cause collisions, but:
  30484. * "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"
  30485. * @returns a pseudo random id
  30486. */
  30487. static RandomId(): string;
  30488. }
  30489. }
  30490. declare module "babylonjs/Materials/Textures/baseTexture" {
  30491. import { Observable } from "babylonjs/Misc/observable";
  30492. import { Nullable } from "babylonjs/types";
  30493. import { Scene } from "babylonjs/scene";
  30494. import { Matrix } from "babylonjs/Maths/math.vector";
  30495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30496. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30497. import { ISize } from "babylonjs/Maths/math.size";
  30498. import "babylonjs/Misc/fileTools";
  30499. /**
  30500. * Base class of all the textures in babylon.
  30501. * It groups all the common properties the materials, post process, lights... might need
  30502. * in order to make a correct use of the texture.
  30503. */
  30504. export class BaseTexture implements IAnimatable {
  30505. /**
  30506. * Default anisotropic filtering level for the application.
  30507. * It is set to 4 as a good tradeoff between perf and quality.
  30508. */
  30509. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30510. /**
  30511. * Gets or sets the unique id of the texture
  30512. */
  30513. uniqueId: number;
  30514. /**
  30515. * Define the name of the texture.
  30516. */
  30517. name: string;
  30518. /**
  30519. * Gets or sets an object used to store user defined information.
  30520. */
  30521. metadata: any;
  30522. /**
  30523. * For internal use only. Please do not use.
  30524. */
  30525. reservedDataStore: any;
  30526. private _hasAlpha;
  30527. /**
  30528. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30529. */
  30530. set hasAlpha(value: boolean);
  30531. get hasAlpha(): boolean;
  30532. /**
  30533. * Defines if the alpha value should be determined via the rgb values.
  30534. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30535. */
  30536. getAlphaFromRGB: boolean;
  30537. /**
  30538. * Intensity or strength of the texture.
  30539. * It is commonly used by materials to fine tune the intensity of the texture
  30540. */
  30541. level: number;
  30542. /**
  30543. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30544. * This is part of the texture as textures usually maps to one uv set.
  30545. */
  30546. coordinatesIndex: number;
  30547. private _coordinatesMode;
  30548. /**
  30549. * How a texture is mapped.
  30550. *
  30551. * | Value | Type | Description |
  30552. * | ----- | ----------------------------------- | ----------- |
  30553. * | 0 | EXPLICIT_MODE | |
  30554. * | 1 | SPHERICAL_MODE | |
  30555. * | 2 | PLANAR_MODE | |
  30556. * | 3 | CUBIC_MODE | |
  30557. * | 4 | PROJECTION_MODE | |
  30558. * | 5 | SKYBOX_MODE | |
  30559. * | 6 | INVCUBIC_MODE | |
  30560. * | 7 | EQUIRECTANGULAR_MODE | |
  30561. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30562. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30563. */
  30564. set coordinatesMode(value: number);
  30565. get coordinatesMode(): number;
  30566. /**
  30567. * | Value | Type | Description |
  30568. * | ----- | ------------------ | ----------- |
  30569. * | 0 | CLAMP_ADDRESSMODE | |
  30570. * | 1 | WRAP_ADDRESSMODE | |
  30571. * | 2 | MIRROR_ADDRESSMODE | |
  30572. */
  30573. wrapU: number;
  30574. /**
  30575. * | Value | Type | Description |
  30576. * | ----- | ------------------ | ----------- |
  30577. * | 0 | CLAMP_ADDRESSMODE | |
  30578. * | 1 | WRAP_ADDRESSMODE | |
  30579. * | 2 | MIRROR_ADDRESSMODE | |
  30580. */
  30581. wrapV: number;
  30582. /**
  30583. * | Value | Type | Description |
  30584. * | ----- | ------------------ | ----------- |
  30585. * | 0 | CLAMP_ADDRESSMODE | |
  30586. * | 1 | WRAP_ADDRESSMODE | |
  30587. * | 2 | MIRROR_ADDRESSMODE | |
  30588. */
  30589. wrapR: number;
  30590. /**
  30591. * With compliant hardware and browser (supporting anisotropic filtering)
  30592. * this defines the level of anisotropic filtering in the texture.
  30593. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30594. */
  30595. anisotropicFilteringLevel: number;
  30596. /**
  30597. * Define if the texture is a cube texture or if false a 2d texture.
  30598. */
  30599. get isCube(): boolean;
  30600. set isCube(value: boolean);
  30601. /**
  30602. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30603. */
  30604. get is3D(): boolean;
  30605. set is3D(value: boolean);
  30606. /**
  30607. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30608. */
  30609. get is2DArray(): boolean;
  30610. set is2DArray(value: boolean);
  30611. /**
  30612. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30613. * HDR texture are usually stored in linear space.
  30614. * This only impacts the PBR and Background materials
  30615. */
  30616. gammaSpace: boolean;
  30617. /**
  30618. * Gets or sets whether or not the texture contains RGBD data.
  30619. */
  30620. get isRGBD(): boolean;
  30621. set isRGBD(value: boolean);
  30622. /**
  30623. * Is Z inverted in the texture (useful in a cube texture).
  30624. */
  30625. invertZ: boolean;
  30626. /**
  30627. * Are mip maps generated for this texture or not.
  30628. */
  30629. get noMipmap(): boolean;
  30630. /**
  30631. * @hidden
  30632. */
  30633. lodLevelInAlpha: boolean;
  30634. /**
  30635. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30636. */
  30637. get lodGenerationOffset(): number;
  30638. set lodGenerationOffset(value: number);
  30639. /**
  30640. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30641. */
  30642. get lodGenerationScale(): number;
  30643. set lodGenerationScale(value: number);
  30644. /**
  30645. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30646. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30647. * average roughness values.
  30648. */
  30649. get linearSpecularLOD(): boolean;
  30650. set linearSpecularLOD(value: boolean);
  30651. /**
  30652. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30653. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30654. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30655. */
  30656. get irradianceTexture(): Nullable<BaseTexture>;
  30657. set irradianceTexture(value: Nullable<BaseTexture>);
  30658. /**
  30659. * Define if the texture is a render target.
  30660. */
  30661. isRenderTarget: boolean;
  30662. /**
  30663. * Define the unique id of the texture in the scene.
  30664. */
  30665. get uid(): string;
  30666. /**
  30667. * Return a string representation of the texture.
  30668. * @returns the texture as a string
  30669. */
  30670. toString(): string;
  30671. /**
  30672. * Get the class name of the texture.
  30673. * @returns "BaseTexture"
  30674. */
  30675. getClassName(): string;
  30676. /**
  30677. * Define the list of animation attached to the texture.
  30678. */
  30679. animations: import("babylonjs/Animations/animation").Animation[];
  30680. /**
  30681. * An event triggered when the texture is disposed.
  30682. */
  30683. onDisposeObservable: Observable<BaseTexture>;
  30684. private _onDisposeObserver;
  30685. /**
  30686. * Callback triggered when the texture has been disposed.
  30687. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30688. */
  30689. set onDispose(callback: () => void);
  30690. /**
  30691. * Define the current state of the loading sequence when in delayed load mode.
  30692. */
  30693. delayLoadState: number;
  30694. private _scene;
  30695. /** @hidden */
  30696. _texture: Nullable<InternalTexture>;
  30697. private _uid;
  30698. /**
  30699. * Define if the texture is preventinga material to render or not.
  30700. * If not and the texture is not ready, the engine will use a default black texture instead.
  30701. */
  30702. get isBlocking(): boolean;
  30703. /**
  30704. * Instantiates a new BaseTexture.
  30705. * Base class of all the textures in babylon.
  30706. * It groups all the common properties the materials, post process, lights... might need
  30707. * in order to make a correct use of the texture.
  30708. * @param scene Define the scene the texture blongs to
  30709. */
  30710. constructor(scene: Nullable<Scene>);
  30711. /**
  30712. * Get the scene the texture belongs to.
  30713. * @returns the scene or null if undefined
  30714. */
  30715. getScene(): Nullable<Scene>;
  30716. /**
  30717. * Get the texture transform matrix used to offset tile the texture for istance.
  30718. * @returns the transformation matrix
  30719. */
  30720. getTextureMatrix(): Matrix;
  30721. /**
  30722. * Get the texture reflection matrix used to rotate/transform the reflection.
  30723. * @returns the reflection matrix
  30724. */
  30725. getReflectionTextureMatrix(): Matrix;
  30726. /**
  30727. * Get the underlying lower level texture from Babylon.
  30728. * @returns the insternal texture
  30729. */
  30730. getInternalTexture(): Nullable<InternalTexture>;
  30731. /**
  30732. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30733. * @returns true if ready or not blocking
  30734. */
  30735. isReadyOrNotBlocking(): boolean;
  30736. /**
  30737. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30738. * @returns true if fully ready
  30739. */
  30740. isReady(): boolean;
  30741. private _cachedSize;
  30742. /**
  30743. * Get the size of the texture.
  30744. * @returns the texture size.
  30745. */
  30746. getSize(): ISize;
  30747. /**
  30748. * Get the base size of the texture.
  30749. * It can be different from the size if the texture has been resized for POT for instance
  30750. * @returns the base size
  30751. */
  30752. getBaseSize(): ISize;
  30753. /**
  30754. * Update the sampling mode of the texture.
  30755. * Default is Trilinear mode.
  30756. *
  30757. * | Value | Type | Description |
  30758. * | ----- | ------------------ | ----------- |
  30759. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30760. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30761. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30762. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30763. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30764. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30765. * | 7 | NEAREST_LINEAR | |
  30766. * | 8 | NEAREST_NEAREST | |
  30767. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30768. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30769. * | 11 | LINEAR_LINEAR | |
  30770. * | 12 | LINEAR_NEAREST | |
  30771. *
  30772. * > _mag_: magnification filter (close to the viewer)
  30773. * > _min_: minification filter (far from the viewer)
  30774. * > _mip_: filter used between mip map levels
  30775. *@param samplingMode Define the new sampling mode of the texture
  30776. */
  30777. updateSamplingMode(samplingMode: number): void;
  30778. /**
  30779. * Scales the texture if is `canRescale()`
  30780. * @param ratio the resize factor we want to use to rescale
  30781. */
  30782. scale(ratio: number): void;
  30783. /**
  30784. * Get if the texture can rescale.
  30785. */
  30786. get canRescale(): boolean;
  30787. /** @hidden */
  30788. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30789. /** @hidden */
  30790. _rebuild(): void;
  30791. /**
  30792. * Triggers the load sequence in delayed load mode.
  30793. */
  30794. delayLoad(): void;
  30795. /**
  30796. * Clones the texture.
  30797. * @returns the cloned texture
  30798. */
  30799. clone(): Nullable<BaseTexture>;
  30800. /**
  30801. * Get the texture underlying type (INT, FLOAT...)
  30802. */
  30803. get textureType(): number;
  30804. /**
  30805. * Get the texture underlying format (RGB, RGBA...)
  30806. */
  30807. get textureFormat(): number;
  30808. /**
  30809. * Indicates that textures need to be re-calculated for all materials
  30810. */
  30811. protected _markAllSubMeshesAsTexturesDirty(): void;
  30812. /**
  30813. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30814. * This will returns an RGBA array buffer containing either in values (0-255) or
  30815. * float values (0-1) depending of the underlying buffer type.
  30816. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30817. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30818. * @param buffer defines a user defined buffer to fill with data (can be null)
  30819. * @returns The Array buffer containing the pixels data.
  30820. */
  30821. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30822. /**
  30823. * Release and destroy the underlying lower level texture aka internalTexture.
  30824. */
  30825. releaseInternalTexture(): void;
  30826. /** @hidden */
  30827. get _lodTextureHigh(): Nullable<BaseTexture>;
  30828. /** @hidden */
  30829. get _lodTextureMid(): Nullable<BaseTexture>;
  30830. /** @hidden */
  30831. get _lodTextureLow(): Nullable<BaseTexture>;
  30832. /**
  30833. * Dispose the texture and release its associated resources.
  30834. */
  30835. dispose(): void;
  30836. /**
  30837. * Serialize the texture into a JSON representation that can be parsed later on.
  30838. * @returns the JSON representation of the texture
  30839. */
  30840. serialize(): any;
  30841. /**
  30842. * Helper function to be called back once a list of texture contains only ready textures.
  30843. * @param textures Define the list of textures to wait for
  30844. * @param callback Define the callback triggered once the entire list will be ready
  30845. */
  30846. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30847. }
  30848. }
  30849. declare module "babylonjs/Materials/effect" {
  30850. import { Observable } from "babylonjs/Misc/observable";
  30851. import { Nullable } from "babylonjs/types";
  30852. import { IDisposable } from "babylonjs/scene";
  30853. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30854. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30855. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30856. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30857. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30858. import { Engine } from "babylonjs/Engines/engine";
  30859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30861. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30862. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30863. /**
  30864. * Options to be used when creating an effect.
  30865. */
  30866. export interface IEffectCreationOptions {
  30867. /**
  30868. * Atrributes that will be used in the shader.
  30869. */
  30870. attributes: string[];
  30871. /**
  30872. * Uniform varible names that will be set in the shader.
  30873. */
  30874. uniformsNames: string[];
  30875. /**
  30876. * Uniform buffer variable names that will be set in the shader.
  30877. */
  30878. uniformBuffersNames: string[];
  30879. /**
  30880. * Sampler texture variable names that will be set in the shader.
  30881. */
  30882. samplers: string[];
  30883. /**
  30884. * Define statements that will be set in the shader.
  30885. */
  30886. defines: any;
  30887. /**
  30888. * Possible fallbacks for this effect to improve performance when needed.
  30889. */
  30890. fallbacks: Nullable<IEffectFallbacks>;
  30891. /**
  30892. * Callback that will be called when the shader is compiled.
  30893. */
  30894. onCompiled: Nullable<(effect: Effect) => void>;
  30895. /**
  30896. * Callback that will be called if an error occurs during shader compilation.
  30897. */
  30898. onError: Nullable<(effect: Effect, errors: string) => void>;
  30899. /**
  30900. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30901. */
  30902. indexParameters?: any;
  30903. /**
  30904. * Max number of lights that can be used in the shader.
  30905. */
  30906. maxSimultaneousLights?: number;
  30907. /**
  30908. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30909. */
  30910. transformFeedbackVaryings?: Nullable<string[]>;
  30911. }
  30912. /**
  30913. * Effect containing vertex and fragment shader that can be executed on an object.
  30914. */
  30915. export class Effect implements IDisposable {
  30916. /**
  30917. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30918. */
  30919. static ShadersRepository: string;
  30920. /**
  30921. * Name of the effect.
  30922. */
  30923. name: any;
  30924. /**
  30925. * String container all the define statements that should be set on the shader.
  30926. */
  30927. defines: string;
  30928. /**
  30929. * Callback that will be called when the shader is compiled.
  30930. */
  30931. onCompiled: Nullable<(effect: Effect) => void>;
  30932. /**
  30933. * Callback that will be called if an error occurs during shader compilation.
  30934. */
  30935. onError: Nullable<(effect: Effect, errors: string) => void>;
  30936. /**
  30937. * Callback that will be called when effect is bound.
  30938. */
  30939. onBind: Nullable<(effect: Effect) => void>;
  30940. /**
  30941. * Unique ID of the effect.
  30942. */
  30943. uniqueId: number;
  30944. /**
  30945. * Observable that will be called when the shader is compiled.
  30946. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30947. */
  30948. onCompileObservable: Observable<Effect>;
  30949. /**
  30950. * Observable that will be called if an error occurs during shader compilation.
  30951. */
  30952. onErrorObservable: Observable<Effect>;
  30953. /** @hidden */
  30954. _onBindObservable: Nullable<Observable<Effect>>;
  30955. /**
  30956. * @hidden
  30957. * Specifies if the effect was previously ready
  30958. */
  30959. _wasPreviouslyReady: boolean;
  30960. /**
  30961. * Observable that will be called when effect is bound.
  30962. */
  30963. get onBindObservable(): Observable<Effect>;
  30964. /** @hidden */
  30965. _bonesComputationForcedToCPU: boolean;
  30966. private static _uniqueIdSeed;
  30967. private _engine;
  30968. private _uniformBuffersNames;
  30969. private _uniformsNames;
  30970. private _samplerList;
  30971. private _samplers;
  30972. private _isReady;
  30973. private _compilationError;
  30974. private _allFallbacksProcessed;
  30975. private _attributesNames;
  30976. private _attributes;
  30977. private _attributeLocationByName;
  30978. private _uniforms;
  30979. /**
  30980. * Key for the effect.
  30981. * @hidden
  30982. */
  30983. _key: string;
  30984. private _indexParameters;
  30985. private _fallbacks;
  30986. private _vertexSourceCode;
  30987. private _fragmentSourceCode;
  30988. private _vertexSourceCodeOverride;
  30989. private _fragmentSourceCodeOverride;
  30990. private _transformFeedbackVaryings;
  30991. /**
  30992. * Compiled shader to webGL program.
  30993. * @hidden
  30994. */
  30995. _pipelineContext: Nullable<IPipelineContext>;
  30996. private _valueCache;
  30997. private static _baseCache;
  30998. /**
  30999. * Instantiates an effect.
  31000. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31001. * @param baseName Name of the effect.
  31002. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31003. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31004. * @param samplers List of sampler variables that will be passed to the shader.
  31005. * @param engine Engine to be used to render the effect
  31006. * @param defines Define statements to be added to the shader.
  31007. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31008. * @param onCompiled Callback that will be called when the shader is compiled.
  31009. * @param onError Callback that will be called if an error occurs during shader compilation.
  31010. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31011. */
  31012. 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);
  31013. private _useFinalCode;
  31014. /**
  31015. * Unique key for this effect
  31016. */
  31017. get key(): string;
  31018. /**
  31019. * If the effect has been compiled and prepared.
  31020. * @returns if the effect is compiled and prepared.
  31021. */
  31022. isReady(): boolean;
  31023. private _isReadyInternal;
  31024. /**
  31025. * The engine the effect was initialized with.
  31026. * @returns the engine.
  31027. */
  31028. getEngine(): Engine;
  31029. /**
  31030. * The pipeline context for this effect
  31031. * @returns the associated pipeline context
  31032. */
  31033. getPipelineContext(): Nullable<IPipelineContext>;
  31034. /**
  31035. * The set of names of attribute variables for the shader.
  31036. * @returns An array of attribute names.
  31037. */
  31038. getAttributesNames(): string[];
  31039. /**
  31040. * Returns the attribute at the given index.
  31041. * @param index The index of the attribute.
  31042. * @returns The location of the attribute.
  31043. */
  31044. getAttributeLocation(index: number): number;
  31045. /**
  31046. * Returns the attribute based on the name of the variable.
  31047. * @param name of the attribute to look up.
  31048. * @returns the attribute location.
  31049. */
  31050. getAttributeLocationByName(name: string): number;
  31051. /**
  31052. * The number of attributes.
  31053. * @returns the numnber of attributes.
  31054. */
  31055. getAttributesCount(): number;
  31056. /**
  31057. * Gets the index of a uniform variable.
  31058. * @param uniformName of the uniform to look up.
  31059. * @returns the index.
  31060. */
  31061. getUniformIndex(uniformName: string): number;
  31062. /**
  31063. * Returns the attribute based on the name of the variable.
  31064. * @param uniformName of the uniform to look up.
  31065. * @returns the location of the uniform.
  31066. */
  31067. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31068. /**
  31069. * Returns an array of sampler variable names
  31070. * @returns The array of sampler variable neames.
  31071. */
  31072. getSamplers(): string[];
  31073. /**
  31074. * The error from the last compilation.
  31075. * @returns the error string.
  31076. */
  31077. getCompilationError(): string;
  31078. /**
  31079. * Gets a boolean indicating that all fallbacks were used during compilation
  31080. * @returns true if all fallbacks were used
  31081. */
  31082. allFallbacksProcessed(): boolean;
  31083. /**
  31084. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31085. * @param func The callback to be used.
  31086. */
  31087. executeWhenCompiled(func: (effect: Effect) => void): void;
  31088. private _checkIsReady;
  31089. private _loadShader;
  31090. /**
  31091. * Recompiles the webGL program
  31092. * @param vertexSourceCode The source code for the vertex shader.
  31093. * @param fragmentSourceCode The source code for the fragment shader.
  31094. * @param onCompiled Callback called when completed.
  31095. * @param onError Callback called on error.
  31096. * @hidden
  31097. */
  31098. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31099. /**
  31100. * Prepares the effect
  31101. * @hidden
  31102. */
  31103. _prepareEffect(): void;
  31104. private _processCompilationErrors;
  31105. /**
  31106. * Checks if the effect is supported. (Must be called after compilation)
  31107. */
  31108. get isSupported(): boolean;
  31109. /**
  31110. * Binds a texture to the engine to be used as output of the shader.
  31111. * @param channel Name of the output variable.
  31112. * @param texture Texture to bind.
  31113. * @hidden
  31114. */
  31115. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31116. /**
  31117. * Sets a texture on the engine to be used in the shader.
  31118. * @param channel Name of the sampler variable.
  31119. * @param texture Texture to set.
  31120. */
  31121. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31122. /**
  31123. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31124. * @param channel Name of the sampler variable.
  31125. * @param texture Texture to set.
  31126. */
  31127. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31128. /**
  31129. * Sets an array of textures on the engine to be used in the shader.
  31130. * @param channel Name of the variable.
  31131. * @param textures Textures to set.
  31132. */
  31133. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31134. /**
  31135. * 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)
  31136. * @param channel Name of the sampler variable.
  31137. * @param postProcess Post process to get the input texture from.
  31138. */
  31139. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31140. /**
  31141. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31142. * 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)
  31143. * @param channel Name of the sampler variable.
  31144. * @param postProcess Post process to get the output texture from.
  31145. */
  31146. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31147. /** @hidden */
  31148. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31149. /** @hidden */
  31150. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31151. /** @hidden */
  31152. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31153. /** @hidden */
  31154. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31155. /**
  31156. * Binds a buffer to a uniform.
  31157. * @param buffer Buffer to bind.
  31158. * @param name Name of the uniform variable to bind to.
  31159. */
  31160. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31161. /**
  31162. * Binds block to a uniform.
  31163. * @param blockName Name of the block to bind.
  31164. * @param index Index to bind.
  31165. */
  31166. bindUniformBlock(blockName: string, index: number): void;
  31167. /**
  31168. * Sets an interger value on a uniform variable.
  31169. * @param uniformName Name of the variable.
  31170. * @param value Value to be set.
  31171. * @returns this effect.
  31172. */
  31173. setInt(uniformName: string, value: number): Effect;
  31174. /**
  31175. * Sets an int array on a uniform variable.
  31176. * @param uniformName Name of the variable.
  31177. * @param array array to be set.
  31178. * @returns this effect.
  31179. */
  31180. setIntArray(uniformName: string, array: Int32Array): Effect;
  31181. /**
  31182. * 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)
  31183. * @param uniformName Name of the variable.
  31184. * @param array array to be set.
  31185. * @returns this effect.
  31186. */
  31187. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31188. /**
  31189. * 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)
  31190. * @param uniformName Name of the variable.
  31191. * @param array array to be set.
  31192. * @returns this effect.
  31193. */
  31194. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31195. /**
  31196. * 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)
  31197. * @param uniformName Name of the variable.
  31198. * @param array array to be set.
  31199. * @returns this effect.
  31200. */
  31201. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31202. /**
  31203. * Sets an float array on a uniform variable.
  31204. * @param uniformName Name of the variable.
  31205. * @param array array to be set.
  31206. * @returns this effect.
  31207. */
  31208. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31209. /**
  31210. * 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)
  31211. * @param uniformName Name of the variable.
  31212. * @param array array to be set.
  31213. * @returns this effect.
  31214. */
  31215. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31216. /**
  31217. * 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)
  31218. * @param uniformName Name of the variable.
  31219. * @param array array to be set.
  31220. * @returns this effect.
  31221. */
  31222. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31223. /**
  31224. * 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)
  31225. * @param uniformName Name of the variable.
  31226. * @param array array to be set.
  31227. * @returns this effect.
  31228. */
  31229. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31230. /**
  31231. * Sets an array on a uniform variable.
  31232. * @param uniformName Name of the variable.
  31233. * @param array array to be set.
  31234. * @returns this effect.
  31235. */
  31236. setArray(uniformName: string, array: number[]): Effect;
  31237. /**
  31238. * 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)
  31239. * @param uniformName Name of the variable.
  31240. * @param array array to be set.
  31241. * @returns this effect.
  31242. */
  31243. setArray2(uniformName: string, array: number[]): Effect;
  31244. /**
  31245. * 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)
  31246. * @param uniformName Name of the variable.
  31247. * @param array array to be set.
  31248. * @returns this effect.
  31249. */
  31250. setArray3(uniformName: string, array: number[]): Effect;
  31251. /**
  31252. * 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)
  31253. * @param uniformName Name of the variable.
  31254. * @param array array to be set.
  31255. * @returns this effect.
  31256. */
  31257. setArray4(uniformName: string, array: number[]): Effect;
  31258. /**
  31259. * Sets matrices on a uniform variable.
  31260. * @param uniformName Name of the variable.
  31261. * @param matrices matrices to be set.
  31262. * @returns this effect.
  31263. */
  31264. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31265. /**
  31266. * Sets matrix on a uniform variable.
  31267. * @param uniformName Name of the variable.
  31268. * @param matrix matrix to be set.
  31269. * @returns this effect.
  31270. */
  31271. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31272. /**
  31273. * 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)
  31274. * @param uniformName Name of the variable.
  31275. * @param matrix matrix to be set.
  31276. * @returns this effect.
  31277. */
  31278. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31279. /**
  31280. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31281. * @param uniformName Name of the variable.
  31282. * @param matrix matrix to be set.
  31283. * @returns this effect.
  31284. */
  31285. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31286. /**
  31287. * Sets a float on a uniform variable.
  31288. * @param uniformName Name of the variable.
  31289. * @param value value to be set.
  31290. * @returns this effect.
  31291. */
  31292. setFloat(uniformName: string, value: number): Effect;
  31293. /**
  31294. * Sets a boolean on a uniform variable.
  31295. * @param uniformName Name of the variable.
  31296. * @param bool value to be set.
  31297. * @returns this effect.
  31298. */
  31299. setBool(uniformName: string, bool: boolean): Effect;
  31300. /**
  31301. * Sets a Vector2 on a uniform variable.
  31302. * @param uniformName Name of the variable.
  31303. * @param vector2 vector2 to be set.
  31304. * @returns this effect.
  31305. */
  31306. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31307. /**
  31308. * Sets a float2 on a uniform variable.
  31309. * @param uniformName Name of the variable.
  31310. * @param x First float in float2.
  31311. * @param y Second float in float2.
  31312. * @returns this effect.
  31313. */
  31314. setFloat2(uniformName: string, x: number, y: number): Effect;
  31315. /**
  31316. * Sets a Vector3 on a uniform variable.
  31317. * @param uniformName Name of the variable.
  31318. * @param vector3 Value to be set.
  31319. * @returns this effect.
  31320. */
  31321. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31322. /**
  31323. * Sets a float3 on a uniform variable.
  31324. * @param uniformName Name of the variable.
  31325. * @param x First float in float3.
  31326. * @param y Second float in float3.
  31327. * @param z Third float in float3.
  31328. * @returns this effect.
  31329. */
  31330. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31331. /**
  31332. * Sets a Vector4 on a uniform variable.
  31333. * @param uniformName Name of the variable.
  31334. * @param vector4 Value to be set.
  31335. * @returns this effect.
  31336. */
  31337. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31338. /**
  31339. * Sets a float4 on a uniform variable.
  31340. * @param uniformName Name of the variable.
  31341. * @param x First float in float4.
  31342. * @param y Second float in float4.
  31343. * @param z Third float in float4.
  31344. * @param w Fourth float in float4.
  31345. * @returns this effect.
  31346. */
  31347. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31348. /**
  31349. * Sets a Color3 on a uniform variable.
  31350. * @param uniformName Name of the variable.
  31351. * @param color3 Value to be set.
  31352. * @returns this effect.
  31353. */
  31354. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31355. /**
  31356. * Sets a Color4 on a uniform variable.
  31357. * @param uniformName Name of the variable.
  31358. * @param color3 Value to be set.
  31359. * @param alpha Alpha value to be set.
  31360. * @returns this effect.
  31361. */
  31362. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31363. /**
  31364. * Sets a Color4 on a uniform variable
  31365. * @param uniformName defines the name of the variable
  31366. * @param color4 defines the value to be set
  31367. * @returns this effect.
  31368. */
  31369. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31370. /** Release all associated resources */
  31371. dispose(): void;
  31372. /**
  31373. * This function will add a new shader to the shader store
  31374. * @param name the name of the shader
  31375. * @param pixelShader optional pixel shader content
  31376. * @param vertexShader optional vertex shader content
  31377. */
  31378. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31379. /**
  31380. * Store of each shader (The can be looked up using effect.key)
  31381. */
  31382. static ShadersStore: {
  31383. [key: string]: string;
  31384. };
  31385. /**
  31386. * Store of each included file for a shader (The can be looked up using effect.key)
  31387. */
  31388. static IncludesShadersStore: {
  31389. [key: string]: string;
  31390. };
  31391. /**
  31392. * Resets the cache of effects.
  31393. */
  31394. static ResetCache(): void;
  31395. }
  31396. }
  31397. declare module "babylonjs/Engines/engineCapabilities" {
  31398. /**
  31399. * Interface used to describe the capabilities of the engine relatively to the current browser
  31400. */
  31401. export interface EngineCapabilities {
  31402. /** Maximum textures units per fragment shader */
  31403. maxTexturesImageUnits: number;
  31404. /** Maximum texture units per vertex shader */
  31405. maxVertexTextureImageUnits: number;
  31406. /** Maximum textures units in the entire pipeline */
  31407. maxCombinedTexturesImageUnits: number;
  31408. /** Maximum texture size */
  31409. maxTextureSize: number;
  31410. /** Maximum texture samples */
  31411. maxSamples?: number;
  31412. /** Maximum cube texture size */
  31413. maxCubemapTextureSize: number;
  31414. /** Maximum render texture size */
  31415. maxRenderTextureSize: number;
  31416. /** Maximum number of vertex attributes */
  31417. maxVertexAttribs: number;
  31418. /** Maximum number of varyings */
  31419. maxVaryingVectors: number;
  31420. /** Maximum number of uniforms per vertex shader */
  31421. maxVertexUniformVectors: number;
  31422. /** Maximum number of uniforms per fragment shader */
  31423. maxFragmentUniformVectors: number;
  31424. /** Defines if standard derivates (dx/dy) are supported */
  31425. standardDerivatives: boolean;
  31426. /** Defines if s3tc texture compression is supported */
  31427. s3tc?: WEBGL_compressed_texture_s3tc;
  31428. /** Defines if pvrtc texture compression is supported */
  31429. pvrtc: any;
  31430. /** Defines if etc1 texture compression is supported */
  31431. etc1: any;
  31432. /** Defines if etc2 texture compression is supported */
  31433. etc2: any;
  31434. /** Defines if astc texture compression is supported */
  31435. astc: any;
  31436. /** Defines if float textures are supported */
  31437. textureFloat: boolean;
  31438. /** Defines if vertex array objects are supported */
  31439. vertexArrayObject: boolean;
  31440. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31441. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31442. /** Gets the maximum level of anisotropy supported */
  31443. maxAnisotropy: number;
  31444. /** Defines if instancing is supported */
  31445. instancedArrays: boolean;
  31446. /** Defines if 32 bits indices are supported */
  31447. uintIndices: boolean;
  31448. /** Defines if high precision shaders are supported */
  31449. highPrecisionShaderSupported: boolean;
  31450. /** Defines if depth reading in the fragment shader is supported */
  31451. fragmentDepthSupported: boolean;
  31452. /** Defines if float texture linear filtering is supported*/
  31453. textureFloatLinearFiltering: boolean;
  31454. /** Defines if rendering to float textures is supported */
  31455. textureFloatRender: boolean;
  31456. /** Defines if half float textures are supported*/
  31457. textureHalfFloat: boolean;
  31458. /** Defines if half float texture linear filtering is supported*/
  31459. textureHalfFloatLinearFiltering: boolean;
  31460. /** Defines if rendering to half float textures is supported */
  31461. textureHalfFloatRender: boolean;
  31462. /** Defines if textureLOD shader command is supported */
  31463. textureLOD: boolean;
  31464. /** Defines if draw buffers extension is supported */
  31465. drawBuffersExtension: boolean;
  31466. /** Defines if depth textures are supported */
  31467. depthTextureExtension: boolean;
  31468. /** Defines if float color buffer are supported */
  31469. colorBufferFloat: boolean;
  31470. /** Gets disjoint timer query extension (null if not supported) */
  31471. timerQuery?: EXT_disjoint_timer_query;
  31472. /** Defines if timestamp can be used with timer query */
  31473. canUseTimestampForTimerQuery: boolean;
  31474. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31475. multiview?: any;
  31476. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31477. oculusMultiview?: any;
  31478. /** Function used to let the system compiles shaders in background */
  31479. parallelShaderCompile?: {
  31480. COMPLETION_STATUS_KHR: number;
  31481. };
  31482. /** Max number of texture samples for MSAA */
  31483. maxMSAASamples: number;
  31484. /** Defines if the blend min max extension is supported */
  31485. blendMinMax: boolean;
  31486. }
  31487. }
  31488. declare module "babylonjs/States/depthCullingState" {
  31489. import { Nullable } from "babylonjs/types";
  31490. /**
  31491. * @hidden
  31492. **/
  31493. export class DepthCullingState {
  31494. private _isDepthTestDirty;
  31495. private _isDepthMaskDirty;
  31496. private _isDepthFuncDirty;
  31497. private _isCullFaceDirty;
  31498. private _isCullDirty;
  31499. private _isZOffsetDirty;
  31500. private _isFrontFaceDirty;
  31501. private _depthTest;
  31502. private _depthMask;
  31503. private _depthFunc;
  31504. private _cull;
  31505. private _cullFace;
  31506. private _zOffset;
  31507. private _frontFace;
  31508. /**
  31509. * Initializes the state.
  31510. */
  31511. constructor();
  31512. get isDirty(): boolean;
  31513. get zOffset(): number;
  31514. set zOffset(value: number);
  31515. get cullFace(): Nullable<number>;
  31516. set cullFace(value: Nullable<number>);
  31517. get cull(): Nullable<boolean>;
  31518. set cull(value: Nullable<boolean>);
  31519. get depthFunc(): Nullable<number>;
  31520. set depthFunc(value: Nullable<number>);
  31521. get depthMask(): boolean;
  31522. set depthMask(value: boolean);
  31523. get depthTest(): boolean;
  31524. set depthTest(value: boolean);
  31525. get frontFace(): Nullable<number>;
  31526. set frontFace(value: Nullable<number>);
  31527. reset(): void;
  31528. apply(gl: WebGLRenderingContext): void;
  31529. }
  31530. }
  31531. declare module "babylonjs/States/stencilState" {
  31532. /**
  31533. * @hidden
  31534. **/
  31535. export class StencilState {
  31536. /** 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 */
  31537. static readonly ALWAYS: number;
  31538. /** Passed to stencilOperation to specify that stencil value must be kept */
  31539. static readonly KEEP: number;
  31540. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31541. static readonly REPLACE: number;
  31542. private _isStencilTestDirty;
  31543. private _isStencilMaskDirty;
  31544. private _isStencilFuncDirty;
  31545. private _isStencilOpDirty;
  31546. private _stencilTest;
  31547. private _stencilMask;
  31548. private _stencilFunc;
  31549. private _stencilFuncRef;
  31550. private _stencilFuncMask;
  31551. private _stencilOpStencilFail;
  31552. private _stencilOpDepthFail;
  31553. private _stencilOpStencilDepthPass;
  31554. get isDirty(): boolean;
  31555. get stencilFunc(): number;
  31556. set stencilFunc(value: number);
  31557. get stencilFuncRef(): number;
  31558. set stencilFuncRef(value: number);
  31559. get stencilFuncMask(): number;
  31560. set stencilFuncMask(value: number);
  31561. get stencilOpStencilFail(): number;
  31562. set stencilOpStencilFail(value: number);
  31563. get stencilOpDepthFail(): number;
  31564. set stencilOpDepthFail(value: number);
  31565. get stencilOpStencilDepthPass(): number;
  31566. set stencilOpStencilDepthPass(value: number);
  31567. get stencilMask(): number;
  31568. set stencilMask(value: number);
  31569. get stencilTest(): boolean;
  31570. set stencilTest(value: boolean);
  31571. constructor();
  31572. reset(): void;
  31573. apply(gl: WebGLRenderingContext): void;
  31574. }
  31575. }
  31576. declare module "babylonjs/States/alphaCullingState" {
  31577. /**
  31578. * @hidden
  31579. **/
  31580. export class AlphaState {
  31581. private _isAlphaBlendDirty;
  31582. private _isBlendFunctionParametersDirty;
  31583. private _isBlendEquationParametersDirty;
  31584. private _isBlendConstantsDirty;
  31585. private _alphaBlend;
  31586. private _blendFunctionParameters;
  31587. private _blendEquationParameters;
  31588. private _blendConstants;
  31589. /**
  31590. * Initializes the state.
  31591. */
  31592. constructor();
  31593. get isDirty(): boolean;
  31594. get alphaBlend(): boolean;
  31595. set alphaBlend(value: boolean);
  31596. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31597. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31598. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31599. reset(): void;
  31600. apply(gl: WebGLRenderingContext): void;
  31601. }
  31602. }
  31603. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31604. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31605. /** @hidden */
  31606. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31607. attributeProcessor(attribute: string): string;
  31608. varyingProcessor(varying: string, isFragment: boolean): string;
  31609. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31610. }
  31611. }
  31612. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31613. /**
  31614. * Interface for attribute information associated with buffer instanciation
  31615. */
  31616. export interface InstancingAttributeInfo {
  31617. /**
  31618. * Name of the GLSL attribute
  31619. * if attribute index is not specified, this is used to retrieve the index from the effect
  31620. */
  31621. attributeName: string;
  31622. /**
  31623. * Index/offset of the attribute in the vertex shader
  31624. * if not specified, this will be computes from the name.
  31625. */
  31626. index?: number;
  31627. /**
  31628. * size of the attribute, 1, 2, 3 or 4
  31629. */
  31630. attributeSize: number;
  31631. /**
  31632. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31633. */
  31634. offset: number;
  31635. /**
  31636. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31637. * default to 1
  31638. */
  31639. divisor?: number;
  31640. /**
  31641. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31642. * default is FLOAT
  31643. */
  31644. attributeType?: number;
  31645. /**
  31646. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31647. */
  31648. normalized?: boolean;
  31649. }
  31650. }
  31651. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31652. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31653. import { Nullable } from "babylonjs/types";
  31654. module "babylonjs/Engines/thinEngine" {
  31655. interface ThinEngine {
  31656. /**
  31657. * Update a video texture
  31658. * @param texture defines the texture to update
  31659. * @param video defines the video element to use
  31660. * @param invertY defines if data must be stored with Y axis inverted
  31661. */
  31662. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31663. }
  31664. }
  31665. }
  31666. declare module "babylonjs/Materials/Textures/videoTexture" {
  31667. import { Observable } from "babylonjs/Misc/observable";
  31668. import { Nullable } from "babylonjs/types";
  31669. import { Scene } from "babylonjs/scene";
  31670. import { Texture } from "babylonjs/Materials/Textures/texture";
  31671. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31672. /**
  31673. * Settings for finer control over video usage
  31674. */
  31675. export interface VideoTextureSettings {
  31676. /**
  31677. * Applies `autoplay` to video, if specified
  31678. */
  31679. autoPlay?: boolean;
  31680. /**
  31681. * Applies `loop` to video, if specified
  31682. */
  31683. loop?: boolean;
  31684. /**
  31685. * Automatically updates internal texture from video at every frame in the render loop
  31686. */
  31687. autoUpdateTexture: boolean;
  31688. /**
  31689. * Image src displayed during the video loading or until the user interacts with the video.
  31690. */
  31691. poster?: string;
  31692. }
  31693. /**
  31694. * If you want to display a video in your scene, this is the special texture for that.
  31695. * This special texture works similar to other textures, with the exception of a few parameters.
  31696. * @see https://doc.babylonjs.com/how_to/video_texture
  31697. */
  31698. export class VideoTexture extends Texture {
  31699. /**
  31700. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31701. */
  31702. readonly autoUpdateTexture: boolean;
  31703. /**
  31704. * The video instance used by the texture internally
  31705. */
  31706. readonly video: HTMLVideoElement;
  31707. private _onUserActionRequestedObservable;
  31708. /**
  31709. * Event triggerd when a dom action is required by the user to play the video.
  31710. * This happens due to recent changes in browser policies preventing video to auto start.
  31711. */
  31712. get onUserActionRequestedObservable(): Observable<Texture>;
  31713. private _generateMipMaps;
  31714. private _engine;
  31715. private _stillImageCaptured;
  31716. private _displayingPosterTexture;
  31717. private _settings;
  31718. private _createInternalTextureOnEvent;
  31719. private _frameId;
  31720. private _currentSrc;
  31721. /**
  31722. * Creates a video texture.
  31723. * If you want to display a video in your scene, this is the special texture for that.
  31724. * This special texture works similar to other textures, with the exception of a few parameters.
  31725. * @see https://doc.babylonjs.com/how_to/video_texture
  31726. * @param name optional name, will detect from video source, if not defined
  31727. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31728. * @param scene is obviously the current scene.
  31729. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31730. * @param invertY is false by default but can be used to invert video on Y axis
  31731. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31732. * @param settings allows finer control over video usage
  31733. */
  31734. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31735. private _getName;
  31736. private _getVideo;
  31737. private _createInternalTexture;
  31738. private reset;
  31739. /**
  31740. * @hidden Internal method to initiate `update`.
  31741. */
  31742. _rebuild(): void;
  31743. /**
  31744. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31745. */
  31746. update(): void;
  31747. /**
  31748. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31749. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31750. */
  31751. updateTexture(isVisible: boolean): void;
  31752. protected _updateInternalTexture: () => void;
  31753. /**
  31754. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31755. * @param url New url.
  31756. */
  31757. updateURL(url: string): void;
  31758. /**
  31759. * Clones the texture.
  31760. * @returns the cloned texture
  31761. */
  31762. clone(): VideoTexture;
  31763. /**
  31764. * Dispose the texture and release its associated resources.
  31765. */
  31766. dispose(): void;
  31767. /**
  31768. * Creates a video texture straight from a stream.
  31769. * @param scene Define the scene the texture should be created in
  31770. * @param stream Define the stream the texture should be created from
  31771. * @returns The created video texture as a promise
  31772. */
  31773. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31774. /**
  31775. * Creates a video texture straight from your WebCam video feed.
  31776. * @param scene Define the scene the texture should be created in
  31777. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31778. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31779. * @returns The created video texture as a promise
  31780. */
  31781. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31782. minWidth: number;
  31783. maxWidth: number;
  31784. minHeight: number;
  31785. maxHeight: number;
  31786. deviceId: string;
  31787. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31788. /**
  31789. * Creates a video texture straight from your WebCam video feed.
  31790. * @param scene Define the scene the texture should be created in
  31791. * @param onReady Define a callback to triggered once the texture will be ready
  31792. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31793. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31794. */
  31795. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31796. minWidth: number;
  31797. maxWidth: number;
  31798. minHeight: number;
  31799. maxHeight: number;
  31800. deviceId: string;
  31801. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31802. }
  31803. }
  31804. declare module "babylonjs/Engines/thinEngine" {
  31805. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31806. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31807. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31808. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31809. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31810. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31811. import { Observable } from "babylonjs/Misc/observable";
  31812. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31813. import { StencilState } from "babylonjs/States/stencilState";
  31814. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31816. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31817. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31818. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31819. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31820. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31821. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31822. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31824. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31825. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31826. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31827. import { WebRequest } from "babylonjs/Misc/webRequest";
  31828. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31829. /**
  31830. * Defines the interface used by objects working like Scene
  31831. * @hidden
  31832. */
  31833. interface ISceneLike {
  31834. _addPendingData(data: any): void;
  31835. _removePendingData(data: any): void;
  31836. offlineProvider: IOfflineProvider;
  31837. }
  31838. /** Interface defining initialization parameters for Engine class */
  31839. export interface EngineOptions extends WebGLContextAttributes {
  31840. /**
  31841. * Defines if the engine should no exceed a specified device ratio
  31842. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31843. */
  31844. limitDeviceRatio?: number;
  31845. /**
  31846. * Defines if webvr should be enabled automatically
  31847. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31848. */
  31849. autoEnableWebVR?: boolean;
  31850. /**
  31851. * Defines if webgl2 should be turned off even if supported
  31852. * @see http://doc.babylonjs.com/features/webgl2
  31853. */
  31854. disableWebGL2Support?: boolean;
  31855. /**
  31856. * Defines if webaudio should be initialized as well
  31857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31858. */
  31859. audioEngine?: boolean;
  31860. /**
  31861. * Defines if animations should run using a deterministic lock step
  31862. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31863. */
  31864. deterministicLockstep?: boolean;
  31865. /** Defines the maximum steps to use with deterministic lock step mode */
  31866. lockstepMaxSteps?: number;
  31867. /** Defines the seconds between each deterministic lock step */
  31868. timeStep?: number;
  31869. /**
  31870. * Defines that engine should ignore context lost events
  31871. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31872. */
  31873. doNotHandleContextLost?: boolean;
  31874. /**
  31875. * Defines that engine should ignore modifying touch action attribute and style
  31876. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31877. */
  31878. doNotHandleTouchAction?: boolean;
  31879. /**
  31880. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31881. */
  31882. useHighPrecisionFloats?: boolean;
  31883. }
  31884. /**
  31885. * The base engine class (root of all engines)
  31886. */
  31887. export class ThinEngine {
  31888. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31889. static ExceptionList: ({
  31890. key: string;
  31891. capture: string;
  31892. captureConstraint: number;
  31893. targets: string[];
  31894. } | {
  31895. key: string;
  31896. capture: null;
  31897. captureConstraint: null;
  31898. targets: string[];
  31899. })[];
  31900. /** @hidden */
  31901. static _TextureLoaders: IInternalTextureLoader[];
  31902. /**
  31903. * Returns the current npm package of the sdk
  31904. */
  31905. static get NpmPackage(): string;
  31906. /**
  31907. * Returns the current version of the framework
  31908. */
  31909. static get Version(): string;
  31910. /**
  31911. * Returns a string describing the current engine
  31912. */
  31913. get description(): string;
  31914. /**
  31915. * Gets or sets the epsilon value used by collision engine
  31916. */
  31917. static CollisionsEpsilon: number;
  31918. /**
  31919. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31920. */
  31921. static get ShadersRepository(): string;
  31922. static set ShadersRepository(value: string);
  31923. /**
  31924. * Gets or sets the textures that the engine should not attempt to load as compressed
  31925. */
  31926. protected _excludedCompressedTextures: string[];
  31927. /**
  31928. * Filters the compressed texture formats to only include
  31929. * files that are not included in the skippable list
  31930. *
  31931. * @param url the current extension
  31932. * @param textureFormatInUse the current compressed texture format
  31933. * @returns "format" string
  31934. */
  31935. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31936. /** @hidden */
  31937. _shaderProcessor: IShaderProcessor;
  31938. /**
  31939. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31940. */
  31941. forcePOTTextures: boolean;
  31942. /**
  31943. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31944. */
  31945. isFullscreen: boolean;
  31946. /**
  31947. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31948. */
  31949. cullBackFaces: boolean;
  31950. /**
  31951. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31952. */
  31953. renderEvenInBackground: boolean;
  31954. /**
  31955. * Gets or sets a boolean indicating that cache can be kept between frames
  31956. */
  31957. preventCacheWipeBetweenFrames: boolean;
  31958. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31959. validateShaderPrograms: boolean;
  31960. /**
  31961. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31962. * This can provide greater z depth for distant objects.
  31963. */
  31964. useReverseDepthBuffer: boolean;
  31965. /**
  31966. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31967. */
  31968. disableUniformBuffers: boolean;
  31969. /** @hidden */
  31970. _uniformBuffers: UniformBuffer[];
  31971. /**
  31972. * Gets a boolean indicating that the engine supports uniform buffers
  31973. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31974. */
  31975. get supportsUniformBuffers(): boolean;
  31976. /** @hidden */
  31977. _gl: WebGLRenderingContext;
  31978. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31979. protected _windowIsBackground: boolean;
  31980. protected _webGLVersion: number;
  31981. protected _creationOptions: EngineOptions;
  31982. protected _highPrecisionShadersAllowed: boolean;
  31983. /** @hidden */
  31984. get _shouldUseHighPrecisionShader(): boolean;
  31985. /**
  31986. * Gets a boolean indicating that only power of 2 textures are supported
  31987. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31988. */
  31989. get needPOTTextures(): boolean;
  31990. /** @hidden */
  31991. _badOS: boolean;
  31992. /** @hidden */
  31993. _badDesktopOS: boolean;
  31994. private _hardwareScalingLevel;
  31995. /** @hidden */
  31996. _caps: EngineCapabilities;
  31997. private _isStencilEnable;
  31998. private _glVersion;
  31999. private _glRenderer;
  32000. private _glVendor;
  32001. /** @hidden */
  32002. _videoTextureSupported: boolean;
  32003. protected _renderingQueueLaunched: boolean;
  32004. protected _activeRenderLoops: (() => void)[];
  32005. /**
  32006. * Observable signaled when a context lost event is raised
  32007. */
  32008. onContextLostObservable: Observable<ThinEngine>;
  32009. /**
  32010. * Observable signaled when a context restored event is raised
  32011. */
  32012. onContextRestoredObservable: Observable<ThinEngine>;
  32013. private _onContextLost;
  32014. private _onContextRestored;
  32015. protected _contextWasLost: boolean;
  32016. /** @hidden */
  32017. _doNotHandleContextLost: boolean;
  32018. /**
  32019. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32021. */
  32022. get doNotHandleContextLost(): boolean;
  32023. set doNotHandleContextLost(value: boolean);
  32024. /**
  32025. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32026. */
  32027. disableVertexArrayObjects: boolean;
  32028. /** @hidden */
  32029. protected _colorWrite: boolean;
  32030. /** @hidden */
  32031. protected _colorWriteChanged: boolean;
  32032. /** @hidden */
  32033. protected _depthCullingState: DepthCullingState;
  32034. /** @hidden */
  32035. protected _stencilState: StencilState;
  32036. /** @hidden */
  32037. _alphaState: AlphaState;
  32038. /** @hidden */
  32039. _alphaMode: number;
  32040. /** @hidden */
  32041. _alphaEquation: number;
  32042. /** @hidden */
  32043. _internalTexturesCache: InternalTexture[];
  32044. /** @hidden */
  32045. protected _activeChannel: number;
  32046. private _currentTextureChannel;
  32047. /** @hidden */
  32048. protected _boundTexturesCache: {
  32049. [key: string]: Nullable<InternalTexture>;
  32050. };
  32051. /** @hidden */
  32052. protected _currentEffect: Nullable<Effect>;
  32053. /** @hidden */
  32054. protected _currentProgram: Nullable<WebGLProgram>;
  32055. private _compiledEffects;
  32056. private _vertexAttribArraysEnabled;
  32057. /** @hidden */
  32058. protected _cachedViewport: Nullable<IViewportLike>;
  32059. private _cachedVertexArrayObject;
  32060. /** @hidden */
  32061. protected _cachedVertexBuffers: any;
  32062. /** @hidden */
  32063. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32064. /** @hidden */
  32065. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32066. /** @hidden */
  32067. _currentRenderTarget: Nullable<InternalTexture>;
  32068. private _uintIndicesCurrentlySet;
  32069. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32070. /** @hidden */
  32071. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32072. private _currentBufferPointers;
  32073. private _currentInstanceLocations;
  32074. private _currentInstanceBuffers;
  32075. private _textureUnits;
  32076. /** @hidden */
  32077. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32078. /** @hidden */
  32079. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32080. /** @hidden */
  32081. _boundRenderFunction: any;
  32082. private _vaoRecordInProgress;
  32083. private _mustWipeVertexAttributes;
  32084. private _emptyTexture;
  32085. private _emptyCubeTexture;
  32086. private _emptyTexture3D;
  32087. private _emptyTexture2DArray;
  32088. /** @hidden */
  32089. _frameHandler: number;
  32090. private _nextFreeTextureSlots;
  32091. private _maxSimultaneousTextures;
  32092. private _activeRequests;
  32093. protected _texturesSupported: string[];
  32094. /** @hidden */
  32095. _textureFormatInUse: Nullable<string>;
  32096. protected get _supportsHardwareTextureRescaling(): boolean;
  32097. /**
  32098. * Gets the list of texture formats supported
  32099. */
  32100. get texturesSupported(): Array<string>;
  32101. /**
  32102. * Gets the list of texture formats in use
  32103. */
  32104. get textureFormatInUse(): Nullable<string>;
  32105. /**
  32106. * Gets the current viewport
  32107. */
  32108. get currentViewport(): Nullable<IViewportLike>;
  32109. /**
  32110. * Gets the default empty texture
  32111. */
  32112. get emptyTexture(): InternalTexture;
  32113. /**
  32114. * Gets the default empty 3D texture
  32115. */
  32116. get emptyTexture3D(): InternalTexture;
  32117. /**
  32118. * Gets the default empty 2D array texture
  32119. */
  32120. get emptyTexture2DArray(): InternalTexture;
  32121. /**
  32122. * Gets the default empty cube texture
  32123. */
  32124. get emptyCubeTexture(): InternalTexture;
  32125. /**
  32126. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32127. */
  32128. readonly premultipliedAlpha: boolean;
  32129. /**
  32130. * Observable event triggered before each texture is initialized
  32131. */
  32132. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32133. /**
  32134. * Creates a new engine
  32135. * @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
  32136. * @param antialias defines enable antialiasing (default: false)
  32137. * @param options defines further options to be sent to the getContext() function
  32138. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32139. */
  32140. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32141. private _rebuildInternalTextures;
  32142. private _rebuildEffects;
  32143. /**
  32144. * Gets a boolean indicating if all created effects are ready
  32145. * @returns true if all effects are ready
  32146. */
  32147. areAllEffectsReady(): boolean;
  32148. protected _rebuildBuffers(): void;
  32149. private _initGLContext;
  32150. /**
  32151. * Gets version of the current webGL context
  32152. */
  32153. get webGLVersion(): number;
  32154. /**
  32155. * Gets a string idenfifying the name of the class
  32156. * @returns "Engine" string
  32157. */
  32158. getClassName(): string;
  32159. /**
  32160. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32161. */
  32162. get isStencilEnable(): boolean;
  32163. /** @hidden */
  32164. _prepareWorkingCanvas(): void;
  32165. /**
  32166. * Reset the texture cache to empty state
  32167. */
  32168. resetTextureCache(): void;
  32169. /**
  32170. * Gets an object containing information about the current webGL context
  32171. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32172. */
  32173. getGlInfo(): {
  32174. vendor: string;
  32175. renderer: string;
  32176. version: string;
  32177. };
  32178. /**
  32179. * Defines the hardware scaling level.
  32180. * By default the hardware scaling level is computed from the window device ratio.
  32181. * 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.
  32182. * @param level defines the level to use
  32183. */
  32184. setHardwareScalingLevel(level: number): void;
  32185. /**
  32186. * Gets the current hardware scaling level.
  32187. * By default the hardware scaling level is computed from the window device ratio.
  32188. * 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.
  32189. * @returns a number indicating the current hardware scaling level
  32190. */
  32191. getHardwareScalingLevel(): number;
  32192. /**
  32193. * Gets the list of loaded textures
  32194. * @returns an array containing all loaded textures
  32195. */
  32196. getLoadedTexturesCache(): InternalTexture[];
  32197. /**
  32198. * Gets the object containing all engine capabilities
  32199. * @returns the EngineCapabilities object
  32200. */
  32201. getCaps(): EngineCapabilities;
  32202. /**
  32203. * stop executing a render loop function and remove it from the execution array
  32204. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32205. */
  32206. stopRenderLoop(renderFunction?: () => void): void;
  32207. /** @hidden */
  32208. _renderLoop(): void;
  32209. /**
  32210. * Gets the HTML canvas attached with the current webGL context
  32211. * @returns a HTML canvas
  32212. */
  32213. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32214. /**
  32215. * Gets host window
  32216. * @returns the host window object
  32217. */
  32218. getHostWindow(): Nullable<Window>;
  32219. /**
  32220. * Gets the current render width
  32221. * @param useScreen defines if screen size must be used (or the current render target if any)
  32222. * @returns a number defining the current render width
  32223. */
  32224. getRenderWidth(useScreen?: boolean): number;
  32225. /**
  32226. * Gets the current render height
  32227. * @param useScreen defines if screen size must be used (or the current render target if any)
  32228. * @returns a number defining the current render height
  32229. */
  32230. getRenderHeight(useScreen?: boolean): number;
  32231. /**
  32232. * Can be used to override the current requestAnimationFrame requester.
  32233. * @hidden
  32234. */
  32235. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32236. /**
  32237. * Register and execute a render loop. The engine can have more than one render function
  32238. * @param renderFunction defines the function to continuously execute
  32239. */
  32240. runRenderLoop(renderFunction: () => void): void;
  32241. /**
  32242. * Clear the current render buffer or the current render target (if any is set up)
  32243. * @param color defines the color to use
  32244. * @param backBuffer defines if the back buffer must be cleared
  32245. * @param depth defines if the depth buffer must be cleared
  32246. * @param stencil defines if the stencil buffer must be cleared
  32247. */
  32248. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32249. private _viewportCached;
  32250. /** @hidden */
  32251. _viewport(x: number, y: number, width: number, height: number): void;
  32252. /**
  32253. * Set the WebGL's viewport
  32254. * @param viewport defines the viewport element to be used
  32255. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32256. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32257. */
  32258. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32259. /**
  32260. * Begin a new frame
  32261. */
  32262. beginFrame(): void;
  32263. /**
  32264. * Enf the current frame
  32265. */
  32266. endFrame(): void;
  32267. /**
  32268. * Resize the view according to the canvas' size
  32269. */
  32270. resize(): void;
  32271. /**
  32272. * Force a specific size of the canvas
  32273. * @param width defines the new canvas' width
  32274. * @param height defines the new canvas' height
  32275. */
  32276. setSize(width: number, height: number): void;
  32277. /**
  32278. * Binds the frame buffer to the specified texture.
  32279. * @param texture The texture to render to or null for the default canvas
  32280. * @param faceIndex The face of the texture to render to in case of cube texture
  32281. * @param requiredWidth The width of the target to render to
  32282. * @param requiredHeight The height of the target to render to
  32283. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32284. * @param lodLevel defines the lod level to bind to the frame buffer
  32285. * @param layer defines the 2d array index to bind to frame buffer to
  32286. */
  32287. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32288. /** @hidden */
  32289. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32290. /**
  32291. * Unbind the current render target texture from the webGL context
  32292. * @param texture defines the render target texture to unbind
  32293. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32294. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32295. */
  32296. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32297. /**
  32298. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32299. */
  32300. flushFramebuffer(): void;
  32301. /**
  32302. * Unbind the current render target and bind the default framebuffer
  32303. */
  32304. restoreDefaultFramebuffer(): void;
  32305. /** @hidden */
  32306. protected _resetVertexBufferBinding(): void;
  32307. /**
  32308. * Creates a vertex buffer
  32309. * @param data the data for the vertex buffer
  32310. * @returns the new WebGL static buffer
  32311. */
  32312. createVertexBuffer(data: DataArray): DataBuffer;
  32313. private _createVertexBuffer;
  32314. /**
  32315. * Creates a dynamic vertex buffer
  32316. * @param data the data for the dynamic vertex buffer
  32317. * @returns the new WebGL dynamic buffer
  32318. */
  32319. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32320. protected _resetIndexBufferBinding(): void;
  32321. /**
  32322. * Creates a new index buffer
  32323. * @param indices defines the content of the index buffer
  32324. * @param updatable defines if the index buffer must be updatable
  32325. * @returns a new webGL buffer
  32326. */
  32327. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32328. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32329. /**
  32330. * Bind a webGL buffer to the webGL context
  32331. * @param buffer defines the buffer to bind
  32332. */
  32333. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32334. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32335. private bindBuffer;
  32336. /**
  32337. * update the bound buffer with the given data
  32338. * @param data defines the data to update
  32339. */
  32340. updateArrayBuffer(data: Float32Array): void;
  32341. private _vertexAttribPointer;
  32342. /** @hidden */
  32343. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32344. private _bindVertexBuffersAttributes;
  32345. /**
  32346. * Records a vertex array object
  32347. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32348. * @param vertexBuffers defines the list of vertex buffers to store
  32349. * @param indexBuffer defines the index buffer to store
  32350. * @param effect defines the effect to store
  32351. * @returns the new vertex array object
  32352. */
  32353. recordVertexArrayObject(vertexBuffers: {
  32354. [key: string]: VertexBuffer;
  32355. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32356. /**
  32357. * Bind a specific vertex array object
  32358. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32359. * @param vertexArrayObject defines the vertex array object to bind
  32360. * @param indexBuffer defines the index buffer to bind
  32361. */
  32362. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32363. /**
  32364. * Bind webGl buffers directly to the webGL context
  32365. * @param vertexBuffer defines the vertex buffer to bind
  32366. * @param indexBuffer defines the index buffer to bind
  32367. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32368. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32369. * @param effect defines the effect associated with the vertex buffer
  32370. */
  32371. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32372. private _unbindVertexArrayObject;
  32373. /**
  32374. * Bind a list of vertex buffers to the webGL context
  32375. * @param vertexBuffers defines the list of vertex buffers to bind
  32376. * @param indexBuffer defines the index buffer to bind
  32377. * @param effect defines the effect associated with the vertex buffers
  32378. */
  32379. bindBuffers(vertexBuffers: {
  32380. [key: string]: Nullable<VertexBuffer>;
  32381. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32382. /**
  32383. * Unbind all instance attributes
  32384. */
  32385. unbindInstanceAttributes(): void;
  32386. /**
  32387. * Release and free the memory of a vertex array object
  32388. * @param vao defines the vertex array object to delete
  32389. */
  32390. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32391. /** @hidden */
  32392. _releaseBuffer(buffer: DataBuffer): boolean;
  32393. protected _deleteBuffer(buffer: DataBuffer): void;
  32394. /**
  32395. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32396. * @param instancesBuffer defines the webGL buffer to update and bind
  32397. * @param data defines the data to store in the buffer
  32398. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32399. */
  32400. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32401. /**
  32402. * Bind the content of a webGL buffer used with instantiation
  32403. * @param instancesBuffer defines the webGL buffer to bind
  32404. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32405. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32406. */
  32407. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32408. /**
  32409. * Disable the instance attribute corresponding to the name in parameter
  32410. * @param name defines the name of the attribute to disable
  32411. */
  32412. disableInstanceAttributeByName(name: string): void;
  32413. /**
  32414. * Disable the instance attribute corresponding to the location in parameter
  32415. * @param attributeLocation defines the attribute location of the attribute to disable
  32416. */
  32417. disableInstanceAttribute(attributeLocation: number): void;
  32418. /**
  32419. * Disable the attribute corresponding to the location in parameter
  32420. * @param attributeLocation defines the attribute location of the attribute to disable
  32421. */
  32422. disableAttributeByIndex(attributeLocation: number): void;
  32423. /**
  32424. * Send a draw order
  32425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32426. * @param indexStart defines the starting index
  32427. * @param indexCount defines the number of index to draw
  32428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32429. */
  32430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32431. /**
  32432. * Draw a list of points
  32433. * @param verticesStart defines the index of first vertex to draw
  32434. * @param verticesCount defines the count of vertices to draw
  32435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32436. */
  32437. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32438. /**
  32439. * Draw a list of unindexed primitives
  32440. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32441. * @param verticesStart defines the index of first vertex to draw
  32442. * @param verticesCount defines the count of vertices to draw
  32443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32444. */
  32445. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32446. /**
  32447. * Draw a list of indexed primitives
  32448. * @param fillMode defines the primitive to use
  32449. * @param indexStart defines the starting index
  32450. * @param indexCount defines the number of index to draw
  32451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32452. */
  32453. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32454. /**
  32455. * Draw a list of unindexed primitives
  32456. * @param fillMode defines the primitive to use
  32457. * @param verticesStart defines the index of first vertex to draw
  32458. * @param verticesCount defines the count of vertices to draw
  32459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32460. */
  32461. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32462. private _drawMode;
  32463. /** @hidden */
  32464. protected _reportDrawCall(): void;
  32465. /** @hidden */
  32466. _releaseEffect(effect: Effect): void;
  32467. /** @hidden */
  32468. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32469. /**
  32470. * Create a new effect (used to store vertex/fragment shaders)
  32471. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32472. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32473. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32474. * @param samplers defines an array of string used to represent textures
  32475. * @param defines defines the string containing the defines to use to compile the shaders
  32476. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32477. * @param onCompiled defines a function to call when the effect creation is successful
  32478. * @param onError defines a function to call when the effect creation has failed
  32479. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32480. * @returns the new Effect
  32481. */
  32482. 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;
  32483. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32484. private _compileShader;
  32485. private _compileRawShader;
  32486. /**
  32487. * Directly creates a webGL program
  32488. * @param pipelineContext defines the pipeline context to attach to
  32489. * @param vertexCode defines the vertex shader code to use
  32490. * @param fragmentCode defines the fragment shader code to use
  32491. * @param context defines the webGL context to use (if not set, the current one will be used)
  32492. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32493. * @returns the new webGL program
  32494. */
  32495. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32496. /**
  32497. * Creates a webGL program
  32498. * @param pipelineContext defines the pipeline context to attach to
  32499. * @param vertexCode defines the vertex shader code to use
  32500. * @param fragmentCode defines the fragment shader code to use
  32501. * @param defines defines the string containing the defines to use to compile the shaders
  32502. * @param context defines the webGL context to use (if not set, the current one will be used)
  32503. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32504. * @returns the new webGL program
  32505. */
  32506. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32507. /**
  32508. * Creates a new pipeline context
  32509. * @returns the new pipeline
  32510. */
  32511. createPipelineContext(): IPipelineContext;
  32512. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32513. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32514. /** @hidden */
  32515. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32516. /** @hidden */
  32517. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32518. /** @hidden */
  32519. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32520. /**
  32521. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32522. * @param pipelineContext defines the pipeline context to use
  32523. * @param uniformsNames defines the list of uniform names
  32524. * @returns an array of webGL uniform locations
  32525. */
  32526. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32527. /**
  32528. * Gets the lsit of active attributes for a given webGL program
  32529. * @param pipelineContext defines the pipeline context to use
  32530. * @param attributesNames defines the list of attribute names to get
  32531. * @returns an array of indices indicating the offset of each attribute
  32532. */
  32533. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32534. /**
  32535. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32536. * @param effect defines the effect to activate
  32537. */
  32538. enableEffect(effect: Nullable<Effect>): void;
  32539. /**
  32540. * Set the value of an uniform to a number (int)
  32541. * @param uniform defines the webGL uniform location where to store the value
  32542. * @param value defines the int number to store
  32543. */
  32544. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32545. /**
  32546. * Set the value of an uniform to an array of int32
  32547. * @param uniform defines the webGL uniform location where to store the value
  32548. * @param array defines the array of int32 to store
  32549. */
  32550. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32551. /**
  32552. * Set the value of an uniform to an array of int32 (stored as vec2)
  32553. * @param uniform defines the webGL uniform location where to store the value
  32554. * @param array defines the array of int32 to store
  32555. */
  32556. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32557. /**
  32558. * Set the value of an uniform to an array of int32 (stored as vec3)
  32559. * @param uniform defines the webGL uniform location where to store the value
  32560. * @param array defines the array of int32 to store
  32561. */
  32562. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32563. /**
  32564. * Set the value of an uniform to an array of int32 (stored as vec4)
  32565. * @param uniform defines the webGL uniform location where to store the value
  32566. * @param array defines the array of int32 to store
  32567. */
  32568. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32569. /**
  32570. * Set the value of an uniform to an array of number
  32571. * @param uniform defines the webGL uniform location where to store the value
  32572. * @param array defines the array of number to store
  32573. */
  32574. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32575. /**
  32576. * Set the value of an uniform to an array of number (stored as vec2)
  32577. * @param uniform defines the webGL uniform location where to store the value
  32578. * @param array defines the array of number to store
  32579. */
  32580. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32581. /**
  32582. * Set the value of an uniform to an array of number (stored as vec3)
  32583. * @param uniform defines the webGL uniform location where to store the value
  32584. * @param array defines the array of number to store
  32585. */
  32586. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32587. /**
  32588. * Set the value of an uniform to an array of number (stored as vec4)
  32589. * @param uniform defines the webGL uniform location where to store the value
  32590. * @param array defines the array of number to store
  32591. */
  32592. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32593. /**
  32594. * Set the value of an uniform to an array of float32 (stored as matrices)
  32595. * @param uniform defines the webGL uniform location where to store the value
  32596. * @param matrices defines the array of float32 to store
  32597. */
  32598. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32599. /**
  32600. * Set the value of an uniform to a matrix (3x3)
  32601. * @param uniform defines the webGL uniform location where to store the value
  32602. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32603. */
  32604. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32605. /**
  32606. * Set the value of an uniform to a matrix (2x2)
  32607. * @param uniform defines the webGL uniform location where to store the value
  32608. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32609. */
  32610. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32611. /**
  32612. * Set the value of an uniform to a number (float)
  32613. * @param uniform defines the webGL uniform location where to store the value
  32614. * @param value defines the float number to store
  32615. */
  32616. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32617. /**
  32618. * Set the value of an uniform to a vec2
  32619. * @param uniform defines the webGL uniform location where to store the value
  32620. * @param x defines the 1st component of the value
  32621. * @param y defines the 2nd component of the value
  32622. */
  32623. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32624. /**
  32625. * Set the value of an uniform to a vec3
  32626. * @param uniform defines the webGL uniform location where to store the value
  32627. * @param x defines the 1st component of the value
  32628. * @param y defines the 2nd component of the value
  32629. * @param z defines the 3rd component of the value
  32630. */
  32631. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32632. /**
  32633. * Set the value of an uniform to a vec4
  32634. * @param uniform defines the webGL uniform location where to store the value
  32635. * @param x defines the 1st component of the value
  32636. * @param y defines the 2nd component of the value
  32637. * @param z defines the 3rd component of the value
  32638. * @param w defines the 4th component of the value
  32639. */
  32640. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32641. /**
  32642. * Apply all cached states (depth, culling, stencil and alpha)
  32643. */
  32644. applyStates(): void;
  32645. /**
  32646. * Enable or disable color writing
  32647. * @param enable defines the state to set
  32648. */
  32649. setColorWrite(enable: boolean): void;
  32650. /**
  32651. * Gets a boolean indicating if color writing is enabled
  32652. * @returns the current color writing state
  32653. */
  32654. getColorWrite(): boolean;
  32655. /**
  32656. * Gets the depth culling state manager
  32657. */
  32658. get depthCullingState(): DepthCullingState;
  32659. /**
  32660. * Gets the alpha state manager
  32661. */
  32662. get alphaState(): AlphaState;
  32663. /**
  32664. * Gets the stencil state manager
  32665. */
  32666. get stencilState(): StencilState;
  32667. /**
  32668. * Clears the list of texture accessible through engine.
  32669. * This can help preventing texture load conflict due to name collision.
  32670. */
  32671. clearInternalTexturesCache(): void;
  32672. /**
  32673. * Force the entire cache to be cleared
  32674. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32675. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32676. */
  32677. wipeCaches(bruteForce?: boolean): void;
  32678. /** @hidden */
  32679. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32680. min: number;
  32681. mag: number;
  32682. };
  32683. /** @hidden */
  32684. _createTexture(): WebGLTexture;
  32685. /**
  32686. * Usually called from Texture.ts.
  32687. * Passed information to create a WebGLTexture
  32688. * @param urlArg defines a value which contains one of the following:
  32689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32693. * @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)
  32694. * @param scene needed for loading to the correct scene
  32695. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32696. * @param onLoad optional callback to be called upon successful completion
  32697. * @param onError optional callback to be called upon failure
  32698. * @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
  32699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32701. * @param forcedExtension defines the extension to use to pick the right loader
  32702. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32703. * @param mimeType defines an optional mime type
  32704. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32705. */
  32706. 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;
  32707. /**
  32708. * Loads an image as an HTMLImageElement.
  32709. * @param input url string, ArrayBuffer, or Blob to load
  32710. * @param onLoad callback called when the image successfully loads
  32711. * @param onError callback called when the image fails to load
  32712. * @param offlineProvider offline provider for caching
  32713. * @param mimeType optional mime type
  32714. * @returns the HTMLImageElement of the loaded image
  32715. * @hidden
  32716. */
  32717. 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>;
  32718. /**
  32719. * @hidden
  32720. */
  32721. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32722. /**
  32723. * Creates a raw texture
  32724. * @param data defines the data to store in the texture
  32725. * @param width defines the width of the texture
  32726. * @param height defines the height of the texture
  32727. * @param format defines the format of the data
  32728. * @param generateMipMaps defines if the engine should generate the mip levels
  32729. * @param invertY defines if data must be stored with Y axis inverted
  32730. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32731. * @param compression defines the compression used (null by default)
  32732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32733. * @returns the raw texture inside an InternalTexture
  32734. */
  32735. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32736. /**
  32737. * Creates a new raw cube texture
  32738. * @param data defines the array of data to use to create each face
  32739. * @param size defines the size of the textures
  32740. * @param format defines the format of the data
  32741. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32742. * @param generateMipMaps defines if the engine should generate the mip levels
  32743. * @param invertY defines if data must be stored with Y axis inverted
  32744. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32745. * @param compression defines the compression used (null by default)
  32746. * @returns the cube texture as an InternalTexture
  32747. */
  32748. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32749. /**
  32750. * Creates a new raw 3D texture
  32751. * @param data defines the data used to create the texture
  32752. * @param width defines the width of the texture
  32753. * @param height defines the height of the texture
  32754. * @param depth defines the depth of the texture
  32755. * @param format defines the format of the texture
  32756. * @param generateMipMaps defines if the engine must generate mip levels
  32757. * @param invertY defines if data must be stored with Y axis inverted
  32758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32759. * @param compression defines the compressed used (can be null)
  32760. * @param textureType defines the compressed used (can be null)
  32761. * @returns a new raw 3D texture (stored in an InternalTexture)
  32762. */
  32763. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32764. /**
  32765. * Creates a new raw 2D array texture
  32766. * @param data defines the data used to create the texture
  32767. * @param width defines the width of the texture
  32768. * @param height defines the height of the texture
  32769. * @param depth defines the number of layers of the texture
  32770. * @param format defines the format of the texture
  32771. * @param generateMipMaps defines if the engine must generate mip levels
  32772. * @param invertY defines if data must be stored with Y axis inverted
  32773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32774. * @param compression defines the compressed used (can be null)
  32775. * @param textureType defines the compressed used (can be null)
  32776. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32777. */
  32778. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32779. private _unpackFlipYCached;
  32780. /**
  32781. * In case you are sharing the context with other applications, it might
  32782. * be interested to not cache the unpack flip y state to ensure a consistent
  32783. * value would be set.
  32784. */
  32785. enableUnpackFlipYCached: boolean;
  32786. /** @hidden */
  32787. _unpackFlipY(value: boolean): void;
  32788. /** @hidden */
  32789. _getUnpackAlignement(): number;
  32790. private _getTextureTarget;
  32791. /**
  32792. * Update the sampling mode of a given texture
  32793. * @param samplingMode defines the required sampling mode
  32794. * @param texture defines the texture to update
  32795. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32796. */
  32797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32798. /**
  32799. * Update the sampling mode of a given texture
  32800. * @param texture defines the texture to update
  32801. * @param wrapU defines the texture wrap mode of the u coordinates
  32802. * @param wrapV defines the texture wrap mode of the v coordinates
  32803. * @param wrapR defines the texture wrap mode of the r coordinates
  32804. */
  32805. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32806. /** @hidden */
  32807. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32808. width: number;
  32809. height: number;
  32810. layers?: number;
  32811. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32812. /** @hidden */
  32813. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32814. /** @hidden */
  32815. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32816. /**
  32817. * Update a portion of an internal texture
  32818. * @param texture defines the texture to update
  32819. * @param imageData defines the data to store into the texture
  32820. * @param xOffset defines the x coordinates of the update rectangle
  32821. * @param yOffset defines the y coordinates of the update rectangle
  32822. * @param width defines the width of the update rectangle
  32823. * @param height defines the height of the update rectangle
  32824. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32825. * @param lod defines the lod level to update (0 by default)
  32826. */
  32827. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32828. /** @hidden */
  32829. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32830. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32831. private _prepareWebGLTexture;
  32832. /** @hidden */
  32833. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32834. private _getDepthStencilBuffer;
  32835. /** @hidden */
  32836. _releaseFramebufferObjects(texture: InternalTexture): void;
  32837. /** @hidden */
  32838. _releaseTexture(texture: InternalTexture): void;
  32839. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32840. protected _setProgram(program: WebGLProgram): void;
  32841. protected _boundUniforms: {
  32842. [key: number]: WebGLUniformLocation;
  32843. };
  32844. /**
  32845. * Binds an effect to the webGL context
  32846. * @param effect defines the effect to bind
  32847. */
  32848. bindSamplers(effect: Effect): void;
  32849. private _activateCurrentTexture;
  32850. /** @hidden */
  32851. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32852. /** @hidden */
  32853. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32854. /**
  32855. * Unbind all textures from the webGL context
  32856. */
  32857. unbindAllTextures(): void;
  32858. /**
  32859. * Sets a texture to the according uniform.
  32860. * @param channel The texture channel
  32861. * @param uniform The uniform to set
  32862. * @param texture The texture to apply
  32863. */
  32864. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32865. private _bindSamplerUniformToChannel;
  32866. private _getTextureWrapMode;
  32867. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32868. /**
  32869. * Sets an array of texture to the webGL context
  32870. * @param channel defines the channel where the texture array must be set
  32871. * @param uniform defines the associated uniform location
  32872. * @param textures defines the array of textures to bind
  32873. */
  32874. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32875. /** @hidden */
  32876. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32877. private _setTextureParameterFloat;
  32878. private _setTextureParameterInteger;
  32879. /**
  32880. * Unbind all vertex attributes from the webGL context
  32881. */
  32882. unbindAllAttributes(): void;
  32883. /**
  32884. * 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
  32885. */
  32886. releaseEffects(): void;
  32887. /**
  32888. * Dispose and release all associated resources
  32889. */
  32890. dispose(): void;
  32891. /**
  32892. * Attach a new callback raised when context lost event is fired
  32893. * @param callback defines the callback to call
  32894. */
  32895. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32896. /**
  32897. * Attach a new callback raised when context restored event is fired
  32898. * @param callback defines the callback to call
  32899. */
  32900. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32901. /**
  32902. * Get the current error code of the webGL context
  32903. * @returns the error code
  32904. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32905. */
  32906. getError(): number;
  32907. private _canRenderToFloatFramebuffer;
  32908. private _canRenderToHalfFloatFramebuffer;
  32909. private _canRenderToFramebuffer;
  32910. /** @hidden */
  32911. _getWebGLTextureType(type: number): number;
  32912. /** @hidden */
  32913. _getInternalFormat(format: number): number;
  32914. /** @hidden */
  32915. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32916. /** @hidden */
  32917. _getRGBAMultiSampleBufferFormat(type: number): number;
  32918. /** @hidden */
  32919. _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;
  32920. /**
  32921. * Loads a file from a url
  32922. * @param url url to load
  32923. * @param onSuccess callback called when the file successfully loads
  32924. * @param onProgress callback called while file is loading (if the server supports this mode)
  32925. * @param offlineProvider defines the offline provider for caching
  32926. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32927. * @param onError callback called when the file fails to load
  32928. * @returns a file request object
  32929. * @hidden
  32930. */
  32931. 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;
  32932. /**
  32933. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32934. * @param x defines the x coordinate of the rectangle where pixels must be read
  32935. * @param y defines the y coordinate of the rectangle where pixels must be read
  32936. * @param width defines the width of the rectangle where pixels must be read
  32937. * @param height defines the height of the rectangle where pixels must be read
  32938. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32939. * @returns a Uint8Array containing RGBA colors
  32940. */
  32941. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32942. private static _isSupported;
  32943. /**
  32944. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32945. * @returns true if the engine can be created
  32946. * @ignorenaming
  32947. */
  32948. static isSupported(): boolean;
  32949. /**
  32950. * Find the next highest power of two.
  32951. * @param x Number to start search from.
  32952. * @return Next highest power of two.
  32953. */
  32954. static CeilingPOT(x: number): number;
  32955. /**
  32956. * Find the next lowest power of two.
  32957. * @param x Number to start search from.
  32958. * @return Next lowest power of two.
  32959. */
  32960. static FloorPOT(x: number): number;
  32961. /**
  32962. * Find the nearest power of two.
  32963. * @param x Number to start search from.
  32964. * @return Next nearest power of two.
  32965. */
  32966. static NearestPOT(x: number): number;
  32967. /**
  32968. * Get the closest exponent of two
  32969. * @param value defines the value to approximate
  32970. * @param max defines the maximum value to return
  32971. * @param mode defines how to define the closest value
  32972. * @returns closest exponent of two of the given value
  32973. */
  32974. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32975. /**
  32976. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32977. * @param func - the function to be called
  32978. * @param requester - the object that will request the next frame. Falls back to window.
  32979. * @returns frame number
  32980. */
  32981. static QueueNewFrame(func: () => void, requester?: any): number;
  32982. /**
  32983. * Gets host document
  32984. * @returns the host document object
  32985. */
  32986. getHostDocument(): Nullable<Document>;
  32987. }
  32988. }
  32989. declare module "babylonjs/Maths/sphericalPolynomial" {
  32990. import { Vector3 } from "babylonjs/Maths/math.vector";
  32991. import { Color3 } from "babylonjs/Maths/math.color";
  32992. /**
  32993. * Class representing spherical harmonics coefficients to the 3rd degree
  32994. */
  32995. export class SphericalHarmonics {
  32996. /**
  32997. * Defines whether or not the harmonics have been prescaled for rendering.
  32998. */
  32999. preScaled: boolean;
  33000. /**
  33001. * The l0,0 coefficients of the spherical harmonics
  33002. */
  33003. l00: Vector3;
  33004. /**
  33005. * The l1,-1 coefficients of the spherical harmonics
  33006. */
  33007. l1_1: Vector3;
  33008. /**
  33009. * The l1,0 coefficients of the spherical harmonics
  33010. */
  33011. l10: Vector3;
  33012. /**
  33013. * The l1,1 coefficients of the spherical harmonics
  33014. */
  33015. l11: Vector3;
  33016. /**
  33017. * The l2,-2 coefficients of the spherical harmonics
  33018. */
  33019. l2_2: Vector3;
  33020. /**
  33021. * The l2,-1 coefficients of the spherical harmonics
  33022. */
  33023. l2_1: Vector3;
  33024. /**
  33025. * The l2,0 coefficients of the spherical harmonics
  33026. */
  33027. l20: Vector3;
  33028. /**
  33029. * The l2,1 coefficients of the spherical harmonics
  33030. */
  33031. l21: Vector3;
  33032. /**
  33033. * The l2,2 coefficients of the spherical harmonics
  33034. */
  33035. l22: Vector3;
  33036. /**
  33037. * Adds a light to the spherical harmonics
  33038. * @param direction the direction of the light
  33039. * @param color the color of the light
  33040. * @param deltaSolidAngle the delta solid angle of the light
  33041. */
  33042. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33043. /**
  33044. * Scales the spherical harmonics by the given amount
  33045. * @param scale the amount to scale
  33046. */
  33047. scaleInPlace(scale: number): void;
  33048. /**
  33049. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33050. *
  33051. * ```
  33052. * E_lm = A_l * L_lm
  33053. * ```
  33054. *
  33055. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33056. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33057. * the scaling factors are given in equation 9.
  33058. */
  33059. convertIncidentRadianceToIrradiance(): void;
  33060. /**
  33061. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33062. *
  33063. * ```
  33064. * L = (1/pi) * E * rho
  33065. * ```
  33066. *
  33067. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33068. */
  33069. convertIrradianceToLambertianRadiance(): void;
  33070. /**
  33071. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33072. * required operations at run time.
  33073. *
  33074. * This is simply done by scaling back the SH with Ylm constants parameter.
  33075. * The trigonometric part being applied by the shader at run time.
  33076. */
  33077. preScaleForRendering(): void;
  33078. /**
  33079. * Constructs a spherical harmonics from an array.
  33080. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33081. * @returns the spherical harmonics
  33082. */
  33083. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33084. /**
  33085. * Gets the spherical harmonics from polynomial
  33086. * @param polynomial the spherical polynomial
  33087. * @returns the spherical harmonics
  33088. */
  33089. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33090. }
  33091. /**
  33092. * Class representing spherical polynomial coefficients to the 3rd degree
  33093. */
  33094. export class SphericalPolynomial {
  33095. private _harmonics;
  33096. /**
  33097. * The spherical harmonics used to create the polynomials.
  33098. */
  33099. get preScaledHarmonics(): SphericalHarmonics;
  33100. /**
  33101. * The x coefficients of the spherical polynomial
  33102. */
  33103. x: Vector3;
  33104. /**
  33105. * The y coefficients of the spherical polynomial
  33106. */
  33107. y: Vector3;
  33108. /**
  33109. * The z coefficients of the spherical polynomial
  33110. */
  33111. z: Vector3;
  33112. /**
  33113. * The xx coefficients of the spherical polynomial
  33114. */
  33115. xx: Vector3;
  33116. /**
  33117. * The yy coefficients of the spherical polynomial
  33118. */
  33119. yy: Vector3;
  33120. /**
  33121. * The zz coefficients of the spherical polynomial
  33122. */
  33123. zz: Vector3;
  33124. /**
  33125. * The xy coefficients of the spherical polynomial
  33126. */
  33127. xy: Vector3;
  33128. /**
  33129. * The yz coefficients of the spherical polynomial
  33130. */
  33131. yz: Vector3;
  33132. /**
  33133. * The zx coefficients of the spherical polynomial
  33134. */
  33135. zx: Vector3;
  33136. /**
  33137. * Adds an ambient color to the spherical polynomial
  33138. * @param color the color to add
  33139. */
  33140. addAmbient(color: Color3): void;
  33141. /**
  33142. * Scales the spherical polynomial by the given amount
  33143. * @param scale the amount to scale
  33144. */
  33145. scaleInPlace(scale: number): void;
  33146. /**
  33147. * Gets the spherical polynomial from harmonics
  33148. * @param harmonics the spherical harmonics
  33149. * @returns the spherical polynomial
  33150. */
  33151. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33152. /**
  33153. * Constructs a spherical polynomial from an array.
  33154. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33155. * @returns the spherical polynomial
  33156. */
  33157. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33158. }
  33159. }
  33160. declare module "babylonjs/Materials/Textures/internalTexture" {
  33161. import { Observable } from "babylonjs/Misc/observable";
  33162. import { Nullable, int } from "babylonjs/types";
  33163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33165. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33166. /**
  33167. * Defines the source of the internal texture
  33168. */
  33169. export enum InternalTextureSource {
  33170. /**
  33171. * The source of the texture data is unknown
  33172. */
  33173. Unknown = 0,
  33174. /**
  33175. * Texture data comes from an URL
  33176. */
  33177. Url = 1,
  33178. /**
  33179. * Texture data is only used for temporary storage
  33180. */
  33181. Temp = 2,
  33182. /**
  33183. * Texture data comes from raw data (ArrayBuffer)
  33184. */
  33185. Raw = 3,
  33186. /**
  33187. * Texture content is dynamic (video or dynamic texture)
  33188. */
  33189. Dynamic = 4,
  33190. /**
  33191. * Texture content is generated by rendering to it
  33192. */
  33193. RenderTarget = 5,
  33194. /**
  33195. * Texture content is part of a multi render target process
  33196. */
  33197. MultiRenderTarget = 6,
  33198. /**
  33199. * Texture data comes from a cube data file
  33200. */
  33201. Cube = 7,
  33202. /**
  33203. * Texture data comes from a raw cube data
  33204. */
  33205. CubeRaw = 8,
  33206. /**
  33207. * Texture data come from a prefiltered cube data file
  33208. */
  33209. CubePrefiltered = 9,
  33210. /**
  33211. * Texture content is raw 3D data
  33212. */
  33213. Raw3D = 10,
  33214. /**
  33215. * Texture content is raw 2D array data
  33216. */
  33217. Raw2DArray = 11,
  33218. /**
  33219. * Texture content is a depth texture
  33220. */
  33221. Depth = 12,
  33222. /**
  33223. * Texture data comes from a raw cube data encoded with RGBD
  33224. */
  33225. CubeRawRGBD = 13
  33226. }
  33227. /**
  33228. * Class used to store data associated with WebGL texture data for the engine
  33229. * This class should not be used directly
  33230. */
  33231. export class InternalTexture {
  33232. /** @hidden */
  33233. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33234. /**
  33235. * Defines if the texture is ready
  33236. */
  33237. isReady: boolean;
  33238. /**
  33239. * Defines if the texture is a cube texture
  33240. */
  33241. isCube: boolean;
  33242. /**
  33243. * Defines if the texture contains 3D data
  33244. */
  33245. is3D: boolean;
  33246. /**
  33247. * Defines if the texture contains 2D array data
  33248. */
  33249. is2DArray: boolean;
  33250. /**
  33251. * Defines if the texture contains multiview data
  33252. */
  33253. isMultiview: boolean;
  33254. /**
  33255. * Gets the URL used to load this texture
  33256. */
  33257. url: string;
  33258. /**
  33259. * Gets the sampling mode of the texture
  33260. */
  33261. samplingMode: number;
  33262. /**
  33263. * Gets a boolean indicating if the texture needs mipmaps generation
  33264. */
  33265. generateMipMaps: boolean;
  33266. /**
  33267. * Gets the number of samples used by the texture (WebGL2+ only)
  33268. */
  33269. samples: number;
  33270. /**
  33271. * Gets the type of the texture (int, float...)
  33272. */
  33273. type: number;
  33274. /**
  33275. * Gets the format of the texture (RGB, RGBA...)
  33276. */
  33277. format: number;
  33278. /**
  33279. * Observable called when the texture is loaded
  33280. */
  33281. onLoadedObservable: Observable<InternalTexture>;
  33282. /**
  33283. * Gets the width of the texture
  33284. */
  33285. width: number;
  33286. /**
  33287. * Gets the height of the texture
  33288. */
  33289. height: number;
  33290. /**
  33291. * Gets the depth of the texture
  33292. */
  33293. depth: number;
  33294. /**
  33295. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33296. */
  33297. baseWidth: number;
  33298. /**
  33299. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33300. */
  33301. baseHeight: number;
  33302. /**
  33303. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33304. */
  33305. baseDepth: number;
  33306. /**
  33307. * Gets a boolean indicating if the texture is inverted on Y axis
  33308. */
  33309. invertY: boolean;
  33310. /** @hidden */
  33311. _invertVScale: boolean;
  33312. /** @hidden */
  33313. _associatedChannel: number;
  33314. /** @hidden */
  33315. _source: InternalTextureSource;
  33316. /** @hidden */
  33317. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33318. /** @hidden */
  33319. _bufferView: Nullable<ArrayBufferView>;
  33320. /** @hidden */
  33321. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33322. /** @hidden */
  33323. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33324. /** @hidden */
  33325. _size: number;
  33326. /** @hidden */
  33327. _extension: string;
  33328. /** @hidden */
  33329. _files: Nullable<string[]>;
  33330. /** @hidden */
  33331. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33332. /** @hidden */
  33333. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33334. /** @hidden */
  33335. _framebuffer: Nullable<WebGLFramebuffer>;
  33336. /** @hidden */
  33337. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33338. /** @hidden */
  33339. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33340. /** @hidden */
  33341. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33342. /** @hidden */
  33343. _attachments: Nullable<number[]>;
  33344. /** @hidden */
  33345. _cachedCoordinatesMode: Nullable<number>;
  33346. /** @hidden */
  33347. _cachedWrapU: Nullable<number>;
  33348. /** @hidden */
  33349. _cachedWrapV: Nullable<number>;
  33350. /** @hidden */
  33351. _cachedWrapR: Nullable<number>;
  33352. /** @hidden */
  33353. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33354. /** @hidden */
  33355. _isDisabled: boolean;
  33356. /** @hidden */
  33357. _compression: Nullable<string>;
  33358. /** @hidden */
  33359. _generateStencilBuffer: boolean;
  33360. /** @hidden */
  33361. _generateDepthBuffer: boolean;
  33362. /** @hidden */
  33363. _comparisonFunction: number;
  33364. /** @hidden */
  33365. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33366. /** @hidden */
  33367. _lodGenerationScale: number;
  33368. /** @hidden */
  33369. _lodGenerationOffset: number;
  33370. /** @hidden */
  33371. _depthStencilTexture: Nullable<InternalTexture>;
  33372. /** @hidden */
  33373. _colorTextureArray: Nullable<WebGLTexture>;
  33374. /** @hidden */
  33375. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33376. /** @hidden */
  33377. _lodTextureHigh: Nullable<BaseTexture>;
  33378. /** @hidden */
  33379. _lodTextureMid: Nullable<BaseTexture>;
  33380. /** @hidden */
  33381. _lodTextureLow: Nullable<BaseTexture>;
  33382. /** @hidden */
  33383. _isRGBD: boolean;
  33384. /** @hidden */
  33385. _linearSpecularLOD: boolean;
  33386. /** @hidden */
  33387. _irradianceTexture: Nullable<BaseTexture>;
  33388. /** @hidden */
  33389. _webGLTexture: Nullable<WebGLTexture>;
  33390. /** @hidden */
  33391. _references: number;
  33392. private _engine;
  33393. /**
  33394. * Gets the Engine the texture belongs to.
  33395. * @returns The babylon engine
  33396. */
  33397. getEngine(): ThinEngine;
  33398. /**
  33399. * Gets the data source type of the texture
  33400. */
  33401. get source(): InternalTextureSource;
  33402. /**
  33403. * Creates a new InternalTexture
  33404. * @param engine defines the engine to use
  33405. * @param source defines the type of data that will be used
  33406. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33407. */
  33408. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33409. /**
  33410. * Increments the number of references (ie. the number of Texture that point to it)
  33411. */
  33412. incrementReferences(): void;
  33413. /**
  33414. * Change the size of the texture (not the size of the content)
  33415. * @param width defines the new width
  33416. * @param height defines the new height
  33417. * @param depth defines the new depth (1 by default)
  33418. */
  33419. updateSize(width: int, height: int, depth?: int): void;
  33420. /** @hidden */
  33421. _rebuild(): void;
  33422. /** @hidden */
  33423. _swapAndDie(target: InternalTexture): void;
  33424. /**
  33425. * Dispose the current allocated resources
  33426. */
  33427. dispose(): void;
  33428. }
  33429. }
  33430. declare module "babylonjs/Audio/analyser" {
  33431. import { Scene } from "babylonjs/scene";
  33432. /**
  33433. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33435. */
  33436. export class Analyser {
  33437. /**
  33438. * Gets or sets the smoothing
  33439. * @ignorenaming
  33440. */
  33441. SMOOTHING: number;
  33442. /**
  33443. * Gets or sets the FFT table size
  33444. * @ignorenaming
  33445. */
  33446. FFT_SIZE: number;
  33447. /**
  33448. * Gets or sets the bar graph amplitude
  33449. * @ignorenaming
  33450. */
  33451. BARGRAPHAMPLITUDE: number;
  33452. /**
  33453. * Gets or sets the position of the debug canvas
  33454. * @ignorenaming
  33455. */
  33456. DEBUGCANVASPOS: {
  33457. x: number;
  33458. y: number;
  33459. };
  33460. /**
  33461. * Gets or sets the debug canvas size
  33462. * @ignorenaming
  33463. */
  33464. DEBUGCANVASSIZE: {
  33465. width: number;
  33466. height: number;
  33467. };
  33468. private _byteFreqs;
  33469. private _byteTime;
  33470. private _floatFreqs;
  33471. private _webAudioAnalyser;
  33472. private _debugCanvas;
  33473. private _debugCanvasContext;
  33474. private _scene;
  33475. private _registerFunc;
  33476. private _audioEngine;
  33477. /**
  33478. * Creates a new analyser
  33479. * @param scene defines hosting scene
  33480. */
  33481. constructor(scene: Scene);
  33482. /**
  33483. * Get the number of data values you will have to play with for the visualization
  33484. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33485. * @returns a number
  33486. */
  33487. getFrequencyBinCount(): number;
  33488. /**
  33489. * Gets the current frequency data as a byte array
  33490. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33491. * @returns a Uint8Array
  33492. */
  33493. getByteFrequencyData(): Uint8Array;
  33494. /**
  33495. * Gets the current waveform as a byte array
  33496. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33497. * @returns a Uint8Array
  33498. */
  33499. getByteTimeDomainData(): Uint8Array;
  33500. /**
  33501. * Gets the current frequency data as a float array
  33502. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33503. * @returns a Float32Array
  33504. */
  33505. getFloatFrequencyData(): Float32Array;
  33506. /**
  33507. * Renders the debug canvas
  33508. */
  33509. drawDebugCanvas(): void;
  33510. /**
  33511. * Stops rendering the debug canvas and removes it
  33512. */
  33513. stopDebugCanvas(): void;
  33514. /**
  33515. * Connects two audio nodes
  33516. * @param inputAudioNode defines first node to connect
  33517. * @param outputAudioNode defines second node to connect
  33518. */
  33519. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33520. /**
  33521. * Releases all associated resources
  33522. */
  33523. dispose(): void;
  33524. }
  33525. }
  33526. declare module "babylonjs/Audio/audioEngine" {
  33527. import { IDisposable } from "babylonjs/scene";
  33528. import { Analyser } from "babylonjs/Audio/analyser";
  33529. import { Nullable } from "babylonjs/types";
  33530. import { Observable } from "babylonjs/Misc/observable";
  33531. /**
  33532. * This represents an audio engine and it is responsible
  33533. * to play, synchronize and analyse sounds throughout the application.
  33534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33535. */
  33536. export interface IAudioEngine extends IDisposable {
  33537. /**
  33538. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33539. */
  33540. readonly canUseWebAudio: boolean;
  33541. /**
  33542. * Gets the current AudioContext if available.
  33543. */
  33544. readonly audioContext: Nullable<AudioContext>;
  33545. /**
  33546. * The master gain node defines the global audio volume of your audio engine.
  33547. */
  33548. readonly masterGain: GainNode;
  33549. /**
  33550. * Gets whether or not mp3 are supported by your browser.
  33551. */
  33552. readonly isMP3supported: boolean;
  33553. /**
  33554. * Gets whether or not ogg are supported by your browser.
  33555. */
  33556. readonly isOGGsupported: boolean;
  33557. /**
  33558. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33559. * @ignoreNaming
  33560. */
  33561. WarnedWebAudioUnsupported: boolean;
  33562. /**
  33563. * Defines if the audio engine relies on a custom unlocked button.
  33564. * In this case, the embedded button will not be displayed.
  33565. */
  33566. useCustomUnlockedButton: boolean;
  33567. /**
  33568. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33569. */
  33570. readonly unlocked: boolean;
  33571. /**
  33572. * Event raised when audio has been unlocked on the browser.
  33573. */
  33574. onAudioUnlockedObservable: Observable<AudioEngine>;
  33575. /**
  33576. * Event raised when audio has been locked on the browser.
  33577. */
  33578. onAudioLockedObservable: Observable<AudioEngine>;
  33579. /**
  33580. * Flags the audio engine in Locked state.
  33581. * This happens due to new browser policies preventing audio to autoplay.
  33582. */
  33583. lock(): void;
  33584. /**
  33585. * Unlocks the audio engine once a user action has been done on the dom.
  33586. * This is helpful to resume play once browser policies have been satisfied.
  33587. */
  33588. unlock(): void;
  33589. }
  33590. /**
  33591. * This represents the default audio engine used in babylon.
  33592. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33594. */
  33595. export class AudioEngine implements IAudioEngine {
  33596. private _audioContext;
  33597. private _audioContextInitialized;
  33598. private _muteButton;
  33599. private _hostElement;
  33600. /**
  33601. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33602. */
  33603. canUseWebAudio: boolean;
  33604. /**
  33605. * The master gain node defines the global audio volume of your audio engine.
  33606. */
  33607. masterGain: GainNode;
  33608. /**
  33609. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33610. * @ignoreNaming
  33611. */
  33612. WarnedWebAudioUnsupported: boolean;
  33613. /**
  33614. * Gets whether or not mp3 are supported by your browser.
  33615. */
  33616. isMP3supported: boolean;
  33617. /**
  33618. * Gets whether or not ogg are supported by your browser.
  33619. */
  33620. isOGGsupported: boolean;
  33621. /**
  33622. * Gets whether audio has been unlocked on the device.
  33623. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33624. * a user interaction has happened.
  33625. */
  33626. unlocked: boolean;
  33627. /**
  33628. * Defines if the audio engine relies on a custom unlocked button.
  33629. * In this case, the embedded button will not be displayed.
  33630. */
  33631. useCustomUnlockedButton: boolean;
  33632. /**
  33633. * Event raised when audio has been unlocked on the browser.
  33634. */
  33635. onAudioUnlockedObservable: Observable<AudioEngine>;
  33636. /**
  33637. * Event raised when audio has been locked on the browser.
  33638. */
  33639. onAudioLockedObservable: Observable<AudioEngine>;
  33640. /**
  33641. * Gets the current AudioContext if available.
  33642. */
  33643. get audioContext(): Nullable<AudioContext>;
  33644. private _connectedAnalyser;
  33645. /**
  33646. * Instantiates a new audio engine.
  33647. *
  33648. * There should be only one per page as some browsers restrict the number
  33649. * of audio contexts you can create.
  33650. * @param hostElement defines the host element where to display the mute icon if necessary
  33651. */
  33652. constructor(hostElement?: Nullable<HTMLElement>);
  33653. /**
  33654. * Flags the audio engine in Locked state.
  33655. * This happens due to new browser policies preventing audio to autoplay.
  33656. */
  33657. lock(): void;
  33658. /**
  33659. * Unlocks the audio engine once a user action has been done on the dom.
  33660. * This is helpful to resume play once browser policies have been satisfied.
  33661. */
  33662. unlock(): void;
  33663. private _resumeAudioContext;
  33664. private _initializeAudioContext;
  33665. private _tryToRun;
  33666. private _triggerRunningState;
  33667. private _triggerSuspendedState;
  33668. private _displayMuteButton;
  33669. private _moveButtonToTopLeft;
  33670. private _onResize;
  33671. private _hideMuteButton;
  33672. /**
  33673. * Destroy and release the resources associated with the audio ccontext.
  33674. */
  33675. dispose(): void;
  33676. /**
  33677. * Gets the global volume sets on the master gain.
  33678. * @returns the global volume if set or -1 otherwise
  33679. */
  33680. getGlobalVolume(): number;
  33681. /**
  33682. * Sets the global volume of your experience (sets on the master gain).
  33683. * @param newVolume Defines the new global volume of the application
  33684. */
  33685. setGlobalVolume(newVolume: number): void;
  33686. /**
  33687. * Connect the audio engine to an audio analyser allowing some amazing
  33688. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33690. * @param analyser The analyser to connect to the engine
  33691. */
  33692. connectToAnalyser(analyser: Analyser): void;
  33693. }
  33694. }
  33695. declare module "babylonjs/Loading/loadingScreen" {
  33696. /**
  33697. * Interface used to present a loading screen while loading a scene
  33698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33699. */
  33700. export interface ILoadingScreen {
  33701. /**
  33702. * Function called to display the loading screen
  33703. */
  33704. displayLoadingUI: () => void;
  33705. /**
  33706. * Function called to hide the loading screen
  33707. */
  33708. hideLoadingUI: () => void;
  33709. /**
  33710. * Gets or sets the color to use for the background
  33711. */
  33712. loadingUIBackgroundColor: string;
  33713. /**
  33714. * Gets or sets the text to display while loading
  33715. */
  33716. loadingUIText: string;
  33717. }
  33718. /**
  33719. * Class used for the default loading screen
  33720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33721. */
  33722. export class DefaultLoadingScreen implements ILoadingScreen {
  33723. private _renderingCanvas;
  33724. private _loadingText;
  33725. private _loadingDivBackgroundColor;
  33726. private _loadingDiv;
  33727. private _loadingTextDiv;
  33728. /** Gets or sets the logo url to use for the default loading screen */
  33729. static DefaultLogoUrl: string;
  33730. /** Gets or sets the spinner url to use for the default loading screen */
  33731. static DefaultSpinnerUrl: string;
  33732. /**
  33733. * Creates a new default loading screen
  33734. * @param _renderingCanvas defines the canvas used to render the scene
  33735. * @param _loadingText defines the default text to display
  33736. * @param _loadingDivBackgroundColor defines the default background color
  33737. */
  33738. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33739. /**
  33740. * Function called to display the loading screen
  33741. */
  33742. displayLoadingUI(): void;
  33743. /**
  33744. * Function called to hide the loading screen
  33745. */
  33746. hideLoadingUI(): void;
  33747. /**
  33748. * Gets or sets the text to display while loading
  33749. */
  33750. set loadingUIText(text: string);
  33751. get loadingUIText(): string;
  33752. /**
  33753. * Gets or sets the color to use for the background
  33754. */
  33755. get loadingUIBackgroundColor(): string;
  33756. set loadingUIBackgroundColor(color: string);
  33757. private _resizeLoadingUI;
  33758. }
  33759. }
  33760. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33761. /**
  33762. * Interface for any object that can request an animation frame
  33763. */
  33764. export interface ICustomAnimationFrameRequester {
  33765. /**
  33766. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33767. */
  33768. renderFunction?: Function;
  33769. /**
  33770. * Called to request the next frame to render to
  33771. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33772. */
  33773. requestAnimationFrame: Function;
  33774. /**
  33775. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33776. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33777. */
  33778. requestID?: number;
  33779. }
  33780. }
  33781. declare module "babylonjs/Misc/performanceMonitor" {
  33782. /**
  33783. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33784. */
  33785. export class PerformanceMonitor {
  33786. private _enabled;
  33787. private _rollingFrameTime;
  33788. private _lastFrameTimeMs;
  33789. /**
  33790. * constructor
  33791. * @param frameSampleSize The number of samples required to saturate the sliding window
  33792. */
  33793. constructor(frameSampleSize?: number);
  33794. /**
  33795. * Samples current frame
  33796. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33797. */
  33798. sampleFrame(timeMs?: number): void;
  33799. /**
  33800. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33801. */
  33802. get averageFrameTime(): number;
  33803. /**
  33804. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33805. */
  33806. get averageFrameTimeVariance(): number;
  33807. /**
  33808. * Returns the frame time of the most recent frame
  33809. */
  33810. get instantaneousFrameTime(): number;
  33811. /**
  33812. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33813. */
  33814. get averageFPS(): number;
  33815. /**
  33816. * Returns the average framerate in frames per second using the most recent frame time
  33817. */
  33818. get instantaneousFPS(): number;
  33819. /**
  33820. * Returns true if enough samples have been taken to completely fill the sliding window
  33821. */
  33822. get isSaturated(): boolean;
  33823. /**
  33824. * Enables contributions to the sliding window sample set
  33825. */
  33826. enable(): void;
  33827. /**
  33828. * Disables contributions to the sliding window sample set
  33829. * Samples will not be interpolated over the disabled period
  33830. */
  33831. disable(): void;
  33832. /**
  33833. * Returns true if sampling is enabled
  33834. */
  33835. get isEnabled(): boolean;
  33836. /**
  33837. * Resets performance monitor
  33838. */
  33839. reset(): void;
  33840. }
  33841. /**
  33842. * RollingAverage
  33843. *
  33844. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33845. */
  33846. export class RollingAverage {
  33847. /**
  33848. * Current average
  33849. */
  33850. average: number;
  33851. /**
  33852. * Current variance
  33853. */
  33854. variance: number;
  33855. protected _samples: Array<number>;
  33856. protected _sampleCount: number;
  33857. protected _pos: number;
  33858. protected _m2: number;
  33859. /**
  33860. * constructor
  33861. * @param length The number of samples required to saturate the sliding window
  33862. */
  33863. constructor(length: number);
  33864. /**
  33865. * Adds a sample to the sample set
  33866. * @param v The sample value
  33867. */
  33868. add(v: number): void;
  33869. /**
  33870. * Returns previously added values or null if outside of history or outside the sliding window domain
  33871. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33872. * @return Value previously recorded with add() or null if outside of range
  33873. */
  33874. history(i: number): number;
  33875. /**
  33876. * Returns true if enough samples have been taken to completely fill the sliding window
  33877. * @return true if sample-set saturated
  33878. */
  33879. isSaturated(): boolean;
  33880. /**
  33881. * Resets the rolling average (equivalent to 0 samples taken so far)
  33882. */
  33883. reset(): void;
  33884. /**
  33885. * Wraps a value around the sample range boundaries
  33886. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33887. * @return Wrapped position in sample range
  33888. */
  33889. protected _wrapPosition(i: number): number;
  33890. }
  33891. }
  33892. declare module "babylonjs/Misc/perfCounter" {
  33893. /**
  33894. * This class is used to track a performance counter which is number based.
  33895. * The user has access to many properties which give statistics of different nature.
  33896. *
  33897. * The implementer can track two kinds of Performance Counter: time and count.
  33898. * 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.
  33899. * 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.
  33900. */
  33901. export class PerfCounter {
  33902. /**
  33903. * Gets or sets a global boolean to turn on and off all the counters
  33904. */
  33905. static Enabled: boolean;
  33906. /**
  33907. * Returns the smallest value ever
  33908. */
  33909. get min(): number;
  33910. /**
  33911. * Returns the biggest value ever
  33912. */
  33913. get max(): number;
  33914. /**
  33915. * Returns the average value since the performance counter is running
  33916. */
  33917. get average(): number;
  33918. /**
  33919. * Returns the average value of the last second the counter was monitored
  33920. */
  33921. get lastSecAverage(): number;
  33922. /**
  33923. * Returns the current value
  33924. */
  33925. get current(): number;
  33926. /**
  33927. * Gets the accumulated total
  33928. */
  33929. get total(): number;
  33930. /**
  33931. * Gets the total value count
  33932. */
  33933. get count(): number;
  33934. /**
  33935. * Creates a new counter
  33936. */
  33937. constructor();
  33938. /**
  33939. * Call this method to start monitoring a new frame.
  33940. * 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.
  33941. */
  33942. fetchNewFrame(): void;
  33943. /**
  33944. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33945. * @param newCount the count value to add to the monitored count
  33946. * @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.
  33947. */
  33948. addCount(newCount: number, fetchResult: boolean): void;
  33949. /**
  33950. * Start monitoring this performance counter
  33951. */
  33952. beginMonitoring(): void;
  33953. /**
  33954. * Compute the time lapsed since the previous beginMonitoring() call.
  33955. * @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
  33956. */
  33957. endMonitoring(newFrame?: boolean): void;
  33958. private _fetchResult;
  33959. private _startMonitoringTime;
  33960. private _min;
  33961. private _max;
  33962. private _average;
  33963. private _current;
  33964. private _totalValueCount;
  33965. private _totalAccumulated;
  33966. private _lastSecAverage;
  33967. private _lastSecAccumulated;
  33968. private _lastSecTime;
  33969. private _lastSecValueCount;
  33970. }
  33971. }
  33972. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33973. module "babylonjs/Engines/thinEngine" {
  33974. interface ThinEngine {
  33975. /**
  33976. * Sets alpha constants used by some alpha blending modes
  33977. * @param r defines the red component
  33978. * @param g defines the green component
  33979. * @param b defines the blue component
  33980. * @param a defines the alpha component
  33981. */
  33982. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33983. /**
  33984. * Sets the current alpha mode
  33985. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33986. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33987. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33988. */
  33989. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33990. /**
  33991. * Gets the current alpha mode
  33992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33993. * @returns the current alpha mode
  33994. */
  33995. getAlphaMode(): number;
  33996. /**
  33997. * Sets the current alpha equation
  33998. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33999. */
  34000. setAlphaEquation(equation: number): void;
  34001. /**
  34002. * Gets the current alpha equation.
  34003. * @returns the current alpha equation
  34004. */
  34005. getAlphaEquation(): number;
  34006. }
  34007. }
  34008. }
  34009. declare module "babylonjs/Engines/engine" {
  34010. import { Observable } from "babylonjs/Misc/observable";
  34011. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34012. import { Scene } from "babylonjs/scene";
  34013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34014. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34015. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34016. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34017. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34018. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34019. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34020. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34021. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34022. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34023. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34024. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34025. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34026. import "babylonjs/Engines/Extensions/engine.alpha";
  34027. import { Material } from "babylonjs/Materials/material";
  34028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34029. /**
  34030. * Defines the interface used by display changed events
  34031. */
  34032. export interface IDisplayChangedEventArgs {
  34033. /** Gets the vrDisplay object (if any) */
  34034. vrDisplay: Nullable<any>;
  34035. /** Gets a boolean indicating if webVR is supported */
  34036. vrSupported: boolean;
  34037. }
  34038. /**
  34039. * Defines the interface used by objects containing a viewport (like a camera)
  34040. */
  34041. interface IViewportOwnerLike {
  34042. /**
  34043. * Gets or sets the viewport
  34044. */
  34045. viewport: IViewportLike;
  34046. }
  34047. /**
  34048. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34049. */
  34050. export class Engine extends ThinEngine {
  34051. /** Defines that alpha blending is disabled */
  34052. static readonly ALPHA_DISABLE: number;
  34053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34054. static readonly ALPHA_ADD: number;
  34055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34056. static readonly ALPHA_COMBINE: number;
  34057. /** Defines that alpha blending to DEST - SRC * DEST */
  34058. static readonly ALPHA_SUBTRACT: number;
  34059. /** Defines that alpha blending to SRC * DEST */
  34060. static readonly ALPHA_MULTIPLY: number;
  34061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34062. static readonly ALPHA_MAXIMIZED: number;
  34063. /** Defines that alpha blending to SRC + DEST */
  34064. static readonly ALPHA_ONEONE: number;
  34065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34066. static readonly ALPHA_PREMULTIPLIED: number;
  34067. /**
  34068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34070. */
  34071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34073. static readonly ALPHA_INTERPOLATE: number;
  34074. /**
  34075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34077. */
  34078. static readonly ALPHA_SCREENMODE: number;
  34079. /** Defines that the ressource is not delayed*/
  34080. static readonly DELAYLOADSTATE_NONE: number;
  34081. /** Defines that the ressource was successfully delay loaded */
  34082. static readonly DELAYLOADSTATE_LOADED: number;
  34083. /** Defines that the ressource is currently delay loading */
  34084. static readonly DELAYLOADSTATE_LOADING: number;
  34085. /** Defines that the ressource is delayed and has not started loading */
  34086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34088. static readonly NEVER: number;
  34089. /** 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 */
  34090. static readonly ALWAYS: number;
  34091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34092. static readonly LESS: number;
  34093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34094. static readonly EQUAL: number;
  34095. /** 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 */
  34096. static readonly LEQUAL: number;
  34097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34098. static readonly GREATER: number;
  34099. /** 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 */
  34100. static readonly GEQUAL: number;
  34101. /** 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 */
  34102. static readonly NOTEQUAL: number;
  34103. /** Passed to stencilOperation to specify that stencil value must be kept */
  34104. static readonly KEEP: number;
  34105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34106. static readonly REPLACE: number;
  34107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34108. static readonly INCR: number;
  34109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34110. static readonly DECR: number;
  34111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34112. static readonly INVERT: number;
  34113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34114. static readonly INCR_WRAP: number;
  34115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34116. static readonly DECR_WRAP: number;
  34117. /** Texture is not repeating outside of 0..1 UVs */
  34118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34119. /** Texture is repeating outside of 0..1 UVs */
  34120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34121. /** Texture is repeating and mirrored */
  34122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34123. /** ALPHA */
  34124. static readonly TEXTUREFORMAT_ALPHA: number;
  34125. /** LUMINANCE */
  34126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34127. /** LUMINANCE_ALPHA */
  34128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34129. /** RGB */
  34130. static readonly TEXTUREFORMAT_RGB: number;
  34131. /** RGBA */
  34132. static readonly TEXTUREFORMAT_RGBA: number;
  34133. /** RED */
  34134. static readonly TEXTUREFORMAT_RED: number;
  34135. /** RED (2nd reference) */
  34136. static readonly TEXTUREFORMAT_R: number;
  34137. /** RG */
  34138. static readonly TEXTUREFORMAT_RG: number;
  34139. /** RED_INTEGER */
  34140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34141. /** RED_INTEGER (2nd reference) */
  34142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34143. /** RG_INTEGER */
  34144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34145. /** RGB_INTEGER */
  34146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34147. /** RGBA_INTEGER */
  34148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34149. /** UNSIGNED_BYTE */
  34150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34151. /** UNSIGNED_BYTE (2nd reference) */
  34152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34153. /** FLOAT */
  34154. static readonly TEXTURETYPE_FLOAT: number;
  34155. /** HALF_FLOAT */
  34156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34157. /** BYTE */
  34158. static readonly TEXTURETYPE_BYTE: number;
  34159. /** SHORT */
  34160. static readonly TEXTURETYPE_SHORT: number;
  34161. /** UNSIGNED_SHORT */
  34162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34163. /** INT */
  34164. static readonly TEXTURETYPE_INT: number;
  34165. /** UNSIGNED_INT */
  34166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34167. /** UNSIGNED_SHORT_4_4_4_4 */
  34168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34169. /** UNSIGNED_SHORT_5_5_5_1 */
  34170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34171. /** UNSIGNED_SHORT_5_6_5 */
  34172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34173. /** UNSIGNED_INT_2_10_10_10_REV */
  34174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34175. /** UNSIGNED_INT_24_8 */
  34176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34177. /** UNSIGNED_INT_10F_11F_11F_REV */
  34178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34179. /** UNSIGNED_INT_5_9_9_9_REV */
  34180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34183. /** nearest is mag = nearest and min = nearest and mip = linear */
  34184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34187. /** Trilinear is mag = linear and min = linear and mip = linear */
  34188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34189. /** nearest is mag = nearest and min = nearest and mip = linear */
  34190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34193. /** Trilinear is mag = linear and min = linear and mip = linear */
  34194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34195. /** mag = nearest and min = nearest and mip = nearest */
  34196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34197. /** mag = nearest and min = linear and mip = nearest */
  34198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34199. /** mag = nearest and min = linear and mip = linear */
  34200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34201. /** mag = nearest and min = linear and mip = none */
  34202. static readonly TEXTURE_NEAREST_LINEAR: number;
  34203. /** mag = nearest and min = nearest and mip = none */
  34204. static readonly TEXTURE_NEAREST_NEAREST: number;
  34205. /** mag = linear and min = nearest and mip = nearest */
  34206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34207. /** mag = linear and min = nearest and mip = linear */
  34208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34209. /** mag = linear and min = linear and mip = none */
  34210. static readonly TEXTURE_LINEAR_LINEAR: number;
  34211. /** mag = linear and min = nearest and mip = none */
  34212. static readonly TEXTURE_LINEAR_NEAREST: number;
  34213. /** Explicit coordinates mode */
  34214. static readonly TEXTURE_EXPLICIT_MODE: number;
  34215. /** Spherical coordinates mode */
  34216. static readonly TEXTURE_SPHERICAL_MODE: number;
  34217. /** Planar coordinates mode */
  34218. static readonly TEXTURE_PLANAR_MODE: number;
  34219. /** Cubic coordinates mode */
  34220. static readonly TEXTURE_CUBIC_MODE: number;
  34221. /** Projection coordinates mode */
  34222. static readonly TEXTURE_PROJECTION_MODE: number;
  34223. /** Skybox coordinates mode */
  34224. static readonly TEXTURE_SKYBOX_MODE: number;
  34225. /** Inverse Cubic coordinates mode */
  34226. static readonly TEXTURE_INVCUBIC_MODE: number;
  34227. /** Equirectangular coordinates mode */
  34228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34229. /** Equirectangular Fixed coordinates mode */
  34230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34231. /** Equirectangular Fixed Mirrored coordinates mode */
  34232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34234. static readonly SCALEMODE_FLOOR: number;
  34235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34236. static readonly SCALEMODE_NEAREST: number;
  34237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34238. static readonly SCALEMODE_CEILING: number;
  34239. /**
  34240. * Returns the current npm package of the sdk
  34241. */
  34242. static get NpmPackage(): string;
  34243. /**
  34244. * Returns the current version of the framework
  34245. */
  34246. static get Version(): string;
  34247. /** Gets the list of created engines */
  34248. static get Instances(): Engine[];
  34249. /**
  34250. * Gets the latest created engine
  34251. */
  34252. static get LastCreatedEngine(): Nullable<Engine>;
  34253. /**
  34254. * Gets the latest created scene
  34255. */
  34256. static get LastCreatedScene(): Nullable<Scene>;
  34257. /**
  34258. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34259. * @param flag defines which part of the materials must be marked as dirty
  34260. * @param predicate defines a predicate used to filter which materials should be affected
  34261. */
  34262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34263. /**
  34264. * Method called to create the default loading screen.
  34265. * This can be overriden in your own app.
  34266. * @param canvas The rendering canvas element
  34267. * @returns The loading screen
  34268. */
  34269. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34270. /**
  34271. * Method called to create the default rescale post process on each engine.
  34272. */
  34273. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34274. /**
  34275. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34276. **/
  34277. enableOfflineSupport: boolean;
  34278. /**
  34279. * 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)
  34280. **/
  34281. disableManifestCheck: boolean;
  34282. /**
  34283. * Gets the list of created scenes
  34284. */
  34285. scenes: Scene[];
  34286. /**
  34287. * Event raised when a new scene is created
  34288. */
  34289. onNewSceneAddedObservable: Observable<Scene>;
  34290. /**
  34291. * Gets the list of created postprocesses
  34292. */
  34293. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34294. /**
  34295. * Gets a boolean indicating if the pointer is currently locked
  34296. */
  34297. isPointerLock: boolean;
  34298. /**
  34299. * Observable event triggered each time the rendering canvas is resized
  34300. */
  34301. onResizeObservable: Observable<Engine>;
  34302. /**
  34303. * Observable event triggered each time the canvas loses focus
  34304. */
  34305. onCanvasBlurObservable: Observable<Engine>;
  34306. /**
  34307. * Observable event triggered each time the canvas gains focus
  34308. */
  34309. onCanvasFocusObservable: Observable<Engine>;
  34310. /**
  34311. * Observable event triggered each time the canvas receives pointerout event
  34312. */
  34313. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34314. /**
  34315. * Observable raised when the engine begins a new frame
  34316. */
  34317. onBeginFrameObservable: Observable<Engine>;
  34318. /**
  34319. * If set, will be used to request the next animation frame for the render loop
  34320. */
  34321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34322. /**
  34323. * Observable raised when the engine ends the current frame
  34324. */
  34325. onEndFrameObservable: Observable<Engine>;
  34326. /**
  34327. * Observable raised when the engine is about to compile a shader
  34328. */
  34329. onBeforeShaderCompilationObservable: Observable<Engine>;
  34330. /**
  34331. * Observable raised when the engine has jsut compiled a shader
  34332. */
  34333. onAfterShaderCompilationObservable: Observable<Engine>;
  34334. /**
  34335. * Gets the audio engine
  34336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34337. * @ignorenaming
  34338. */
  34339. static audioEngine: IAudioEngine;
  34340. /**
  34341. * Default AudioEngine factory responsible of creating the Audio Engine.
  34342. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34343. */
  34344. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34345. /**
  34346. * Default offline support factory responsible of creating a tool used to store data locally.
  34347. * By default, this will create a Database object if the workload has been embedded.
  34348. */
  34349. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34350. private _loadingScreen;
  34351. private _pointerLockRequested;
  34352. private _dummyFramebuffer;
  34353. private _rescalePostProcess;
  34354. private _deterministicLockstep;
  34355. private _lockstepMaxSteps;
  34356. private _timeStep;
  34357. protected get _supportsHardwareTextureRescaling(): boolean;
  34358. private _fps;
  34359. private _deltaTime;
  34360. /** @hidden */
  34361. _drawCalls: PerfCounter;
  34362. /** 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 */
  34363. canvasTabIndex: number;
  34364. /**
  34365. * Turn this value on if you want to pause FPS computation when in background
  34366. */
  34367. disablePerformanceMonitorInBackground: boolean;
  34368. private _performanceMonitor;
  34369. /**
  34370. * Gets the performance monitor attached to this engine
  34371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34372. */
  34373. get performanceMonitor(): PerformanceMonitor;
  34374. private _onFocus;
  34375. private _onBlur;
  34376. private _onCanvasPointerOut;
  34377. private _onCanvasBlur;
  34378. private _onCanvasFocus;
  34379. private _onFullscreenChange;
  34380. private _onPointerLockChange;
  34381. /**
  34382. * Gets the HTML element used to attach event listeners
  34383. * @returns a HTML element
  34384. */
  34385. getInputElement(): Nullable<HTMLElement>;
  34386. /**
  34387. * Creates a new engine
  34388. * @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
  34389. * @param antialias defines enable antialiasing (default: false)
  34390. * @param options defines further options to be sent to the getContext() function
  34391. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34392. */
  34393. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34394. /**
  34395. * Gets current aspect ratio
  34396. * @param viewportOwner defines the camera to use to get the aspect ratio
  34397. * @param useScreen defines if screen size must be used (or the current render target if any)
  34398. * @returns a number defining the aspect ratio
  34399. */
  34400. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34401. /**
  34402. * Gets current screen aspect ratio
  34403. * @returns a number defining the aspect ratio
  34404. */
  34405. getScreenAspectRatio(): number;
  34406. /**
  34407. * Gets the client rect of the HTML canvas attached with the current webGL context
  34408. * @returns a client rectanglee
  34409. */
  34410. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34411. /**
  34412. * Gets the client rect of the HTML element used for events
  34413. * @returns a client rectanglee
  34414. */
  34415. getInputElementClientRect(): Nullable<ClientRect>;
  34416. /**
  34417. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34419. * @returns true if engine is in deterministic lock step mode
  34420. */
  34421. isDeterministicLockStep(): boolean;
  34422. /**
  34423. * Gets the max steps when engine is running in deterministic lock step
  34424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34425. * @returns the max steps
  34426. */
  34427. getLockstepMaxSteps(): number;
  34428. /**
  34429. * Returns the time in ms between steps when using deterministic lock step.
  34430. * @returns time step in (ms)
  34431. */
  34432. getTimeStep(): number;
  34433. /**
  34434. * Force the mipmap generation for the given render target texture
  34435. * @param texture defines the render target texture to use
  34436. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34437. */
  34438. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34439. /** States */
  34440. /**
  34441. * Set various states to the webGL context
  34442. * @param culling defines backface culling state
  34443. * @param zOffset defines the value to apply to zOffset (0 by default)
  34444. * @param force defines if states must be applied even if cache is up to date
  34445. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34446. */
  34447. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34448. /**
  34449. * Set the z offset to apply to current rendering
  34450. * @param value defines the offset to apply
  34451. */
  34452. setZOffset(value: number): void;
  34453. /**
  34454. * Gets the current value of the zOffset
  34455. * @returns the current zOffset state
  34456. */
  34457. getZOffset(): number;
  34458. /**
  34459. * Enable or disable depth buffering
  34460. * @param enable defines the state to set
  34461. */
  34462. setDepthBuffer(enable: boolean): void;
  34463. /**
  34464. * Gets a boolean indicating if depth writing is enabled
  34465. * @returns the current depth writing state
  34466. */
  34467. getDepthWrite(): boolean;
  34468. /**
  34469. * Enable or disable depth writing
  34470. * @param enable defines the state to set
  34471. */
  34472. setDepthWrite(enable: boolean): void;
  34473. /**
  34474. * Gets a boolean indicating if stencil buffer is enabled
  34475. * @returns the current stencil buffer state
  34476. */
  34477. getStencilBuffer(): boolean;
  34478. /**
  34479. * Enable or disable the stencil buffer
  34480. * @param enable defines if the stencil buffer must be enabled or disabled
  34481. */
  34482. setStencilBuffer(enable: boolean): void;
  34483. /**
  34484. * Gets the current stencil mask
  34485. * @returns a number defining the new stencil mask to use
  34486. */
  34487. getStencilMask(): number;
  34488. /**
  34489. * Sets the current stencil mask
  34490. * @param mask defines the new stencil mask to use
  34491. */
  34492. setStencilMask(mask: number): void;
  34493. /**
  34494. * Gets the current stencil function
  34495. * @returns a number defining the stencil function to use
  34496. */
  34497. getStencilFunction(): number;
  34498. /**
  34499. * Gets the current stencil reference value
  34500. * @returns a number defining the stencil reference value to use
  34501. */
  34502. getStencilFunctionReference(): number;
  34503. /**
  34504. * Gets the current stencil mask
  34505. * @returns a number defining the stencil mask to use
  34506. */
  34507. getStencilFunctionMask(): number;
  34508. /**
  34509. * Sets the current stencil function
  34510. * @param stencilFunc defines the new stencil function to use
  34511. */
  34512. setStencilFunction(stencilFunc: number): void;
  34513. /**
  34514. * Sets the current stencil reference
  34515. * @param reference defines the new stencil reference to use
  34516. */
  34517. setStencilFunctionReference(reference: number): void;
  34518. /**
  34519. * Sets the current stencil mask
  34520. * @param mask defines the new stencil mask to use
  34521. */
  34522. setStencilFunctionMask(mask: number): void;
  34523. /**
  34524. * Gets the current stencil operation when stencil fails
  34525. * @returns a number defining stencil operation to use when stencil fails
  34526. */
  34527. getStencilOperationFail(): number;
  34528. /**
  34529. * Gets the current stencil operation when depth fails
  34530. * @returns a number defining stencil operation to use when depth fails
  34531. */
  34532. getStencilOperationDepthFail(): number;
  34533. /**
  34534. * Gets the current stencil operation when stencil passes
  34535. * @returns a number defining stencil operation to use when stencil passes
  34536. */
  34537. getStencilOperationPass(): number;
  34538. /**
  34539. * Sets the stencil operation to use when stencil fails
  34540. * @param operation defines the stencil operation to use when stencil fails
  34541. */
  34542. setStencilOperationFail(operation: number): void;
  34543. /**
  34544. * Sets the stencil operation to use when depth fails
  34545. * @param operation defines the stencil operation to use when depth fails
  34546. */
  34547. setStencilOperationDepthFail(operation: number): void;
  34548. /**
  34549. * Sets the stencil operation to use when stencil passes
  34550. * @param operation defines the stencil operation to use when stencil passes
  34551. */
  34552. setStencilOperationPass(operation: number): void;
  34553. /**
  34554. * Sets a boolean indicating if the dithering state is enabled or disabled
  34555. * @param value defines the dithering state
  34556. */
  34557. setDitheringState(value: boolean): void;
  34558. /**
  34559. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34560. * @param value defines the rasterizer state
  34561. */
  34562. setRasterizerState(value: boolean): void;
  34563. /**
  34564. * Gets the current depth function
  34565. * @returns a number defining the depth function
  34566. */
  34567. getDepthFunction(): Nullable<number>;
  34568. /**
  34569. * Sets the current depth function
  34570. * @param depthFunc defines the function to use
  34571. */
  34572. setDepthFunction(depthFunc: number): void;
  34573. /**
  34574. * Sets the current depth function to GREATER
  34575. */
  34576. setDepthFunctionToGreater(): void;
  34577. /**
  34578. * Sets the current depth function to GEQUAL
  34579. */
  34580. setDepthFunctionToGreaterOrEqual(): void;
  34581. /**
  34582. * Sets the current depth function to LESS
  34583. */
  34584. setDepthFunctionToLess(): void;
  34585. /**
  34586. * Sets the current depth function to LEQUAL
  34587. */
  34588. setDepthFunctionToLessOrEqual(): void;
  34589. private _cachedStencilBuffer;
  34590. private _cachedStencilFunction;
  34591. private _cachedStencilMask;
  34592. private _cachedStencilOperationPass;
  34593. private _cachedStencilOperationFail;
  34594. private _cachedStencilOperationDepthFail;
  34595. private _cachedStencilReference;
  34596. /**
  34597. * Caches the the state of the stencil buffer
  34598. */
  34599. cacheStencilState(): void;
  34600. /**
  34601. * Restores the state of the stencil buffer
  34602. */
  34603. restoreStencilState(): void;
  34604. /**
  34605. * Directly set the WebGL Viewport
  34606. * @param x defines the x coordinate of the viewport (in screen space)
  34607. * @param y defines the y coordinate of the viewport (in screen space)
  34608. * @param width defines the width of the viewport (in screen space)
  34609. * @param height defines the height of the viewport (in screen space)
  34610. * @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
  34611. */
  34612. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34613. /**
  34614. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34616. * @param y defines the y-coordinate of the corner of the clear rectangle
  34617. * @param width defines the width of the clear rectangle
  34618. * @param height defines the height of the clear rectangle
  34619. * @param clearColor defines the clear color
  34620. */
  34621. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34622. /**
  34623. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34624. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34625. * @param y defines the y-coordinate of the corner of the clear rectangle
  34626. * @param width defines the width of the clear rectangle
  34627. * @param height defines the height of the clear rectangle
  34628. */
  34629. enableScissor(x: number, y: number, width: number, height: number): void;
  34630. /**
  34631. * Disable previously set scissor test rectangle
  34632. */
  34633. disableScissor(): void;
  34634. protected _reportDrawCall(): void;
  34635. /**
  34636. * Initializes a webVR display and starts listening to display change events
  34637. * The onVRDisplayChangedObservable will be notified upon these changes
  34638. * @returns The onVRDisplayChangedObservable
  34639. */
  34640. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34641. /** @hidden */
  34642. _prepareVRComponent(): void;
  34643. /** @hidden */
  34644. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34645. /** @hidden */
  34646. _submitVRFrame(): void;
  34647. /**
  34648. * Call this function to leave webVR mode
  34649. * Will do nothing if webVR is not supported or if there is no webVR device
  34650. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34651. */
  34652. disableVR(): void;
  34653. /**
  34654. * Gets a boolean indicating that the system is in VR mode and is presenting
  34655. * @returns true if VR mode is engaged
  34656. */
  34657. isVRPresenting(): boolean;
  34658. /** @hidden */
  34659. _requestVRFrame(): void;
  34660. /** @hidden */
  34661. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34662. /**
  34663. * Gets the source code of the vertex shader associated with a specific webGL program
  34664. * @param program defines the program to use
  34665. * @returns a string containing the source code of the vertex shader associated with the program
  34666. */
  34667. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34668. /**
  34669. * Gets the source code of the fragment shader associated with a specific webGL program
  34670. * @param program defines the program to use
  34671. * @returns a string containing the source code of the fragment shader associated with the program
  34672. */
  34673. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34674. /**
  34675. * Sets a depth stencil texture from a render target to the according uniform.
  34676. * @param channel The texture channel
  34677. * @param uniform The uniform to set
  34678. * @param texture The render target texture containing the depth stencil texture to apply
  34679. */
  34680. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34681. /**
  34682. * Sets a texture to the webGL context from a postprocess
  34683. * @param channel defines the channel to use
  34684. * @param postProcess defines the source postprocess
  34685. */
  34686. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34687. /**
  34688. * Binds the output of the passed in post process to the texture channel specified
  34689. * @param channel The channel the texture should be bound to
  34690. * @param postProcess The post process which's output should be bound
  34691. */
  34692. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34693. /** @hidden */
  34694. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34695. protected _rebuildBuffers(): void;
  34696. /** @hidden */
  34697. _renderFrame(): void;
  34698. _renderLoop(): void;
  34699. /** @hidden */
  34700. _renderViews(): boolean;
  34701. /**
  34702. * Toggle full screen mode
  34703. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34704. */
  34705. switchFullscreen(requestPointerLock: boolean): void;
  34706. /**
  34707. * Enters full screen mode
  34708. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34709. */
  34710. enterFullscreen(requestPointerLock: boolean): void;
  34711. /**
  34712. * Exits full screen mode
  34713. */
  34714. exitFullscreen(): void;
  34715. /**
  34716. * Enters Pointerlock mode
  34717. */
  34718. enterPointerlock(): void;
  34719. /**
  34720. * Exits Pointerlock mode
  34721. */
  34722. exitPointerlock(): void;
  34723. /**
  34724. * Begin a new frame
  34725. */
  34726. beginFrame(): void;
  34727. /**
  34728. * Enf the current frame
  34729. */
  34730. endFrame(): void;
  34731. resize(): void;
  34732. /**
  34733. * Set the compressed texture format to use, based on the formats you have, and the formats
  34734. * supported by the hardware / browser.
  34735. *
  34736. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34737. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34738. * to API arguments needed to compressed textures. This puts the burden on the container
  34739. * generator to house the arcane code for determining these for current & future formats.
  34740. *
  34741. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34742. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34743. *
  34744. * Note: The result of this call is not taken into account when a texture is base64.
  34745. *
  34746. * @param formatsAvailable defines the list of those format families you have created
  34747. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34748. *
  34749. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34750. * @returns The extension selected.
  34751. */
  34752. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34753. /**
  34754. * Set the compressed texture extensions or file names to skip.
  34755. *
  34756. * @param skippedFiles defines the list of those texture files you want to skip
  34757. * Example: [".dds", ".env", "myfile.png"]
  34758. */
  34759. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34760. /**
  34761. * Force a specific size of the canvas
  34762. * @param width defines the new canvas' width
  34763. * @param height defines the new canvas' height
  34764. */
  34765. setSize(width: number, height: number): void;
  34766. /**
  34767. * Updates a dynamic vertex buffer.
  34768. * @param vertexBuffer the vertex buffer to update
  34769. * @param data the data used to update the vertex buffer
  34770. * @param byteOffset the byte offset of the data
  34771. * @param byteLength the byte length of the data
  34772. */
  34773. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34774. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34775. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34776. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34777. _releaseTexture(texture: InternalTexture): void;
  34778. /**
  34779. * @hidden
  34780. * Rescales a texture
  34781. * @param source input texutre
  34782. * @param destination destination texture
  34783. * @param scene scene to use to render the resize
  34784. * @param internalFormat format to use when resizing
  34785. * @param onComplete callback to be called when resize has completed
  34786. */
  34787. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34788. /**
  34789. * Gets the current framerate
  34790. * @returns a number representing the framerate
  34791. */
  34792. getFps(): number;
  34793. /**
  34794. * Gets the time spent between current and previous frame
  34795. * @returns a number representing the delta time in ms
  34796. */
  34797. getDeltaTime(): number;
  34798. private _measureFps;
  34799. /** @hidden */
  34800. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34801. /**
  34802. * Update a dynamic index buffer
  34803. * @param indexBuffer defines the target index buffer
  34804. * @param indices defines the data to update
  34805. * @param offset defines the offset in the target index buffer where update should start
  34806. */
  34807. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34808. /**
  34809. * Updates the sample count of a render target texture
  34810. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34811. * @param texture defines the texture to update
  34812. * @param samples defines the sample count to set
  34813. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34814. */
  34815. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34816. /**
  34817. * Updates a depth texture Comparison Mode and Function.
  34818. * If the comparison Function is equal to 0, the mode will be set to none.
  34819. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34820. * @param texture The texture to set the comparison function for
  34821. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34822. */
  34823. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34824. /**
  34825. * Creates a webGL buffer to use with instanciation
  34826. * @param capacity defines the size of the buffer
  34827. * @returns the webGL buffer
  34828. */
  34829. createInstancesBuffer(capacity: number): DataBuffer;
  34830. /**
  34831. * Delete a webGL buffer used with instanciation
  34832. * @param buffer defines the webGL buffer to delete
  34833. */
  34834. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34835. /** @hidden */
  34836. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34837. dispose(): void;
  34838. private _disableTouchAction;
  34839. /**
  34840. * Display the loading screen
  34841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34842. */
  34843. displayLoadingUI(): void;
  34844. /**
  34845. * Hide the loading screen
  34846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34847. */
  34848. hideLoadingUI(): void;
  34849. /**
  34850. * Gets the current loading screen object
  34851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34852. */
  34853. get loadingScreen(): ILoadingScreen;
  34854. /**
  34855. * Sets the current loading screen object
  34856. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34857. */
  34858. set loadingScreen(loadingScreen: ILoadingScreen);
  34859. /**
  34860. * Sets the current loading screen text
  34861. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34862. */
  34863. set loadingUIText(text: string);
  34864. /**
  34865. * Sets the current loading screen background color
  34866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34867. */
  34868. set loadingUIBackgroundColor(color: string);
  34869. /** Pointerlock and fullscreen */
  34870. /**
  34871. * Ask the browser to promote the current element to pointerlock mode
  34872. * @param element defines the DOM element to promote
  34873. */
  34874. static _RequestPointerlock(element: HTMLElement): void;
  34875. /**
  34876. * Asks the browser to exit pointerlock mode
  34877. */
  34878. static _ExitPointerlock(): void;
  34879. /**
  34880. * Ask the browser to promote the current element to fullscreen rendering mode
  34881. * @param element defines the DOM element to promote
  34882. */
  34883. static _RequestFullscreen(element: HTMLElement): void;
  34884. /**
  34885. * Asks the browser to exit fullscreen mode
  34886. */
  34887. static _ExitFullscreen(): void;
  34888. }
  34889. }
  34890. declare module "babylonjs/Engines/engineStore" {
  34891. import { Nullable } from "babylonjs/types";
  34892. import { Engine } from "babylonjs/Engines/engine";
  34893. import { Scene } from "babylonjs/scene";
  34894. /**
  34895. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34896. * during the life time of the application.
  34897. */
  34898. export class EngineStore {
  34899. /** Gets the list of created engines */
  34900. static Instances: import("babylonjs/Engines/engine").Engine[];
  34901. /** @hidden */
  34902. static _LastCreatedScene: Nullable<Scene>;
  34903. /**
  34904. * Gets the latest created engine
  34905. */
  34906. static get LastCreatedEngine(): Nullable<Engine>;
  34907. /**
  34908. * Gets the latest created scene
  34909. */
  34910. static get LastCreatedScene(): Nullable<Scene>;
  34911. /**
  34912. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34913. * @ignorenaming
  34914. */
  34915. static UseFallbackTexture: boolean;
  34916. /**
  34917. * Texture content used if a texture cannot loaded
  34918. * @ignorenaming
  34919. */
  34920. static FallbackTexture: string;
  34921. }
  34922. }
  34923. declare module "babylonjs/Misc/promise" {
  34924. /**
  34925. * Helper class that provides a small promise polyfill
  34926. */
  34927. export class PromisePolyfill {
  34928. /**
  34929. * Static function used to check if the polyfill is required
  34930. * If this is the case then the function will inject the polyfill to window.Promise
  34931. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34932. */
  34933. static Apply(force?: boolean): void;
  34934. }
  34935. }
  34936. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34937. /**
  34938. * Interface for screenshot methods with describe argument called `size` as object with options
  34939. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34940. */
  34941. export interface IScreenshotSize {
  34942. /**
  34943. * number in pixels for canvas height
  34944. */
  34945. height?: number;
  34946. /**
  34947. * multiplier allowing render at a higher or lower resolution
  34948. * If value is defined then height and width will be ignored and taken from camera
  34949. */
  34950. precision?: number;
  34951. /**
  34952. * number in pixels for canvas width
  34953. */
  34954. width?: number;
  34955. }
  34956. }
  34957. declare module "babylonjs/Misc/tools" {
  34958. import { Nullable, float } from "babylonjs/types";
  34959. import { DomManagement } from "babylonjs/Misc/domManagement";
  34960. import { WebRequest } from "babylonjs/Misc/webRequest";
  34961. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34962. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34963. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34964. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34965. import { Camera } from "babylonjs/Cameras/camera";
  34966. import { Engine } from "babylonjs/Engines/engine";
  34967. interface IColor4Like {
  34968. r: float;
  34969. g: float;
  34970. b: float;
  34971. a: float;
  34972. }
  34973. /**
  34974. * Class containing a set of static utilities functions
  34975. */
  34976. export class Tools {
  34977. /**
  34978. * Gets or sets the base URL to use to load assets
  34979. */
  34980. static get BaseUrl(): string;
  34981. static set BaseUrl(value: string);
  34982. /**
  34983. * Enable/Disable Custom HTTP Request Headers globally.
  34984. * default = false
  34985. * @see CustomRequestHeaders
  34986. */
  34987. static UseCustomRequestHeaders: boolean;
  34988. /**
  34989. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34990. * i.e. when loading files, where the server/service expects an Authorization header
  34991. */
  34992. static CustomRequestHeaders: {
  34993. [key: string]: string;
  34994. };
  34995. /**
  34996. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34997. */
  34998. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34999. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35000. /**
  35001. * Default behaviour for cors in the application.
  35002. * It can be a string if the expected behavior is identical in the entire app.
  35003. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35004. */
  35005. static CorsBehavior: string | ((url: string | string[]) => string);
  35006. /**
  35007. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35008. * @ignorenaming
  35009. */
  35010. static get UseFallbackTexture(): boolean;
  35011. static set UseFallbackTexture(value: boolean);
  35012. /**
  35013. * Use this object to register external classes like custom textures or material
  35014. * to allow the laoders to instantiate them
  35015. */
  35016. static get RegisteredExternalClasses(): {
  35017. [key: string]: Object;
  35018. };
  35019. static set RegisteredExternalClasses(classes: {
  35020. [key: string]: Object;
  35021. });
  35022. /**
  35023. * Texture content used if a texture cannot loaded
  35024. * @ignorenaming
  35025. */
  35026. static get fallbackTexture(): string;
  35027. static set fallbackTexture(value: string);
  35028. /**
  35029. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35030. * @param u defines the coordinate on X axis
  35031. * @param v defines the coordinate on Y axis
  35032. * @param width defines the width of the source data
  35033. * @param height defines the height of the source data
  35034. * @param pixels defines the source byte array
  35035. * @param color defines the output color
  35036. */
  35037. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35038. /**
  35039. * Interpolates between a and b via alpha
  35040. * @param a The lower value (returned when alpha = 0)
  35041. * @param b The upper value (returned when alpha = 1)
  35042. * @param alpha The interpolation-factor
  35043. * @return The mixed value
  35044. */
  35045. static Mix(a: number, b: number, alpha: number): number;
  35046. /**
  35047. * Tries to instantiate a new object from a given class name
  35048. * @param className defines the class name to instantiate
  35049. * @returns the new object or null if the system was not able to do the instantiation
  35050. */
  35051. static Instantiate(className: string): any;
  35052. /**
  35053. * Provides a slice function that will work even on IE
  35054. * @param data defines the array to slice
  35055. * @param start defines the start of the data (optional)
  35056. * @param end defines the end of the data (optional)
  35057. * @returns the new sliced array
  35058. */
  35059. static Slice<T>(data: T, start?: number, end?: number): T;
  35060. /**
  35061. * Polyfill for setImmediate
  35062. * @param action defines the action to execute after the current execution block
  35063. */
  35064. static SetImmediate(action: () => void): void;
  35065. /**
  35066. * Function indicating if a number is an exponent of 2
  35067. * @param value defines the value to test
  35068. * @returns true if the value is an exponent of 2
  35069. */
  35070. static IsExponentOfTwo(value: number): boolean;
  35071. private static _tmpFloatArray;
  35072. /**
  35073. * Returns the nearest 32-bit single precision float representation of a Number
  35074. * @param value A Number. If the parameter is of a different type, it will get converted
  35075. * to a number or to NaN if it cannot be converted
  35076. * @returns number
  35077. */
  35078. static FloatRound(value: number): number;
  35079. /**
  35080. * Extracts the filename from a path
  35081. * @param path defines the path to use
  35082. * @returns the filename
  35083. */
  35084. static GetFilename(path: string): string;
  35085. /**
  35086. * Extracts the "folder" part of a path (everything before the filename).
  35087. * @param uri The URI to extract the info from
  35088. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35089. * @returns The "folder" part of the path
  35090. */
  35091. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35092. /**
  35093. * Extracts text content from a DOM element hierarchy
  35094. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35095. */
  35096. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35097. /**
  35098. * Convert an angle in radians to degrees
  35099. * @param angle defines the angle to convert
  35100. * @returns the angle in degrees
  35101. */
  35102. static ToDegrees(angle: number): number;
  35103. /**
  35104. * Convert an angle in degrees to radians
  35105. * @param angle defines the angle to convert
  35106. * @returns the angle in radians
  35107. */
  35108. static ToRadians(angle: number): number;
  35109. /**
  35110. * Returns an array if obj is not an array
  35111. * @param obj defines the object to evaluate as an array
  35112. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35113. * @returns either obj directly if obj is an array or a new array containing obj
  35114. */
  35115. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35116. /**
  35117. * Gets the pointer prefix to use
  35118. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35119. */
  35120. static GetPointerPrefix(): string;
  35121. /**
  35122. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35123. * @param url define the url we are trying
  35124. * @param element define the dom element where to configure the cors policy
  35125. */
  35126. static SetCorsBehavior(url: string | string[], element: {
  35127. crossOrigin: string | null;
  35128. }): void;
  35129. /**
  35130. * Removes unwanted characters from an url
  35131. * @param url defines the url to clean
  35132. * @returns the cleaned url
  35133. */
  35134. static CleanUrl(url: string): string;
  35135. /**
  35136. * Gets or sets a function used to pre-process url before using them to load assets
  35137. */
  35138. static get PreprocessUrl(): (url: string) => string;
  35139. static set PreprocessUrl(processor: (url: string) => string);
  35140. /**
  35141. * Loads an image as an HTMLImageElement.
  35142. * @param input url string, ArrayBuffer, or Blob to load
  35143. * @param onLoad callback called when the image successfully loads
  35144. * @param onError callback called when the image fails to load
  35145. * @param offlineProvider offline provider for caching
  35146. * @param mimeType optional mime type
  35147. * @returns the HTMLImageElement of the loaded image
  35148. */
  35149. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35150. /**
  35151. * Loads a file from a url
  35152. * @param url url string, ArrayBuffer, or Blob to load
  35153. * @param onSuccess callback called when the file successfully loads
  35154. * @param onProgress callback called while file is loading (if the server supports this mode)
  35155. * @param offlineProvider defines the offline provider for caching
  35156. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35157. * @param onError callback called when the file fails to load
  35158. * @returns a file request object
  35159. */
  35160. 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;
  35161. /**
  35162. * Loads a file from a url
  35163. * @param url the file url to load
  35164. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35165. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35166. */
  35167. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35168. /**
  35169. * Load a script (identified by an url). When the url returns, the
  35170. * content of this file is added into a new script element, attached to the DOM (body element)
  35171. * @param scriptUrl defines the url of the script to laod
  35172. * @param onSuccess defines the callback called when the script is loaded
  35173. * @param onError defines the callback to call if an error occurs
  35174. * @param scriptId defines the id of the script element
  35175. */
  35176. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35177. /**
  35178. * Load an asynchronous script (identified by an url). When the url returns, the
  35179. * content of this file is added into a new script element, attached to the DOM (body element)
  35180. * @param scriptUrl defines the url of the script to laod
  35181. * @param scriptId defines the id of the script element
  35182. * @returns a promise request object
  35183. */
  35184. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35185. /**
  35186. * Loads a file from a blob
  35187. * @param fileToLoad defines the blob to use
  35188. * @param callback defines the callback to call when data is loaded
  35189. * @param progressCallback defines the callback to call during loading process
  35190. * @returns a file request object
  35191. */
  35192. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35193. /**
  35194. * Reads a file from a File object
  35195. * @param file defines the file to load
  35196. * @param onSuccess defines the callback to call when data is loaded
  35197. * @param onProgress defines the callback to call during loading process
  35198. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35199. * @param onError defines the callback to call when an error occurs
  35200. * @returns a file request object
  35201. */
  35202. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35203. /**
  35204. * Creates a data url from a given string content
  35205. * @param content defines the content to convert
  35206. * @returns the new data url link
  35207. */
  35208. static FileAsURL(content: string): string;
  35209. /**
  35210. * Format the given number to a specific decimal format
  35211. * @param value defines the number to format
  35212. * @param decimals defines the number of decimals to use
  35213. * @returns the formatted string
  35214. */
  35215. static Format(value: number, decimals?: number): string;
  35216. /**
  35217. * Tries to copy an object by duplicating every property
  35218. * @param source defines the source object
  35219. * @param destination defines the target object
  35220. * @param doNotCopyList defines a list of properties to avoid
  35221. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35222. */
  35223. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35224. /**
  35225. * Gets a boolean indicating if the given object has no own property
  35226. * @param obj defines the object to test
  35227. * @returns true if object has no own property
  35228. */
  35229. static IsEmpty(obj: any): boolean;
  35230. /**
  35231. * Function used to register events at window level
  35232. * @param windowElement defines the Window object to use
  35233. * @param events defines the events to register
  35234. */
  35235. static RegisterTopRootEvents(windowElement: Window, events: {
  35236. name: string;
  35237. handler: Nullable<(e: FocusEvent) => any>;
  35238. }[]): void;
  35239. /**
  35240. * Function used to unregister events from window level
  35241. * @param windowElement defines the Window object to use
  35242. * @param events defines the events to unregister
  35243. */
  35244. static UnregisterTopRootEvents(windowElement: Window, events: {
  35245. name: string;
  35246. handler: Nullable<(e: FocusEvent) => any>;
  35247. }[]): void;
  35248. /**
  35249. * @ignore
  35250. */
  35251. static _ScreenshotCanvas: HTMLCanvasElement;
  35252. /**
  35253. * Dumps the current bound framebuffer
  35254. * @param width defines the rendering width
  35255. * @param height defines the rendering height
  35256. * @param engine defines the hosting engine
  35257. * @param successCallback defines the callback triggered once the data are available
  35258. * @param mimeType defines the mime type of the result
  35259. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35260. */
  35261. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35262. /**
  35263. * Converts the canvas data to blob.
  35264. * This acts as a polyfill for browsers not supporting the to blob function.
  35265. * @param canvas Defines the canvas to extract the data from
  35266. * @param successCallback Defines the callback triggered once the data are available
  35267. * @param mimeType Defines the mime type of the result
  35268. */
  35269. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35270. /**
  35271. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35272. * @param successCallback defines the callback triggered once the data are available
  35273. * @param mimeType defines the mime type of the result
  35274. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35275. */
  35276. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35277. /**
  35278. * Downloads a blob in the browser
  35279. * @param blob defines the blob to download
  35280. * @param fileName defines the name of the downloaded file
  35281. */
  35282. static Download(blob: Blob, fileName: string): void;
  35283. /**
  35284. * Captures a screenshot of the current rendering
  35285. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35286. * @param engine defines the rendering engine
  35287. * @param camera defines the source camera
  35288. * @param size This parameter can be set to a single number or to an object with the
  35289. * following (optional) properties: precision, width, height. If a single number is passed,
  35290. * it will be used for both width and height. If an object is passed, the screenshot size
  35291. * will be derived from the parameters. The precision property is a multiplier allowing
  35292. * rendering at a higher or lower resolution
  35293. * @param successCallback defines the callback receives a single parameter which contains the
  35294. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35295. * src parameter of an <img> to display it
  35296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35297. * Check your browser for supported MIME types
  35298. */
  35299. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35300. /**
  35301. * Captures a screenshot of the current rendering
  35302. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35303. * @param engine defines the rendering engine
  35304. * @param camera defines the source camera
  35305. * @param size This parameter can be set to a single number or to an object with the
  35306. * following (optional) properties: precision, width, height. If a single number is passed,
  35307. * it will be used for both width and height. If an object is passed, the screenshot size
  35308. * will be derived from the parameters. The precision property is a multiplier allowing
  35309. * rendering at a higher or lower resolution
  35310. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35311. * Check your browser for supported MIME types
  35312. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35313. * to the src parameter of an <img> to display it
  35314. */
  35315. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35316. /**
  35317. * Generates an image screenshot from the specified camera.
  35318. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35319. * @param engine The engine to use for rendering
  35320. * @param camera The camera to use for rendering
  35321. * @param size This parameter can be set to a single number or to an object with the
  35322. * following (optional) properties: precision, width, height. If a single number is passed,
  35323. * it will be used for both width and height. If an object is passed, the screenshot size
  35324. * will be derived from the parameters. The precision property is a multiplier allowing
  35325. * rendering at a higher or lower resolution
  35326. * @param successCallback The callback receives a single parameter which contains the
  35327. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35328. * src parameter of an <img> to display it
  35329. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35330. * Check your browser for supported MIME types
  35331. * @param samples Texture samples (default: 1)
  35332. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35333. * @param fileName A name for for the downloaded file.
  35334. */
  35335. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35336. /**
  35337. * Generates an image screenshot from the specified camera.
  35338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35339. * @param engine The engine to use for rendering
  35340. * @param camera The camera to use for rendering
  35341. * @param size This parameter can be set to a single number or to an object with the
  35342. * following (optional) properties: precision, width, height. If a single number is passed,
  35343. * it will be used for both width and height. If an object is passed, the screenshot size
  35344. * will be derived from the parameters. The precision property is a multiplier allowing
  35345. * rendering at a higher or lower resolution
  35346. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35347. * Check your browser for supported MIME types
  35348. * @param samples Texture samples (default: 1)
  35349. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35350. * @param fileName A name for for the downloaded file.
  35351. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35352. * to the src parameter of an <img> to display it
  35353. */
  35354. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35355. /**
  35356. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35357. * Be aware Math.random() could cause collisions, but:
  35358. * "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"
  35359. * @returns a pseudo random id
  35360. */
  35361. static RandomId(): string;
  35362. /**
  35363. * Test if the given uri is a base64 string
  35364. * @param uri The uri to test
  35365. * @return True if the uri is a base64 string or false otherwise
  35366. */
  35367. static IsBase64(uri: string): boolean;
  35368. /**
  35369. * Decode the given base64 uri.
  35370. * @param uri The uri to decode
  35371. * @return The decoded base64 data.
  35372. */
  35373. static DecodeBase64(uri: string): ArrayBuffer;
  35374. /**
  35375. * Gets the absolute url.
  35376. * @param url the input url
  35377. * @return the absolute url
  35378. */
  35379. static GetAbsoluteUrl(url: string): string;
  35380. /**
  35381. * No log
  35382. */
  35383. static readonly NoneLogLevel: number;
  35384. /**
  35385. * Only message logs
  35386. */
  35387. static readonly MessageLogLevel: number;
  35388. /**
  35389. * Only warning logs
  35390. */
  35391. static readonly WarningLogLevel: number;
  35392. /**
  35393. * Only error logs
  35394. */
  35395. static readonly ErrorLogLevel: number;
  35396. /**
  35397. * All logs
  35398. */
  35399. static readonly AllLogLevel: number;
  35400. /**
  35401. * Gets a value indicating the number of loading errors
  35402. * @ignorenaming
  35403. */
  35404. static get errorsCount(): number;
  35405. /**
  35406. * Callback called when a new log is added
  35407. */
  35408. static OnNewCacheEntry: (entry: string) => void;
  35409. /**
  35410. * Log a message to the console
  35411. * @param message defines the message to log
  35412. */
  35413. static Log(message: string): void;
  35414. /**
  35415. * Write a warning message to the console
  35416. * @param message defines the message to log
  35417. */
  35418. static Warn(message: string): void;
  35419. /**
  35420. * Write an error message to the console
  35421. * @param message defines the message to log
  35422. */
  35423. static Error(message: string): void;
  35424. /**
  35425. * Gets current log cache (list of logs)
  35426. */
  35427. static get LogCache(): string;
  35428. /**
  35429. * Clears the log cache
  35430. */
  35431. static ClearLogCache(): void;
  35432. /**
  35433. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35434. */
  35435. static set LogLevels(level: number);
  35436. /**
  35437. * Checks if the window object exists
  35438. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35439. */
  35440. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35441. /**
  35442. * No performance log
  35443. */
  35444. static readonly PerformanceNoneLogLevel: number;
  35445. /**
  35446. * Use user marks to log performance
  35447. */
  35448. static readonly PerformanceUserMarkLogLevel: number;
  35449. /**
  35450. * Log performance to the console
  35451. */
  35452. static readonly PerformanceConsoleLogLevel: number;
  35453. private static _performance;
  35454. /**
  35455. * Sets the current performance log level
  35456. */
  35457. static set PerformanceLogLevel(level: number);
  35458. private static _StartPerformanceCounterDisabled;
  35459. private static _EndPerformanceCounterDisabled;
  35460. private static _StartUserMark;
  35461. private static _EndUserMark;
  35462. private static _StartPerformanceConsole;
  35463. private static _EndPerformanceConsole;
  35464. /**
  35465. * Starts a performance counter
  35466. */
  35467. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35468. /**
  35469. * Ends a specific performance coutner
  35470. */
  35471. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35472. /**
  35473. * Gets either window.performance.now() if supported or Date.now() else
  35474. */
  35475. static get Now(): number;
  35476. /**
  35477. * This method will return the name of the class used to create the instance of the given object.
  35478. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35479. * @param object the object to get the class name from
  35480. * @param isType defines if the object is actually a type
  35481. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35482. */
  35483. static GetClassName(object: any, isType?: boolean): string;
  35484. /**
  35485. * Gets the first element of an array satisfying a given predicate
  35486. * @param array defines the array to browse
  35487. * @param predicate defines the predicate to use
  35488. * @returns null if not found or the element
  35489. */
  35490. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35491. /**
  35492. * This method will return the name of the full name of the class, including its owning module (if any).
  35493. * 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).
  35494. * @param object the object to get the class name from
  35495. * @param isType defines if the object is actually a type
  35496. * @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.
  35497. * @ignorenaming
  35498. */
  35499. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35500. /**
  35501. * Returns a promise that resolves after the given amount of time.
  35502. * @param delay Number of milliseconds to delay
  35503. * @returns Promise that resolves after the given amount of time
  35504. */
  35505. static DelayAsync(delay: number): Promise<void>;
  35506. /**
  35507. * Utility function to detect if the current user agent is Safari
  35508. * @returns whether or not the current user agent is safari
  35509. */
  35510. static IsSafari(): boolean;
  35511. }
  35512. /**
  35513. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35514. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35515. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35516. * @param name The name of the class, case should be preserved
  35517. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35518. */
  35519. export function className(name: string, module?: string): (target: Object) => void;
  35520. /**
  35521. * An implementation of a loop for asynchronous functions.
  35522. */
  35523. export class AsyncLoop {
  35524. /**
  35525. * Defines the number of iterations for the loop
  35526. */
  35527. iterations: number;
  35528. /**
  35529. * Defines the current index of the loop.
  35530. */
  35531. index: number;
  35532. private _done;
  35533. private _fn;
  35534. private _successCallback;
  35535. /**
  35536. * Constructor.
  35537. * @param iterations the number of iterations.
  35538. * @param func the function to run each iteration
  35539. * @param successCallback the callback that will be called upon succesful execution
  35540. * @param offset starting offset.
  35541. */
  35542. constructor(
  35543. /**
  35544. * Defines the number of iterations for the loop
  35545. */
  35546. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35547. /**
  35548. * Execute the next iteration. Must be called after the last iteration was finished.
  35549. */
  35550. executeNext(): void;
  35551. /**
  35552. * Break the loop and run the success callback.
  35553. */
  35554. breakLoop(): void;
  35555. /**
  35556. * Create and run an async loop.
  35557. * @param iterations the number of iterations.
  35558. * @param fn the function to run each iteration
  35559. * @param successCallback the callback that will be called upon succesful execution
  35560. * @param offset starting offset.
  35561. * @returns the created async loop object
  35562. */
  35563. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35564. /**
  35565. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35566. * @param iterations total number of iterations
  35567. * @param syncedIterations number of synchronous iterations in each async iteration.
  35568. * @param fn the function to call each iteration.
  35569. * @param callback a success call back that will be called when iterating stops.
  35570. * @param breakFunction a break condition (optional)
  35571. * @param timeout timeout settings for the setTimeout function. default - 0.
  35572. * @returns the created async loop object
  35573. */
  35574. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35575. }
  35576. }
  35577. declare module "babylonjs/Misc/stringDictionary" {
  35578. import { Nullable } from "babylonjs/types";
  35579. /**
  35580. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35581. * The underlying implementation relies on an associative array to ensure the best performances.
  35582. * The value can be anything including 'null' but except 'undefined'
  35583. */
  35584. export class StringDictionary<T> {
  35585. /**
  35586. * This will clear this dictionary and copy the content from the 'source' one.
  35587. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35588. * @param source the dictionary to take the content from and copy to this dictionary
  35589. */
  35590. copyFrom(source: StringDictionary<T>): void;
  35591. /**
  35592. * Get a value based from its key
  35593. * @param key the given key to get the matching value from
  35594. * @return the value if found, otherwise undefined is returned
  35595. */
  35596. get(key: string): T | undefined;
  35597. /**
  35598. * Get a value from its key or add it if it doesn't exist.
  35599. * This method will ensure you that a given key/data will be present in the dictionary.
  35600. * @param key the given key to get the matching value from
  35601. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35602. * The factory will only be invoked if there's no data for the given key.
  35603. * @return the value corresponding to the key.
  35604. */
  35605. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35606. /**
  35607. * Get a value from its key if present in the dictionary otherwise add it
  35608. * @param key the key to get the value from
  35609. * @param val if there's no such key/value pair in the dictionary add it with this value
  35610. * @return the value corresponding to the key
  35611. */
  35612. getOrAdd(key: string, val: T): T;
  35613. /**
  35614. * Check if there's a given key in the dictionary
  35615. * @param key the key to check for
  35616. * @return true if the key is present, false otherwise
  35617. */
  35618. contains(key: string): boolean;
  35619. /**
  35620. * Add a new key and its corresponding value
  35621. * @param key the key to add
  35622. * @param value the value corresponding to the key
  35623. * @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
  35624. */
  35625. add(key: string, value: T): boolean;
  35626. /**
  35627. * Update a specific value associated to a key
  35628. * @param key defines the key to use
  35629. * @param value defines the value to store
  35630. * @returns true if the value was updated (or false if the key was not found)
  35631. */
  35632. set(key: string, value: T): boolean;
  35633. /**
  35634. * Get the element of the given key and remove it from the dictionary
  35635. * @param key defines the key to search
  35636. * @returns the value associated with the key or null if not found
  35637. */
  35638. getAndRemove(key: string): Nullable<T>;
  35639. /**
  35640. * Remove a key/value from the dictionary.
  35641. * @param key the key to remove
  35642. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35643. */
  35644. remove(key: string): boolean;
  35645. /**
  35646. * Clear the whole content of the dictionary
  35647. */
  35648. clear(): void;
  35649. /**
  35650. * Gets the current count
  35651. */
  35652. get count(): number;
  35653. /**
  35654. * Execute a callback on each key/val of the dictionary.
  35655. * Note that you can remove any element in this dictionary in the callback implementation
  35656. * @param callback the callback to execute on a given key/value pair
  35657. */
  35658. forEach(callback: (key: string, val: T) => void): void;
  35659. /**
  35660. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35661. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35662. * Note that you can remove any element in this dictionary in the callback implementation
  35663. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35664. * @returns the first item
  35665. */
  35666. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35667. private _count;
  35668. private _data;
  35669. }
  35670. }
  35671. declare module "babylonjs/Collisions/collisionCoordinator" {
  35672. import { Nullable } from "babylonjs/types";
  35673. import { Scene } from "babylonjs/scene";
  35674. import { Vector3 } from "babylonjs/Maths/math.vector";
  35675. import { Collider } from "babylonjs/Collisions/collider";
  35676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35677. /** @hidden */
  35678. export interface ICollisionCoordinator {
  35679. createCollider(): Collider;
  35680. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35681. init(scene: Scene): void;
  35682. }
  35683. /** @hidden */
  35684. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35685. private _scene;
  35686. private _scaledPosition;
  35687. private _scaledVelocity;
  35688. private _finalPosition;
  35689. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35690. createCollider(): Collider;
  35691. init(scene: Scene): void;
  35692. private _collideWithWorld;
  35693. }
  35694. }
  35695. declare module "babylonjs/Inputs/scene.inputManager" {
  35696. import { Nullable } from "babylonjs/types";
  35697. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35698. import { Vector2 } from "babylonjs/Maths/math.vector";
  35699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35700. import { Scene } from "babylonjs/scene";
  35701. /**
  35702. * Class used to manage all inputs for the scene.
  35703. */
  35704. export class InputManager {
  35705. /** The distance in pixel that you have to move to prevent some events */
  35706. static DragMovementThreshold: number;
  35707. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35708. static LongPressDelay: number;
  35709. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35710. static DoubleClickDelay: number;
  35711. /** If you need to check double click without raising a single click at first click, enable this flag */
  35712. static ExclusiveDoubleClickMode: boolean;
  35713. private _wheelEventName;
  35714. private _onPointerMove;
  35715. private _onPointerDown;
  35716. private _onPointerUp;
  35717. private _initClickEvent;
  35718. private _initActionManager;
  35719. private _delayedSimpleClick;
  35720. private _delayedSimpleClickTimeout;
  35721. private _previousDelayedSimpleClickTimeout;
  35722. private _meshPickProceed;
  35723. private _previousButtonPressed;
  35724. private _currentPickResult;
  35725. private _previousPickResult;
  35726. private _totalPointersPressed;
  35727. private _doubleClickOccured;
  35728. private _pointerOverMesh;
  35729. private _pickedDownMesh;
  35730. private _pickedUpMesh;
  35731. private _pointerX;
  35732. private _pointerY;
  35733. private _unTranslatedPointerX;
  35734. private _unTranslatedPointerY;
  35735. private _startingPointerPosition;
  35736. private _previousStartingPointerPosition;
  35737. private _startingPointerTime;
  35738. private _previousStartingPointerTime;
  35739. private _pointerCaptures;
  35740. private _onKeyDown;
  35741. private _onKeyUp;
  35742. private _onCanvasFocusObserver;
  35743. private _onCanvasBlurObserver;
  35744. private _scene;
  35745. /**
  35746. * Creates a new InputManager
  35747. * @param scene defines the hosting scene
  35748. */
  35749. constructor(scene: Scene);
  35750. /**
  35751. * Gets the mesh that is currently under the pointer
  35752. */
  35753. get meshUnderPointer(): Nullable<AbstractMesh>;
  35754. /**
  35755. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35756. */
  35757. get unTranslatedPointer(): Vector2;
  35758. /**
  35759. * Gets or sets the current on-screen X position of the pointer
  35760. */
  35761. get pointerX(): number;
  35762. set pointerX(value: number);
  35763. /**
  35764. * Gets or sets the current on-screen Y position of the pointer
  35765. */
  35766. get pointerY(): number;
  35767. set pointerY(value: number);
  35768. private _updatePointerPosition;
  35769. private _processPointerMove;
  35770. private _setRayOnPointerInfo;
  35771. private _checkPrePointerObservable;
  35772. /**
  35773. * Use this method to simulate a pointer move on a mesh
  35774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35777. */
  35778. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35779. /**
  35780. * Use this method to simulate a pointer down on a mesh
  35781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35784. */
  35785. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35786. private _processPointerDown;
  35787. /** @hidden */
  35788. _isPointerSwiping(): boolean;
  35789. /**
  35790. * Use this method to simulate a pointer up on a mesh
  35791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35794. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35795. */
  35796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35797. private _processPointerUp;
  35798. /**
  35799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35801. * @returns true if the pointer was captured
  35802. */
  35803. isPointerCaptured(pointerId?: number): boolean;
  35804. /**
  35805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35806. * @param attachUp defines if you want to attach events to pointerup
  35807. * @param attachDown defines if you want to attach events to pointerdown
  35808. * @param attachMove defines if you want to attach events to pointermove
  35809. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35810. */
  35811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35812. /**
  35813. * Detaches all event handlers
  35814. */
  35815. detachControl(): void;
  35816. /**
  35817. * Force the value of meshUnderPointer
  35818. * @param mesh defines the mesh to use
  35819. */
  35820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35821. /**
  35822. * Gets the mesh under the pointer
  35823. * @returns a Mesh or null if no mesh is under the pointer
  35824. */
  35825. getPointerOverMesh(): Nullable<AbstractMesh>;
  35826. }
  35827. }
  35828. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35829. /**
  35830. * Helper class used to generate session unique ID
  35831. */
  35832. export class UniqueIdGenerator {
  35833. private static _UniqueIdCounter;
  35834. /**
  35835. * Gets an unique (relatively to the current scene) Id
  35836. */
  35837. static get UniqueId(): number;
  35838. }
  35839. }
  35840. declare module "babylonjs/Animations/animationGroup" {
  35841. import { Animatable } from "babylonjs/Animations/animatable";
  35842. import { Animation } from "babylonjs/Animations/animation";
  35843. import { Scene, IDisposable } from "babylonjs/scene";
  35844. import { Observable } from "babylonjs/Misc/observable";
  35845. import { Nullable } from "babylonjs/types";
  35846. import "babylonjs/Animations/animatable";
  35847. /**
  35848. * This class defines the direct association between an animation and a target
  35849. */
  35850. export class TargetedAnimation {
  35851. /**
  35852. * Animation to perform
  35853. */
  35854. animation: Animation;
  35855. /**
  35856. * Target to animate
  35857. */
  35858. target: any;
  35859. /**
  35860. * Serialize the object
  35861. * @returns the JSON object representing the current entity
  35862. */
  35863. serialize(): any;
  35864. }
  35865. /**
  35866. * Use this class to create coordinated animations on multiple targets
  35867. */
  35868. export class AnimationGroup implements IDisposable {
  35869. /** The name of the animation group */
  35870. name: string;
  35871. private _scene;
  35872. private _targetedAnimations;
  35873. private _animatables;
  35874. private _from;
  35875. private _to;
  35876. private _isStarted;
  35877. private _isPaused;
  35878. private _speedRatio;
  35879. private _loopAnimation;
  35880. /**
  35881. * Gets or sets the unique id of the node
  35882. */
  35883. uniqueId: number;
  35884. /**
  35885. * This observable will notify when one animation have ended
  35886. */
  35887. onAnimationEndObservable: Observable<TargetedAnimation>;
  35888. /**
  35889. * Observer raised when one animation loops
  35890. */
  35891. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35892. /**
  35893. * Observer raised when all animations have looped
  35894. */
  35895. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35896. /**
  35897. * This observable will notify when all animations have ended.
  35898. */
  35899. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35900. /**
  35901. * This observable will notify when all animations have paused.
  35902. */
  35903. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35904. /**
  35905. * This observable will notify when all animations are playing.
  35906. */
  35907. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35908. /**
  35909. * Gets the first frame
  35910. */
  35911. get from(): number;
  35912. /**
  35913. * Gets the last frame
  35914. */
  35915. get to(): number;
  35916. /**
  35917. * Define if the animations are started
  35918. */
  35919. get isStarted(): boolean;
  35920. /**
  35921. * Gets a value indicating that the current group is playing
  35922. */
  35923. get isPlaying(): boolean;
  35924. /**
  35925. * Gets or sets the speed ratio to use for all animations
  35926. */
  35927. get speedRatio(): number;
  35928. /**
  35929. * Gets or sets the speed ratio to use for all animations
  35930. */
  35931. set speedRatio(value: number);
  35932. /**
  35933. * Gets or sets if all animations should loop or not
  35934. */
  35935. get loopAnimation(): boolean;
  35936. set loopAnimation(value: boolean);
  35937. /**
  35938. * Gets the targeted animations for this animation group
  35939. */
  35940. get targetedAnimations(): Array<TargetedAnimation>;
  35941. /**
  35942. * returning the list of animatables controlled by this animation group.
  35943. */
  35944. get animatables(): Array<Animatable>;
  35945. /**
  35946. * Instantiates a new Animation Group.
  35947. * This helps managing several animations at once.
  35948. * @see http://doc.babylonjs.com/how_to/group
  35949. * @param name Defines the name of the group
  35950. * @param scene Defines the scene the group belongs to
  35951. */
  35952. constructor(
  35953. /** The name of the animation group */
  35954. name: string, scene?: Nullable<Scene>);
  35955. /**
  35956. * Add an animation (with its target) in the group
  35957. * @param animation defines the animation we want to add
  35958. * @param target defines the target of the animation
  35959. * @returns the TargetedAnimation object
  35960. */
  35961. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35962. /**
  35963. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35964. * It can add constant keys at begin or end
  35965. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35966. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35967. * @returns the animation group
  35968. */
  35969. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35970. private _animationLoopCount;
  35971. private _animationLoopFlags;
  35972. private _processLoop;
  35973. /**
  35974. * Start all animations on given targets
  35975. * @param loop defines if animations must loop
  35976. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35977. * @param from defines the from key (optional)
  35978. * @param to defines the to key (optional)
  35979. * @returns the current animation group
  35980. */
  35981. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35982. /**
  35983. * Pause all animations
  35984. * @returns the animation group
  35985. */
  35986. pause(): AnimationGroup;
  35987. /**
  35988. * Play all animations to initial state
  35989. * This function will start() the animations if they were not started or will restart() them if they were paused
  35990. * @param loop defines if animations must loop
  35991. * @returns the animation group
  35992. */
  35993. play(loop?: boolean): AnimationGroup;
  35994. /**
  35995. * Reset all animations to initial state
  35996. * @returns the animation group
  35997. */
  35998. reset(): AnimationGroup;
  35999. /**
  36000. * Restart animations from key 0
  36001. * @returns the animation group
  36002. */
  36003. restart(): AnimationGroup;
  36004. /**
  36005. * Stop all animations
  36006. * @returns the animation group
  36007. */
  36008. stop(): AnimationGroup;
  36009. /**
  36010. * Set animation weight for all animatables
  36011. * @param weight defines the weight to use
  36012. * @return the animationGroup
  36013. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36014. */
  36015. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36016. /**
  36017. * Synchronize and normalize all animatables with a source animatable
  36018. * @param root defines the root animatable to synchronize with
  36019. * @return the animationGroup
  36020. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36021. */
  36022. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36023. /**
  36024. * Goes to a specific frame in this animation group
  36025. * @param frame the frame number to go to
  36026. * @return the animationGroup
  36027. */
  36028. goToFrame(frame: number): AnimationGroup;
  36029. /**
  36030. * Dispose all associated resources
  36031. */
  36032. dispose(): void;
  36033. private _checkAnimationGroupEnded;
  36034. /**
  36035. * Clone the current animation group and returns a copy
  36036. * @param newName defines the name of the new group
  36037. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36038. * @returns the new aniamtion group
  36039. */
  36040. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36041. /**
  36042. * Serializes the animationGroup to an object
  36043. * @returns Serialized object
  36044. */
  36045. serialize(): any;
  36046. /**
  36047. * Returns a new AnimationGroup object parsed from the source provided.
  36048. * @param parsedAnimationGroup defines the source
  36049. * @param scene defines the scene that will receive the animationGroup
  36050. * @returns a new AnimationGroup
  36051. */
  36052. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36053. /**
  36054. * Returns the string "AnimationGroup"
  36055. * @returns "AnimationGroup"
  36056. */
  36057. getClassName(): string;
  36058. /**
  36059. * Creates a detailled string about the object
  36060. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36061. * @returns a string representing the object
  36062. */
  36063. toString(fullDetails?: boolean): string;
  36064. }
  36065. }
  36066. declare module "babylonjs/scene" {
  36067. import { Nullable } from "babylonjs/types";
  36068. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36069. import { Observable } from "babylonjs/Misc/observable";
  36070. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36071. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36072. import { Geometry } from "babylonjs/Meshes/geometry";
  36073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36076. import { Mesh } from "babylonjs/Meshes/mesh";
  36077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36078. import { Bone } from "babylonjs/Bones/bone";
  36079. import { Skeleton } from "babylonjs/Bones/skeleton";
  36080. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36081. import { Camera } from "babylonjs/Cameras/camera";
  36082. import { AbstractScene } from "babylonjs/abstractScene";
  36083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36084. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36085. import { Material } from "babylonjs/Materials/material";
  36086. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36087. import { Effect } from "babylonjs/Materials/effect";
  36088. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36089. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36090. import { Light } from "babylonjs/Lights/light";
  36091. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36092. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36093. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36094. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36095. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36096. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36097. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36098. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36099. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36100. import { Engine } from "babylonjs/Engines/engine";
  36101. import { Node } from "babylonjs/node";
  36102. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36103. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36104. import { WebRequest } from "babylonjs/Misc/webRequest";
  36105. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36106. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36107. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36108. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36109. import { Plane } from "babylonjs/Maths/math.plane";
  36110. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36111. import { Ray } from "babylonjs/Culling/ray";
  36112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36113. import { Animation } from "babylonjs/Animations/animation";
  36114. import { Animatable } from "babylonjs/Animations/animatable";
  36115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36116. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36117. import { Collider } from "babylonjs/Collisions/collider";
  36118. /**
  36119. * Define an interface for all classes that will hold resources
  36120. */
  36121. export interface IDisposable {
  36122. /**
  36123. * Releases all held resources
  36124. */
  36125. dispose(): void;
  36126. }
  36127. /** Interface defining initialization parameters for Scene class */
  36128. export interface SceneOptions {
  36129. /**
  36130. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36131. * It will improve performance when the number of geometries becomes important.
  36132. */
  36133. useGeometryUniqueIdsMap?: boolean;
  36134. /**
  36135. * Defines that each material of the scene should keep up-to-date a map of referencing 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. useMaterialMeshMap?: boolean;
  36139. /**
  36140. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36141. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36142. */
  36143. useClonedMeshMap?: boolean;
  36144. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36145. virtual?: boolean;
  36146. }
  36147. /**
  36148. * Represents a scene to be rendered by the engine.
  36149. * @see http://doc.babylonjs.com/features/scene
  36150. */
  36151. export class Scene extends AbstractScene implements IAnimatable {
  36152. /** The fog is deactivated */
  36153. static readonly FOGMODE_NONE: number;
  36154. /** The fog density is following an exponential function */
  36155. static readonly FOGMODE_EXP: number;
  36156. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36157. static readonly FOGMODE_EXP2: number;
  36158. /** The fog density is following a linear function. */
  36159. static readonly FOGMODE_LINEAR: number;
  36160. /**
  36161. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36163. */
  36164. static MinDeltaTime: number;
  36165. /**
  36166. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36168. */
  36169. static MaxDeltaTime: number;
  36170. /**
  36171. * Factory used to create the default material.
  36172. * @param name The name of the material to create
  36173. * @param scene The scene to create the material for
  36174. * @returns The default material
  36175. */
  36176. static DefaultMaterialFactory(scene: Scene): Material;
  36177. /**
  36178. * Factory used to create the a collision coordinator.
  36179. * @returns The collision coordinator
  36180. */
  36181. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36182. /** @hidden */
  36183. _inputManager: InputManager;
  36184. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36185. cameraToUseForPointers: Nullable<Camera>;
  36186. /** @hidden */
  36187. readonly _isScene: boolean;
  36188. /**
  36189. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36190. */
  36191. autoClear: boolean;
  36192. /**
  36193. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36194. */
  36195. autoClearDepthAndStencil: boolean;
  36196. /**
  36197. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36198. */
  36199. clearColor: Color4;
  36200. /**
  36201. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36202. */
  36203. ambientColor: Color3;
  36204. /**
  36205. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36206. * It should only be one of the following (if not the default embedded one):
  36207. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36208. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36209. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36210. * The material properties need to be setup according to the type of texture in use.
  36211. */
  36212. environmentBRDFTexture: BaseTexture;
  36213. /** @hidden */
  36214. protected _environmentTexture: Nullable<BaseTexture>;
  36215. /**
  36216. * Texture used in all pbr material as the reflection texture.
  36217. * As in the majority of the scene they are the same (exception for multi room and so on),
  36218. * this is easier to reference from here than from all the materials.
  36219. */
  36220. get environmentTexture(): Nullable<BaseTexture>;
  36221. /**
  36222. * Texture used in all pbr material as the reflection texture.
  36223. * As in the majority of the scene they are the same (exception for multi room and so on),
  36224. * this is easier to set here than in all the materials.
  36225. */
  36226. set environmentTexture(value: Nullable<BaseTexture>);
  36227. /** @hidden */
  36228. protected _environmentIntensity: number;
  36229. /**
  36230. * Intensity of the environment in all pbr material.
  36231. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36232. * As in the majority of the scene they are the same (exception for multi room and so on),
  36233. * this is easier to reference from here than from all the materials.
  36234. */
  36235. get environmentIntensity(): number;
  36236. /**
  36237. * Intensity of the environment in all pbr material.
  36238. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36239. * As in the majority of the scene they are the same (exception for multi room and so on),
  36240. * this is easier to set here than in all the materials.
  36241. */
  36242. set environmentIntensity(value: number);
  36243. /** @hidden */
  36244. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36245. /**
  36246. * Default image processing configuration used either in the rendering
  36247. * Forward main pass or through the imageProcessingPostProcess if present.
  36248. * As in the majority of the scene they are the same (exception for multi camera),
  36249. * this is easier to reference from here than from all the materials and post process.
  36250. *
  36251. * No setter as we it is a shared configuration, you can set the values instead.
  36252. */
  36253. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36254. private _forceWireframe;
  36255. /**
  36256. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36257. */
  36258. set forceWireframe(value: boolean);
  36259. get forceWireframe(): boolean;
  36260. private _skipFrustumClipping;
  36261. /**
  36262. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36263. */
  36264. set skipFrustumClipping(value: boolean);
  36265. get skipFrustumClipping(): boolean;
  36266. private _forcePointsCloud;
  36267. /**
  36268. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36269. */
  36270. set forcePointsCloud(value: boolean);
  36271. get forcePointsCloud(): boolean;
  36272. /**
  36273. * Gets or sets the active clipplane 1
  36274. */
  36275. clipPlane: Nullable<Plane>;
  36276. /**
  36277. * Gets or sets the active clipplane 2
  36278. */
  36279. clipPlane2: Nullable<Plane>;
  36280. /**
  36281. * Gets or sets the active clipplane 3
  36282. */
  36283. clipPlane3: Nullable<Plane>;
  36284. /**
  36285. * Gets or sets the active clipplane 4
  36286. */
  36287. clipPlane4: Nullable<Plane>;
  36288. /**
  36289. * Gets or sets the active clipplane 5
  36290. */
  36291. clipPlane5: Nullable<Plane>;
  36292. /**
  36293. * Gets or sets the active clipplane 6
  36294. */
  36295. clipPlane6: Nullable<Plane>;
  36296. /**
  36297. * Gets or sets a boolean indicating if animations are enabled
  36298. */
  36299. animationsEnabled: boolean;
  36300. private _animationPropertiesOverride;
  36301. /**
  36302. * Gets or sets the animation properties override
  36303. */
  36304. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36305. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36306. /**
  36307. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36308. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36309. */
  36310. useConstantAnimationDeltaTime: boolean;
  36311. /**
  36312. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36313. * Please note that it requires to run a ray cast through the scene on every frame
  36314. */
  36315. constantlyUpdateMeshUnderPointer: boolean;
  36316. /**
  36317. * Defines the HTML cursor to use when hovering over interactive elements
  36318. */
  36319. hoverCursor: string;
  36320. /**
  36321. * Defines the HTML default cursor to use (empty by default)
  36322. */
  36323. defaultCursor: string;
  36324. /**
  36325. * Defines whether cursors are handled by the scene.
  36326. */
  36327. doNotHandleCursors: boolean;
  36328. /**
  36329. * This is used to call preventDefault() on pointer down
  36330. * in order to block unwanted artifacts like system double clicks
  36331. */
  36332. preventDefaultOnPointerDown: boolean;
  36333. /**
  36334. * This is used to call preventDefault() on pointer up
  36335. * in order to block unwanted artifacts like system double clicks
  36336. */
  36337. preventDefaultOnPointerUp: boolean;
  36338. /**
  36339. * Gets or sets user defined metadata
  36340. */
  36341. metadata: any;
  36342. /**
  36343. * For internal use only. Please do not use.
  36344. */
  36345. reservedDataStore: any;
  36346. /**
  36347. * Gets the name of the plugin used to load this scene (null by default)
  36348. */
  36349. loadingPluginName: string;
  36350. /**
  36351. * Use this array to add regular expressions used to disable offline support for specific urls
  36352. */
  36353. disableOfflineSupportExceptionRules: RegExp[];
  36354. /**
  36355. * An event triggered when the scene is disposed.
  36356. */
  36357. onDisposeObservable: Observable<Scene>;
  36358. private _onDisposeObserver;
  36359. /** Sets a function to be executed when this scene is disposed. */
  36360. set onDispose(callback: () => void);
  36361. /**
  36362. * An event triggered before rendering the scene (right after animations and physics)
  36363. */
  36364. onBeforeRenderObservable: Observable<Scene>;
  36365. private _onBeforeRenderObserver;
  36366. /** Sets a function to be executed before rendering this scene */
  36367. set beforeRender(callback: Nullable<() => void>);
  36368. /**
  36369. * An event triggered after rendering the scene
  36370. */
  36371. onAfterRenderObservable: Observable<Scene>;
  36372. /**
  36373. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36374. */
  36375. onAfterRenderCameraObservable: Observable<Camera>;
  36376. private _onAfterRenderObserver;
  36377. /** Sets a function to be executed after rendering this scene */
  36378. set afterRender(callback: Nullable<() => void>);
  36379. /**
  36380. * An event triggered before animating the scene
  36381. */
  36382. onBeforeAnimationsObservable: Observable<Scene>;
  36383. /**
  36384. * An event triggered after animations processing
  36385. */
  36386. onAfterAnimationsObservable: Observable<Scene>;
  36387. /**
  36388. * An event triggered before draw calls are ready to be sent
  36389. */
  36390. onBeforeDrawPhaseObservable: Observable<Scene>;
  36391. /**
  36392. * An event triggered after draw calls have been sent
  36393. */
  36394. onAfterDrawPhaseObservable: Observable<Scene>;
  36395. /**
  36396. * An event triggered when the scene is ready
  36397. */
  36398. onReadyObservable: Observable<Scene>;
  36399. /**
  36400. * An event triggered before rendering a camera
  36401. */
  36402. onBeforeCameraRenderObservable: Observable<Camera>;
  36403. private _onBeforeCameraRenderObserver;
  36404. /** Sets a function to be executed before rendering a camera*/
  36405. set beforeCameraRender(callback: () => void);
  36406. /**
  36407. * An event triggered after rendering a camera
  36408. */
  36409. onAfterCameraRenderObservable: Observable<Camera>;
  36410. private _onAfterCameraRenderObserver;
  36411. /** Sets a function to be executed after rendering a camera*/
  36412. set afterCameraRender(callback: () => void);
  36413. /**
  36414. * An event triggered when active meshes evaluation is about to start
  36415. */
  36416. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36417. /**
  36418. * An event triggered when active meshes evaluation is done
  36419. */
  36420. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36421. /**
  36422. * An event triggered when particles rendering is about to start
  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. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36426. /**
  36427. * An event triggered when particles rendering is done
  36428. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36429. */
  36430. onAfterParticlesRenderingObservable: Observable<Scene>;
  36431. /**
  36432. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36433. */
  36434. onDataLoadedObservable: Observable<Scene>;
  36435. /**
  36436. * An event triggered when a camera is created
  36437. */
  36438. onNewCameraAddedObservable: Observable<Camera>;
  36439. /**
  36440. * An event triggered when a camera is removed
  36441. */
  36442. onCameraRemovedObservable: Observable<Camera>;
  36443. /**
  36444. * An event triggered when a light is created
  36445. */
  36446. onNewLightAddedObservable: Observable<Light>;
  36447. /**
  36448. * An event triggered when a light is removed
  36449. */
  36450. onLightRemovedObservable: Observable<Light>;
  36451. /**
  36452. * An event triggered when a geometry is created
  36453. */
  36454. onNewGeometryAddedObservable: Observable<Geometry>;
  36455. /**
  36456. * An event triggered when a geometry is removed
  36457. */
  36458. onGeometryRemovedObservable: Observable<Geometry>;
  36459. /**
  36460. * An event triggered when a transform node is created
  36461. */
  36462. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36463. /**
  36464. * An event triggered when a transform node is removed
  36465. */
  36466. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36467. /**
  36468. * An event triggered when a mesh is created
  36469. */
  36470. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36471. /**
  36472. * An event triggered when a mesh is removed
  36473. */
  36474. onMeshRemovedObservable: Observable<AbstractMesh>;
  36475. /**
  36476. * An event triggered when a skeleton is created
  36477. */
  36478. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36479. /**
  36480. * An event triggered when a skeleton is removed
  36481. */
  36482. onSkeletonRemovedObservable: Observable<Skeleton>;
  36483. /**
  36484. * An event triggered when a material is created
  36485. */
  36486. onNewMaterialAddedObservable: Observable<Material>;
  36487. /**
  36488. * An event triggered when a material is removed
  36489. */
  36490. onMaterialRemovedObservable: Observable<Material>;
  36491. /**
  36492. * An event triggered when a texture is created
  36493. */
  36494. onNewTextureAddedObservable: Observable<BaseTexture>;
  36495. /**
  36496. * An event triggered when a texture is removed
  36497. */
  36498. onTextureRemovedObservable: Observable<BaseTexture>;
  36499. /**
  36500. * An event triggered when render targets are about to be rendered
  36501. * Can happen multiple times per frame.
  36502. */
  36503. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36504. /**
  36505. * An event triggered when render targets were rendered.
  36506. * Can happen multiple times per frame.
  36507. */
  36508. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36509. /**
  36510. * An event triggered before calculating deterministic simulation step
  36511. */
  36512. onBeforeStepObservable: Observable<Scene>;
  36513. /**
  36514. * An event triggered after calculating deterministic simulation step
  36515. */
  36516. onAfterStepObservable: Observable<Scene>;
  36517. /**
  36518. * An event triggered when the activeCamera property is updated
  36519. */
  36520. onActiveCameraChanged: Observable<Scene>;
  36521. /**
  36522. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36523. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36524. * 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)
  36525. */
  36526. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36527. /**
  36528. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36529. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36530. * 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)
  36531. */
  36532. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36533. /**
  36534. * This Observable will when a mesh has been imported into the scene.
  36535. */
  36536. onMeshImportedObservable: Observable<AbstractMesh>;
  36537. /**
  36538. * This Observable will when an animation file has been imported into the scene.
  36539. */
  36540. onAnimationFileImportedObservable: Observable<Scene>;
  36541. /**
  36542. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36543. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36544. */
  36545. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36546. /** @hidden */
  36547. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36548. /**
  36549. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36550. */
  36551. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36552. /**
  36553. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36554. */
  36555. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36556. /**
  36557. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36558. */
  36559. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36560. /** Callback called when a pointer move is detected */
  36561. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36562. /** Callback called when a pointer down is detected */
  36563. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36564. /** Callback called when a pointer up is detected */
  36565. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36566. /** Callback called when a pointer pick is detected */
  36567. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36568. /**
  36569. * 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).
  36570. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36571. */
  36572. onPrePointerObservable: Observable<PointerInfoPre>;
  36573. /**
  36574. * Observable event triggered each time an input event is received from the rendering canvas
  36575. */
  36576. onPointerObservable: Observable<PointerInfo>;
  36577. /**
  36578. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36579. */
  36580. get unTranslatedPointer(): Vector2;
  36581. /**
  36582. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36583. */
  36584. static get DragMovementThreshold(): number;
  36585. static set DragMovementThreshold(value: number);
  36586. /**
  36587. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36588. */
  36589. static get LongPressDelay(): number;
  36590. static set LongPressDelay(value: number);
  36591. /**
  36592. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36593. */
  36594. static get DoubleClickDelay(): number;
  36595. static set DoubleClickDelay(value: number);
  36596. /** If you need to check double click without raising a single click at first click, enable this flag */
  36597. static get ExclusiveDoubleClickMode(): boolean;
  36598. static set ExclusiveDoubleClickMode(value: boolean);
  36599. /** @hidden */
  36600. _mirroredCameraPosition: Nullable<Vector3>;
  36601. /**
  36602. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36603. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36604. */
  36605. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36606. /**
  36607. * Observable event triggered each time an keyboard event is received from the hosting window
  36608. */
  36609. onKeyboardObservable: Observable<KeyboardInfo>;
  36610. private _useRightHandedSystem;
  36611. /**
  36612. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36613. */
  36614. set useRightHandedSystem(value: boolean);
  36615. get useRightHandedSystem(): boolean;
  36616. private _timeAccumulator;
  36617. private _currentStepId;
  36618. private _currentInternalStep;
  36619. /**
  36620. * Sets the step Id used by deterministic lock step
  36621. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36622. * @param newStepId defines the step Id
  36623. */
  36624. setStepId(newStepId: number): void;
  36625. /**
  36626. * Gets the step Id used by deterministic lock step
  36627. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36628. * @returns the step Id
  36629. */
  36630. getStepId(): number;
  36631. /**
  36632. * Gets the internal step used by deterministic lock step
  36633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36634. * @returns the internal step
  36635. */
  36636. getInternalStep(): number;
  36637. private _fogEnabled;
  36638. /**
  36639. * Gets or sets a boolean indicating if fog is enabled on this scene
  36640. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36641. * (Default is true)
  36642. */
  36643. set fogEnabled(value: boolean);
  36644. get fogEnabled(): boolean;
  36645. private _fogMode;
  36646. /**
  36647. * Gets or sets the fog mode to use
  36648. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36649. * | mode | value |
  36650. * | --- | --- |
  36651. * | FOGMODE_NONE | 0 |
  36652. * | FOGMODE_EXP | 1 |
  36653. * | FOGMODE_EXP2 | 2 |
  36654. * | FOGMODE_LINEAR | 3 |
  36655. */
  36656. set fogMode(value: number);
  36657. get fogMode(): number;
  36658. /**
  36659. * Gets or sets the fog color to use
  36660. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36661. * (Default is Color3(0.2, 0.2, 0.3))
  36662. */
  36663. fogColor: Color3;
  36664. /**
  36665. * Gets or sets the fog density to use
  36666. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36667. * (Default is 0.1)
  36668. */
  36669. fogDensity: number;
  36670. /**
  36671. * Gets or sets the fog start distance to use
  36672. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36673. * (Default is 0)
  36674. */
  36675. fogStart: number;
  36676. /**
  36677. * Gets or sets the fog end distance to use
  36678. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36679. * (Default is 1000)
  36680. */
  36681. fogEnd: number;
  36682. private _shadowsEnabled;
  36683. /**
  36684. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36685. */
  36686. set shadowsEnabled(value: boolean);
  36687. get shadowsEnabled(): boolean;
  36688. private _lightsEnabled;
  36689. /**
  36690. * Gets or sets a boolean indicating if lights are enabled on this scene
  36691. */
  36692. set lightsEnabled(value: boolean);
  36693. get lightsEnabled(): boolean;
  36694. /** All of the active cameras added to this scene. */
  36695. activeCameras: Camera[];
  36696. /** @hidden */
  36697. _activeCamera: Nullable<Camera>;
  36698. /** Gets or sets the current active camera */
  36699. get activeCamera(): Nullable<Camera>;
  36700. set activeCamera(value: Nullable<Camera>);
  36701. private _defaultMaterial;
  36702. /** The default material used on meshes when no material is affected */
  36703. get defaultMaterial(): Material;
  36704. /** The default material used on meshes when no material is affected */
  36705. set defaultMaterial(value: Material);
  36706. private _texturesEnabled;
  36707. /**
  36708. * Gets or sets a boolean indicating if textures are enabled on this scene
  36709. */
  36710. set texturesEnabled(value: boolean);
  36711. get texturesEnabled(): boolean;
  36712. /**
  36713. * Gets or sets a boolean indicating if particles are enabled on this scene
  36714. */
  36715. particlesEnabled: boolean;
  36716. /**
  36717. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36718. */
  36719. spritesEnabled: boolean;
  36720. private _skeletonsEnabled;
  36721. /**
  36722. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36723. */
  36724. set skeletonsEnabled(value: boolean);
  36725. get skeletonsEnabled(): boolean;
  36726. /**
  36727. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36728. */
  36729. lensFlaresEnabled: boolean;
  36730. /**
  36731. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36732. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36733. */
  36734. collisionsEnabled: boolean;
  36735. private _collisionCoordinator;
  36736. /** @hidden */
  36737. get collisionCoordinator(): ICollisionCoordinator;
  36738. /**
  36739. * Defines the gravity applied to this scene (used only for collisions)
  36740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36741. */
  36742. gravity: Vector3;
  36743. /**
  36744. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36745. */
  36746. postProcessesEnabled: boolean;
  36747. /**
  36748. * The list of postprocesses added to the scene
  36749. */
  36750. postProcesses: PostProcess[];
  36751. /**
  36752. * Gets the current postprocess manager
  36753. */
  36754. postProcessManager: PostProcessManager;
  36755. /**
  36756. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36757. */
  36758. renderTargetsEnabled: boolean;
  36759. /**
  36760. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36761. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36762. */
  36763. dumpNextRenderTargets: boolean;
  36764. /**
  36765. * The list of user defined render targets added to the scene
  36766. */
  36767. customRenderTargets: RenderTargetTexture[];
  36768. /**
  36769. * Defines if texture loading must be delayed
  36770. * If true, textures will only be loaded when they need to be rendered
  36771. */
  36772. useDelayedTextureLoading: boolean;
  36773. /**
  36774. * Gets the list of meshes imported to the scene through SceneLoader
  36775. */
  36776. importedMeshesFiles: String[];
  36777. /**
  36778. * Gets or sets a boolean indicating if probes are enabled on this scene
  36779. */
  36780. probesEnabled: boolean;
  36781. /**
  36782. * Gets or sets the current offline provider to use to store scene data
  36783. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36784. */
  36785. offlineProvider: IOfflineProvider;
  36786. /**
  36787. * Gets or sets the action manager associated with the scene
  36788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36789. */
  36790. actionManager: AbstractActionManager;
  36791. private _meshesForIntersections;
  36792. /**
  36793. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36794. */
  36795. proceduralTexturesEnabled: boolean;
  36796. private _engine;
  36797. private _totalVertices;
  36798. /** @hidden */
  36799. _activeIndices: PerfCounter;
  36800. /** @hidden */
  36801. _activeParticles: PerfCounter;
  36802. /** @hidden */
  36803. _activeBones: PerfCounter;
  36804. private _animationRatio;
  36805. /** @hidden */
  36806. _animationTimeLast: number;
  36807. /** @hidden */
  36808. _animationTime: number;
  36809. /**
  36810. * Gets or sets a general scale for animation speed
  36811. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36812. */
  36813. animationTimeScale: number;
  36814. /** @hidden */
  36815. _cachedMaterial: Nullable<Material>;
  36816. /** @hidden */
  36817. _cachedEffect: Nullable<Effect>;
  36818. /** @hidden */
  36819. _cachedVisibility: Nullable<number>;
  36820. private _renderId;
  36821. private _frameId;
  36822. private _executeWhenReadyTimeoutId;
  36823. private _intermediateRendering;
  36824. private _viewUpdateFlag;
  36825. private _projectionUpdateFlag;
  36826. /** @hidden */
  36827. _toBeDisposed: Nullable<IDisposable>[];
  36828. private _activeRequests;
  36829. /** @hidden */
  36830. _pendingData: any[];
  36831. private _isDisposed;
  36832. /**
  36833. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36834. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36835. */
  36836. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36837. private _activeMeshes;
  36838. private _processedMaterials;
  36839. private _renderTargets;
  36840. /** @hidden */
  36841. _activeParticleSystems: SmartArray<IParticleSystem>;
  36842. private _activeSkeletons;
  36843. private _softwareSkinnedMeshes;
  36844. private _renderingManager;
  36845. /** @hidden */
  36846. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36847. private _transformMatrix;
  36848. private _sceneUbo;
  36849. /** @hidden */
  36850. _viewMatrix: Matrix;
  36851. private _projectionMatrix;
  36852. /** @hidden */
  36853. _forcedViewPosition: Nullable<Vector3>;
  36854. /** @hidden */
  36855. _frustumPlanes: Plane[];
  36856. /**
  36857. * Gets the list of frustum planes (built from the active camera)
  36858. */
  36859. get frustumPlanes(): Plane[];
  36860. /**
  36861. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36862. * This is useful if there are more lights that the maximum simulteanous authorized
  36863. */
  36864. requireLightSorting: boolean;
  36865. /** @hidden */
  36866. readonly useMaterialMeshMap: boolean;
  36867. /** @hidden */
  36868. readonly useClonedMeshMap: boolean;
  36869. private _externalData;
  36870. private _uid;
  36871. /**
  36872. * @hidden
  36873. * Backing store of defined scene components.
  36874. */
  36875. _components: ISceneComponent[];
  36876. /**
  36877. * @hidden
  36878. * Backing store of defined scene components.
  36879. */
  36880. _serializableComponents: ISceneSerializableComponent[];
  36881. /**
  36882. * List of components to register on the next registration step.
  36883. */
  36884. private _transientComponents;
  36885. /**
  36886. * Registers the transient components if needed.
  36887. */
  36888. private _registerTransientComponents;
  36889. /**
  36890. * @hidden
  36891. * Add a component to the scene.
  36892. * Note that the ccomponent could be registered on th next frame if this is called after
  36893. * the register component stage.
  36894. * @param component Defines the component to add to the scene
  36895. */
  36896. _addComponent(component: ISceneComponent): void;
  36897. /**
  36898. * @hidden
  36899. * Gets a component from the scene.
  36900. * @param name defines the name of the component to retrieve
  36901. * @returns the component or null if not present
  36902. */
  36903. _getComponent(name: string): Nullable<ISceneComponent>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening before camera updates.
  36907. */
  36908. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions happening before clear the canvas.
  36912. */
  36913. _beforeClearStage: Stage<SimpleStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions when collecting render targets for the frame.
  36917. */
  36918. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening for one camera in the frame.
  36922. */
  36923. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening during the per mesh ready checks.
  36927. */
  36928. _isReadyForMeshStage: Stage<MeshStageAction>;
  36929. /**
  36930. * @hidden
  36931. * Defines the actions happening before evaluate active mesh checks.
  36932. */
  36933. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36934. /**
  36935. * @hidden
  36936. * Defines the actions happening during the evaluate sub mesh checks.
  36937. */
  36938. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36939. /**
  36940. * @hidden
  36941. * Defines the actions happening during the active mesh stage.
  36942. */
  36943. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36944. /**
  36945. * @hidden
  36946. * Defines the actions happening during the per camera render target step.
  36947. */
  36948. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36949. /**
  36950. * @hidden
  36951. * Defines the actions happening just before the active camera is drawing.
  36952. */
  36953. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36954. /**
  36955. * @hidden
  36956. * Defines the actions happening just before a render target is drawing.
  36957. */
  36958. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36959. /**
  36960. * @hidden
  36961. * Defines the actions happening just before a rendering group is drawing.
  36962. */
  36963. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36964. /**
  36965. * @hidden
  36966. * Defines the actions happening just before a mesh is drawing.
  36967. */
  36968. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36969. /**
  36970. * @hidden
  36971. * Defines the actions happening just after a mesh has been drawn.
  36972. */
  36973. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36974. /**
  36975. * @hidden
  36976. * Defines the actions happening just after a rendering group has been drawn.
  36977. */
  36978. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36979. /**
  36980. * @hidden
  36981. * Defines the actions happening just after the active camera has been drawn.
  36982. */
  36983. _afterCameraDrawStage: Stage<CameraStageAction>;
  36984. /**
  36985. * @hidden
  36986. * Defines the actions happening just after a render target has been drawn.
  36987. */
  36988. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36989. /**
  36990. * @hidden
  36991. * Defines the actions happening just after rendering all cameras and computing intersections.
  36992. */
  36993. _afterRenderStage: Stage<SimpleStageAction>;
  36994. /**
  36995. * @hidden
  36996. * Defines the actions happening when a pointer move event happens.
  36997. */
  36998. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36999. /**
  37000. * @hidden
  37001. * Defines the actions happening when a pointer down event happens.
  37002. */
  37003. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37004. /**
  37005. * @hidden
  37006. * Defines the actions happening when a pointer up event happens.
  37007. */
  37008. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37009. /**
  37010. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37011. */
  37012. private geometriesByUniqueId;
  37013. /**
  37014. * Creates a new Scene
  37015. * @param engine defines the engine to use to render this scene
  37016. * @param options defines the scene options
  37017. */
  37018. constructor(engine: Engine, options?: SceneOptions);
  37019. /**
  37020. * Gets a string idenfifying the name of the class
  37021. * @returns "Scene" string
  37022. */
  37023. getClassName(): string;
  37024. private _defaultMeshCandidates;
  37025. /**
  37026. * @hidden
  37027. */
  37028. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37029. private _defaultSubMeshCandidates;
  37030. /**
  37031. * @hidden
  37032. */
  37033. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37034. /**
  37035. * Sets the default candidate providers for the scene.
  37036. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37037. * and getCollidingSubMeshCandidates to their default function
  37038. */
  37039. setDefaultCandidateProviders(): void;
  37040. /**
  37041. * Gets the mesh that is currently under the pointer
  37042. */
  37043. get meshUnderPointer(): Nullable<AbstractMesh>;
  37044. /**
  37045. * Gets or sets the current on-screen X position of the pointer
  37046. */
  37047. get pointerX(): number;
  37048. set pointerX(value: number);
  37049. /**
  37050. * Gets or sets the current on-screen Y position of the pointer
  37051. */
  37052. get pointerY(): number;
  37053. set pointerY(value: number);
  37054. /**
  37055. * Gets the cached material (ie. the latest rendered one)
  37056. * @returns the cached material
  37057. */
  37058. getCachedMaterial(): Nullable<Material>;
  37059. /**
  37060. * Gets the cached effect (ie. the latest rendered one)
  37061. * @returns the cached effect
  37062. */
  37063. getCachedEffect(): Nullable<Effect>;
  37064. /**
  37065. * Gets the cached visibility state (ie. the latest rendered one)
  37066. * @returns the cached visibility state
  37067. */
  37068. getCachedVisibility(): Nullable<number>;
  37069. /**
  37070. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37071. * @param material defines the current material
  37072. * @param effect defines the current effect
  37073. * @param visibility defines the current visibility state
  37074. * @returns true if one parameter is not cached
  37075. */
  37076. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37077. /**
  37078. * Gets the engine associated with the scene
  37079. * @returns an Engine
  37080. */
  37081. getEngine(): Engine;
  37082. /**
  37083. * Gets the total number of vertices rendered per frame
  37084. * @returns the total number of vertices rendered per frame
  37085. */
  37086. getTotalVertices(): number;
  37087. /**
  37088. * Gets the performance counter for total vertices
  37089. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37090. */
  37091. get totalVerticesPerfCounter(): PerfCounter;
  37092. /**
  37093. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37094. * @returns the total number of active indices rendered per frame
  37095. */
  37096. getActiveIndices(): number;
  37097. /**
  37098. * Gets the performance counter for active indices
  37099. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37100. */
  37101. get totalActiveIndicesPerfCounter(): PerfCounter;
  37102. /**
  37103. * Gets the total number of active particles rendered per frame
  37104. * @returns the total number of active particles rendered per frame
  37105. */
  37106. getActiveParticles(): number;
  37107. /**
  37108. * Gets the performance counter for active particles
  37109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37110. */
  37111. get activeParticlesPerfCounter(): PerfCounter;
  37112. /**
  37113. * Gets the total number of active bones rendered per frame
  37114. * @returns the total number of active bones rendered per frame
  37115. */
  37116. getActiveBones(): number;
  37117. /**
  37118. * Gets the performance counter for active bones
  37119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37120. */
  37121. get activeBonesPerfCounter(): PerfCounter;
  37122. /**
  37123. * Gets the array of active meshes
  37124. * @returns an array of AbstractMesh
  37125. */
  37126. getActiveMeshes(): SmartArray<AbstractMesh>;
  37127. /**
  37128. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37129. * @returns a number
  37130. */
  37131. getAnimationRatio(): number;
  37132. /**
  37133. * Gets an unique Id for the current render phase
  37134. * @returns a number
  37135. */
  37136. getRenderId(): number;
  37137. /**
  37138. * Gets an unique Id for the current frame
  37139. * @returns a number
  37140. */
  37141. getFrameId(): number;
  37142. /** Call this function if you want to manually increment the render Id*/
  37143. incrementRenderId(): void;
  37144. private _createUbo;
  37145. /**
  37146. * Use this method to simulate a pointer move on a mesh
  37147. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37148. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37149. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37150. * @returns the current scene
  37151. */
  37152. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37153. /**
  37154. * Use this method to simulate a pointer down on a mesh
  37155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37158. * @returns the current scene
  37159. */
  37160. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37161. /**
  37162. * Use this method to simulate a pointer up on a mesh
  37163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37166. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37167. * @returns the current scene
  37168. */
  37169. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37170. /**
  37171. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37172. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37173. * @returns true if the pointer was captured
  37174. */
  37175. isPointerCaptured(pointerId?: number): boolean;
  37176. /**
  37177. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37178. * @param attachUp defines if you want to attach events to pointerup
  37179. * @param attachDown defines if you want to attach events to pointerdown
  37180. * @param attachMove defines if you want to attach events to pointermove
  37181. */
  37182. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37183. /** Detaches all event handlers*/
  37184. detachControl(): void;
  37185. /**
  37186. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37187. * Delay loaded resources are not taking in account
  37188. * @return true if all required resources are ready
  37189. */
  37190. isReady(): boolean;
  37191. /** Resets all cached information relative to material (including effect and visibility) */
  37192. resetCachedMaterial(): void;
  37193. /**
  37194. * Registers a function to be called before every frame render
  37195. * @param func defines the function to register
  37196. */
  37197. registerBeforeRender(func: () => void): void;
  37198. /**
  37199. * Unregisters a function called before every frame render
  37200. * @param func defines the function to unregister
  37201. */
  37202. unregisterBeforeRender(func: () => void): void;
  37203. /**
  37204. * Registers a function to be called after every frame render
  37205. * @param func defines the function to register
  37206. */
  37207. registerAfterRender(func: () => void): void;
  37208. /**
  37209. * Unregisters a function called after every frame render
  37210. * @param func defines the function to unregister
  37211. */
  37212. unregisterAfterRender(func: () => void): void;
  37213. private _executeOnceBeforeRender;
  37214. /**
  37215. * The provided function will run before render once and will be disposed afterwards.
  37216. * A timeout delay can be provided so that the function will be executed in N ms.
  37217. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37218. * @param func The function to be executed.
  37219. * @param timeout optional delay in ms
  37220. */
  37221. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37222. /** @hidden */
  37223. _addPendingData(data: any): void;
  37224. /** @hidden */
  37225. _removePendingData(data: any): void;
  37226. /**
  37227. * Returns the number of items waiting to be loaded
  37228. * @returns the number of items waiting to be loaded
  37229. */
  37230. getWaitingItemsCount(): number;
  37231. /**
  37232. * Returns a boolean indicating if the scene is still loading data
  37233. */
  37234. get isLoading(): boolean;
  37235. /**
  37236. * Registers a function to be executed when the scene is ready
  37237. * @param {Function} func - the function to be executed
  37238. */
  37239. executeWhenReady(func: () => void): void;
  37240. /**
  37241. * Returns a promise that resolves when the scene is ready
  37242. * @returns A promise that resolves when the scene is ready
  37243. */
  37244. whenReadyAsync(): Promise<void>;
  37245. /** @hidden */
  37246. _checkIsReady(): void;
  37247. /**
  37248. * Gets all animatable attached to the scene
  37249. */
  37250. get animatables(): Animatable[];
  37251. /**
  37252. * Resets the last animation time frame.
  37253. * Useful to override when animations start running when loading a scene for the first time.
  37254. */
  37255. resetLastAnimationTimeFrame(): void;
  37256. /**
  37257. * Gets the current view matrix
  37258. * @returns a Matrix
  37259. */
  37260. getViewMatrix(): Matrix;
  37261. /**
  37262. * Gets the current projection matrix
  37263. * @returns a Matrix
  37264. */
  37265. getProjectionMatrix(): Matrix;
  37266. /**
  37267. * Gets the current transform matrix
  37268. * @returns a Matrix made of View * Projection
  37269. */
  37270. getTransformMatrix(): Matrix;
  37271. /**
  37272. * Sets the current transform matrix
  37273. * @param viewL defines the View matrix to use
  37274. * @param projectionL defines the Projection matrix to use
  37275. * @param viewR defines the right View matrix to use (if provided)
  37276. * @param projectionR defines the right Projection matrix to use (if provided)
  37277. */
  37278. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37279. /**
  37280. * Gets the uniform buffer used to store scene data
  37281. * @returns a UniformBuffer
  37282. */
  37283. getSceneUniformBuffer(): UniformBuffer;
  37284. /**
  37285. * Gets an unique (relatively to the current scene) Id
  37286. * @returns an unique number for the scene
  37287. */
  37288. getUniqueId(): number;
  37289. /**
  37290. * Add a mesh to the list of scene's meshes
  37291. * @param newMesh defines the mesh to add
  37292. * @param recursive if all child meshes should also be added to the scene
  37293. */
  37294. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37295. /**
  37296. * Remove a mesh for the list of scene's meshes
  37297. * @param toRemove defines the mesh to remove
  37298. * @param recursive if all child meshes should also be removed from the scene
  37299. * @returns the index where the mesh was in the mesh list
  37300. */
  37301. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37302. /**
  37303. * Add a transform node to the list of scene's transform nodes
  37304. * @param newTransformNode defines the transform node to add
  37305. */
  37306. addTransformNode(newTransformNode: TransformNode): void;
  37307. /**
  37308. * Remove a transform node for the list of scene's transform nodes
  37309. * @param toRemove defines the transform node to remove
  37310. * @returns the index where the transform node was in the transform node list
  37311. */
  37312. removeTransformNode(toRemove: TransformNode): number;
  37313. /**
  37314. * Remove a skeleton for the list of scene's skeletons
  37315. * @param toRemove defines the skeleton to remove
  37316. * @returns the index where the skeleton was in the skeleton list
  37317. */
  37318. removeSkeleton(toRemove: Skeleton): number;
  37319. /**
  37320. * Remove a morph target for the list of scene's morph targets
  37321. * @param toRemove defines the morph target to remove
  37322. * @returns the index where the morph target was in the morph target list
  37323. */
  37324. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37325. /**
  37326. * Remove a light for the list of scene's lights
  37327. * @param toRemove defines the light to remove
  37328. * @returns the index where the light was in the light list
  37329. */
  37330. removeLight(toRemove: Light): number;
  37331. /**
  37332. * Remove a camera for the list of scene's cameras
  37333. * @param toRemove defines the camera to remove
  37334. * @returns the index where the camera was in the camera list
  37335. */
  37336. removeCamera(toRemove: Camera): number;
  37337. /**
  37338. * Remove a particle system for the list of scene's particle systems
  37339. * @param toRemove defines the particle system to remove
  37340. * @returns the index where the particle system was in the particle system list
  37341. */
  37342. removeParticleSystem(toRemove: IParticleSystem): number;
  37343. /**
  37344. * Remove a animation for the list of scene's animations
  37345. * @param toRemove defines the animation to remove
  37346. * @returns the index where the animation was in the animation list
  37347. */
  37348. removeAnimation(toRemove: Animation): number;
  37349. /**
  37350. * Will stop the animation of the given target
  37351. * @param target - the target
  37352. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37353. * @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)
  37354. */
  37355. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37356. /**
  37357. * Removes the given animation group from this scene.
  37358. * @param toRemove The animation group to remove
  37359. * @returns The index of the removed animation group
  37360. */
  37361. removeAnimationGroup(toRemove: AnimationGroup): number;
  37362. /**
  37363. * Removes the given multi-material from this scene.
  37364. * @param toRemove The multi-material to remove
  37365. * @returns The index of the removed multi-material
  37366. */
  37367. removeMultiMaterial(toRemove: MultiMaterial): number;
  37368. /**
  37369. * Removes the given material from this scene.
  37370. * @param toRemove The material to remove
  37371. * @returns The index of the removed material
  37372. */
  37373. removeMaterial(toRemove: Material): number;
  37374. /**
  37375. * Removes the given action manager from this scene.
  37376. * @param toRemove The action manager to remove
  37377. * @returns The index of the removed action manager
  37378. */
  37379. removeActionManager(toRemove: AbstractActionManager): number;
  37380. /**
  37381. * Removes the given texture from this scene.
  37382. * @param toRemove The texture to remove
  37383. * @returns The index of the removed texture
  37384. */
  37385. removeTexture(toRemove: BaseTexture): number;
  37386. /**
  37387. * Adds the given light to this scene
  37388. * @param newLight The light to add
  37389. */
  37390. addLight(newLight: Light): void;
  37391. /**
  37392. * Sorts the list list based on light priorities
  37393. */
  37394. sortLightsByPriority(): void;
  37395. /**
  37396. * Adds the given camera to this scene
  37397. * @param newCamera The camera to add
  37398. */
  37399. addCamera(newCamera: Camera): void;
  37400. /**
  37401. * Adds the given skeleton to this scene
  37402. * @param newSkeleton The skeleton to add
  37403. */
  37404. addSkeleton(newSkeleton: Skeleton): void;
  37405. /**
  37406. * Adds the given particle system to this scene
  37407. * @param newParticleSystem The particle system to add
  37408. */
  37409. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37410. /**
  37411. * Adds the given animation to this scene
  37412. * @param newAnimation The animation to add
  37413. */
  37414. addAnimation(newAnimation: Animation): void;
  37415. /**
  37416. * Adds the given animation group to this scene.
  37417. * @param newAnimationGroup The animation group to add
  37418. */
  37419. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37420. /**
  37421. * Adds the given multi-material to this scene
  37422. * @param newMultiMaterial The multi-material to add
  37423. */
  37424. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37425. /**
  37426. * Adds the given material to this scene
  37427. * @param newMaterial The material to add
  37428. */
  37429. addMaterial(newMaterial: Material): void;
  37430. /**
  37431. * Adds the given morph target to this scene
  37432. * @param newMorphTargetManager The morph target to add
  37433. */
  37434. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37435. /**
  37436. * Adds the given geometry to this scene
  37437. * @param newGeometry The geometry to add
  37438. */
  37439. addGeometry(newGeometry: Geometry): void;
  37440. /**
  37441. * Adds the given action manager to this scene
  37442. * @param newActionManager The action manager to add
  37443. */
  37444. addActionManager(newActionManager: AbstractActionManager): void;
  37445. /**
  37446. * Adds the given texture to this scene.
  37447. * @param newTexture The texture to add
  37448. */
  37449. addTexture(newTexture: BaseTexture): void;
  37450. /**
  37451. * Switch active camera
  37452. * @param newCamera defines the new active camera
  37453. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37454. */
  37455. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37456. /**
  37457. * sets the active camera of the scene using its ID
  37458. * @param id defines the camera's ID
  37459. * @return the new active camera or null if none found.
  37460. */
  37461. setActiveCameraByID(id: string): Nullable<Camera>;
  37462. /**
  37463. * sets the active camera of the scene using its name
  37464. * @param name defines the camera's name
  37465. * @returns the new active camera or null if none found.
  37466. */
  37467. setActiveCameraByName(name: string): Nullable<Camera>;
  37468. /**
  37469. * get an animation group using its name
  37470. * @param name defines the material's name
  37471. * @return the animation group or null if none found.
  37472. */
  37473. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37474. /**
  37475. * Get a material using its unique id
  37476. * @param uniqueId defines the material's unique id
  37477. * @return the material or null if none found.
  37478. */
  37479. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37480. /**
  37481. * get a material using its id
  37482. * @param id defines the material's ID
  37483. * @return the material or null if none found.
  37484. */
  37485. getMaterialByID(id: string): Nullable<Material>;
  37486. /**
  37487. * Gets a the last added material using a given id
  37488. * @param id defines the material's ID
  37489. * @return the last material with the given id or null if none found.
  37490. */
  37491. getLastMaterialByID(id: string): Nullable<Material>;
  37492. /**
  37493. * Gets a material using its name
  37494. * @param name defines the material's name
  37495. * @return the material or null if none found.
  37496. */
  37497. getMaterialByName(name: string): Nullable<Material>;
  37498. /**
  37499. * Get a texture using its unique id
  37500. * @param uniqueId defines the texture's unique id
  37501. * @return the texture or null if none found.
  37502. */
  37503. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37504. /**
  37505. * Gets a camera using its id
  37506. * @param id defines the id to look for
  37507. * @returns the camera or null if not found
  37508. */
  37509. getCameraByID(id: string): Nullable<Camera>;
  37510. /**
  37511. * Gets a camera using its unique id
  37512. * @param uniqueId defines the unique id to look for
  37513. * @returns the camera or null if not found
  37514. */
  37515. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37516. /**
  37517. * Gets a camera using its name
  37518. * @param name defines the camera's name
  37519. * @return the camera or null if none found.
  37520. */
  37521. getCameraByName(name: string): Nullable<Camera>;
  37522. /**
  37523. * Gets a bone using its id
  37524. * @param id defines the bone's id
  37525. * @return the bone or null if not found
  37526. */
  37527. getBoneByID(id: string): Nullable<Bone>;
  37528. /**
  37529. * Gets a bone using its id
  37530. * @param name defines the bone's name
  37531. * @return the bone or null if not found
  37532. */
  37533. getBoneByName(name: string): Nullable<Bone>;
  37534. /**
  37535. * Gets a light node using its name
  37536. * @param name defines the the light's name
  37537. * @return the light or null if none found.
  37538. */
  37539. getLightByName(name: string): Nullable<Light>;
  37540. /**
  37541. * Gets a light node using its id
  37542. * @param id defines the light's id
  37543. * @return the light or null if none found.
  37544. */
  37545. getLightByID(id: string): Nullable<Light>;
  37546. /**
  37547. * Gets a light node using its scene-generated unique ID
  37548. * @param uniqueId defines the light's unique id
  37549. * @return the light or null if none found.
  37550. */
  37551. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37552. /**
  37553. * Gets a particle system by id
  37554. * @param id defines the particle system id
  37555. * @return the corresponding system or null if none found
  37556. */
  37557. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37558. /**
  37559. * Gets a geometry using its ID
  37560. * @param id defines the geometry's id
  37561. * @return the geometry or null if none found.
  37562. */
  37563. getGeometryByID(id: string): Nullable<Geometry>;
  37564. private _getGeometryByUniqueID;
  37565. /**
  37566. * Add a new geometry to this scene
  37567. * @param geometry defines the geometry to be added to the scene.
  37568. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37569. * @return a boolean defining if the geometry was added or not
  37570. */
  37571. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37572. /**
  37573. * Removes an existing geometry
  37574. * @param geometry defines the geometry to be removed from the scene
  37575. * @return a boolean defining if the geometry was removed or not
  37576. */
  37577. removeGeometry(geometry: Geometry): boolean;
  37578. /**
  37579. * Gets the list of geometries attached to the scene
  37580. * @returns an array of Geometry
  37581. */
  37582. getGeometries(): Geometry[];
  37583. /**
  37584. * Gets the first added mesh found of a given ID
  37585. * @param id defines the id to search for
  37586. * @return the mesh found or null if not found at all
  37587. */
  37588. getMeshByID(id: string): Nullable<AbstractMesh>;
  37589. /**
  37590. * Gets a list of meshes using their id
  37591. * @param id defines the id to search for
  37592. * @returns a list of meshes
  37593. */
  37594. getMeshesByID(id: string): Array<AbstractMesh>;
  37595. /**
  37596. * Gets the first added transform node found of a given ID
  37597. * @param id defines the id to search for
  37598. * @return the found transform node or null if not found at all.
  37599. */
  37600. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37601. /**
  37602. * Gets a transform node with its auto-generated unique id
  37603. * @param uniqueId efines the unique id to search for
  37604. * @return the found transform node or null if not found at all.
  37605. */
  37606. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37607. /**
  37608. * Gets a list of transform nodes using their id
  37609. * @param id defines the id to search for
  37610. * @returns a list of transform nodes
  37611. */
  37612. getTransformNodesByID(id: string): Array<TransformNode>;
  37613. /**
  37614. * Gets a mesh with its auto-generated unique id
  37615. * @param uniqueId defines the unique id to search for
  37616. * @return the found mesh or null if not found at all.
  37617. */
  37618. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37619. /**
  37620. * Gets a the last added mesh using a given id
  37621. * @param id defines the id to search for
  37622. * @return the found mesh or null if not found at all.
  37623. */
  37624. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37625. /**
  37626. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37627. * @param id defines the id to search for
  37628. * @return the found node or null if not found at all
  37629. */
  37630. getLastEntryByID(id: string): Nullable<Node>;
  37631. /**
  37632. * Gets a node (Mesh, Camera, Light) using a given id
  37633. * @param id defines the id to search for
  37634. * @return the found node or null if not found at all
  37635. */
  37636. getNodeByID(id: string): Nullable<Node>;
  37637. /**
  37638. * Gets a node (Mesh, Camera, Light) using a given name
  37639. * @param name defines the name to search for
  37640. * @return the found node or null if not found at all.
  37641. */
  37642. getNodeByName(name: string): Nullable<Node>;
  37643. /**
  37644. * Gets a mesh using a given name
  37645. * @param name defines the name to search for
  37646. * @return the found mesh or null if not found at all.
  37647. */
  37648. getMeshByName(name: string): Nullable<AbstractMesh>;
  37649. /**
  37650. * Gets a transform node using a given name
  37651. * @param name defines the name to search for
  37652. * @return the found transform node or null if not found at all.
  37653. */
  37654. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37655. /**
  37656. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37657. * @param id defines the id to search for
  37658. * @return the found skeleton or null if not found at all.
  37659. */
  37660. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37661. /**
  37662. * Gets a skeleton using a given auto generated unique id
  37663. * @param uniqueId defines the unique id to search for
  37664. * @return the found skeleton or null if not found at all.
  37665. */
  37666. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37667. /**
  37668. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37669. * @param id defines the id to search for
  37670. * @return the found skeleton or null if not found at all.
  37671. */
  37672. getSkeletonById(id: string): Nullable<Skeleton>;
  37673. /**
  37674. * Gets a skeleton using a given name
  37675. * @param name defines the name to search for
  37676. * @return the found skeleton or null if not found at all.
  37677. */
  37678. getSkeletonByName(name: string): Nullable<Skeleton>;
  37679. /**
  37680. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37681. * @param id defines the id to search for
  37682. * @return the found morph target manager or null if not found at all.
  37683. */
  37684. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37685. /**
  37686. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37687. * @param id defines the id to search for
  37688. * @return the found morph target or null if not found at all.
  37689. */
  37690. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37691. /**
  37692. * Gets a boolean indicating if the given mesh is active
  37693. * @param mesh defines the mesh to look for
  37694. * @returns true if the mesh is in the active list
  37695. */
  37696. isActiveMesh(mesh: AbstractMesh): boolean;
  37697. /**
  37698. * Return a unique id as a string which can serve as an identifier for the scene
  37699. */
  37700. get uid(): string;
  37701. /**
  37702. * Add an externaly attached data from its key.
  37703. * This method call will fail and return false, if such key already exists.
  37704. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37705. * @param key the unique key that identifies the data
  37706. * @param data the data object to associate to the key for this Engine instance
  37707. * @return true if no such key were already present and the data was added successfully, false otherwise
  37708. */
  37709. addExternalData<T>(key: string, data: T): boolean;
  37710. /**
  37711. * Get an externaly attached data from its key
  37712. * @param key the unique key that identifies the data
  37713. * @return the associated data, if present (can be null), or undefined if not present
  37714. */
  37715. getExternalData<T>(key: string): Nullable<T>;
  37716. /**
  37717. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37718. * @param key the unique key that identifies the data
  37719. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37720. * @return the associated data, can be null if the factory returned null.
  37721. */
  37722. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37723. /**
  37724. * Remove an externaly attached data from the Engine instance
  37725. * @param key the unique key that identifies the data
  37726. * @return true if the data was successfully removed, false if it doesn't exist
  37727. */
  37728. removeExternalData(key: string): boolean;
  37729. private _evaluateSubMesh;
  37730. /**
  37731. * Clear the processed materials smart array preventing retention point in material dispose.
  37732. */
  37733. freeProcessedMaterials(): void;
  37734. private _preventFreeActiveMeshesAndRenderingGroups;
  37735. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37736. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37737. * when disposing several meshes in a row or a hierarchy of meshes.
  37738. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37739. */
  37740. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37741. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37742. /**
  37743. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37744. */
  37745. freeActiveMeshes(): void;
  37746. /**
  37747. * Clear the info related to rendering groups preventing retention points during dispose.
  37748. */
  37749. freeRenderingGroups(): void;
  37750. /** @hidden */
  37751. _isInIntermediateRendering(): boolean;
  37752. /**
  37753. * Lambda returning the list of potentially active meshes.
  37754. */
  37755. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37756. /**
  37757. * Lambda returning the list of potentially active sub meshes.
  37758. */
  37759. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37760. /**
  37761. * Lambda returning the list of potentially intersecting sub meshes.
  37762. */
  37763. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37764. /**
  37765. * Lambda returning the list of potentially colliding sub meshes.
  37766. */
  37767. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37768. private _activeMeshesFrozen;
  37769. private _skipEvaluateActiveMeshesCompletely;
  37770. /**
  37771. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37772. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37773. * @returns the current scene
  37774. */
  37775. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37776. /**
  37777. * Use this function to restart evaluating active meshes on every frame
  37778. * @returns the current scene
  37779. */
  37780. unfreezeActiveMeshes(): Scene;
  37781. private _evaluateActiveMeshes;
  37782. private _activeMesh;
  37783. /**
  37784. * Update the transform matrix to update from the current active camera
  37785. * @param force defines a boolean used to force the update even if cache is up to date
  37786. */
  37787. updateTransformMatrix(force?: boolean): void;
  37788. private _bindFrameBuffer;
  37789. /** @hidden */
  37790. _allowPostProcessClearColor: boolean;
  37791. /** @hidden */
  37792. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37793. private _processSubCameras;
  37794. private _checkIntersections;
  37795. /** @hidden */
  37796. _advancePhysicsEngineStep(step: number): void;
  37797. /**
  37798. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37799. */
  37800. getDeterministicFrameTime: () => number;
  37801. /** @hidden */
  37802. _animate(): void;
  37803. /** Execute all animations (for a frame) */
  37804. animate(): void;
  37805. /**
  37806. * Render the scene
  37807. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37808. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37809. */
  37810. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37811. /**
  37812. * Freeze all materials
  37813. * A frozen material will not be updatable but should be faster to render
  37814. */
  37815. freezeMaterials(): void;
  37816. /**
  37817. * Unfreeze all materials
  37818. * A frozen material will not be updatable but should be faster to render
  37819. */
  37820. unfreezeMaterials(): void;
  37821. /**
  37822. * Releases all held ressources
  37823. */
  37824. dispose(): void;
  37825. /**
  37826. * Gets if the scene is already disposed
  37827. */
  37828. get isDisposed(): boolean;
  37829. /**
  37830. * Call this function to reduce memory footprint of the scene.
  37831. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37832. */
  37833. clearCachedVertexData(): void;
  37834. /**
  37835. * This function will remove the local cached buffer data from texture.
  37836. * It will save memory but will prevent the texture from being rebuilt
  37837. */
  37838. cleanCachedTextureBuffer(): void;
  37839. /**
  37840. * Get the world extend vectors with an optional filter
  37841. *
  37842. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37843. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37844. */
  37845. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37846. min: Vector3;
  37847. max: Vector3;
  37848. };
  37849. /**
  37850. * Creates a ray that can be used to pick in the scene
  37851. * @param x defines the x coordinate of the origin (on-screen)
  37852. * @param y defines the y coordinate of the origin (on-screen)
  37853. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37854. * @param camera defines the camera to use for the picking
  37855. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37856. * @returns a Ray
  37857. */
  37858. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37859. /**
  37860. * Creates a ray that can be used to pick in the scene
  37861. * @param x defines the x coordinate of the origin (on-screen)
  37862. * @param y defines the y coordinate of the origin (on-screen)
  37863. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37864. * @param result defines the ray where to store the picking ray
  37865. * @param camera defines the camera to use for the picking
  37866. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37867. * @returns the current scene
  37868. */
  37869. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37870. /**
  37871. * Creates a ray that can be used to pick in the scene
  37872. * @param x defines the x coordinate of the origin (on-screen)
  37873. * @param y defines the y coordinate of the origin (on-screen)
  37874. * @param camera defines the camera to use for the picking
  37875. * @returns a Ray
  37876. */
  37877. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37878. /**
  37879. * Creates a ray that can be used to pick in the scene
  37880. * @param x defines the x coordinate of the origin (on-screen)
  37881. * @param y defines the y coordinate of the origin (on-screen)
  37882. * @param result defines the ray where to store the picking ray
  37883. * @param camera defines the camera to use for the picking
  37884. * @returns the current scene
  37885. */
  37886. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37887. /** Launch a ray to try to pick a mesh in the scene
  37888. * @param x position on screen
  37889. * @param y position on screen
  37890. * @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
  37891. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37892. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37893. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37894. * @returns a PickingInfo
  37895. */
  37896. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37897. /** Use the given ray to pick a mesh in the scene
  37898. * @param ray The ray to use to pick meshes
  37899. * @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
  37900. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37901. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37902. * @returns a PickingInfo
  37903. */
  37904. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37905. /**
  37906. * Launch a ray to try to pick a mesh in the scene
  37907. * @param x X position on screen
  37908. * @param y Y position on screen
  37909. * @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
  37910. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37911. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37912. * @returns an array of PickingInfo
  37913. */
  37914. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37915. /**
  37916. * Launch a ray to try to pick a mesh in the scene
  37917. * @param ray Ray to use
  37918. * @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
  37919. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37920. * @returns an array of PickingInfo
  37921. */
  37922. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37923. /**
  37924. * Force the value of meshUnderPointer
  37925. * @param mesh defines the mesh to use
  37926. */
  37927. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37928. /**
  37929. * Gets the mesh under the pointer
  37930. * @returns a Mesh or null if no mesh is under the pointer
  37931. */
  37932. getPointerOverMesh(): Nullable<AbstractMesh>;
  37933. /** @hidden */
  37934. _rebuildGeometries(): void;
  37935. /** @hidden */
  37936. _rebuildTextures(): void;
  37937. private _getByTags;
  37938. /**
  37939. * Get a list of meshes by tags
  37940. * @param tagsQuery defines the tags query to use
  37941. * @param forEach defines a predicate used to filter results
  37942. * @returns an array of Mesh
  37943. */
  37944. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37945. /**
  37946. * Get a list of cameras by tags
  37947. * @param tagsQuery defines the tags query to use
  37948. * @param forEach defines a predicate used to filter results
  37949. * @returns an array of Camera
  37950. */
  37951. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37952. /**
  37953. * Get a list of lights by tags
  37954. * @param tagsQuery defines the tags query to use
  37955. * @param forEach defines a predicate used to filter results
  37956. * @returns an array of Light
  37957. */
  37958. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37959. /**
  37960. * Get a list of materials by tags
  37961. * @param tagsQuery defines the tags query to use
  37962. * @param forEach defines a predicate used to filter results
  37963. * @returns an array of Material
  37964. */
  37965. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37966. /**
  37967. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37968. * This allowed control for front to back rendering or reversly depending of the special needs.
  37969. *
  37970. * @param renderingGroupId The rendering group id corresponding to its index
  37971. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37972. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37973. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37974. */
  37975. 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;
  37976. /**
  37977. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37978. *
  37979. * @param renderingGroupId The rendering group id corresponding to its index
  37980. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37981. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37982. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37983. */
  37984. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37985. /**
  37986. * Gets the current auto clear configuration for one rendering group of the rendering
  37987. * manager.
  37988. * @param index the rendering group index to get the information for
  37989. * @returns The auto clear setup for the requested rendering group
  37990. */
  37991. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37992. private _blockMaterialDirtyMechanism;
  37993. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37994. get blockMaterialDirtyMechanism(): boolean;
  37995. set blockMaterialDirtyMechanism(value: boolean);
  37996. /**
  37997. * Will flag all materials as dirty to trigger new shader compilation
  37998. * @param flag defines the flag used to specify which material part must be marked as dirty
  37999. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38000. */
  38001. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38002. /** @hidden */
  38003. _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;
  38004. /** @hidden */
  38005. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38006. /** @hidden */
  38007. _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;
  38008. /** @hidden */
  38009. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38010. /** @hidden */
  38011. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38012. /** @hidden */
  38013. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38014. }
  38015. }
  38016. declare module "babylonjs/assetContainer" {
  38017. import { AbstractScene } from "babylonjs/abstractScene";
  38018. import { Scene } from "babylonjs/scene";
  38019. import { Mesh } from "babylonjs/Meshes/mesh";
  38020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38021. import { Skeleton } from "babylonjs/Bones/skeleton";
  38022. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38023. import { Animatable } from "babylonjs/Animations/animatable";
  38024. import { Nullable } from "babylonjs/types";
  38025. import { Node } from "babylonjs/node";
  38026. /**
  38027. * Set of assets to keep when moving a scene into an asset container.
  38028. */
  38029. export class KeepAssets extends AbstractScene {
  38030. }
  38031. /**
  38032. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38033. */
  38034. export class InstantiatedEntries {
  38035. /**
  38036. * List of new root nodes (eg. nodes with no parent)
  38037. */
  38038. rootNodes: TransformNode[];
  38039. /**
  38040. * List of new skeletons
  38041. */
  38042. skeletons: Skeleton[];
  38043. /**
  38044. * List of new animation groups
  38045. */
  38046. animationGroups: AnimationGroup[];
  38047. }
  38048. /**
  38049. * Container with a set of assets that can be added or removed from a scene.
  38050. */
  38051. export class AssetContainer extends AbstractScene {
  38052. /**
  38053. * The scene the AssetContainer belongs to.
  38054. */
  38055. scene: Scene;
  38056. /**
  38057. * Instantiates an AssetContainer.
  38058. * @param scene The scene the AssetContainer belongs to.
  38059. */
  38060. constructor(scene: Scene);
  38061. /**
  38062. * Instantiate or clone all meshes and add the new ones to the scene.
  38063. * Skeletons and animation groups will all be cloned
  38064. * @param nameFunction defines an optional function used to get new names for clones
  38065. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38066. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38067. */
  38068. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38069. /**
  38070. * Adds all the assets from the container to the scene.
  38071. */
  38072. addAllToScene(): void;
  38073. /**
  38074. * Removes all the assets in the container from the scene
  38075. */
  38076. removeAllFromScene(): void;
  38077. /**
  38078. * Disposes all the assets in the container
  38079. */
  38080. dispose(): void;
  38081. private _moveAssets;
  38082. /**
  38083. * Removes all the assets contained in the scene and adds them to the container.
  38084. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38085. */
  38086. moveAllFromScene(keepAssets?: KeepAssets): void;
  38087. /**
  38088. * 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.
  38089. * @returns the root mesh
  38090. */
  38091. createRootMesh(): Mesh;
  38092. /**
  38093. * Merge animations from this asset container into a scene
  38094. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38095. * @param animatables set of animatables to retarget to a node from the scene
  38096. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38097. */
  38098. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38099. }
  38100. }
  38101. declare module "babylonjs/abstractScene" {
  38102. import { Scene } from "babylonjs/scene";
  38103. import { Nullable } from "babylonjs/types";
  38104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38105. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38106. import { Geometry } from "babylonjs/Meshes/geometry";
  38107. import { Skeleton } from "babylonjs/Bones/skeleton";
  38108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38109. import { AssetContainer } from "babylonjs/assetContainer";
  38110. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38111. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38113. import { Material } from "babylonjs/Materials/material";
  38114. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38115. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38116. import { Camera } from "babylonjs/Cameras/camera";
  38117. import { Light } from "babylonjs/Lights/light";
  38118. import { Node } from "babylonjs/node";
  38119. import { Animation } from "babylonjs/Animations/animation";
  38120. /**
  38121. * Defines how the parser contract is defined.
  38122. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38123. */
  38124. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38125. /**
  38126. * Defines how the individual parser contract is defined.
  38127. * These parser can parse an individual asset
  38128. */
  38129. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38130. /**
  38131. * Base class of the scene acting as a container for the different elements composing a scene.
  38132. * This class is dynamically extended by the different components of the scene increasing
  38133. * flexibility and reducing coupling
  38134. */
  38135. export abstract class AbstractScene {
  38136. /**
  38137. * Stores the list of available parsers in the application.
  38138. */
  38139. private static _BabylonFileParsers;
  38140. /**
  38141. * Stores the list of available individual parsers in the application.
  38142. */
  38143. private static _IndividualBabylonFileParsers;
  38144. /**
  38145. * Adds a parser in the list of available ones
  38146. * @param name Defines the name of the parser
  38147. * @param parser Defines the parser to add
  38148. */
  38149. static AddParser(name: string, parser: BabylonFileParser): void;
  38150. /**
  38151. * Gets a general parser from the list of avaialble ones
  38152. * @param name Defines the name of the parser
  38153. * @returns the requested parser or null
  38154. */
  38155. static GetParser(name: string): Nullable<BabylonFileParser>;
  38156. /**
  38157. * Adds n individual parser in the list of available ones
  38158. * @param name Defines the name of the parser
  38159. * @param parser Defines the parser to add
  38160. */
  38161. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38162. /**
  38163. * Gets an individual parser from the list of avaialble ones
  38164. * @param name Defines the name of the parser
  38165. * @returns the requested parser or null
  38166. */
  38167. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38168. /**
  38169. * Parser json data and populate both a scene and its associated container object
  38170. * @param jsonData Defines the data to parse
  38171. * @param scene Defines the scene to parse the data for
  38172. * @param container Defines the container attached to the parsing sequence
  38173. * @param rootUrl Defines the root url of the data
  38174. */
  38175. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38176. /**
  38177. * Gets the list of root nodes (ie. nodes with no parent)
  38178. */
  38179. rootNodes: Node[];
  38180. /** All of the cameras added to this scene
  38181. * @see http://doc.babylonjs.com/babylon101/cameras
  38182. */
  38183. cameras: Camera[];
  38184. /**
  38185. * All of the lights added to this scene
  38186. * @see http://doc.babylonjs.com/babylon101/lights
  38187. */
  38188. lights: Light[];
  38189. /**
  38190. * All of the (abstract) meshes added to this scene
  38191. */
  38192. meshes: AbstractMesh[];
  38193. /**
  38194. * The list of skeletons added to the scene
  38195. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38196. */
  38197. skeletons: Skeleton[];
  38198. /**
  38199. * All of the particle systems added to this scene
  38200. * @see http://doc.babylonjs.com/babylon101/particles
  38201. */
  38202. particleSystems: IParticleSystem[];
  38203. /**
  38204. * Gets a list of Animations associated with the scene
  38205. */
  38206. animations: Animation[];
  38207. /**
  38208. * All of the animation groups added to this scene
  38209. * @see http://doc.babylonjs.com/how_to/group
  38210. */
  38211. animationGroups: AnimationGroup[];
  38212. /**
  38213. * All of the multi-materials added to this scene
  38214. * @see http://doc.babylonjs.com/how_to/multi_materials
  38215. */
  38216. multiMaterials: MultiMaterial[];
  38217. /**
  38218. * All of the materials added to this scene
  38219. * In the context of a Scene, it is not supposed to be modified manually.
  38220. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38221. * Note also that the order of the Material within the array is not significant and might change.
  38222. * @see http://doc.babylonjs.com/babylon101/materials
  38223. */
  38224. materials: Material[];
  38225. /**
  38226. * The list of morph target managers added to the scene
  38227. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38228. */
  38229. morphTargetManagers: MorphTargetManager[];
  38230. /**
  38231. * The list of geometries used in the scene.
  38232. */
  38233. geometries: Geometry[];
  38234. /**
  38235. * All of the tranform nodes added to this scene
  38236. * In the context of a Scene, it is not supposed to be modified manually.
  38237. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38238. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38239. * @see http://doc.babylonjs.com/how_to/transformnode
  38240. */
  38241. transformNodes: TransformNode[];
  38242. /**
  38243. * ActionManagers available on the scene.
  38244. */
  38245. actionManagers: AbstractActionManager[];
  38246. /**
  38247. * Textures to keep.
  38248. */
  38249. textures: BaseTexture[];
  38250. /**
  38251. * Environment texture for the scene
  38252. */
  38253. environmentTexture: Nullable<BaseTexture>;
  38254. /**
  38255. * @returns all meshes, lights, cameras, transformNodes and bones
  38256. */
  38257. getNodes(): Array<Node>;
  38258. }
  38259. }
  38260. declare module "babylonjs/Audio/sound" {
  38261. import { Observable } from "babylonjs/Misc/observable";
  38262. import { Vector3 } from "babylonjs/Maths/math.vector";
  38263. import { Nullable } from "babylonjs/types";
  38264. import { Scene } from "babylonjs/scene";
  38265. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38266. /**
  38267. * Interface used to define options for Sound class
  38268. */
  38269. export interface ISoundOptions {
  38270. /**
  38271. * Does the sound autoplay once loaded.
  38272. */
  38273. autoplay?: boolean;
  38274. /**
  38275. * Does the sound loop after it finishes playing once.
  38276. */
  38277. loop?: boolean;
  38278. /**
  38279. * Sound's volume
  38280. */
  38281. volume?: number;
  38282. /**
  38283. * Is it a spatial sound?
  38284. */
  38285. spatialSound?: boolean;
  38286. /**
  38287. * Maximum distance to hear that sound
  38288. */
  38289. maxDistance?: number;
  38290. /**
  38291. * Uses user defined attenuation function
  38292. */
  38293. useCustomAttenuation?: boolean;
  38294. /**
  38295. * Define the roll off factor of spatial sounds.
  38296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38297. */
  38298. rolloffFactor?: number;
  38299. /**
  38300. * Define the reference distance the sound should be heard perfectly.
  38301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38302. */
  38303. refDistance?: number;
  38304. /**
  38305. * Define the distance attenuation model the sound will follow.
  38306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38307. */
  38308. distanceModel?: string;
  38309. /**
  38310. * Defines the playback speed (1 by default)
  38311. */
  38312. playbackRate?: number;
  38313. /**
  38314. * Defines if the sound is from a streaming source
  38315. */
  38316. streaming?: boolean;
  38317. /**
  38318. * Defines an optional length (in seconds) inside the sound file
  38319. */
  38320. length?: number;
  38321. /**
  38322. * Defines an optional offset (in seconds) inside the sound file
  38323. */
  38324. offset?: number;
  38325. /**
  38326. * If true, URLs will not be required to state the audio file codec to use.
  38327. */
  38328. skipCodecCheck?: boolean;
  38329. }
  38330. /**
  38331. * Defines a sound that can be played in the application.
  38332. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38334. */
  38335. export class Sound {
  38336. /**
  38337. * The name of the sound in the scene.
  38338. */
  38339. name: string;
  38340. /**
  38341. * Does the sound autoplay once loaded.
  38342. */
  38343. autoplay: boolean;
  38344. /**
  38345. * Does the sound loop after it finishes playing once.
  38346. */
  38347. loop: boolean;
  38348. /**
  38349. * Does the sound use a custom attenuation curve to simulate the falloff
  38350. * happening when the source gets further away from the camera.
  38351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38352. */
  38353. useCustomAttenuation: boolean;
  38354. /**
  38355. * The sound track id this sound belongs to.
  38356. */
  38357. soundTrackId: number;
  38358. /**
  38359. * Is this sound currently played.
  38360. */
  38361. isPlaying: boolean;
  38362. /**
  38363. * Is this sound currently paused.
  38364. */
  38365. isPaused: boolean;
  38366. /**
  38367. * Does this sound enables spatial sound.
  38368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38369. */
  38370. spatialSound: boolean;
  38371. /**
  38372. * Define the reference distance the sound should be heard perfectly.
  38373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38374. */
  38375. refDistance: number;
  38376. /**
  38377. * Define the roll off factor of spatial sounds.
  38378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38379. */
  38380. rolloffFactor: number;
  38381. /**
  38382. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38384. */
  38385. maxDistance: number;
  38386. /**
  38387. * Define the distance attenuation model the sound will follow.
  38388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38389. */
  38390. distanceModel: string;
  38391. /**
  38392. * @hidden
  38393. * Back Compat
  38394. **/
  38395. onended: () => any;
  38396. /**
  38397. * Observable event when the current playing sound finishes.
  38398. */
  38399. onEndedObservable: Observable<Sound>;
  38400. private _panningModel;
  38401. private _playbackRate;
  38402. private _streaming;
  38403. private _startTime;
  38404. private _startOffset;
  38405. private _position;
  38406. /** @hidden */
  38407. _positionInEmitterSpace: boolean;
  38408. private _localDirection;
  38409. private _volume;
  38410. private _isReadyToPlay;
  38411. private _isDirectional;
  38412. private _readyToPlayCallback;
  38413. private _audioBuffer;
  38414. private _soundSource;
  38415. private _streamingSource;
  38416. private _soundPanner;
  38417. private _soundGain;
  38418. private _inputAudioNode;
  38419. private _outputAudioNode;
  38420. private _coneInnerAngle;
  38421. private _coneOuterAngle;
  38422. private _coneOuterGain;
  38423. private _scene;
  38424. private _connectedTransformNode;
  38425. private _customAttenuationFunction;
  38426. private _registerFunc;
  38427. private _isOutputConnected;
  38428. private _htmlAudioElement;
  38429. private _urlType;
  38430. private _length?;
  38431. private _offset?;
  38432. /** @hidden */
  38433. static _SceneComponentInitialization: (scene: Scene) => void;
  38434. /**
  38435. * Create a sound and attach it to a scene
  38436. * @param name Name of your sound
  38437. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38438. * @param scene defines the scene the sound belongs to
  38439. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38440. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38441. */
  38442. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38443. /**
  38444. * Release the sound and its associated resources
  38445. */
  38446. dispose(): void;
  38447. /**
  38448. * Gets if the sounds is ready to be played or not.
  38449. * @returns true if ready, otherwise false
  38450. */
  38451. isReady(): boolean;
  38452. private _soundLoaded;
  38453. /**
  38454. * Sets the data of the sound from an audiobuffer
  38455. * @param audioBuffer The audioBuffer containing the data
  38456. */
  38457. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38458. /**
  38459. * Updates the current sounds options such as maxdistance, loop...
  38460. * @param options A JSON object containing values named as the object properties
  38461. */
  38462. updateOptions(options: ISoundOptions): void;
  38463. private _createSpatialParameters;
  38464. private _updateSpatialParameters;
  38465. /**
  38466. * Switch the panning model to HRTF:
  38467. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38469. */
  38470. switchPanningModelToHRTF(): void;
  38471. /**
  38472. * Switch the panning model to Equal Power:
  38473. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38475. */
  38476. switchPanningModelToEqualPower(): void;
  38477. private _switchPanningModel;
  38478. /**
  38479. * Connect this sound to a sound track audio node like gain...
  38480. * @param soundTrackAudioNode the sound track audio node to connect to
  38481. */
  38482. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38483. /**
  38484. * Transform this sound into a directional source
  38485. * @param coneInnerAngle Size of the inner cone in degree
  38486. * @param coneOuterAngle Size of the outer cone in degree
  38487. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38488. */
  38489. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38490. /**
  38491. * Gets or sets the inner angle for the directional cone.
  38492. */
  38493. get directionalConeInnerAngle(): number;
  38494. /**
  38495. * Gets or sets the inner angle for the directional cone.
  38496. */
  38497. set directionalConeInnerAngle(value: number);
  38498. /**
  38499. * Gets or sets the outer angle for the directional cone.
  38500. */
  38501. get directionalConeOuterAngle(): number;
  38502. /**
  38503. * Gets or sets the outer angle for the directional cone.
  38504. */
  38505. set directionalConeOuterAngle(value: number);
  38506. /**
  38507. * Sets the position of the emitter if spatial sound is enabled
  38508. * @param newPosition Defines the new posisiton
  38509. */
  38510. setPosition(newPosition: Vector3): void;
  38511. /**
  38512. * Sets the local direction of the emitter if spatial sound is enabled
  38513. * @param newLocalDirection Defines the new local direction
  38514. */
  38515. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38516. private _updateDirection;
  38517. /** @hidden */
  38518. updateDistanceFromListener(): void;
  38519. /**
  38520. * Sets a new custom attenuation function for the sound.
  38521. * @param callback Defines the function used for the attenuation
  38522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38523. */
  38524. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38525. /**
  38526. * Play the sound
  38527. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38528. * @param offset (optional) Start the sound at a specific time in seconds
  38529. * @param length (optional) Sound duration (in seconds)
  38530. */
  38531. play(time?: number, offset?: number, length?: number): void;
  38532. private _onended;
  38533. /**
  38534. * Stop the sound
  38535. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38536. */
  38537. stop(time?: number): void;
  38538. /**
  38539. * Put the sound in pause
  38540. */
  38541. pause(): void;
  38542. /**
  38543. * Sets a dedicated volume for this sounds
  38544. * @param newVolume Define the new volume of the sound
  38545. * @param time Define time for gradual change to new volume
  38546. */
  38547. setVolume(newVolume: number, time?: number): void;
  38548. /**
  38549. * Set the sound play back rate
  38550. * @param newPlaybackRate Define the playback rate the sound should be played at
  38551. */
  38552. setPlaybackRate(newPlaybackRate: number): void;
  38553. /**
  38554. * Gets the volume of the sound.
  38555. * @returns the volume of the sound
  38556. */
  38557. getVolume(): number;
  38558. /**
  38559. * Attach the sound to a dedicated mesh
  38560. * @param transformNode The transform node to connect the sound with
  38561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38562. */
  38563. attachToMesh(transformNode: TransformNode): void;
  38564. /**
  38565. * Detach the sound from the previously attached mesh
  38566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38567. */
  38568. detachFromMesh(): void;
  38569. private _onRegisterAfterWorldMatrixUpdate;
  38570. /**
  38571. * Clone the current sound in the scene.
  38572. * @returns the new sound clone
  38573. */
  38574. clone(): Nullable<Sound>;
  38575. /**
  38576. * Gets the current underlying audio buffer containing the data
  38577. * @returns the audio buffer
  38578. */
  38579. getAudioBuffer(): Nullable<AudioBuffer>;
  38580. /**
  38581. * Serializes the Sound in a JSON representation
  38582. * @returns the JSON representation of the sound
  38583. */
  38584. serialize(): any;
  38585. /**
  38586. * Parse a JSON representation of a sound to innstantiate in a given scene
  38587. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38588. * @param scene Define the scene the new parsed sound should be created in
  38589. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38590. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38591. * @returns the newly parsed sound
  38592. */
  38593. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38594. }
  38595. }
  38596. declare module "babylonjs/Actions/directAudioActions" {
  38597. import { Action } from "babylonjs/Actions/action";
  38598. import { Condition } from "babylonjs/Actions/condition";
  38599. import { Sound } from "babylonjs/Audio/sound";
  38600. /**
  38601. * This defines an action helpful to play a defined sound on a triggered action.
  38602. */
  38603. export class PlaySoundAction extends Action {
  38604. private _sound;
  38605. /**
  38606. * Instantiate the action
  38607. * @param triggerOptions defines the trigger options
  38608. * @param sound defines the sound to play
  38609. * @param condition defines the trigger related conditions
  38610. */
  38611. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38612. /** @hidden */
  38613. _prepare(): void;
  38614. /**
  38615. * Execute the action and play the sound.
  38616. */
  38617. execute(): void;
  38618. /**
  38619. * Serializes the actions and its related information.
  38620. * @param parent defines the object to serialize in
  38621. * @returns the serialized object
  38622. */
  38623. serialize(parent: any): any;
  38624. }
  38625. /**
  38626. * This defines an action helpful to stop a defined sound on a triggered action.
  38627. */
  38628. export class StopSoundAction extends Action {
  38629. private _sound;
  38630. /**
  38631. * Instantiate the action
  38632. * @param triggerOptions defines the trigger options
  38633. * @param sound defines the sound to stop
  38634. * @param condition defines the trigger related conditions
  38635. */
  38636. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38637. /** @hidden */
  38638. _prepare(): void;
  38639. /**
  38640. * Execute the action and stop the sound.
  38641. */
  38642. execute(): void;
  38643. /**
  38644. * Serializes the actions and its related information.
  38645. * @param parent defines the object to serialize in
  38646. * @returns the serialized object
  38647. */
  38648. serialize(parent: any): any;
  38649. }
  38650. }
  38651. declare module "babylonjs/Actions/interpolateValueAction" {
  38652. import { Action } from "babylonjs/Actions/action";
  38653. import { Condition } from "babylonjs/Actions/condition";
  38654. import { Observable } from "babylonjs/Misc/observable";
  38655. /**
  38656. * This defines an action responsible to change the value of a property
  38657. * by interpolating between its current value and the newly set one once triggered.
  38658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38659. */
  38660. export class InterpolateValueAction extends Action {
  38661. /**
  38662. * Defines the path of the property where the value should be interpolated
  38663. */
  38664. propertyPath: string;
  38665. /**
  38666. * Defines the target value at the end of the interpolation.
  38667. */
  38668. value: any;
  38669. /**
  38670. * Defines the time it will take for the property to interpolate to the value.
  38671. */
  38672. duration: number;
  38673. /**
  38674. * Defines if the other scene animations should be stopped when the action has been triggered
  38675. */
  38676. stopOtherAnimations?: boolean;
  38677. /**
  38678. * Defines a callback raised once the interpolation animation has been done.
  38679. */
  38680. onInterpolationDone?: () => void;
  38681. /**
  38682. * Observable triggered once the interpolation animation has been done.
  38683. */
  38684. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38685. private _target;
  38686. private _effectiveTarget;
  38687. private _property;
  38688. /**
  38689. * Instantiate the action
  38690. * @param triggerOptions defines the trigger options
  38691. * @param target defines the object containing the value to interpolate
  38692. * @param propertyPath defines the path to the property in the target object
  38693. * @param value defines the target value at the end of the interpolation
  38694. * @param duration deines the time it will take for the property to interpolate to the value.
  38695. * @param condition defines the trigger related conditions
  38696. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38697. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38698. */
  38699. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38700. /** @hidden */
  38701. _prepare(): void;
  38702. /**
  38703. * Execute the action starts the value interpolation.
  38704. */
  38705. execute(): void;
  38706. /**
  38707. * Serializes the actions and its related information.
  38708. * @param parent defines the object to serialize in
  38709. * @returns the serialized object
  38710. */
  38711. serialize(parent: any): any;
  38712. }
  38713. }
  38714. declare module "babylonjs/Actions/index" {
  38715. export * from "babylonjs/Actions/abstractActionManager";
  38716. export * from "babylonjs/Actions/action";
  38717. export * from "babylonjs/Actions/actionEvent";
  38718. export * from "babylonjs/Actions/actionManager";
  38719. export * from "babylonjs/Actions/condition";
  38720. export * from "babylonjs/Actions/directActions";
  38721. export * from "babylonjs/Actions/directAudioActions";
  38722. export * from "babylonjs/Actions/interpolateValueAction";
  38723. }
  38724. declare module "babylonjs/Animations/index" {
  38725. export * from "babylonjs/Animations/animatable";
  38726. export * from "babylonjs/Animations/animation";
  38727. export * from "babylonjs/Animations/animationGroup";
  38728. export * from "babylonjs/Animations/animationPropertiesOverride";
  38729. export * from "babylonjs/Animations/easing";
  38730. export * from "babylonjs/Animations/runtimeAnimation";
  38731. export * from "babylonjs/Animations/animationEvent";
  38732. export * from "babylonjs/Animations/animationGroup";
  38733. export * from "babylonjs/Animations/animationKey";
  38734. export * from "babylonjs/Animations/animationRange";
  38735. export * from "babylonjs/Animations/animatable.interface";
  38736. }
  38737. declare module "babylonjs/Audio/soundTrack" {
  38738. import { Sound } from "babylonjs/Audio/sound";
  38739. import { Analyser } from "babylonjs/Audio/analyser";
  38740. import { Scene } from "babylonjs/scene";
  38741. /**
  38742. * Options allowed during the creation of a sound track.
  38743. */
  38744. export interface ISoundTrackOptions {
  38745. /**
  38746. * The volume the sound track should take during creation
  38747. */
  38748. volume?: number;
  38749. /**
  38750. * Define if the sound track is the main sound track of the scene
  38751. */
  38752. mainTrack?: boolean;
  38753. }
  38754. /**
  38755. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38756. * It will be also used in a future release to apply effects on a specific track.
  38757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38758. */
  38759. export class SoundTrack {
  38760. /**
  38761. * The unique identifier of the sound track in the scene.
  38762. */
  38763. id: number;
  38764. /**
  38765. * The list of sounds included in the sound track.
  38766. */
  38767. soundCollection: Array<Sound>;
  38768. private _outputAudioNode;
  38769. private _scene;
  38770. private _connectedAnalyser;
  38771. private _options;
  38772. private _isInitialized;
  38773. /**
  38774. * Creates a new sound track.
  38775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38776. * @param scene Define the scene the sound track belongs to
  38777. * @param options
  38778. */
  38779. constructor(scene: Scene, options?: ISoundTrackOptions);
  38780. private _initializeSoundTrackAudioGraph;
  38781. /**
  38782. * Release the sound track and its associated resources
  38783. */
  38784. dispose(): void;
  38785. /**
  38786. * Adds a sound to this sound track
  38787. * @param sound define the cound to add
  38788. * @ignoreNaming
  38789. */
  38790. AddSound(sound: Sound): void;
  38791. /**
  38792. * Removes a sound to this sound track
  38793. * @param sound define the cound to remove
  38794. * @ignoreNaming
  38795. */
  38796. RemoveSound(sound: Sound): void;
  38797. /**
  38798. * Set a global volume for the full sound track.
  38799. * @param newVolume Define the new volume of the sound track
  38800. */
  38801. setVolume(newVolume: number): void;
  38802. /**
  38803. * Switch the panning model to HRTF:
  38804. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38806. */
  38807. switchPanningModelToHRTF(): void;
  38808. /**
  38809. * Switch the panning model to Equal Power:
  38810. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38812. */
  38813. switchPanningModelToEqualPower(): void;
  38814. /**
  38815. * Connect the sound track to an audio analyser allowing some amazing
  38816. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38818. * @param analyser The analyser to connect to the engine
  38819. */
  38820. connectToAnalyser(analyser: Analyser): void;
  38821. }
  38822. }
  38823. declare module "babylonjs/Audio/audioSceneComponent" {
  38824. import { Sound } from "babylonjs/Audio/sound";
  38825. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38826. import { Nullable } from "babylonjs/types";
  38827. import { Vector3 } from "babylonjs/Maths/math.vector";
  38828. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38829. import { Scene } from "babylonjs/scene";
  38830. import { AbstractScene } from "babylonjs/abstractScene";
  38831. import "babylonjs/Audio/audioEngine";
  38832. module "babylonjs/abstractScene" {
  38833. interface AbstractScene {
  38834. /**
  38835. * The list of sounds used in the scene.
  38836. */
  38837. sounds: Nullable<Array<Sound>>;
  38838. }
  38839. }
  38840. module "babylonjs/scene" {
  38841. interface Scene {
  38842. /**
  38843. * @hidden
  38844. * Backing field
  38845. */
  38846. _mainSoundTrack: SoundTrack;
  38847. /**
  38848. * The main sound track played by the scene.
  38849. * It cotains your primary collection of sounds.
  38850. */
  38851. mainSoundTrack: SoundTrack;
  38852. /**
  38853. * The list of sound tracks added to the scene
  38854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38855. */
  38856. soundTracks: Nullable<Array<SoundTrack>>;
  38857. /**
  38858. * Gets a sound using a given name
  38859. * @param name defines the name to search for
  38860. * @return the found sound or null if not found at all.
  38861. */
  38862. getSoundByName(name: string): Nullable<Sound>;
  38863. /**
  38864. * Gets or sets if audio support is enabled
  38865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38866. */
  38867. audioEnabled: boolean;
  38868. /**
  38869. * Gets or sets if audio will be output to headphones
  38870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38871. */
  38872. headphone: boolean;
  38873. /**
  38874. * Gets or sets custom audio listener position provider
  38875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38876. */
  38877. audioListenerPositionProvider: Nullable<() => Vector3>;
  38878. /**
  38879. * Gets or sets a refresh rate when using 3D audio positioning
  38880. */
  38881. audioPositioningRefreshRate: number;
  38882. }
  38883. }
  38884. /**
  38885. * Defines the sound scene component responsible to manage any sounds
  38886. * in a given scene.
  38887. */
  38888. export class AudioSceneComponent implements ISceneSerializableComponent {
  38889. /**
  38890. * The component name helpfull to identify the component in the list of scene components.
  38891. */
  38892. readonly name: string;
  38893. /**
  38894. * The scene the component belongs to.
  38895. */
  38896. scene: Scene;
  38897. private _audioEnabled;
  38898. /**
  38899. * Gets whether audio is enabled or not.
  38900. * Please use related enable/disable method to switch state.
  38901. */
  38902. get audioEnabled(): boolean;
  38903. private _headphone;
  38904. /**
  38905. * Gets whether audio is outputing to headphone or not.
  38906. * Please use the according Switch methods to change output.
  38907. */
  38908. get headphone(): boolean;
  38909. /**
  38910. * Gets or sets a refresh rate when using 3D audio positioning
  38911. */
  38912. audioPositioningRefreshRate: number;
  38913. private _audioListenerPositionProvider;
  38914. /**
  38915. * Gets the current audio listener position provider
  38916. */
  38917. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38918. /**
  38919. * Sets a custom listener position for all sounds in the scene
  38920. * By default, this is the position of the first active camera
  38921. */
  38922. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38923. /**
  38924. * Creates a new instance of the component for the given scene
  38925. * @param scene Defines the scene to register the component in
  38926. */
  38927. constructor(scene: Scene);
  38928. /**
  38929. * Registers the component in a given scene
  38930. */
  38931. register(): void;
  38932. /**
  38933. * Rebuilds the elements related to this component in case of
  38934. * context lost for instance.
  38935. */
  38936. rebuild(): void;
  38937. /**
  38938. * Serializes the component data to the specified json object
  38939. * @param serializationObject The object to serialize to
  38940. */
  38941. serialize(serializationObject: any): void;
  38942. /**
  38943. * Adds all the elements from the container to the scene
  38944. * @param container the container holding the elements
  38945. */
  38946. addFromContainer(container: AbstractScene): void;
  38947. /**
  38948. * Removes all the elements in the container from the scene
  38949. * @param container contains the elements to remove
  38950. * @param dispose if the removed element should be disposed (default: false)
  38951. */
  38952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38953. /**
  38954. * Disposes the component and the associated ressources.
  38955. */
  38956. dispose(): void;
  38957. /**
  38958. * Disables audio in the associated scene.
  38959. */
  38960. disableAudio(): void;
  38961. /**
  38962. * Enables audio in the associated scene.
  38963. */
  38964. enableAudio(): void;
  38965. /**
  38966. * Switch audio to headphone output.
  38967. */
  38968. switchAudioModeForHeadphones(): void;
  38969. /**
  38970. * Switch audio to normal speakers.
  38971. */
  38972. switchAudioModeForNormalSpeakers(): void;
  38973. private _cachedCameraDirection;
  38974. private _cachedCameraPosition;
  38975. private _lastCheck;
  38976. private _afterRender;
  38977. }
  38978. }
  38979. declare module "babylonjs/Audio/weightedsound" {
  38980. import { Sound } from "babylonjs/Audio/sound";
  38981. /**
  38982. * Wraps one or more Sound objects and selects one with random weight for playback.
  38983. */
  38984. export class WeightedSound {
  38985. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38986. loop: boolean;
  38987. private _coneInnerAngle;
  38988. private _coneOuterAngle;
  38989. private _volume;
  38990. /** A Sound is currently playing. */
  38991. isPlaying: boolean;
  38992. /** A Sound is currently paused. */
  38993. isPaused: boolean;
  38994. private _sounds;
  38995. private _weights;
  38996. private _currentIndex?;
  38997. /**
  38998. * Creates a new WeightedSound from the list of sounds given.
  38999. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39000. * @param sounds Array of Sounds that will be selected from.
  39001. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39002. */
  39003. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39004. /**
  39005. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39006. */
  39007. get directionalConeInnerAngle(): number;
  39008. /**
  39009. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39010. */
  39011. set directionalConeInnerAngle(value: 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. get directionalConeOuterAngle(): number;
  39017. /**
  39018. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39019. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39020. */
  39021. set directionalConeOuterAngle(value: number);
  39022. /**
  39023. * Playback volume.
  39024. */
  39025. get volume(): number;
  39026. /**
  39027. * Playback volume.
  39028. */
  39029. set volume(value: number);
  39030. private _onended;
  39031. /**
  39032. * Suspend playback
  39033. */
  39034. pause(): void;
  39035. /**
  39036. * Stop playback
  39037. */
  39038. stop(): void;
  39039. /**
  39040. * Start playback.
  39041. * @param startOffset Position the clip head at a specific time in seconds.
  39042. */
  39043. play(startOffset?: number): void;
  39044. }
  39045. }
  39046. declare module "babylonjs/Audio/index" {
  39047. export * from "babylonjs/Audio/analyser";
  39048. export * from "babylonjs/Audio/audioEngine";
  39049. export * from "babylonjs/Audio/audioSceneComponent";
  39050. export * from "babylonjs/Audio/sound";
  39051. export * from "babylonjs/Audio/soundTrack";
  39052. export * from "babylonjs/Audio/weightedsound";
  39053. }
  39054. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39055. import { Behavior } from "babylonjs/Behaviors/behavior";
  39056. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39057. import { BackEase } from "babylonjs/Animations/easing";
  39058. /**
  39059. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39061. */
  39062. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39063. /**
  39064. * Gets the name of the behavior.
  39065. */
  39066. get name(): string;
  39067. /**
  39068. * The easing function used by animations
  39069. */
  39070. static EasingFunction: BackEase;
  39071. /**
  39072. * The easing mode used by animations
  39073. */
  39074. static EasingMode: number;
  39075. /**
  39076. * The duration of the animation, in milliseconds
  39077. */
  39078. transitionDuration: number;
  39079. /**
  39080. * Length of the distance animated by the transition when lower radius is reached
  39081. */
  39082. lowerRadiusTransitionRange: number;
  39083. /**
  39084. * Length of the distance animated by the transition when upper radius is reached
  39085. */
  39086. upperRadiusTransitionRange: number;
  39087. private _autoTransitionRange;
  39088. /**
  39089. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39090. */
  39091. get autoTransitionRange(): boolean;
  39092. /**
  39093. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39094. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39095. */
  39096. set autoTransitionRange(value: boolean);
  39097. private _attachedCamera;
  39098. private _onAfterCheckInputsObserver;
  39099. private _onMeshTargetChangedObserver;
  39100. /**
  39101. * Initializes the behavior.
  39102. */
  39103. init(): void;
  39104. /**
  39105. * Attaches the behavior to its arc rotate camera.
  39106. * @param camera Defines the camera to attach the behavior to
  39107. */
  39108. attach(camera: ArcRotateCamera): void;
  39109. /**
  39110. * Detaches the behavior from its current arc rotate camera.
  39111. */
  39112. detach(): void;
  39113. private _radiusIsAnimating;
  39114. private _radiusBounceTransition;
  39115. private _animatables;
  39116. private _cachedWheelPrecision;
  39117. /**
  39118. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39119. * @param radiusLimit The limit to check against.
  39120. * @return Bool to indicate if at limit.
  39121. */
  39122. private _isRadiusAtLimit;
  39123. /**
  39124. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39125. * @param radiusDelta The delta by which to animate to. Can be negative.
  39126. */
  39127. private _applyBoundRadiusAnimation;
  39128. /**
  39129. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39130. */
  39131. protected _clearAnimationLocks(): void;
  39132. /**
  39133. * Stops and removes all animations that have been applied to the camera
  39134. */
  39135. stopAllAnimations(): void;
  39136. }
  39137. }
  39138. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39139. import { Behavior } from "babylonjs/Behaviors/behavior";
  39140. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39141. import { ExponentialEase } from "babylonjs/Animations/easing";
  39142. import { Nullable } from "babylonjs/types";
  39143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39144. import { Vector3 } from "babylonjs/Maths/math.vector";
  39145. /**
  39146. * 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.
  39147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39148. */
  39149. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39150. /**
  39151. * Gets the name of the behavior.
  39152. */
  39153. get name(): string;
  39154. private _mode;
  39155. private _radiusScale;
  39156. private _positionScale;
  39157. private _defaultElevation;
  39158. private _elevationReturnTime;
  39159. private _elevationReturnWaitTime;
  39160. private _zoomStopsAnimation;
  39161. private _framingTime;
  39162. /**
  39163. * The easing function used by animations
  39164. */
  39165. static EasingFunction: ExponentialEase;
  39166. /**
  39167. * The easing mode used by animations
  39168. */
  39169. static EasingMode: number;
  39170. /**
  39171. * Sets the current mode used by the behavior
  39172. */
  39173. set mode(mode: number);
  39174. /**
  39175. * Gets current mode used by the behavior.
  39176. */
  39177. get mode(): number;
  39178. /**
  39179. * Sets the scale applied to the radius (1 by default)
  39180. */
  39181. set radiusScale(radius: number);
  39182. /**
  39183. * Gets the scale applied to the radius
  39184. */
  39185. get radiusScale(): number;
  39186. /**
  39187. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39188. */
  39189. set positionScale(scale: number);
  39190. /**
  39191. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39192. */
  39193. get positionScale(): number;
  39194. /**
  39195. * Sets 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. set defaultElevation(elevation: number);
  39199. /**
  39200. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39201. * behaviour is triggered, in radians.
  39202. */
  39203. get defaultElevation(): number;
  39204. /**
  39205. * Sets the time (in milliseconds) taken to return to the default beta position.
  39206. * Negative value indicates camera should not return to default.
  39207. */
  39208. set elevationReturnTime(speed: number);
  39209. /**
  39210. * Gets the time (in milliseconds) taken to return to the default beta position.
  39211. * Negative value indicates camera should not return to default.
  39212. */
  39213. get elevationReturnTime(): number;
  39214. /**
  39215. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39216. */
  39217. set elevationReturnWaitTime(time: number);
  39218. /**
  39219. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39220. */
  39221. get elevationReturnWaitTime(): number;
  39222. /**
  39223. * Sets the flag that indicates if user zooming should stop animation.
  39224. */
  39225. set zoomStopsAnimation(flag: boolean);
  39226. /**
  39227. * Gets the flag that indicates if user zooming should stop animation.
  39228. */
  39229. get zoomStopsAnimation(): boolean;
  39230. /**
  39231. * Sets the transition time when framing the mesh, in milliseconds
  39232. */
  39233. set framingTime(time: number);
  39234. /**
  39235. * Gets the transition time when framing the mesh, in milliseconds
  39236. */
  39237. get framingTime(): number;
  39238. /**
  39239. * Define if the behavior should automatically change the configured
  39240. * camera limits and sensibilities.
  39241. */
  39242. autoCorrectCameraLimitsAndSensibility: boolean;
  39243. private _onPrePointerObservableObserver;
  39244. private _onAfterCheckInputsObserver;
  39245. private _onMeshTargetChangedObserver;
  39246. private _attachedCamera;
  39247. private _isPointerDown;
  39248. private _lastInteractionTime;
  39249. /**
  39250. * Initializes the behavior.
  39251. */
  39252. init(): void;
  39253. /**
  39254. * Attaches the behavior to its arc rotate camera.
  39255. * @param camera Defines the camera to attach the behavior to
  39256. */
  39257. attach(camera: ArcRotateCamera): void;
  39258. /**
  39259. * Detaches the behavior from its current arc rotate camera.
  39260. */
  39261. detach(): void;
  39262. private _animatables;
  39263. private _betaIsAnimating;
  39264. private _betaTransition;
  39265. private _radiusTransition;
  39266. private _vectorTransition;
  39267. /**
  39268. * Targets the given mesh and updates zoom level accordingly.
  39269. * @param mesh The mesh to target.
  39270. * @param radius Optional. If a cached radius position already exists, overrides default.
  39271. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39272. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39273. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39274. */
  39275. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39276. /**
  39277. * Targets the given mesh with its children and updates zoom level accordingly.
  39278. * @param mesh The mesh to target.
  39279. * @param radius Optional. If a cached radius position already exists, overrides default.
  39280. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39283. */
  39284. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39285. /**
  39286. * Targets the given meshes with their children and updates zoom level accordingly.
  39287. * @param meshes The mesh to target.
  39288. * @param radius Optional. If a cached radius position already exists, overrides default.
  39289. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39290. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39291. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39292. */
  39293. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39294. /**
  39295. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39296. * @param minimumWorld Determines the smaller position of the bounding box extend
  39297. * @param maximumWorld Determines the bigger position of the bounding box extend
  39298. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39299. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39300. */
  39301. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39302. /**
  39303. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39304. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39305. * frustum width.
  39306. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39307. * to fully enclose the mesh in the viewing frustum.
  39308. */
  39309. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39310. /**
  39311. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39312. * is automatically returned to its default position (expected to be above ground plane).
  39313. */
  39314. private _maintainCameraAboveGround;
  39315. /**
  39316. * Returns the frustum slope based on the canvas ratio and camera FOV
  39317. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39318. */
  39319. private _getFrustumSlope;
  39320. /**
  39321. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39322. */
  39323. private _clearAnimationLocks;
  39324. /**
  39325. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39326. */
  39327. private _applyUserInteraction;
  39328. /**
  39329. * Stops and removes all animations that have been applied to the camera
  39330. */
  39331. stopAllAnimations(): void;
  39332. /**
  39333. * Gets a value indicating if the user is moving the camera
  39334. */
  39335. get isUserIsMoving(): boolean;
  39336. /**
  39337. * The camera can move all the way towards the mesh.
  39338. */
  39339. static IgnoreBoundsSizeMode: number;
  39340. /**
  39341. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39342. */
  39343. static FitFrustumSidesMode: number;
  39344. }
  39345. }
  39346. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39347. import { Nullable } from "babylonjs/types";
  39348. import { Camera } from "babylonjs/Cameras/camera";
  39349. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39350. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39351. /**
  39352. * Base class for Camera Pointer Inputs.
  39353. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39354. * for example usage.
  39355. */
  39356. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39357. /**
  39358. * Defines the camera the input is attached to.
  39359. */
  39360. abstract camera: Camera;
  39361. /**
  39362. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39363. */
  39364. protected _altKey: boolean;
  39365. protected _ctrlKey: boolean;
  39366. protected _metaKey: boolean;
  39367. protected _shiftKey: boolean;
  39368. /**
  39369. * Which mouse buttons were pressed at time of last mouse event.
  39370. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39371. */
  39372. protected _buttonsPressed: number;
  39373. /**
  39374. * Defines the buttons associated with the input to handle camera move.
  39375. */
  39376. buttons: number[];
  39377. /**
  39378. * Attach the input controls to a specific dom element to get the input from.
  39379. * @param element Defines the element the controls should be listened from
  39380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39381. */
  39382. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39383. /**
  39384. * Detach the current controls from the specified dom element.
  39385. * @param element Defines the element to stop listening the inputs from
  39386. */
  39387. detachControl(element: Nullable<HTMLElement>): void;
  39388. /**
  39389. * Gets the class name of the current input.
  39390. * @returns the class name
  39391. */
  39392. getClassName(): string;
  39393. /**
  39394. * Get the friendly name associated with the input class.
  39395. * @returns the input friendly name
  39396. */
  39397. getSimpleName(): string;
  39398. /**
  39399. * Called on pointer POINTERDOUBLETAP event.
  39400. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39401. */
  39402. protected onDoubleTap(type: string): void;
  39403. /**
  39404. * Called on pointer POINTERMOVE event if only a single touch is active.
  39405. * Override this method to provide functionality.
  39406. */
  39407. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39408. /**
  39409. * Called on pointer POINTERMOVE event if multiple touches are active.
  39410. * Override this method to provide functionality.
  39411. */
  39412. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39413. /**
  39414. * Called on JS contextmenu event.
  39415. * Override this method to provide functionality.
  39416. */
  39417. protected onContextMenu(evt: PointerEvent): void;
  39418. /**
  39419. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39420. * press.
  39421. * Override this method to provide functionality.
  39422. */
  39423. protected onButtonDown(evt: PointerEvent): void;
  39424. /**
  39425. * Called each time a new POINTERUP event occurs. Ie, for each button
  39426. * release.
  39427. * Override this method to provide functionality.
  39428. */
  39429. protected onButtonUp(evt: PointerEvent): void;
  39430. /**
  39431. * Called when window becomes inactive.
  39432. * Override this method to provide functionality.
  39433. */
  39434. protected onLostFocus(): void;
  39435. private _pointerInput;
  39436. private _observer;
  39437. private _onLostFocus;
  39438. private pointA;
  39439. private pointB;
  39440. }
  39441. }
  39442. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39443. import { Nullable } from "babylonjs/types";
  39444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39445. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39446. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39447. /**
  39448. * Manage the pointers inputs to control an arc rotate camera.
  39449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39450. */
  39451. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39452. /**
  39453. * Defines the camera the input is attached to.
  39454. */
  39455. camera: ArcRotateCamera;
  39456. /**
  39457. * Gets the class name of the current input.
  39458. * @returns the class name
  39459. */
  39460. getClassName(): string;
  39461. /**
  39462. * Defines the buttons associated with the input to handle camera move.
  39463. */
  39464. buttons: number[];
  39465. /**
  39466. * Defines the pointer angular sensibility along the X axis or how fast is
  39467. * the camera rotating.
  39468. */
  39469. angularSensibilityX: number;
  39470. /**
  39471. * Defines the pointer angular sensibility along the Y axis or how fast is
  39472. * the camera rotating.
  39473. */
  39474. angularSensibilityY: number;
  39475. /**
  39476. * Defines the pointer pinch precision or how fast is the camera zooming.
  39477. */
  39478. pinchPrecision: number;
  39479. /**
  39480. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39481. * from 0.
  39482. * It defines the percentage of current camera.radius to use as delta when
  39483. * pinch zoom is used.
  39484. */
  39485. pinchDeltaPercentage: number;
  39486. /**
  39487. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39488. * that any object in the plane at the camera's target point will scale
  39489. * perfectly with finger motion.
  39490. * Overrides pinchDeltaPercentage and pinchPrecision.
  39491. */
  39492. useNaturalPinchZoom: boolean;
  39493. /**
  39494. * Defines the pointer panning sensibility or how fast is the camera moving.
  39495. */
  39496. panningSensibility: number;
  39497. /**
  39498. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39499. */
  39500. multiTouchPanning: boolean;
  39501. /**
  39502. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39503. * zoom (pinch) through multitouch.
  39504. */
  39505. multiTouchPanAndZoom: boolean;
  39506. /**
  39507. * Revers pinch action direction.
  39508. */
  39509. pinchInwards: boolean;
  39510. private _isPanClick;
  39511. private _twoFingerActivityCount;
  39512. private _isPinching;
  39513. /**
  39514. * Called on pointer POINTERMOVE event if only a single touch is active.
  39515. */
  39516. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39517. /**
  39518. * Called on pointer POINTERDOUBLETAP event.
  39519. */
  39520. protected onDoubleTap(type: string): void;
  39521. /**
  39522. * Called on pointer POINTERMOVE event if multiple touches are active.
  39523. */
  39524. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39525. /**
  39526. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39527. * press.
  39528. */
  39529. protected onButtonDown(evt: PointerEvent): void;
  39530. /**
  39531. * Called each time a new POINTERUP event occurs. Ie, for each button
  39532. * release.
  39533. */
  39534. protected onButtonUp(evt: PointerEvent): void;
  39535. /**
  39536. * Called when window becomes inactive.
  39537. */
  39538. protected onLostFocus(): void;
  39539. }
  39540. }
  39541. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39542. import { Nullable } from "babylonjs/types";
  39543. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39544. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39545. /**
  39546. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39548. */
  39549. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39550. /**
  39551. * Defines the camera the input is attached to.
  39552. */
  39553. camera: ArcRotateCamera;
  39554. /**
  39555. * Defines the list of key codes associated with the up action (increase alpha)
  39556. */
  39557. keysUp: number[];
  39558. /**
  39559. * Defines the list of key codes associated with the down action (decrease alpha)
  39560. */
  39561. keysDown: number[];
  39562. /**
  39563. * Defines the list of key codes associated with the left action (increase beta)
  39564. */
  39565. keysLeft: number[];
  39566. /**
  39567. * Defines the list of key codes associated with the right action (decrease beta)
  39568. */
  39569. keysRight: number[];
  39570. /**
  39571. * Defines the list of key codes associated with the reset action.
  39572. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39573. */
  39574. keysReset: number[];
  39575. /**
  39576. * Defines the panning sensibility of the inputs.
  39577. * (How fast is the camera panning)
  39578. */
  39579. panningSensibility: number;
  39580. /**
  39581. * Defines the zooming sensibility of the inputs.
  39582. * (How fast is the camera zooming)
  39583. */
  39584. zoomingSensibility: number;
  39585. /**
  39586. * Defines whether maintaining the alt key down switch the movement mode from
  39587. * orientation to zoom.
  39588. */
  39589. useAltToZoom: boolean;
  39590. /**
  39591. * Rotation speed of the camera
  39592. */
  39593. angularSpeed: number;
  39594. private _keys;
  39595. private _ctrlPressed;
  39596. private _altPressed;
  39597. private _onCanvasBlurObserver;
  39598. private _onKeyboardObserver;
  39599. private _engine;
  39600. private _scene;
  39601. /**
  39602. * Attach the input controls to a specific dom element to get the input from.
  39603. * @param element Defines the element the controls should be listened from
  39604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39605. */
  39606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39607. /**
  39608. * Detach the current controls from the specified dom element.
  39609. * @param element Defines the element to stop listening the inputs from
  39610. */
  39611. detachControl(element: Nullable<HTMLElement>): void;
  39612. /**
  39613. * Update the current camera state depending on the inputs that have been used this frame.
  39614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39615. */
  39616. checkInputs(): void;
  39617. /**
  39618. * Gets the class name of the current intput.
  39619. * @returns the class name
  39620. */
  39621. getClassName(): string;
  39622. /**
  39623. * Get the friendly name associated with the input class.
  39624. * @returns the input friendly name
  39625. */
  39626. getSimpleName(): string;
  39627. }
  39628. }
  39629. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39630. import { Nullable } from "babylonjs/types";
  39631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39633. /**
  39634. * Manage the mouse wheel inputs to control an arc rotate camera.
  39635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39636. */
  39637. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39638. /**
  39639. * Defines the camera the input is attached to.
  39640. */
  39641. camera: ArcRotateCamera;
  39642. /**
  39643. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39644. */
  39645. wheelPrecision: number;
  39646. /**
  39647. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39648. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39649. */
  39650. wheelDeltaPercentage: number;
  39651. private _wheel;
  39652. private _observer;
  39653. private computeDeltaFromMouseWheelLegacyEvent;
  39654. /**
  39655. * Attach the input controls to a specific dom element to get the input from.
  39656. * @param element Defines the element the controls should be listened from
  39657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39658. */
  39659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39660. /**
  39661. * Detach the current controls from the specified dom element.
  39662. * @param element Defines the element to stop listening the inputs from
  39663. */
  39664. detachControl(element: Nullable<HTMLElement>): void;
  39665. /**
  39666. * Gets the class name of the current intput.
  39667. * @returns the class name
  39668. */
  39669. getClassName(): string;
  39670. /**
  39671. * Get the friendly name associated with the input class.
  39672. * @returns the input friendly name
  39673. */
  39674. getSimpleName(): string;
  39675. }
  39676. }
  39677. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39679. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39680. /**
  39681. * Default Inputs manager for the ArcRotateCamera.
  39682. * It groups all the default supported inputs for ease of use.
  39683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39684. */
  39685. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39686. /**
  39687. * Instantiates a new ArcRotateCameraInputsManager.
  39688. * @param camera Defines the camera the inputs belong to
  39689. */
  39690. constructor(camera: ArcRotateCamera);
  39691. /**
  39692. * Add mouse wheel input support to the input manager.
  39693. * @returns the current input manager
  39694. */
  39695. addMouseWheel(): ArcRotateCameraInputsManager;
  39696. /**
  39697. * Add pointers input support to the input manager.
  39698. * @returns the current input manager
  39699. */
  39700. addPointers(): ArcRotateCameraInputsManager;
  39701. /**
  39702. * Add keyboard input support to the input manager.
  39703. * @returns the current input manager
  39704. */
  39705. addKeyboard(): ArcRotateCameraInputsManager;
  39706. }
  39707. }
  39708. declare module "babylonjs/Cameras/arcRotateCamera" {
  39709. import { Observable } from "babylonjs/Misc/observable";
  39710. import { Nullable } from "babylonjs/types";
  39711. import { Scene } from "babylonjs/scene";
  39712. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39714. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39715. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39716. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39717. import { Camera } from "babylonjs/Cameras/camera";
  39718. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39719. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39720. import { Collider } from "babylonjs/Collisions/collider";
  39721. /**
  39722. * This represents an orbital type of camera.
  39723. *
  39724. * 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.
  39725. * 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.
  39726. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39727. */
  39728. export class ArcRotateCamera extends TargetCamera {
  39729. /**
  39730. * Defines the rotation angle of the camera along the longitudinal axis.
  39731. */
  39732. alpha: number;
  39733. /**
  39734. * Defines the rotation angle of the camera along the latitudinal axis.
  39735. */
  39736. beta: number;
  39737. /**
  39738. * Defines the radius of the camera from it s target point.
  39739. */
  39740. radius: number;
  39741. protected _target: Vector3;
  39742. protected _targetHost: Nullable<AbstractMesh>;
  39743. /**
  39744. * Defines the target point of the camera.
  39745. * The camera looks towards it form the radius distance.
  39746. */
  39747. get target(): Vector3;
  39748. set target(value: Vector3);
  39749. /**
  39750. * Define the current local position of the camera in the scene
  39751. */
  39752. get position(): Vector3;
  39753. set position(newPosition: Vector3);
  39754. protected _upVector: Vector3;
  39755. protected _upToYMatrix: Matrix;
  39756. protected _YToUpMatrix: Matrix;
  39757. /**
  39758. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39759. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39760. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39761. */
  39762. set upVector(vec: Vector3);
  39763. get upVector(): Vector3;
  39764. /**
  39765. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39766. */
  39767. setMatUp(): void;
  39768. /**
  39769. * Current inertia value on the longitudinal axis.
  39770. * The bigger this number the longer it will take for the camera to stop.
  39771. */
  39772. inertialAlphaOffset: number;
  39773. /**
  39774. * Current inertia value on the latitudinal axis.
  39775. * The bigger this number the longer it will take for the camera to stop.
  39776. */
  39777. inertialBetaOffset: number;
  39778. /**
  39779. * Current inertia value on the radius axis.
  39780. * The bigger this number the longer it will take for the camera to stop.
  39781. */
  39782. inertialRadiusOffset: number;
  39783. /**
  39784. * Minimum allowed angle on the longitudinal axis.
  39785. * This can help limiting how the Camera is able to move in the scene.
  39786. */
  39787. lowerAlphaLimit: Nullable<number>;
  39788. /**
  39789. * Maximum allowed angle on the longitudinal axis.
  39790. * This can help limiting how the Camera is able to move in the scene.
  39791. */
  39792. upperAlphaLimit: Nullable<number>;
  39793. /**
  39794. * Minimum allowed angle on the latitudinal axis.
  39795. * This can help limiting how the Camera is able to move in the scene.
  39796. */
  39797. lowerBetaLimit: number;
  39798. /**
  39799. * Maximum allowed angle on the latitudinal axis.
  39800. * This can help limiting how the Camera is able to move in the scene.
  39801. */
  39802. upperBetaLimit: number;
  39803. /**
  39804. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39805. * This can help limiting how the Camera is able to move in the scene.
  39806. */
  39807. lowerRadiusLimit: Nullable<number>;
  39808. /**
  39809. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39810. * This can help limiting how the Camera is able to move in the scene.
  39811. */
  39812. upperRadiusLimit: Nullable<number>;
  39813. /**
  39814. * Defines the current inertia value used during panning of the camera along the X axis.
  39815. */
  39816. inertialPanningX: number;
  39817. /**
  39818. * Defines the current inertia value used during panning of the camera along the Y axis.
  39819. */
  39820. inertialPanningY: number;
  39821. /**
  39822. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39823. * Basically if your fingers moves away from more than this distance you will be considered
  39824. * in pinch mode.
  39825. */
  39826. pinchToPanMaxDistance: number;
  39827. /**
  39828. * Defines the maximum distance the camera can pan.
  39829. * This could help keeping the cammera always in your scene.
  39830. */
  39831. panningDistanceLimit: Nullable<number>;
  39832. /**
  39833. * Defines the target of the camera before paning.
  39834. */
  39835. panningOriginTarget: Vector3;
  39836. /**
  39837. * Defines the value of the inertia used during panning.
  39838. * 0 would mean stop inertia and one would mean no decelleration at all.
  39839. */
  39840. panningInertia: number;
  39841. /**
  39842. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39843. */
  39844. get angularSensibilityX(): number;
  39845. set angularSensibilityX(value: number);
  39846. /**
  39847. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39848. */
  39849. get angularSensibilityY(): number;
  39850. set angularSensibilityY(value: number);
  39851. /**
  39852. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39853. */
  39854. get pinchPrecision(): number;
  39855. set pinchPrecision(value: number);
  39856. /**
  39857. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39858. * It will be used instead of pinchDeltaPrecision if different from 0.
  39859. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39860. */
  39861. get pinchDeltaPercentage(): number;
  39862. set pinchDeltaPercentage(value: number);
  39863. /**
  39864. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39865. * and pinch delta percentage.
  39866. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39867. * that any object in the plane at the camera's target point will scale
  39868. * perfectly with finger motion.
  39869. */
  39870. get useNaturalPinchZoom(): boolean;
  39871. set useNaturalPinchZoom(value: boolean);
  39872. /**
  39873. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39874. */
  39875. get panningSensibility(): number;
  39876. set panningSensibility(value: number);
  39877. /**
  39878. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39879. */
  39880. get keysUp(): number[];
  39881. set keysUp(value: number[]);
  39882. /**
  39883. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39884. */
  39885. get keysDown(): number[];
  39886. set keysDown(value: number[]);
  39887. /**
  39888. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39889. */
  39890. get keysLeft(): number[];
  39891. set keysLeft(value: number[]);
  39892. /**
  39893. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39894. */
  39895. get keysRight(): number[];
  39896. set keysRight(value: number[]);
  39897. /**
  39898. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39899. */
  39900. get wheelPrecision(): number;
  39901. set wheelPrecision(value: number);
  39902. /**
  39903. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39904. * It will be used instead of pinchDeltaPrecision if different from 0.
  39905. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39906. */
  39907. get wheelDeltaPercentage(): number;
  39908. set wheelDeltaPercentage(value: number);
  39909. /**
  39910. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39911. */
  39912. zoomOnFactor: number;
  39913. /**
  39914. * Defines a screen offset for the camera position.
  39915. */
  39916. targetScreenOffset: Vector2;
  39917. /**
  39918. * Allows the camera to be completely reversed.
  39919. * If false the camera can not arrive upside down.
  39920. */
  39921. allowUpsideDown: boolean;
  39922. /**
  39923. * Define if double tap/click is used to restore the previously saved state of the camera.
  39924. */
  39925. useInputToRestoreState: boolean;
  39926. /** @hidden */
  39927. _viewMatrix: Matrix;
  39928. /** @hidden */
  39929. _useCtrlForPanning: boolean;
  39930. /** @hidden */
  39931. _panningMouseButton: number;
  39932. /**
  39933. * Defines the input associated to the camera.
  39934. */
  39935. inputs: ArcRotateCameraInputsManager;
  39936. /** @hidden */
  39937. _reset: () => void;
  39938. /**
  39939. * Defines the allowed panning axis.
  39940. */
  39941. panningAxis: Vector3;
  39942. protected _localDirection: Vector3;
  39943. protected _transformedDirection: Vector3;
  39944. private _bouncingBehavior;
  39945. /**
  39946. * Gets the bouncing behavior of the camera if it has been enabled.
  39947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39948. */
  39949. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39950. /**
  39951. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39953. */
  39954. get useBouncingBehavior(): boolean;
  39955. set useBouncingBehavior(value: boolean);
  39956. private _framingBehavior;
  39957. /**
  39958. * Gets the framing behavior of the camera if it has been enabled.
  39959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39960. */
  39961. get framingBehavior(): Nullable<FramingBehavior>;
  39962. /**
  39963. * Defines if the framing behavior of the camera is enabled on the camera.
  39964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39965. */
  39966. get useFramingBehavior(): boolean;
  39967. set useFramingBehavior(value: boolean);
  39968. private _autoRotationBehavior;
  39969. /**
  39970. * Gets the auto rotation behavior of the camera if it has been enabled.
  39971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39972. */
  39973. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39974. /**
  39975. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39977. */
  39978. get useAutoRotationBehavior(): boolean;
  39979. set useAutoRotationBehavior(value: boolean);
  39980. /**
  39981. * Observable triggered when the mesh target has been changed on the camera.
  39982. */
  39983. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39984. /**
  39985. * Event raised when the camera is colliding with a mesh.
  39986. */
  39987. onCollide: (collidedMesh: AbstractMesh) => void;
  39988. /**
  39989. * Defines whether the camera should check collision with the objects oh the scene.
  39990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39991. */
  39992. checkCollisions: boolean;
  39993. /**
  39994. * Defines the collision radius of the camera.
  39995. * This simulates a sphere around the camera.
  39996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39997. */
  39998. collisionRadius: Vector3;
  39999. protected _collider: Collider;
  40000. protected _previousPosition: Vector3;
  40001. protected _collisionVelocity: Vector3;
  40002. protected _newPosition: Vector3;
  40003. protected _previousAlpha: number;
  40004. protected _previousBeta: number;
  40005. protected _previousRadius: number;
  40006. protected _collisionTriggered: boolean;
  40007. protected _targetBoundingCenter: Nullable<Vector3>;
  40008. private _computationVector;
  40009. /**
  40010. * Instantiates a new ArcRotateCamera in a given scene
  40011. * @param name Defines the name of the camera
  40012. * @param alpha Defines the camera rotation along the logitudinal axis
  40013. * @param beta Defines the camera rotation along the latitudinal axis
  40014. * @param radius Defines the camera distance from its target
  40015. * @param target Defines the camera target
  40016. * @param scene Defines the scene the camera belongs to
  40017. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40018. */
  40019. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40020. /** @hidden */
  40021. _initCache(): void;
  40022. /** @hidden */
  40023. _updateCache(ignoreParentClass?: boolean): void;
  40024. protected _getTargetPosition(): Vector3;
  40025. private _storedAlpha;
  40026. private _storedBeta;
  40027. private _storedRadius;
  40028. private _storedTarget;
  40029. private _storedTargetScreenOffset;
  40030. /**
  40031. * Stores the current state of the camera (alpha, beta, radius and target)
  40032. * @returns the camera itself
  40033. */
  40034. storeState(): Camera;
  40035. /**
  40036. * @hidden
  40037. * Restored camera state. You must call storeState() first
  40038. */
  40039. _restoreStateValues(): boolean;
  40040. /** @hidden */
  40041. _isSynchronizedViewMatrix(): boolean;
  40042. /**
  40043. * Attached controls to the current camera.
  40044. * @param element Defines the element the controls should be listened from
  40045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40046. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40047. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40048. */
  40049. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40050. /**
  40051. * Detach the current controls from the camera.
  40052. * The camera will stop reacting to inputs.
  40053. * @param element Defines the element to stop listening the inputs from
  40054. */
  40055. detachControl(element: HTMLElement): void;
  40056. /** @hidden */
  40057. _checkInputs(): void;
  40058. protected _checkLimits(): void;
  40059. /**
  40060. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40061. */
  40062. rebuildAnglesAndRadius(): void;
  40063. /**
  40064. * Use a position to define the current camera related information like alpha, beta and radius
  40065. * @param position Defines the position to set the camera at
  40066. */
  40067. setPosition(position: Vector3): void;
  40068. /**
  40069. * Defines the target the camera should look at.
  40070. * This will automatically adapt alpha beta and radius to fit within the new target.
  40071. * @param target Defines the new target as a Vector or a mesh
  40072. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40073. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40074. */
  40075. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40076. /** @hidden */
  40077. _getViewMatrix(): Matrix;
  40078. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40079. /**
  40080. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40081. * @param meshes Defines the mesh to zoom on
  40082. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  40083. */
  40084. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40085. /**
  40086. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40087. * The target will be changed but the radius
  40088. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40089. * @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)
  40090. */
  40091. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40092. min: Vector3;
  40093. max: Vector3;
  40094. distance: number;
  40095. }, doNotUpdateMaxZ?: boolean): void;
  40096. /**
  40097. * @override
  40098. * Override Camera.createRigCamera
  40099. */
  40100. createRigCamera(name: string, cameraIndex: number): Camera;
  40101. /**
  40102. * @hidden
  40103. * @override
  40104. * Override Camera._updateRigCameras
  40105. */
  40106. _updateRigCameras(): void;
  40107. /**
  40108. * Destroy the camera and release the current resources hold by it.
  40109. */
  40110. dispose(): void;
  40111. /**
  40112. * Gets the current object class name.
  40113. * @return the class name
  40114. */
  40115. getClassName(): string;
  40116. }
  40117. }
  40118. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40119. import { Behavior } from "babylonjs/Behaviors/behavior";
  40120. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40121. /**
  40122. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40124. */
  40125. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40126. /**
  40127. * Gets the name of the behavior.
  40128. */
  40129. get name(): string;
  40130. private _zoomStopsAnimation;
  40131. private _idleRotationSpeed;
  40132. private _idleRotationWaitTime;
  40133. private _idleRotationSpinupTime;
  40134. /**
  40135. * Sets the flag that indicates if user zooming should stop animation.
  40136. */
  40137. set zoomStopsAnimation(flag: boolean);
  40138. /**
  40139. * Gets the flag that indicates if user zooming should stop animation.
  40140. */
  40141. get zoomStopsAnimation(): boolean;
  40142. /**
  40143. * Sets the default speed at which the camera rotates around the model.
  40144. */
  40145. set idleRotationSpeed(speed: number);
  40146. /**
  40147. * Gets the default speed at which the camera rotates around the model.
  40148. */
  40149. get idleRotationSpeed(): number;
  40150. /**
  40151. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40152. */
  40153. set idleRotationWaitTime(time: number);
  40154. /**
  40155. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40156. */
  40157. get idleRotationWaitTime(): number;
  40158. /**
  40159. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40160. */
  40161. set idleRotationSpinupTime(time: number);
  40162. /**
  40163. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40164. */
  40165. get idleRotationSpinupTime(): number;
  40166. /**
  40167. * Gets a value indicating if the camera is currently rotating because of this behavior
  40168. */
  40169. get rotationInProgress(): boolean;
  40170. private _onPrePointerObservableObserver;
  40171. private _onAfterCheckInputsObserver;
  40172. private _attachedCamera;
  40173. private _isPointerDown;
  40174. private _lastFrameTime;
  40175. private _lastInteractionTime;
  40176. private _cameraRotationSpeed;
  40177. /**
  40178. * Initializes the behavior.
  40179. */
  40180. init(): void;
  40181. /**
  40182. * Attaches the behavior to its arc rotate camera.
  40183. * @param camera Defines the camera to attach the behavior to
  40184. */
  40185. attach(camera: ArcRotateCamera): void;
  40186. /**
  40187. * Detaches the behavior from its current arc rotate camera.
  40188. */
  40189. detach(): void;
  40190. /**
  40191. * Returns true if user is scrolling.
  40192. * @return true if user is scrolling.
  40193. */
  40194. private _userIsZooming;
  40195. private _lastFrameRadius;
  40196. private _shouldAnimationStopForInteraction;
  40197. /**
  40198. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40199. */
  40200. private _applyUserInteraction;
  40201. private _userIsMoving;
  40202. }
  40203. }
  40204. declare module "babylonjs/Behaviors/Cameras/index" {
  40205. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40206. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40207. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40208. }
  40209. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40210. import { Mesh } from "babylonjs/Meshes/mesh";
  40211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40212. import { Behavior } from "babylonjs/Behaviors/behavior";
  40213. /**
  40214. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40215. */
  40216. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40217. private ui;
  40218. /**
  40219. * The name of the behavior
  40220. */
  40221. name: string;
  40222. /**
  40223. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40224. */
  40225. distanceAwayFromFace: number;
  40226. /**
  40227. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40228. */
  40229. distanceAwayFromBottomOfFace: number;
  40230. private _faceVectors;
  40231. private _target;
  40232. private _scene;
  40233. private _onRenderObserver;
  40234. private _tmpMatrix;
  40235. private _tmpVector;
  40236. /**
  40237. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40238. * @param ui The transform node that should be attched to the mesh
  40239. */
  40240. constructor(ui: TransformNode);
  40241. /**
  40242. * Initializes the behavior
  40243. */
  40244. init(): void;
  40245. private _closestFace;
  40246. private _zeroVector;
  40247. private _lookAtTmpMatrix;
  40248. private _lookAtToRef;
  40249. /**
  40250. * Attaches the AttachToBoxBehavior to the passed in mesh
  40251. * @param target The mesh that the specified node will be attached to
  40252. */
  40253. attach(target: Mesh): void;
  40254. /**
  40255. * Detaches the behavior from the mesh
  40256. */
  40257. detach(): void;
  40258. }
  40259. }
  40260. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40261. import { Behavior } from "babylonjs/Behaviors/behavior";
  40262. import { Mesh } from "babylonjs/Meshes/mesh";
  40263. /**
  40264. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40265. */
  40266. export class FadeInOutBehavior implements Behavior<Mesh> {
  40267. /**
  40268. * Time in milliseconds to delay before fading in (Default: 0)
  40269. */
  40270. delay: number;
  40271. /**
  40272. * Time in milliseconds for the mesh to fade in (Default: 300)
  40273. */
  40274. fadeInTime: number;
  40275. private _millisecondsPerFrame;
  40276. private _hovered;
  40277. private _hoverValue;
  40278. private _ownerNode;
  40279. /**
  40280. * Instatiates the FadeInOutBehavior
  40281. */
  40282. constructor();
  40283. /**
  40284. * The name of the behavior
  40285. */
  40286. get name(): string;
  40287. /**
  40288. * Initializes the behavior
  40289. */
  40290. init(): void;
  40291. /**
  40292. * Attaches the fade behavior on the passed in mesh
  40293. * @param ownerNode The mesh that will be faded in/out once attached
  40294. */
  40295. attach(ownerNode: Mesh): void;
  40296. /**
  40297. * Detaches the behavior from the mesh
  40298. */
  40299. detach(): void;
  40300. /**
  40301. * Triggers the mesh to begin fading in or out
  40302. * @param value if the object should fade in or out (true to fade in)
  40303. */
  40304. fadeIn(value: boolean): void;
  40305. private _update;
  40306. private _setAllVisibility;
  40307. }
  40308. }
  40309. declare module "babylonjs/Misc/pivotTools" {
  40310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40311. /**
  40312. * Class containing a set of static utilities functions for managing Pivots
  40313. * @hidden
  40314. */
  40315. export class PivotTools {
  40316. private static _PivotCached;
  40317. private static _OldPivotPoint;
  40318. private static _PivotTranslation;
  40319. private static _PivotTmpVector;
  40320. /** @hidden */
  40321. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40322. /** @hidden */
  40323. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40324. }
  40325. }
  40326. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40327. import { Scene } from "babylonjs/scene";
  40328. import { Vector4 } from "babylonjs/Maths/math.vector";
  40329. import { Mesh } from "babylonjs/Meshes/mesh";
  40330. import { Nullable } from "babylonjs/types";
  40331. import { Plane } from "babylonjs/Maths/math.plane";
  40332. /**
  40333. * Class containing static functions to help procedurally build meshes
  40334. */
  40335. export class PlaneBuilder {
  40336. /**
  40337. * Creates a plane mesh
  40338. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40339. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40340. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40344. * @param name defines the name of the mesh
  40345. * @param options defines the options used to create the mesh
  40346. * @param scene defines the hosting scene
  40347. * @returns the plane mesh
  40348. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40349. */
  40350. static CreatePlane(name: string, options: {
  40351. size?: number;
  40352. width?: number;
  40353. height?: number;
  40354. sideOrientation?: number;
  40355. frontUVs?: Vector4;
  40356. backUVs?: Vector4;
  40357. updatable?: boolean;
  40358. sourcePlane?: Plane;
  40359. }, scene?: Nullable<Scene>): Mesh;
  40360. }
  40361. }
  40362. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40363. import { Behavior } from "babylonjs/Behaviors/behavior";
  40364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40365. import { Observable } from "babylonjs/Misc/observable";
  40366. import { Vector3 } from "babylonjs/Maths/math.vector";
  40367. import { Ray } from "babylonjs/Culling/ray";
  40368. import "babylonjs/Meshes/Builders/planeBuilder";
  40369. /**
  40370. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40371. */
  40372. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40373. private static _AnyMouseID;
  40374. /**
  40375. * Abstract mesh the behavior is set on
  40376. */
  40377. attachedNode: AbstractMesh;
  40378. private _dragPlane;
  40379. private _scene;
  40380. private _pointerObserver;
  40381. private _beforeRenderObserver;
  40382. private static _planeScene;
  40383. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40384. /**
  40385. * 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)
  40386. */
  40387. maxDragAngle: number;
  40388. /**
  40389. * @hidden
  40390. */
  40391. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40392. /**
  40393. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40394. */
  40395. currentDraggingPointerID: number;
  40396. /**
  40397. * The last position where the pointer hit the drag plane in world space
  40398. */
  40399. lastDragPosition: Vector3;
  40400. /**
  40401. * If the behavior is currently in a dragging state
  40402. */
  40403. dragging: boolean;
  40404. /**
  40405. * 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)
  40406. */
  40407. dragDeltaRatio: number;
  40408. /**
  40409. * If the drag plane orientation should be updated during the dragging (Default: true)
  40410. */
  40411. updateDragPlane: boolean;
  40412. private _debugMode;
  40413. private _moving;
  40414. /**
  40415. * Fires each time the attached mesh is dragged with the pointer
  40416. * * delta between last drag position and current drag position in world space
  40417. * * dragDistance along the drag axis
  40418. * * dragPlaneNormal normal of the current drag plane used during the drag
  40419. * * dragPlanePoint in world space where the drag intersects the drag plane
  40420. */
  40421. onDragObservable: Observable<{
  40422. delta: Vector3;
  40423. dragPlanePoint: Vector3;
  40424. dragPlaneNormal: Vector3;
  40425. dragDistance: number;
  40426. pointerId: number;
  40427. }>;
  40428. /**
  40429. * Fires each time a drag begins (eg. mouse down on mesh)
  40430. */
  40431. onDragStartObservable: Observable<{
  40432. dragPlanePoint: Vector3;
  40433. pointerId: number;
  40434. }>;
  40435. /**
  40436. * Fires each time a drag ends (eg. mouse release after drag)
  40437. */
  40438. onDragEndObservable: Observable<{
  40439. dragPlanePoint: Vector3;
  40440. pointerId: number;
  40441. }>;
  40442. /**
  40443. * If the attached mesh should be moved when dragged
  40444. */
  40445. moveAttached: boolean;
  40446. /**
  40447. * If the drag behavior will react to drag events (Default: true)
  40448. */
  40449. enabled: boolean;
  40450. /**
  40451. * If pointer events should start and release the drag (Default: true)
  40452. */
  40453. startAndReleaseDragOnPointerEvents: boolean;
  40454. /**
  40455. * If camera controls should be detached during the drag
  40456. */
  40457. detachCameraControls: boolean;
  40458. /**
  40459. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40460. */
  40461. useObjectOrientationForDragging: boolean;
  40462. private _options;
  40463. /**
  40464. * Gets the options used by the behavior
  40465. */
  40466. get options(): {
  40467. dragAxis?: Vector3;
  40468. dragPlaneNormal?: Vector3;
  40469. };
  40470. /**
  40471. * Sets the options used by the behavior
  40472. */
  40473. set options(options: {
  40474. dragAxis?: Vector3;
  40475. dragPlaneNormal?: Vector3;
  40476. });
  40477. /**
  40478. * Creates a pointer drag behavior that can be attached to a mesh
  40479. * @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)
  40480. */
  40481. constructor(options?: {
  40482. dragAxis?: Vector3;
  40483. dragPlaneNormal?: Vector3;
  40484. });
  40485. /**
  40486. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40487. */
  40488. validateDrag: (targetPosition: Vector3) => boolean;
  40489. /**
  40490. * The name of the behavior
  40491. */
  40492. get name(): string;
  40493. /**
  40494. * Initializes the behavior
  40495. */
  40496. init(): void;
  40497. private _tmpVector;
  40498. private _alternatePickedPoint;
  40499. private _worldDragAxis;
  40500. private _targetPosition;
  40501. private _attachedElement;
  40502. /**
  40503. * Attaches the drag behavior the passed in mesh
  40504. * @param ownerNode The mesh that will be dragged around once attached
  40505. * @param predicate Predicate to use for pick filtering
  40506. */
  40507. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40508. /**
  40509. * Force relase the drag action by code.
  40510. */
  40511. releaseDrag(): void;
  40512. private _startDragRay;
  40513. private _lastPointerRay;
  40514. /**
  40515. * Simulates the start of a pointer drag event on the behavior
  40516. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40517. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40518. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40519. */
  40520. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40521. private _startDrag;
  40522. private _dragDelta;
  40523. private _moveDrag;
  40524. private _pickWithRayOnDragPlane;
  40525. private _pointA;
  40526. private _pointB;
  40527. private _pointC;
  40528. private _lineA;
  40529. private _lineB;
  40530. private _localAxis;
  40531. private _lookAt;
  40532. private _updateDragPlanePosition;
  40533. /**
  40534. * Detaches the behavior from the mesh
  40535. */
  40536. detach(): void;
  40537. }
  40538. }
  40539. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40540. import { Mesh } from "babylonjs/Meshes/mesh";
  40541. import { Behavior } from "babylonjs/Behaviors/behavior";
  40542. /**
  40543. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40544. */
  40545. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40546. private _dragBehaviorA;
  40547. private _dragBehaviorB;
  40548. private _startDistance;
  40549. private _initialScale;
  40550. private _targetScale;
  40551. private _ownerNode;
  40552. private _sceneRenderObserver;
  40553. /**
  40554. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40555. */
  40556. constructor();
  40557. /**
  40558. * The name of the behavior
  40559. */
  40560. get name(): string;
  40561. /**
  40562. * Initializes the behavior
  40563. */
  40564. init(): void;
  40565. private _getCurrentDistance;
  40566. /**
  40567. * Attaches the scale behavior the passed in mesh
  40568. * @param ownerNode The mesh that will be scaled around once attached
  40569. */
  40570. attach(ownerNode: Mesh): void;
  40571. /**
  40572. * Detaches the behavior from the mesh
  40573. */
  40574. detach(): void;
  40575. }
  40576. }
  40577. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40578. import { Behavior } from "babylonjs/Behaviors/behavior";
  40579. import { Mesh } from "babylonjs/Meshes/mesh";
  40580. import { Observable } from "babylonjs/Misc/observable";
  40581. /**
  40582. * 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
  40583. */
  40584. export class SixDofDragBehavior implements Behavior<Mesh> {
  40585. private static _virtualScene;
  40586. private _ownerNode;
  40587. private _sceneRenderObserver;
  40588. private _scene;
  40589. private _targetPosition;
  40590. private _virtualOriginMesh;
  40591. private _virtualDragMesh;
  40592. private _pointerObserver;
  40593. private _moving;
  40594. private _startingOrientation;
  40595. /**
  40596. * 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)
  40597. */
  40598. private zDragFactor;
  40599. /**
  40600. * If the object should rotate to face the drag origin
  40601. */
  40602. rotateDraggedObject: boolean;
  40603. /**
  40604. * If the behavior is currently in a dragging state
  40605. */
  40606. dragging: boolean;
  40607. /**
  40608. * 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)
  40609. */
  40610. dragDeltaRatio: number;
  40611. /**
  40612. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40613. */
  40614. currentDraggingPointerID: number;
  40615. /**
  40616. * If camera controls should be detached during the drag
  40617. */
  40618. detachCameraControls: boolean;
  40619. /**
  40620. * Fires each time a drag starts
  40621. */
  40622. onDragStartObservable: Observable<{}>;
  40623. /**
  40624. * Fires each time a drag ends (eg. mouse release after drag)
  40625. */
  40626. onDragEndObservable: Observable<{}>;
  40627. /**
  40628. * 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
  40629. */
  40630. constructor();
  40631. /**
  40632. * The name of the behavior
  40633. */
  40634. get name(): string;
  40635. /**
  40636. * Initializes the behavior
  40637. */
  40638. init(): void;
  40639. /**
  40640. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40641. */
  40642. private get _pointerCamera();
  40643. /**
  40644. * Attaches the scale behavior the passed in mesh
  40645. * @param ownerNode The mesh that will be scaled around once attached
  40646. */
  40647. attach(ownerNode: Mesh): void;
  40648. /**
  40649. * Detaches the behavior from the mesh
  40650. */
  40651. detach(): void;
  40652. }
  40653. }
  40654. declare module "babylonjs/Behaviors/Meshes/index" {
  40655. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40656. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40657. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40658. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40659. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40660. }
  40661. declare module "babylonjs/Behaviors/index" {
  40662. export * from "babylonjs/Behaviors/behavior";
  40663. export * from "babylonjs/Behaviors/Cameras/index";
  40664. export * from "babylonjs/Behaviors/Meshes/index";
  40665. }
  40666. declare module "babylonjs/Bones/boneIKController" {
  40667. import { Bone } from "babylonjs/Bones/bone";
  40668. import { Vector3 } from "babylonjs/Maths/math.vector";
  40669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40670. import { Nullable } from "babylonjs/types";
  40671. /**
  40672. * Class used to apply inverse kinematics to bones
  40673. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40674. */
  40675. export class BoneIKController {
  40676. private static _tmpVecs;
  40677. private static _tmpQuat;
  40678. private static _tmpMats;
  40679. /**
  40680. * Gets or sets the target mesh
  40681. */
  40682. targetMesh: AbstractMesh;
  40683. /** Gets or sets the mesh used as pole */
  40684. poleTargetMesh: AbstractMesh;
  40685. /**
  40686. * Gets or sets the bone used as pole
  40687. */
  40688. poleTargetBone: Nullable<Bone>;
  40689. /**
  40690. * Gets or sets the target position
  40691. */
  40692. targetPosition: Vector3;
  40693. /**
  40694. * Gets or sets the pole target position
  40695. */
  40696. poleTargetPosition: Vector3;
  40697. /**
  40698. * Gets or sets the pole target local offset
  40699. */
  40700. poleTargetLocalOffset: Vector3;
  40701. /**
  40702. * Gets or sets the pole angle
  40703. */
  40704. poleAngle: number;
  40705. /**
  40706. * Gets or sets the mesh associated with the controller
  40707. */
  40708. mesh: AbstractMesh;
  40709. /**
  40710. * 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)
  40711. */
  40712. slerpAmount: number;
  40713. private _bone1Quat;
  40714. private _bone1Mat;
  40715. private _bone2Ang;
  40716. private _bone1;
  40717. private _bone2;
  40718. private _bone1Length;
  40719. private _bone2Length;
  40720. private _maxAngle;
  40721. private _maxReach;
  40722. private _rightHandedSystem;
  40723. private _bendAxis;
  40724. private _slerping;
  40725. private _adjustRoll;
  40726. /**
  40727. * Gets or sets maximum allowed angle
  40728. */
  40729. get maxAngle(): number;
  40730. set maxAngle(value: number);
  40731. /**
  40732. * Creates a new BoneIKController
  40733. * @param mesh defines the mesh to control
  40734. * @param bone defines the bone to control
  40735. * @param options defines options to set up the controller
  40736. */
  40737. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40738. targetMesh?: AbstractMesh;
  40739. poleTargetMesh?: AbstractMesh;
  40740. poleTargetBone?: Bone;
  40741. poleTargetLocalOffset?: Vector3;
  40742. poleAngle?: number;
  40743. bendAxis?: Vector3;
  40744. maxAngle?: number;
  40745. slerpAmount?: number;
  40746. });
  40747. private _setMaxAngle;
  40748. /**
  40749. * Force the controller to update the bones
  40750. */
  40751. update(): void;
  40752. }
  40753. }
  40754. declare module "babylonjs/Bones/boneLookController" {
  40755. import { Vector3 } from "babylonjs/Maths/math.vector";
  40756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40757. import { Bone } from "babylonjs/Bones/bone";
  40758. import { Space } from "babylonjs/Maths/math.axis";
  40759. /**
  40760. * Class used to make a bone look toward a point in space
  40761. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40762. */
  40763. export class BoneLookController {
  40764. private static _tmpVecs;
  40765. private static _tmpQuat;
  40766. private static _tmpMats;
  40767. /**
  40768. * The target Vector3 that the bone will look at
  40769. */
  40770. target: Vector3;
  40771. /**
  40772. * The mesh that the bone is attached to
  40773. */
  40774. mesh: AbstractMesh;
  40775. /**
  40776. * The bone that will be looking to the target
  40777. */
  40778. bone: Bone;
  40779. /**
  40780. * The up axis of the coordinate system that is used when the bone is rotated
  40781. */
  40782. upAxis: Vector3;
  40783. /**
  40784. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40785. */
  40786. upAxisSpace: Space;
  40787. /**
  40788. * Used to make an adjustment to the yaw of the bone
  40789. */
  40790. adjustYaw: number;
  40791. /**
  40792. * Used to make an adjustment to the pitch of the bone
  40793. */
  40794. adjustPitch: number;
  40795. /**
  40796. * Used to make an adjustment to the roll of the bone
  40797. */
  40798. adjustRoll: number;
  40799. /**
  40800. * 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)
  40801. */
  40802. slerpAmount: number;
  40803. private _minYaw;
  40804. private _maxYaw;
  40805. private _minPitch;
  40806. private _maxPitch;
  40807. private _minYawSin;
  40808. private _minYawCos;
  40809. private _maxYawSin;
  40810. private _maxYawCos;
  40811. private _midYawConstraint;
  40812. private _minPitchTan;
  40813. private _maxPitchTan;
  40814. private _boneQuat;
  40815. private _slerping;
  40816. private _transformYawPitch;
  40817. private _transformYawPitchInv;
  40818. private _firstFrameSkipped;
  40819. private _yawRange;
  40820. private _fowardAxis;
  40821. /**
  40822. * Gets or sets the minimum yaw angle that the bone can look to
  40823. */
  40824. get minYaw(): number;
  40825. set minYaw(value: number);
  40826. /**
  40827. * Gets or sets the maximum yaw angle that the bone can look to
  40828. */
  40829. get maxYaw(): number;
  40830. set maxYaw(value: number);
  40831. /**
  40832. * Gets or sets the minimum pitch angle that the bone can look to
  40833. */
  40834. get minPitch(): number;
  40835. set minPitch(value: number);
  40836. /**
  40837. * Gets or sets the maximum pitch angle that the bone can look to
  40838. */
  40839. get maxPitch(): number;
  40840. set maxPitch(value: number);
  40841. /**
  40842. * Create a BoneLookController
  40843. * @param mesh the mesh that the bone belongs to
  40844. * @param bone the bone that will be looking to the target
  40845. * @param target the target Vector3 to look at
  40846. * @param options optional settings:
  40847. * * maxYaw: the maximum angle the bone will yaw to
  40848. * * minYaw: the minimum angle the bone will yaw to
  40849. * * maxPitch: the maximum angle the bone will pitch to
  40850. * * minPitch: the minimum angle the bone will yaw to
  40851. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40852. * * upAxis: the up axis of the coordinate system
  40853. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40854. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40855. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40856. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40857. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40858. * * adjustRoll: used to make an adjustment to the roll of the bone
  40859. **/
  40860. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40861. maxYaw?: number;
  40862. minYaw?: number;
  40863. maxPitch?: number;
  40864. minPitch?: number;
  40865. slerpAmount?: number;
  40866. upAxis?: Vector3;
  40867. upAxisSpace?: Space;
  40868. yawAxis?: Vector3;
  40869. pitchAxis?: Vector3;
  40870. adjustYaw?: number;
  40871. adjustPitch?: number;
  40872. adjustRoll?: number;
  40873. });
  40874. /**
  40875. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40876. */
  40877. update(): void;
  40878. private _getAngleDiff;
  40879. private _getAngleBetween;
  40880. private _isAngleBetween;
  40881. }
  40882. }
  40883. declare module "babylonjs/Bones/index" {
  40884. export * from "babylonjs/Bones/bone";
  40885. export * from "babylonjs/Bones/boneIKController";
  40886. export * from "babylonjs/Bones/boneLookController";
  40887. export * from "babylonjs/Bones/skeleton";
  40888. }
  40889. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40890. import { Nullable } from "babylonjs/types";
  40891. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40892. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40893. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40894. /**
  40895. * Manage the gamepad inputs to control an arc rotate camera.
  40896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40897. */
  40898. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40899. /**
  40900. * Defines the camera the input is attached to.
  40901. */
  40902. camera: ArcRotateCamera;
  40903. /**
  40904. * Defines the gamepad the input is gathering event from.
  40905. */
  40906. gamepad: Nullable<Gamepad>;
  40907. /**
  40908. * Defines the gamepad rotation sensiblity.
  40909. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40910. */
  40911. gamepadRotationSensibility: number;
  40912. /**
  40913. * Defines the gamepad move sensiblity.
  40914. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40915. */
  40916. gamepadMoveSensibility: number;
  40917. private _yAxisScale;
  40918. /**
  40919. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40920. */
  40921. get invertYAxis(): boolean;
  40922. set invertYAxis(value: boolean);
  40923. private _onGamepadConnectedObserver;
  40924. private _onGamepadDisconnectedObserver;
  40925. /**
  40926. * Attach the input controls to a specific dom element to get the input from.
  40927. * @param element Defines the element the controls should be listened from
  40928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40929. */
  40930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40931. /**
  40932. * Detach the current controls from the specified dom element.
  40933. * @param element Defines the element to stop listening the inputs from
  40934. */
  40935. detachControl(element: Nullable<HTMLElement>): void;
  40936. /**
  40937. * Update the current camera state depending on the inputs that have been used this frame.
  40938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40939. */
  40940. checkInputs(): void;
  40941. /**
  40942. * Gets the class name of the current intput.
  40943. * @returns the class name
  40944. */
  40945. getClassName(): string;
  40946. /**
  40947. * Get the friendly name associated with the input class.
  40948. * @returns the input friendly name
  40949. */
  40950. getSimpleName(): string;
  40951. }
  40952. }
  40953. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40954. import { Nullable } from "babylonjs/types";
  40955. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40956. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40957. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40958. interface ArcRotateCameraInputsManager {
  40959. /**
  40960. * Add orientation input support to the input manager.
  40961. * @returns the current input manager
  40962. */
  40963. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40964. }
  40965. }
  40966. /**
  40967. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40969. */
  40970. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40971. /**
  40972. * Defines the camera the input is attached to.
  40973. */
  40974. camera: ArcRotateCamera;
  40975. /**
  40976. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40977. */
  40978. alphaCorrection: number;
  40979. /**
  40980. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40981. */
  40982. gammaCorrection: number;
  40983. private _alpha;
  40984. private _gamma;
  40985. private _dirty;
  40986. private _deviceOrientationHandler;
  40987. /**
  40988. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40989. */
  40990. constructor();
  40991. /**
  40992. * Attach the input controls to a specific dom element to get the input from.
  40993. * @param element Defines the element the controls should be listened from
  40994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40995. */
  40996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40997. /** @hidden */
  40998. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40999. /**
  41000. * Update the current camera state depending on the inputs that have been used this frame.
  41001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41002. */
  41003. checkInputs(): void;
  41004. /**
  41005. * Detach the current controls from the specified dom element.
  41006. * @param element Defines the element to stop listening the inputs from
  41007. */
  41008. detachControl(element: Nullable<HTMLElement>): void;
  41009. /**
  41010. * Gets the class name of the current intput.
  41011. * @returns the class name
  41012. */
  41013. getClassName(): string;
  41014. /**
  41015. * Get the friendly name associated with the input class.
  41016. * @returns the input friendly name
  41017. */
  41018. getSimpleName(): string;
  41019. }
  41020. }
  41021. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41022. import { Nullable } from "babylonjs/types";
  41023. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41024. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41025. /**
  41026. * Listen to mouse events to control the camera.
  41027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41028. */
  41029. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41030. /**
  41031. * Defines the camera the input is attached to.
  41032. */
  41033. camera: FlyCamera;
  41034. /**
  41035. * Defines if touch is enabled. (Default is true.)
  41036. */
  41037. touchEnabled: boolean;
  41038. /**
  41039. * Defines the buttons associated with the input to handle camera rotation.
  41040. */
  41041. buttons: number[];
  41042. /**
  41043. * Assign buttons for Yaw control.
  41044. */
  41045. buttonsYaw: number[];
  41046. /**
  41047. * Assign buttons for Pitch control.
  41048. */
  41049. buttonsPitch: number[];
  41050. /**
  41051. * Assign buttons for Roll control.
  41052. */
  41053. buttonsRoll: number[];
  41054. /**
  41055. * Detect if any button is being pressed while mouse is moved.
  41056. * -1 = Mouse locked.
  41057. * 0 = Left button.
  41058. * 1 = Middle Button.
  41059. * 2 = Right Button.
  41060. */
  41061. activeButton: number;
  41062. /**
  41063. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41064. * Higher values reduce its sensitivity.
  41065. */
  41066. angularSensibility: number;
  41067. private _mousemoveCallback;
  41068. private _observer;
  41069. private _rollObserver;
  41070. private previousPosition;
  41071. private noPreventDefault;
  41072. private element;
  41073. /**
  41074. * Listen to mouse events to control the camera.
  41075. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41077. */
  41078. constructor(touchEnabled?: boolean);
  41079. /**
  41080. * Attach the mouse control to the HTML DOM element.
  41081. * @param element Defines the element that listens to the input events.
  41082. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41083. */
  41084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41085. /**
  41086. * Detach the current controls from the specified dom element.
  41087. * @param element Defines the element to stop listening the inputs from
  41088. */
  41089. detachControl(element: Nullable<HTMLElement>): void;
  41090. /**
  41091. * Gets the class name of the current input.
  41092. * @returns the class name.
  41093. */
  41094. getClassName(): string;
  41095. /**
  41096. * Get the friendly name associated with the input class.
  41097. * @returns the input's friendly name.
  41098. */
  41099. getSimpleName(): string;
  41100. private _pointerInput;
  41101. private _onMouseMove;
  41102. /**
  41103. * Rotate camera by mouse offset.
  41104. */
  41105. private rotateCamera;
  41106. }
  41107. }
  41108. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41109. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41110. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41111. /**
  41112. * Default Inputs manager for the FlyCamera.
  41113. * It groups all the default supported inputs for ease of use.
  41114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41115. */
  41116. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41117. /**
  41118. * Instantiates a new FlyCameraInputsManager.
  41119. * @param camera Defines the camera the inputs belong to.
  41120. */
  41121. constructor(camera: FlyCamera);
  41122. /**
  41123. * Add keyboard input support to the input manager.
  41124. * @returns the new FlyCameraKeyboardMoveInput().
  41125. */
  41126. addKeyboard(): FlyCameraInputsManager;
  41127. /**
  41128. * Add mouse input support to the input manager.
  41129. * @param touchEnabled Enable touch screen support.
  41130. * @returns the new FlyCameraMouseInput().
  41131. */
  41132. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41133. }
  41134. }
  41135. declare module "babylonjs/Cameras/flyCamera" {
  41136. import { Scene } from "babylonjs/scene";
  41137. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41139. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41140. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41141. /**
  41142. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41143. * such as in a 3D Space Shooter or a Flight Simulator.
  41144. */
  41145. export class FlyCamera extends TargetCamera {
  41146. /**
  41147. * Define the collision ellipsoid of the camera.
  41148. * This is helpful for simulating a camera body, like a player's body.
  41149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41150. */
  41151. ellipsoid: Vector3;
  41152. /**
  41153. * Define an offset for the position of the ellipsoid around the camera.
  41154. * This can be helpful if the camera is attached away from the player's body center,
  41155. * such as at its head.
  41156. */
  41157. ellipsoidOffset: Vector3;
  41158. /**
  41159. * Enable or disable collisions of the camera with the rest of the scene objects.
  41160. */
  41161. checkCollisions: boolean;
  41162. /**
  41163. * Enable or disable gravity on the camera.
  41164. */
  41165. applyGravity: boolean;
  41166. /**
  41167. * Define the current direction the camera is moving to.
  41168. */
  41169. cameraDirection: Vector3;
  41170. /**
  41171. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41172. * This overrides and empties cameraRotation.
  41173. */
  41174. rotationQuaternion: Quaternion;
  41175. /**
  41176. * Track Roll to maintain the wanted Rolling when looking around.
  41177. */
  41178. _trackRoll: number;
  41179. /**
  41180. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41181. */
  41182. rollCorrect: number;
  41183. /**
  41184. * Mimic a banked turn, Rolling the camera when Yawing.
  41185. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41186. */
  41187. bankedTurn: boolean;
  41188. /**
  41189. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41190. */
  41191. bankedTurnLimit: number;
  41192. /**
  41193. * Value of 0 disables the banked Roll.
  41194. * Value of 1 is equal to the Yaw angle in radians.
  41195. */
  41196. bankedTurnMultiplier: number;
  41197. /**
  41198. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41199. */
  41200. inputs: FlyCameraInputsManager;
  41201. /**
  41202. * Gets the input sensibility for mouse input.
  41203. * Higher values reduce sensitivity.
  41204. */
  41205. get angularSensibility(): number;
  41206. /**
  41207. * Sets the input sensibility for a mouse input.
  41208. * Higher values reduce sensitivity.
  41209. */
  41210. set angularSensibility(value: number);
  41211. /**
  41212. * Get the keys for camera movement forward.
  41213. */
  41214. get keysForward(): number[];
  41215. /**
  41216. * Set the keys for camera movement forward.
  41217. */
  41218. set keysForward(value: number[]);
  41219. /**
  41220. * Get the keys for camera movement backward.
  41221. */
  41222. get keysBackward(): number[];
  41223. set keysBackward(value: number[]);
  41224. /**
  41225. * Get the keys for camera movement up.
  41226. */
  41227. get keysUp(): number[];
  41228. /**
  41229. * Set the keys for camera movement up.
  41230. */
  41231. set keysUp(value: number[]);
  41232. /**
  41233. * Get the keys for camera movement down.
  41234. */
  41235. get keysDown(): number[];
  41236. /**
  41237. * Set the keys for camera movement down.
  41238. */
  41239. set keysDown(value: number[]);
  41240. /**
  41241. * Get the keys for camera movement left.
  41242. */
  41243. get keysLeft(): number[];
  41244. /**
  41245. * Set the keys for camera movement left.
  41246. */
  41247. set keysLeft(value: number[]);
  41248. /**
  41249. * Set the keys for camera movement right.
  41250. */
  41251. get keysRight(): number[];
  41252. /**
  41253. * Set the keys for camera movement right.
  41254. */
  41255. set keysRight(value: number[]);
  41256. /**
  41257. * Event raised when the camera collides with a mesh in the scene.
  41258. */
  41259. onCollide: (collidedMesh: AbstractMesh) => void;
  41260. private _collider;
  41261. private _needMoveForGravity;
  41262. private _oldPosition;
  41263. private _diffPosition;
  41264. private _newPosition;
  41265. /** @hidden */
  41266. _localDirection: Vector3;
  41267. /** @hidden */
  41268. _transformedDirection: Vector3;
  41269. /**
  41270. * Instantiates a FlyCamera.
  41271. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41272. * such as in a 3D Space Shooter or a Flight Simulator.
  41273. * @param name Define the name of the camera in the scene.
  41274. * @param position Define the starting position of the camera in the scene.
  41275. * @param scene Define the scene the camera belongs to.
  41276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41277. */
  41278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41279. /**
  41280. * Attach a control to the HTML DOM element.
  41281. * @param element Defines the element that listens to the input events.
  41282. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41283. */
  41284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41285. /**
  41286. * Detach a control from the HTML DOM element.
  41287. * The camera will stop reacting to that input.
  41288. * @param element Defines the element that listens to the input events.
  41289. */
  41290. detachControl(element: HTMLElement): void;
  41291. private _collisionMask;
  41292. /**
  41293. * Get the mask that the camera ignores in collision events.
  41294. */
  41295. get collisionMask(): number;
  41296. /**
  41297. * Set the mask that the camera ignores in collision events.
  41298. */
  41299. set collisionMask(mask: number);
  41300. /** @hidden */
  41301. _collideWithWorld(displacement: Vector3): void;
  41302. /** @hidden */
  41303. private _onCollisionPositionChange;
  41304. /** @hidden */
  41305. _checkInputs(): void;
  41306. /** @hidden */
  41307. _decideIfNeedsToMove(): boolean;
  41308. /** @hidden */
  41309. _updatePosition(): void;
  41310. /**
  41311. * Restore the Roll to its target value at the rate specified.
  41312. * @param rate - Higher means slower restoring.
  41313. * @hidden
  41314. */
  41315. restoreRoll(rate: number): void;
  41316. /**
  41317. * Destroy the camera and release the current resources held by it.
  41318. */
  41319. dispose(): void;
  41320. /**
  41321. * Get the current object class name.
  41322. * @returns the class name.
  41323. */
  41324. getClassName(): string;
  41325. }
  41326. }
  41327. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41328. import { Nullable } from "babylonjs/types";
  41329. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41330. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41331. /**
  41332. * Listen to keyboard events to control the camera.
  41333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41334. */
  41335. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41336. /**
  41337. * Defines the camera the input is attached to.
  41338. */
  41339. camera: FlyCamera;
  41340. /**
  41341. * The list of keyboard keys used to control the forward move of the camera.
  41342. */
  41343. keysForward: number[];
  41344. /**
  41345. * The list of keyboard keys used to control the backward move of the camera.
  41346. */
  41347. keysBackward: number[];
  41348. /**
  41349. * The list of keyboard keys used to control the forward move of the camera.
  41350. */
  41351. keysUp: number[];
  41352. /**
  41353. * The list of keyboard keys used to control the backward move of the camera.
  41354. */
  41355. keysDown: number[];
  41356. /**
  41357. * The list of keyboard keys used to control the right strafe move of the camera.
  41358. */
  41359. keysRight: number[];
  41360. /**
  41361. * The list of keyboard keys used to control the left strafe move of the camera.
  41362. */
  41363. keysLeft: number[];
  41364. private _keys;
  41365. private _onCanvasBlurObserver;
  41366. private _onKeyboardObserver;
  41367. private _engine;
  41368. private _scene;
  41369. /**
  41370. * Attach the input controls to a specific dom element to get the input from.
  41371. * @param element Defines the element the controls should be listened from
  41372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41373. */
  41374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41375. /**
  41376. * Detach the current controls from the specified dom element.
  41377. * @param element Defines the element to stop listening the inputs from
  41378. */
  41379. detachControl(element: Nullable<HTMLElement>): void;
  41380. /**
  41381. * Gets the class name of the current intput.
  41382. * @returns the class name
  41383. */
  41384. getClassName(): string;
  41385. /** @hidden */
  41386. _onLostFocus(e: FocusEvent): void;
  41387. /**
  41388. * Get the friendly name associated with the input class.
  41389. * @returns the input friendly name
  41390. */
  41391. getSimpleName(): string;
  41392. /**
  41393. * Update the current camera state depending on the inputs that have been used this frame.
  41394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41395. */
  41396. checkInputs(): void;
  41397. }
  41398. }
  41399. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41400. import { Nullable } from "babylonjs/types";
  41401. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41402. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41403. /**
  41404. * Manage the mouse wheel inputs to control a follow camera.
  41405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41406. */
  41407. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41408. /**
  41409. * Defines the camera the input is attached to.
  41410. */
  41411. camera: FollowCamera;
  41412. /**
  41413. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41414. */
  41415. axisControlRadius: boolean;
  41416. /**
  41417. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41418. */
  41419. axisControlHeight: boolean;
  41420. /**
  41421. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41422. */
  41423. axisControlRotation: boolean;
  41424. /**
  41425. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41426. * relation to mouseWheel events.
  41427. */
  41428. wheelPrecision: number;
  41429. /**
  41430. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41431. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41432. */
  41433. wheelDeltaPercentage: number;
  41434. private _wheel;
  41435. private _observer;
  41436. /**
  41437. * Attach the input controls to a specific dom element to get the input from.
  41438. * @param element Defines the element the controls should be listened from
  41439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41440. */
  41441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41442. /**
  41443. * Detach the current controls from the specified dom element.
  41444. * @param element Defines the element to stop listening the inputs from
  41445. */
  41446. detachControl(element: Nullable<HTMLElement>): void;
  41447. /**
  41448. * Gets the class name of the current intput.
  41449. * @returns the class name
  41450. */
  41451. getClassName(): string;
  41452. /**
  41453. * Get the friendly name associated with the input class.
  41454. * @returns the input friendly name
  41455. */
  41456. getSimpleName(): string;
  41457. }
  41458. }
  41459. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41460. import { Nullable } from "babylonjs/types";
  41461. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41462. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41463. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41464. /**
  41465. * Manage the pointers inputs to control an follow camera.
  41466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41467. */
  41468. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41469. /**
  41470. * Defines the camera the input is attached to.
  41471. */
  41472. camera: FollowCamera;
  41473. /**
  41474. * Gets the class name of the current input.
  41475. * @returns the class name
  41476. */
  41477. getClassName(): string;
  41478. /**
  41479. * Defines the pointer angular sensibility along the X axis or how fast is
  41480. * the camera rotating.
  41481. * A negative number will reverse the axis direction.
  41482. */
  41483. angularSensibilityX: number;
  41484. /**
  41485. * Defines the pointer angular sensibility along the Y axis or how fast is
  41486. * the camera rotating.
  41487. * A negative number will reverse the axis direction.
  41488. */
  41489. angularSensibilityY: number;
  41490. /**
  41491. * Defines the pointer pinch precision or how fast is the camera zooming.
  41492. * A negative number will reverse the axis direction.
  41493. */
  41494. pinchPrecision: number;
  41495. /**
  41496. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41497. * from 0.
  41498. * It defines the percentage of current camera.radius to use as delta when
  41499. * pinch zoom is used.
  41500. */
  41501. pinchDeltaPercentage: number;
  41502. /**
  41503. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41504. */
  41505. axisXControlRadius: boolean;
  41506. /**
  41507. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41508. */
  41509. axisXControlHeight: boolean;
  41510. /**
  41511. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41512. */
  41513. axisXControlRotation: boolean;
  41514. /**
  41515. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41516. */
  41517. axisYControlRadius: boolean;
  41518. /**
  41519. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41520. */
  41521. axisYControlHeight: boolean;
  41522. /**
  41523. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41524. */
  41525. axisYControlRotation: boolean;
  41526. /**
  41527. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41528. */
  41529. axisPinchControlRadius: boolean;
  41530. /**
  41531. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41532. */
  41533. axisPinchControlHeight: boolean;
  41534. /**
  41535. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41536. */
  41537. axisPinchControlRotation: boolean;
  41538. /**
  41539. * Log error messages if basic misconfiguration has occurred.
  41540. */
  41541. warningEnable: boolean;
  41542. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41544. private _warningCounter;
  41545. private _warning;
  41546. }
  41547. }
  41548. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41549. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41550. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41551. /**
  41552. * Default Inputs manager for the FollowCamera.
  41553. * It groups all the default supported inputs for ease of use.
  41554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41555. */
  41556. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41557. /**
  41558. * Instantiates a new FollowCameraInputsManager.
  41559. * @param camera Defines the camera the inputs belong to
  41560. */
  41561. constructor(camera: FollowCamera);
  41562. /**
  41563. * Add keyboard input support to the input manager.
  41564. * @returns the current input manager
  41565. */
  41566. addKeyboard(): FollowCameraInputsManager;
  41567. /**
  41568. * Add mouse wheel input support to the input manager.
  41569. * @returns the current input manager
  41570. */
  41571. addMouseWheel(): FollowCameraInputsManager;
  41572. /**
  41573. * Add pointers input support to the input manager.
  41574. * @returns the current input manager
  41575. */
  41576. addPointers(): FollowCameraInputsManager;
  41577. /**
  41578. * Add orientation input support to the input manager.
  41579. * @returns the current input manager
  41580. */
  41581. addVRDeviceOrientation(): FollowCameraInputsManager;
  41582. }
  41583. }
  41584. declare module "babylonjs/Cameras/followCamera" {
  41585. import { Nullable } from "babylonjs/types";
  41586. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41587. import { Scene } from "babylonjs/scene";
  41588. import { Vector3 } from "babylonjs/Maths/math.vector";
  41589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41590. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41591. /**
  41592. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41593. * an arc rotate version arcFollowCamera are available.
  41594. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41595. */
  41596. export class FollowCamera extends TargetCamera {
  41597. /**
  41598. * Distance the follow camera should follow an object at
  41599. */
  41600. radius: number;
  41601. /**
  41602. * Minimum allowed distance of the camera to the axis of rotation
  41603. * (The camera can not get closer).
  41604. * This can help limiting how the Camera is able to move in the scene.
  41605. */
  41606. lowerRadiusLimit: Nullable<number>;
  41607. /**
  41608. * Maximum allowed distance of the camera to the axis of rotation
  41609. * (The camera can not get further).
  41610. * This can help limiting how the Camera is able to move in the scene.
  41611. */
  41612. upperRadiusLimit: Nullable<number>;
  41613. /**
  41614. * Define a rotation offset between the camera and the object it follows
  41615. */
  41616. rotationOffset: number;
  41617. /**
  41618. * Minimum 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. lowerRotationOffsetLimit: Nullable<number>;
  41622. /**
  41623. * Maximum allowed angle to camera position relative to target object.
  41624. * This can help limiting how the Camera is able to move in the scene.
  41625. */
  41626. upperRotationOffsetLimit: Nullable<number>;
  41627. /**
  41628. * Define a height offset between the camera and the object it follows.
  41629. * It can help following an object from the top (like a car chaing a plane)
  41630. */
  41631. heightOffset: number;
  41632. /**
  41633. * Minimum 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. lowerHeightOffsetLimit: Nullable<number>;
  41637. /**
  41638. * Maximum allowed height of camera position relative to target object.
  41639. * This can help limiting how the Camera is able to move in the scene.
  41640. */
  41641. upperHeightOffsetLimit: Nullable<number>;
  41642. /**
  41643. * Define how fast the camera can accelerate to follow it s target.
  41644. */
  41645. cameraAcceleration: number;
  41646. /**
  41647. * Define the speed limit of the camera following an object.
  41648. */
  41649. maxCameraSpeed: number;
  41650. /**
  41651. * Define the target of the camera.
  41652. */
  41653. lockedTarget: Nullable<AbstractMesh>;
  41654. /**
  41655. * Defines the input associated with the camera.
  41656. */
  41657. inputs: FollowCameraInputsManager;
  41658. /**
  41659. * Instantiates the follow camera.
  41660. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41661. * @param name Define the name of the camera in the scene
  41662. * @param position Define the position of the camera
  41663. * @param scene Define the scene the camera belong to
  41664. * @param lockedTarget Define the target of the camera
  41665. */
  41666. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41667. private _follow;
  41668. /**
  41669. * Attached controls to the current camera.
  41670. * @param element Defines the element the controls should be listened from
  41671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41672. */
  41673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41674. /**
  41675. * Detach the current controls from the camera.
  41676. * The camera will stop reacting to inputs.
  41677. * @param element Defines the element to stop listening the inputs from
  41678. */
  41679. detachControl(element: HTMLElement): void;
  41680. /** @hidden */
  41681. _checkInputs(): void;
  41682. private _checkLimits;
  41683. /**
  41684. * Gets the camera class name.
  41685. * @returns the class name
  41686. */
  41687. getClassName(): string;
  41688. }
  41689. /**
  41690. * Arc Rotate version of the follow camera.
  41691. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41692. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41693. */
  41694. export class ArcFollowCamera extends TargetCamera {
  41695. /** The longitudinal angle of the camera */
  41696. alpha: number;
  41697. /** The latitudinal angle of the camera */
  41698. beta: number;
  41699. /** The radius of the camera from its target */
  41700. radius: number;
  41701. /** Define the camera target (the messh it should follow) */
  41702. target: Nullable<AbstractMesh>;
  41703. private _cartesianCoordinates;
  41704. /**
  41705. * Instantiates a new ArcFollowCamera
  41706. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41707. * @param name Define the name of the camera
  41708. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41709. * @param beta Define the rotation angle of the camera around the elevation axis
  41710. * @param radius Define the radius of the camera from its target point
  41711. * @param target Define the target of the camera
  41712. * @param scene Define the scene the camera belongs to
  41713. */
  41714. constructor(name: string,
  41715. /** The longitudinal angle of the camera */
  41716. alpha: number,
  41717. /** The latitudinal angle of the camera */
  41718. beta: number,
  41719. /** The radius of the camera from its target */
  41720. radius: number,
  41721. /** Define the camera target (the messh it should follow) */
  41722. target: Nullable<AbstractMesh>, scene: Scene);
  41723. private _follow;
  41724. /** @hidden */
  41725. _checkInputs(): void;
  41726. /**
  41727. * Returns the class name of the object.
  41728. * It is mostly used internally for serialization purposes.
  41729. */
  41730. getClassName(): string;
  41731. }
  41732. }
  41733. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41734. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41735. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41736. import { Nullable } from "babylonjs/types";
  41737. /**
  41738. * Manage the keyboard inputs to control the movement of a follow camera.
  41739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41740. */
  41741. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41742. /**
  41743. * Defines the camera the input is attached to.
  41744. */
  41745. camera: FollowCamera;
  41746. /**
  41747. * Defines the list of key codes associated with the up action (increase heightOffset)
  41748. */
  41749. keysHeightOffsetIncr: number[];
  41750. /**
  41751. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41752. */
  41753. keysHeightOffsetDecr: number[];
  41754. /**
  41755. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41756. */
  41757. keysHeightOffsetModifierAlt: boolean;
  41758. /**
  41759. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41760. */
  41761. keysHeightOffsetModifierCtrl: boolean;
  41762. /**
  41763. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41764. */
  41765. keysHeightOffsetModifierShift: boolean;
  41766. /**
  41767. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41768. */
  41769. keysRotationOffsetIncr: number[];
  41770. /**
  41771. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41772. */
  41773. keysRotationOffsetDecr: number[];
  41774. /**
  41775. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41776. */
  41777. keysRotationOffsetModifierAlt: boolean;
  41778. /**
  41779. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41780. */
  41781. keysRotationOffsetModifierCtrl: boolean;
  41782. /**
  41783. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41784. */
  41785. keysRotationOffsetModifierShift: boolean;
  41786. /**
  41787. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41788. */
  41789. keysRadiusIncr: number[];
  41790. /**
  41791. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41792. */
  41793. keysRadiusDecr: number[];
  41794. /**
  41795. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41796. */
  41797. keysRadiusModifierAlt: boolean;
  41798. /**
  41799. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41800. */
  41801. keysRadiusModifierCtrl: boolean;
  41802. /**
  41803. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41804. */
  41805. keysRadiusModifierShift: boolean;
  41806. /**
  41807. * Defines the rate of change of heightOffset.
  41808. */
  41809. heightSensibility: number;
  41810. /**
  41811. * Defines the rate of change of rotationOffset.
  41812. */
  41813. rotationSensibility: number;
  41814. /**
  41815. * Defines the rate of change of radius.
  41816. */
  41817. radiusSensibility: number;
  41818. private _keys;
  41819. private _ctrlPressed;
  41820. private _altPressed;
  41821. private _shiftPressed;
  41822. private _onCanvasBlurObserver;
  41823. private _onKeyboardObserver;
  41824. private _engine;
  41825. private _scene;
  41826. /**
  41827. * Attach the input controls to a specific dom element to get the input from.
  41828. * @param element Defines the element the controls should be listened from
  41829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41830. */
  41831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41832. /**
  41833. * Detach the current controls from the specified dom element.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: Nullable<HTMLElement>): void;
  41837. /**
  41838. * Update the current camera state depending on the inputs that have been used this frame.
  41839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41840. */
  41841. checkInputs(): void;
  41842. /**
  41843. * Gets the class name of the current input.
  41844. * @returns the class name
  41845. */
  41846. getClassName(): string;
  41847. /**
  41848. * Get the friendly name associated with the input class.
  41849. * @returns the input friendly name
  41850. */
  41851. getSimpleName(): string;
  41852. /**
  41853. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41854. * allow modification of the heightOffset value.
  41855. */
  41856. private _modifierHeightOffset;
  41857. /**
  41858. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41859. * allow modification of the rotationOffset value.
  41860. */
  41861. private _modifierRotationOffset;
  41862. /**
  41863. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41864. * allow modification of the radius value.
  41865. */
  41866. private _modifierRadius;
  41867. }
  41868. }
  41869. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41870. import { Nullable } from "babylonjs/types";
  41871. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41872. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41873. import { Observable } from "babylonjs/Misc/observable";
  41874. module "babylonjs/Cameras/freeCameraInputsManager" {
  41875. interface FreeCameraInputsManager {
  41876. /**
  41877. * @hidden
  41878. */
  41879. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41880. /**
  41881. * Add orientation input support to the input manager.
  41882. * @returns the current input manager
  41883. */
  41884. addDeviceOrientation(): FreeCameraInputsManager;
  41885. }
  41886. }
  41887. /**
  41888. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41889. * Screen rotation is taken into account.
  41890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41891. */
  41892. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41893. private _camera;
  41894. private _screenOrientationAngle;
  41895. private _constantTranform;
  41896. private _screenQuaternion;
  41897. private _alpha;
  41898. private _beta;
  41899. private _gamma;
  41900. /**
  41901. * Can be used to detect if a device orientation sensor is available on a device
  41902. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41903. * @returns a promise that will resolve on orientation change
  41904. */
  41905. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41906. /**
  41907. * @hidden
  41908. */
  41909. _onDeviceOrientationChangedObservable: Observable<void>;
  41910. /**
  41911. * Instantiates a new input
  41912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41913. */
  41914. constructor();
  41915. /**
  41916. * Define the camera controlled by the input.
  41917. */
  41918. get camera(): FreeCamera;
  41919. set camera(camera: FreeCamera);
  41920. /**
  41921. * Attach the input controls to a specific dom element to get the input from.
  41922. * @param element Defines the element the controls should be listened from
  41923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41924. */
  41925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41926. private _orientationChanged;
  41927. private _deviceOrientation;
  41928. /**
  41929. * Detach the current controls from the specified dom element.
  41930. * @param element Defines the element to stop listening the inputs from
  41931. */
  41932. detachControl(element: Nullable<HTMLElement>): void;
  41933. /**
  41934. * Update the current camera state depending on the inputs that have been used this frame.
  41935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41936. */
  41937. checkInputs(): void;
  41938. /**
  41939. * Gets the class name of the current intput.
  41940. * @returns the class name
  41941. */
  41942. getClassName(): string;
  41943. /**
  41944. * Get the friendly name associated with the input class.
  41945. * @returns the input friendly name
  41946. */
  41947. getSimpleName(): string;
  41948. }
  41949. }
  41950. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41951. import { Nullable } from "babylonjs/types";
  41952. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41953. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41954. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41955. /**
  41956. * Manage the gamepad inputs to control a free camera.
  41957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41958. */
  41959. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41960. /**
  41961. * Define the camera the input is attached to.
  41962. */
  41963. camera: FreeCamera;
  41964. /**
  41965. * Define the Gamepad controlling the input
  41966. */
  41967. gamepad: Nullable<Gamepad>;
  41968. /**
  41969. * Defines the gamepad rotation sensiblity.
  41970. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41971. */
  41972. gamepadAngularSensibility: number;
  41973. /**
  41974. * Defines the gamepad move sensiblity.
  41975. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41976. */
  41977. gamepadMoveSensibility: number;
  41978. private _yAxisScale;
  41979. /**
  41980. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41981. */
  41982. get invertYAxis(): boolean;
  41983. set invertYAxis(value: boolean);
  41984. private _onGamepadConnectedObserver;
  41985. private _onGamepadDisconnectedObserver;
  41986. private _cameraTransform;
  41987. private _deltaTransform;
  41988. private _vector3;
  41989. private _vector2;
  41990. /**
  41991. * Attach the input controls to a specific dom element to get the input from.
  41992. * @param element Defines the element the controls should be listened from
  41993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41994. */
  41995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41996. /**
  41997. * Detach the current controls from the specified dom element.
  41998. * @param element Defines the element to stop listening the inputs from
  41999. */
  42000. detachControl(element: Nullable<HTMLElement>): void;
  42001. /**
  42002. * Update the current camera state depending on the inputs that have been used this frame.
  42003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42004. */
  42005. checkInputs(): void;
  42006. /**
  42007. * Gets the class name of the current intput.
  42008. * @returns the class name
  42009. */
  42010. getClassName(): string;
  42011. /**
  42012. * Get the friendly name associated with the input class.
  42013. * @returns the input friendly name
  42014. */
  42015. getSimpleName(): string;
  42016. }
  42017. }
  42018. declare module "babylonjs/Misc/virtualJoystick" {
  42019. import { Nullable } from "babylonjs/types";
  42020. import { Vector3 } from "babylonjs/Maths/math.vector";
  42021. /**
  42022. * Defines the potential axis of a Joystick
  42023. */
  42024. export enum JoystickAxis {
  42025. /** X axis */
  42026. X = 0,
  42027. /** Y axis */
  42028. Y = 1,
  42029. /** Z axis */
  42030. Z = 2
  42031. }
  42032. /**
  42033. * Class used to define virtual joystick (used in touch mode)
  42034. */
  42035. export class VirtualJoystick {
  42036. /**
  42037. * Gets or sets a boolean indicating that left and right values must be inverted
  42038. */
  42039. reverseLeftRight: boolean;
  42040. /**
  42041. * Gets or sets a boolean indicating that up and down values must be inverted
  42042. */
  42043. reverseUpDown: boolean;
  42044. /**
  42045. * Gets the offset value for the position (ie. the change of the position value)
  42046. */
  42047. deltaPosition: Vector3;
  42048. /**
  42049. * Gets a boolean indicating if the virtual joystick was pressed
  42050. */
  42051. pressed: boolean;
  42052. /**
  42053. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42054. */
  42055. static Canvas: Nullable<HTMLCanvasElement>;
  42056. private static _globalJoystickIndex;
  42057. private static vjCanvasContext;
  42058. private static vjCanvasWidth;
  42059. private static vjCanvasHeight;
  42060. private static halfWidth;
  42061. private _action;
  42062. private _axisTargetedByLeftAndRight;
  42063. private _axisTargetedByUpAndDown;
  42064. private _joystickSensibility;
  42065. private _inversedSensibility;
  42066. private _joystickPointerID;
  42067. private _joystickColor;
  42068. private _joystickPointerPos;
  42069. private _joystickPreviousPointerPos;
  42070. private _joystickPointerStartPos;
  42071. private _deltaJoystickVector;
  42072. private _leftJoystick;
  42073. private _touches;
  42074. private _onPointerDownHandlerRef;
  42075. private _onPointerMoveHandlerRef;
  42076. private _onPointerUpHandlerRef;
  42077. private _onResize;
  42078. /**
  42079. * Creates a new virtual joystick
  42080. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42081. */
  42082. constructor(leftJoystick?: boolean);
  42083. /**
  42084. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42085. * @param newJoystickSensibility defines the new sensibility
  42086. */
  42087. setJoystickSensibility(newJoystickSensibility: number): void;
  42088. private _onPointerDown;
  42089. private _onPointerMove;
  42090. private _onPointerUp;
  42091. /**
  42092. * Change the color of the virtual joystick
  42093. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42094. */
  42095. setJoystickColor(newColor: string): void;
  42096. /**
  42097. * Defines a callback to call when the joystick is touched
  42098. * @param action defines the callback
  42099. */
  42100. setActionOnTouch(action: () => any): void;
  42101. /**
  42102. * Defines which axis you'd like to control for left & right
  42103. * @param axis defines the axis to use
  42104. */
  42105. setAxisForLeftRight(axis: JoystickAxis): void;
  42106. /**
  42107. * Defines which axis you'd like to control for up & down
  42108. * @param axis defines the axis to use
  42109. */
  42110. setAxisForUpDown(axis: JoystickAxis): void;
  42111. private _drawVirtualJoystick;
  42112. /**
  42113. * Release internal HTML canvas
  42114. */
  42115. releaseCanvas(): void;
  42116. }
  42117. }
  42118. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42119. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42120. import { Nullable } from "babylonjs/types";
  42121. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42122. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42123. module "babylonjs/Cameras/freeCameraInputsManager" {
  42124. interface FreeCameraInputsManager {
  42125. /**
  42126. * Add virtual joystick input support to the input manager.
  42127. * @returns the current input manager
  42128. */
  42129. addVirtualJoystick(): FreeCameraInputsManager;
  42130. }
  42131. }
  42132. /**
  42133. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42135. */
  42136. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42137. /**
  42138. * Defines the camera the input is attached to.
  42139. */
  42140. camera: FreeCamera;
  42141. private _leftjoystick;
  42142. private _rightjoystick;
  42143. /**
  42144. * Gets the left stick of the virtual joystick.
  42145. * @returns The virtual Joystick
  42146. */
  42147. getLeftJoystick(): VirtualJoystick;
  42148. /**
  42149. * Gets the right stick of the virtual joystick.
  42150. * @returns The virtual Joystick
  42151. */
  42152. getRightJoystick(): VirtualJoystick;
  42153. /**
  42154. * Update the current camera state depending on the inputs that have been used this frame.
  42155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42156. */
  42157. checkInputs(): void;
  42158. /**
  42159. * Attach the input controls to a specific dom element to get the input from.
  42160. * @param element Defines the element the controls should be listened from
  42161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42162. */
  42163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42164. /**
  42165. * Detach the current controls from the specified dom element.
  42166. * @param element Defines the element to stop listening the inputs from
  42167. */
  42168. detachControl(element: Nullable<HTMLElement>): void;
  42169. /**
  42170. * Gets the class name of the current intput.
  42171. * @returns the class name
  42172. */
  42173. getClassName(): string;
  42174. /**
  42175. * Get the friendly name associated with the input class.
  42176. * @returns the input friendly name
  42177. */
  42178. getSimpleName(): string;
  42179. }
  42180. }
  42181. declare module "babylonjs/Cameras/Inputs/index" {
  42182. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42183. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42184. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42185. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42186. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42187. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42188. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42189. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42190. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42191. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42192. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42193. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42194. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42195. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42196. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42197. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42198. }
  42199. declare module "babylonjs/Cameras/touchCamera" {
  42200. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42201. import { Scene } from "babylonjs/scene";
  42202. import { Vector3 } from "babylonjs/Maths/math.vector";
  42203. /**
  42204. * This represents a FPS type of camera controlled by touch.
  42205. * This is like a universal camera minus the Gamepad controls.
  42206. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42207. */
  42208. export class TouchCamera extends FreeCamera {
  42209. /**
  42210. * Defines the touch sensibility for rotation.
  42211. * The higher the faster.
  42212. */
  42213. get touchAngularSensibility(): number;
  42214. set touchAngularSensibility(value: number);
  42215. /**
  42216. * Defines the touch sensibility for move.
  42217. * The higher the faster.
  42218. */
  42219. get touchMoveSensibility(): number;
  42220. set touchMoveSensibility(value: number);
  42221. /**
  42222. * Instantiates a new touch camera.
  42223. * This represents a FPS type of camera controlled by touch.
  42224. * This is like a universal camera minus the Gamepad controls.
  42225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42226. * @param name Define the name of the camera in the scene
  42227. * @param position Define the start position of the camera in the scene
  42228. * @param scene Define the scene the camera belongs to
  42229. */
  42230. constructor(name: string, position: Vector3, scene: Scene);
  42231. /**
  42232. * Gets the current object class name.
  42233. * @return the class name
  42234. */
  42235. getClassName(): string;
  42236. /** @hidden */
  42237. _setupInputs(): void;
  42238. }
  42239. }
  42240. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42241. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42242. import { Scene } from "babylonjs/scene";
  42243. import { Vector3 } from "babylonjs/Maths/math.vector";
  42244. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42245. import { Axis } from "babylonjs/Maths/math.axis";
  42246. /**
  42247. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42248. * being tilted forward or back and left or right.
  42249. */
  42250. export class DeviceOrientationCamera extends FreeCamera {
  42251. private _initialQuaternion;
  42252. private _quaternionCache;
  42253. private _tmpDragQuaternion;
  42254. private _disablePointerInputWhenUsingDeviceOrientation;
  42255. /**
  42256. * Creates a new device orientation camera
  42257. * @param name The name of the camera
  42258. * @param position The start position camera
  42259. * @param scene The scene the camera belongs to
  42260. */
  42261. constructor(name: string, position: Vector3, scene: Scene);
  42262. /**
  42263. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42264. */
  42265. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42266. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42267. private _dragFactor;
  42268. /**
  42269. * Enabled turning on the y axis when the orientation sensor is active
  42270. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42271. */
  42272. enableHorizontalDragging(dragFactor?: number): void;
  42273. /**
  42274. * Gets the current instance class name ("DeviceOrientationCamera").
  42275. * This helps avoiding instanceof at run time.
  42276. * @returns the class name
  42277. */
  42278. getClassName(): string;
  42279. /**
  42280. * @hidden
  42281. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42282. */
  42283. _checkInputs(): void;
  42284. /**
  42285. * Reset the camera to its default orientation on the specified axis only.
  42286. * @param axis The axis to reset
  42287. */
  42288. resetToCurrentRotation(axis?: Axis): void;
  42289. }
  42290. }
  42291. declare module "babylonjs/Gamepads/xboxGamepad" {
  42292. import { Observable } from "babylonjs/Misc/observable";
  42293. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42294. /**
  42295. * Defines supported buttons for XBox360 compatible gamepads
  42296. */
  42297. export enum Xbox360Button {
  42298. /** A */
  42299. A = 0,
  42300. /** B */
  42301. B = 1,
  42302. /** X */
  42303. X = 2,
  42304. /** Y */
  42305. Y = 3,
  42306. /** Start */
  42307. Start = 4,
  42308. /** Back */
  42309. Back = 5,
  42310. /** Left button */
  42311. LB = 6,
  42312. /** Right button */
  42313. RB = 7,
  42314. /** Left stick */
  42315. LeftStick = 8,
  42316. /** Right stick */
  42317. RightStick = 9
  42318. }
  42319. /** Defines values for XBox360 DPad */
  42320. export enum Xbox360Dpad {
  42321. /** Up */
  42322. Up = 0,
  42323. /** Down */
  42324. Down = 1,
  42325. /** Left */
  42326. Left = 2,
  42327. /** Right */
  42328. Right = 3
  42329. }
  42330. /**
  42331. * Defines a XBox360 gamepad
  42332. */
  42333. export class Xbox360Pad extends Gamepad {
  42334. private _leftTrigger;
  42335. private _rightTrigger;
  42336. private _onlefttriggerchanged;
  42337. private _onrighttriggerchanged;
  42338. private _onbuttondown;
  42339. private _onbuttonup;
  42340. private _ondpaddown;
  42341. private _ondpadup;
  42342. /** Observable raised when a button is pressed */
  42343. onButtonDownObservable: Observable<Xbox360Button>;
  42344. /** Observable raised when a button is released */
  42345. onButtonUpObservable: Observable<Xbox360Button>;
  42346. /** Observable raised when a pad is pressed */
  42347. onPadDownObservable: Observable<Xbox360Dpad>;
  42348. /** Observable raised when a pad is released */
  42349. onPadUpObservable: Observable<Xbox360Dpad>;
  42350. private _buttonA;
  42351. private _buttonB;
  42352. private _buttonX;
  42353. private _buttonY;
  42354. private _buttonBack;
  42355. private _buttonStart;
  42356. private _buttonLB;
  42357. private _buttonRB;
  42358. private _buttonLeftStick;
  42359. private _buttonRightStick;
  42360. private _dPadUp;
  42361. private _dPadDown;
  42362. private _dPadLeft;
  42363. private _dPadRight;
  42364. private _isXboxOnePad;
  42365. /**
  42366. * Creates a new XBox360 gamepad object
  42367. * @param id defines the id of this gamepad
  42368. * @param index defines its index
  42369. * @param gamepad defines the internal HTML gamepad object
  42370. * @param xboxOne defines if it is a XBox One gamepad
  42371. */
  42372. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42373. /**
  42374. * Defines the callback to call when left trigger is pressed
  42375. * @param callback defines the callback to use
  42376. */
  42377. onlefttriggerchanged(callback: (value: number) => void): void;
  42378. /**
  42379. * Defines the callback to call when right trigger is pressed
  42380. * @param callback defines the callback to use
  42381. */
  42382. onrighttriggerchanged(callback: (value: number) => void): void;
  42383. /**
  42384. * Gets the left trigger value
  42385. */
  42386. get leftTrigger(): number;
  42387. /**
  42388. * Sets the left trigger value
  42389. */
  42390. set leftTrigger(newValue: number);
  42391. /**
  42392. * Gets the right trigger value
  42393. */
  42394. get rightTrigger(): number;
  42395. /**
  42396. * Sets the right trigger value
  42397. */
  42398. set rightTrigger(newValue: number);
  42399. /**
  42400. * Defines the callback to call when a button is pressed
  42401. * @param callback defines the callback to use
  42402. */
  42403. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42404. /**
  42405. * Defines the callback to call when a button is released
  42406. * @param callback defines the callback to use
  42407. */
  42408. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42409. /**
  42410. * Defines the callback to call when a pad is pressed
  42411. * @param callback defines the callback to use
  42412. */
  42413. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42414. /**
  42415. * Defines the callback to call when a pad is released
  42416. * @param callback defines the callback to use
  42417. */
  42418. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42419. private _setButtonValue;
  42420. private _setDPadValue;
  42421. /**
  42422. * Gets the value of the `A` button
  42423. */
  42424. get buttonA(): number;
  42425. /**
  42426. * Sets the value of the `A` button
  42427. */
  42428. set buttonA(value: number);
  42429. /**
  42430. * Gets the value of the `B` button
  42431. */
  42432. get buttonB(): number;
  42433. /**
  42434. * Sets the value of the `B` button
  42435. */
  42436. set buttonB(value: number);
  42437. /**
  42438. * Gets the value of the `X` button
  42439. */
  42440. get buttonX(): number;
  42441. /**
  42442. * Sets the value of the `X` button
  42443. */
  42444. set buttonX(value: number);
  42445. /**
  42446. * Gets the value of the `Y` button
  42447. */
  42448. get buttonY(): number;
  42449. /**
  42450. * Sets the value of the `Y` button
  42451. */
  42452. set buttonY(value: number);
  42453. /**
  42454. * Gets the value of the `Start` button
  42455. */
  42456. get buttonStart(): number;
  42457. /**
  42458. * Sets the value of the `Start` button
  42459. */
  42460. set buttonStart(value: number);
  42461. /**
  42462. * Gets the value of the `Back` button
  42463. */
  42464. get buttonBack(): number;
  42465. /**
  42466. * Sets the value of the `Back` button
  42467. */
  42468. set buttonBack(value: number);
  42469. /**
  42470. * Gets the value of the `Left` button
  42471. */
  42472. get buttonLB(): number;
  42473. /**
  42474. * Sets the value of the `Left` button
  42475. */
  42476. set buttonLB(value: number);
  42477. /**
  42478. * Gets the value of the `Right` button
  42479. */
  42480. get buttonRB(): number;
  42481. /**
  42482. * Sets the value of the `Right` button
  42483. */
  42484. set buttonRB(value: number);
  42485. /**
  42486. * Gets the value of the Left joystick
  42487. */
  42488. get buttonLeftStick(): number;
  42489. /**
  42490. * Sets the value of the Left joystick
  42491. */
  42492. set buttonLeftStick(value: number);
  42493. /**
  42494. * Gets the value of the Right joystick
  42495. */
  42496. get buttonRightStick(): number;
  42497. /**
  42498. * Sets the value of the Right joystick
  42499. */
  42500. set buttonRightStick(value: number);
  42501. /**
  42502. * Gets the value of D-pad up
  42503. */
  42504. get dPadUp(): number;
  42505. /**
  42506. * Sets the value of D-pad up
  42507. */
  42508. set dPadUp(value: number);
  42509. /**
  42510. * Gets the value of D-pad down
  42511. */
  42512. get dPadDown(): number;
  42513. /**
  42514. * Sets the value of D-pad down
  42515. */
  42516. set dPadDown(value: number);
  42517. /**
  42518. * Gets the value of D-pad left
  42519. */
  42520. get dPadLeft(): number;
  42521. /**
  42522. * Sets the value of D-pad left
  42523. */
  42524. set dPadLeft(value: number);
  42525. /**
  42526. * Gets the value of D-pad right
  42527. */
  42528. get dPadRight(): number;
  42529. /**
  42530. * Sets the value of D-pad right
  42531. */
  42532. set dPadRight(value: number);
  42533. /**
  42534. * Force the gamepad to synchronize with device values
  42535. */
  42536. update(): void;
  42537. /**
  42538. * Disposes the gamepad
  42539. */
  42540. dispose(): void;
  42541. }
  42542. }
  42543. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42544. import { Observable } from "babylonjs/Misc/observable";
  42545. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42546. /**
  42547. * Defines supported buttons for DualShock compatible gamepads
  42548. */
  42549. export enum DualShockButton {
  42550. /** Cross */
  42551. Cross = 0,
  42552. /** Circle */
  42553. Circle = 1,
  42554. /** Square */
  42555. Square = 2,
  42556. /** Triangle */
  42557. Triangle = 3,
  42558. /** Options */
  42559. Options = 4,
  42560. /** Share */
  42561. Share = 5,
  42562. /** L1 */
  42563. L1 = 6,
  42564. /** R1 */
  42565. R1 = 7,
  42566. /** Left stick */
  42567. LeftStick = 8,
  42568. /** Right stick */
  42569. RightStick = 9
  42570. }
  42571. /** Defines values for DualShock DPad */
  42572. export enum DualShockDpad {
  42573. /** Up */
  42574. Up = 0,
  42575. /** Down */
  42576. Down = 1,
  42577. /** Left */
  42578. Left = 2,
  42579. /** Right */
  42580. Right = 3
  42581. }
  42582. /**
  42583. * Defines a DualShock gamepad
  42584. */
  42585. export class DualShockPad extends Gamepad {
  42586. private _leftTrigger;
  42587. private _rightTrigger;
  42588. private _onlefttriggerchanged;
  42589. private _onrighttriggerchanged;
  42590. private _onbuttondown;
  42591. private _onbuttonup;
  42592. private _ondpaddown;
  42593. private _ondpadup;
  42594. /** Observable raised when a button is pressed */
  42595. onButtonDownObservable: Observable<DualShockButton>;
  42596. /** Observable raised when a button is released */
  42597. onButtonUpObservable: Observable<DualShockButton>;
  42598. /** Observable raised when a pad is pressed */
  42599. onPadDownObservable: Observable<DualShockDpad>;
  42600. /** Observable raised when a pad is released */
  42601. onPadUpObservable: Observable<DualShockDpad>;
  42602. private _buttonCross;
  42603. private _buttonCircle;
  42604. private _buttonSquare;
  42605. private _buttonTriangle;
  42606. private _buttonShare;
  42607. private _buttonOptions;
  42608. private _buttonL1;
  42609. private _buttonR1;
  42610. private _buttonLeftStick;
  42611. private _buttonRightStick;
  42612. private _dPadUp;
  42613. private _dPadDown;
  42614. private _dPadLeft;
  42615. private _dPadRight;
  42616. /**
  42617. * Creates a new DualShock gamepad object
  42618. * @param id defines the id of this gamepad
  42619. * @param index defines its index
  42620. * @param gamepad defines the internal HTML gamepad object
  42621. */
  42622. constructor(id: string, index: number, gamepad: any);
  42623. /**
  42624. * Defines the callback to call when left trigger is pressed
  42625. * @param callback defines the callback to use
  42626. */
  42627. onlefttriggerchanged(callback: (value: number) => void): void;
  42628. /**
  42629. * Defines the callback to call when right trigger is pressed
  42630. * @param callback defines the callback to use
  42631. */
  42632. onrighttriggerchanged(callback: (value: number) => void): void;
  42633. /**
  42634. * Gets the left trigger value
  42635. */
  42636. get leftTrigger(): number;
  42637. /**
  42638. * Sets the left trigger value
  42639. */
  42640. set leftTrigger(newValue: number);
  42641. /**
  42642. * Gets the right trigger value
  42643. */
  42644. get rightTrigger(): number;
  42645. /**
  42646. * Sets the right trigger value
  42647. */
  42648. set rightTrigger(newValue: number);
  42649. /**
  42650. * Defines the callback to call when a button is pressed
  42651. * @param callback defines the callback to use
  42652. */
  42653. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42654. /**
  42655. * Defines the callback to call when a button is released
  42656. * @param callback defines the callback to use
  42657. */
  42658. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42659. /**
  42660. * Defines the callback to call when a pad is pressed
  42661. * @param callback defines the callback to use
  42662. */
  42663. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42664. /**
  42665. * Defines the callback to call when a pad is released
  42666. * @param callback defines the callback to use
  42667. */
  42668. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42669. private _setButtonValue;
  42670. private _setDPadValue;
  42671. /**
  42672. * Gets the value of the `Cross` button
  42673. */
  42674. get buttonCross(): number;
  42675. /**
  42676. * Sets the value of the `Cross` button
  42677. */
  42678. set buttonCross(value: number);
  42679. /**
  42680. * Gets the value of the `Circle` button
  42681. */
  42682. get buttonCircle(): number;
  42683. /**
  42684. * Sets the value of the `Circle` button
  42685. */
  42686. set buttonCircle(value: number);
  42687. /**
  42688. * Gets the value of the `Square` button
  42689. */
  42690. get buttonSquare(): number;
  42691. /**
  42692. * Sets the value of the `Square` button
  42693. */
  42694. set buttonSquare(value: number);
  42695. /**
  42696. * Gets the value of the `Triangle` button
  42697. */
  42698. get buttonTriangle(): number;
  42699. /**
  42700. * Sets the value of the `Triangle` button
  42701. */
  42702. set buttonTriangle(value: number);
  42703. /**
  42704. * Gets the value of the `Options` button
  42705. */
  42706. get buttonOptions(): number;
  42707. /**
  42708. * Sets the value of the `Options` button
  42709. */
  42710. set buttonOptions(value: number);
  42711. /**
  42712. * Gets the value of the `Share` button
  42713. */
  42714. get buttonShare(): number;
  42715. /**
  42716. * Sets the value of the `Share` button
  42717. */
  42718. set buttonShare(value: number);
  42719. /**
  42720. * Gets the value of the `L1` button
  42721. */
  42722. get buttonL1(): number;
  42723. /**
  42724. * Sets the value of the `L1` button
  42725. */
  42726. set buttonL1(value: number);
  42727. /**
  42728. * Gets the value of the `R1` button
  42729. */
  42730. get buttonR1(): number;
  42731. /**
  42732. * Sets the value of the `R1` button
  42733. */
  42734. set buttonR1(value: number);
  42735. /**
  42736. * Gets the value of the Left joystick
  42737. */
  42738. get buttonLeftStick(): number;
  42739. /**
  42740. * Sets the value of the Left joystick
  42741. */
  42742. set buttonLeftStick(value: number);
  42743. /**
  42744. * Gets the value of the Right joystick
  42745. */
  42746. get buttonRightStick(): number;
  42747. /**
  42748. * Sets the value of the Right joystick
  42749. */
  42750. set buttonRightStick(value: number);
  42751. /**
  42752. * Gets the value of D-pad up
  42753. */
  42754. get dPadUp(): number;
  42755. /**
  42756. * Sets the value of D-pad up
  42757. */
  42758. set dPadUp(value: number);
  42759. /**
  42760. * Gets the value of D-pad down
  42761. */
  42762. get dPadDown(): number;
  42763. /**
  42764. * Sets the value of D-pad down
  42765. */
  42766. set dPadDown(value: number);
  42767. /**
  42768. * Gets the value of D-pad left
  42769. */
  42770. get dPadLeft(): number;
  42771. /**
  42772. * Sets the value of D-pad left
  42773. */
  42774. set dPadLeft(value: number);
  42775. /**
  42776. * Gets the value of D-pad right
  42777. */
  42778. get dPadRight(): number;
  42779. /**
  42780. * Sets the value of D-pad right
  42781. */
  42782. set dPadRight(value: number);
  42783. /**
  42784. * Force the gamepad to synchronize with device values
  42785. */
  42786. update(): void;
  42787. /**
  42788. * Disposes the gamepad
  42789. */
  42790. dispose(): void;
  42791. }
  42792. }
  42793. declare module "babylonjs/Gamepads/gamepadManager" {
  42794. import { Observable } from "babylonjs/Misc/observable";
  42795. import { Nullable } from "babylonjs/types";
  42796. import { Scene } from "babylonjs/scene";
  42797. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42798. /**
  42799. * Manager for handling gamepads
  42800. */
  42801. export class GamepadManager {
  42802. private _scene?;
  42803. private _babylonGamepads;
  42804. private _oneGamepadConnected;
  42805. /** @hidden */
  42806. _isMonitoring: boolean;
  42807. private _gamepadEventSupported;
  42808. private _gamepadSupport?;
  42809. /**
  42810. * observable to be triggered when the gamepad controller has been connected
  42811. */
  42812. onGamepadConnectedObservable: Observable<Gamepad>;
  42813. /**
  42814. * observable to be triggered when the gamepad controller has been disconnected
  42815. */
  42816. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42817. private _onGamepadConnectedEvent;
  42818. private _onGamepadDisconnectedEvent;
  42819. /**
  42820. * Initializes the gamepad manager
  42821. * @param _scene BabylonJS scene
  42822. */
  42823. constructor(_scene?: Scene | undefined);
  42824. /**
  42825. * The gamepads in the game pad manager
  42826. */
  42827. get gamepads(): Gamepad[];
  42828. /**
  42829. * Get the gamepad controllers based on type
  42830. * @param type The type of gamepad controller
  42831. * @returns Nullable gamepad
  42832. */
  42833. getGamepadByType(type?: number): Nullable<Gamepad>;
  42834. /**
  42835. * Disposes the gamepad manager
  42836. */
  42837. dispose(): void;
  42838. private _addNewGamepad;
  42839. private _startMonitoringGamepads;
  42840. private _stopMonitoringGamepads;
  42841. /** @hidden */
  42842. _checkGamepadsStatus(): void;
  42843. private _updateGamepadObjects;
  42844. }
  42845. }
  42846. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42847. import { Nullable } from "babylonjs/types";
  42848. import { Scene } from "babylonjs/scene";
  42849. import { ISceneComponent } from "babylonjs/sceneComponent";
  42850. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42851. module "babylonjs/scene" {
  42852. interface Scene {
  42853. /** @hidden */
  42854. _gamepadManager: Nullable<GamepadManager>;
  42855. /**
  42856. * Gets the gamepad manager associated with the scene
  42857. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42858. */
  42859. gamepadManager: GamepadManager;
  42860. }
  42861. }
  42862. module "babylonjs/Cameras/freeCameraInputsManager" {
  42863. /**
  42864. * Interface representing a free camera inputs manager
  42865. */
  42866. interface FreeCameraInputsManager {
  42867. /**
  42868. * Adds gamepad input support to the FreeCameraInputsManager.
  42869. * @returns the FreeCameraInputsManager
  42870. */
  42871. addGamepad(): FreeCameraInputsManager;
  42872. }
  42873. }
  42874. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42875. /**
  42876. * Interface representing an arc rotate camera inputs manager
  42877. */
  42878. interface ArcRotateCameraInputsManager {
  42879. /**
  42880. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42881. * @returns the camera inputs manager
  42882. */
  42883. addGamepad(): ArcRotateCameraInputsManager;
  42884. }
  42885. }
  42886. /**
  42887. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42888. */
  42889. export class GamepadSystemSceneComponent implements ISceneComponent {
  42890. /**
  42891. * The component name helpfull to identify the component in the list of scene components.
  42892. */
  42893. readonly name: string;
  42894. /**
  42895. * The scene the component belongs to.
  42896. */
  42897. scene: Scene;
  42898. /**
  42899. * Creates a new instance of the component for the given scene
  42900. * @param scene Defines the scene to register the component in
  42901. */
  42902. constructor(scene: Scene);
  42903. /**
  42904. * Registers the component in a given scene
  42905. */
  42906. register(): void;
  42907. /**
  42908. * Rebuilds the elements related to this component in case of
  42909. * context lost for instance.
  42910. */
  42911. rebuild(): void;
  42912. /**
  42913. * Disposes the component and the associated ressources
  42914. */
  42915. dispose(): void;
  42916. private _beforeCameraUpdate;
  42917. }
  42918. }
  42919. declare module "babylonjs/Cameras/universalCamera" {
  42920. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42921. import { Scene } from "babylonjs/scene";
  42922. import { Vector3 } from "babylonjs/Maths/math.vector";
  42923. import "babylonjs/Gamepads/gamepadSceneComponent";
  42924. /**
  42925. * 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,
  42926. * which still works and will still be found in many Playgrounds.
  42927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42928. */
  42929. export class UniversalCamera extends TouchCamera {
  42930. /**
  42931. * Defines the gamepad rotation sensiblity.
  42932. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42933. */
  42934. get gamepadAngularSensibility(): number;
  42935. set gamepadAngularSensibility(value: number);
  42936. /**
  42937. * Defines the gamepad move sensiblity.
  42938. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42939. */
  42940. get gamepadMoveSensibility(): number;
  42941. set gamepadMoveSensibility(value: number);
  42942. /**
  42943. * 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,
  42944. * which still works and will still be found in many Playgrounds.
  42945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42946. * @param name Define the name of the camera in the scene
  42947. * @param position Define the start position of the camera in the scene
  42948. * @param scene Define the scene the camera belongs to
  42949. */
  42950. constructor(name: string, position: Vector3, scene: Scene);
  42951. /**
  42952. * Gets the current object class name.
  42953. * @return the class name
  42954. */
  42955. getClassName(): string;
  42956. }
  42957. }
  42958. declare module "babylonjs/Cameras/gamepadCamera" {
  42959. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42960. import { Scene } from "babylonjs/scene";
  42961. import { Vector3 } from "babylonjs/Maths/math.vector";
  42962. /**
  42963. * This represents a FPS type of camera. This is only here for back compat purpose.
  42964. * Please use the UniversalCamera instead as both are identical.
  42965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42966. */
  42967. export class GamepadCamera extends UniversalCamera {
  42968. /**
  42969. * Instantiates a new Gamepad Camera
  42970. * This represents a FPS type of camera. This is only here for back compat purpose.
  42971. * Please use the UniversalCamera instead as both are identical.
  42972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42973. * @param name Define the name of the camera in the scene
  42974. * @param position Define the start position of the camera in the scene
  42975. * @param scene Define the scene the camera belongs to
  42976. */
  42977. constructor(name: string, position: Vector3, scene: Scene);
  42978. /**
  42979. * Gets the current object class name.
  42980. * @return the class name
  42981. */
  42982. getClassName(): string;
  42983. }
  42984. }
  42985. declare module "babylonjs/Shaders/pass.fragment" {
  42986. /** @hidden */
  42987. export var passPixelShader: {
  42988. name: string;
  42989. shader: string;
  42990. };
  42991. }
  42992. declare module "babylonjs/Shaders/passCube.fragment" {
  42993. /** @hidden */
  42994. export var passCubePixelShader: {
  42995. name: string;
  42996. shader: string;
  42997. };
  42998. }
  42999. declare module "babylonjs/PostProcesses/passPostProcess" {
  43000. import { Nullable } from "babylonjs/types";
  43001. import { Camera } from "babylonjs/Cameras/camera";
  43002. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43003. import { Engine } from "babylonjs/Engines/engine";
  43004. import "babylonjs/Shaders/pass.fragment";
  43005. import "babylonjs/Shaders/passCube.fragment";
  43006. /**
  43007. * PassPostProcess which produces an output the same as it's input
  43008. */
  43009. export class PassPostProcess extends PostProcess {
  43010. /**
  43011. * Creates the PassPostProcess
  43012. * @param name The name of the effect.
  43013. * @param options The required width/height ratio to downsize to before computing the render pass.
  43014. * @param camera The camera to apply the render pass to.
  43015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43016. * @param engine The engine which the post process will be applied. (default: current engine)
  43017. * @param reusable If the post process can be reused on the same frame. (default: false)
  43018. * @param textureType The type of texture to be used when performing the post processing.
  43019. * @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)
  43020. */
  43021. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43022. }
  43023. /**
  43024. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43025. */
  43026. export class PassCubePostProcess extends PostProcess {
  43027. private _face;
  43028. /**
  43029. * Gets or sets the cube face to display.
  43030. * * 0 is +X
  43031. * * 1 is -X
  43032. * * 2 is +Y
  43033. * * 3 is -Y
  43034. * * 4 is +Z
  43035. * * 5 is -Z
  43036. */
  43037. get face(): number;
  43038. set face(value: number);
  43039. /**
  43040. * Creates the PassCubePostProcess
  43041. * @param name The name of the effect.
  43042. * @param options The required width/height ratio to downsize to before computing the render pass.
  43043. * @param camera The camera to apply the render pass to.
  43044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43045. * @param engine The engine which the post process will be applied. (default: current engine)
  43046. * @param reusable If the post process can be reused on the same frame. (default: false)
  43047. * @param textureType The type of texture to be used when performing the post processing.
  43048. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  43049. */
  43050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43051. }
  43052. }
  43053. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43054. /** @hidden */
  43055. export var anaglyphPixelShader: {
  43056. name: string;
  43057. shader: string;
  43058. };
  43059. }
  43060. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43061. import { Engine } from "babylonjs/Engines/engine";
  43062. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43063. import { Camera } from "babylonjs/Cameras/camera";
  43064. import "babylonjs/Shaders/anaglyph.fragment";
  43065. /**
  43066. * Postprocess used to generate anaglyphic rendering
  43067. */
  43068. export class AnaglyphPostProcess extends PostProcess {
  43069. private _passedProcess;
  43070. /**
  43071. * Creates a new AnaglyphPostProcess
  43072. * @param name defines postprocess name
  43073. * @param options defines creation options or target ratio scale
  43074. * @param rigCameras defines cameras using this postprocess
  43075. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43076. * @param engine defines hosting engine
  43077. * @param reusable defines if the postprocess will be reused multiple times per frame
  43078. */
  43079. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43080. }
  43081. }
  43082. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43083. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43084. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43085. import { Scene } from "babylonjs/scene";
  43086. import { Vector3 } from "babylonjs/Maths/math.vector";
  43087. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43088. /**
  43089. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43090. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43091. */
  43092. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43093. /**
  43094. * Creates a new AnaglyphArcRotateCamera
  43095. * @param name defines camera name
  43096. * @param alpha defines alpha angle (in radians)
  43097. * @param beta defines beta angle (in radians)
  43098. * @param radius defines radius
  43099. * @param target defines camera target
  43100. * @param interaxialDistance defines distance between each color axis
  43101. * @param scene defines the hosting scene
  43102. */
  43103. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43104. /**
  43105. * Gets camera class name
  43106. * @returns AnaglyphArcRotateCamera
  43107. */
  43108. getClassName(): string;
  43109. }
  43110. }
  43111. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43112. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43113. import { Scene } from "babylonjs/scene";
  43114. import { Vector3 } from "babylonjs/Maths/math.vector";
  43115. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43116. /**
  43117. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43118. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43119. */
  43120. export class AnaglyphFreeCamera extends FreeCamera {
  43121. /**
  43122. * Creates a new AnaglyphFreeCamera
  43123. * @param name defines camera name
  43124. * @param position defines initial position
  43125. * @param interaxialDistance defines distance between each color axis
  43126. * @param scene defines the hosting scene
  43127. */
  43128. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43129. /**
  43130. * Gets camera class name
  43131. * @returns AnaglyphFreeCamera
  43132. */
  43133. getClassName(): string;
  43134. }
  43135. }
  43136. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43137. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43138. import { Scene } from "babylonjs/scene";
  43139. import { Vector3 } from "babylonjs/Maths/math.vector";
  43140. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43141. /**
  43142. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43143. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43144. */
  43145. export class AnaglyphGamepadCamera extends GamepadCamera {
  43146. /**
  43147. * Creates a new AnaglyphGamepadCamera
  43148. * @param name defines camera name
  43149. * @param position defines initial position
  43150. * @param interaxialDistance defines distance between each color axis
  43151. * @param scene defines the hosting scene
  43152. */
  43153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43154. /**
  43155. * Gets camera class name
  43156. * @returns AnaglyphGamepadCamera
  43157. */
  43158. getClassName(): string;
  43159. }
  43160. }
  43161. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43162. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43163. import { Scene } from "babylonjs/scene";
  43164. import { Vector3 } from "babylonjs/Maths/math.vector";
  43165. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43166. /**
  43167. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43168. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43169. */
  43170. export class AnaglyphUniversalCamera extends UniversalCamera {
  43171. /**
  43172. * Creates a new AnaglyphUniversalCamera
  43173. * @param name defines camera name
  43174. * @param position defines initial position
  43175. * @param interaxialDistance defines distance between each color axis
  43176. * @param scene defines the hosting scene
  43177. */
  43178. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43179. /**
  43180. * Gets camera class name
  43181. * @returns AnaglyphUniversalCamera
  43182. */
  43183. getClassName(): string;
  43184. }
  43185. }
  43186. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43187. /** @hidden */
  43188. export var stereoscopicInterlacePixelShader: {
  43189. name: string;
  43190. shader: string;
  43191. };
  43192. }
  43193. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43194. import { Camera } from "babylonjs/Cameras/camera";
  43195. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43196. import { Engine } from "babylonjs/Engines/engine";
  43197. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43198. /**
  43199. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43200. */
  43201. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43202. private _stepSize;
  43203. private _passedProcess;
  43204. /**
  43205. * Initializes a StereoscopicInterlacePostProcessI
  43206. * @param name The name of the effect.
  43207. * @param rigCameras The rig cameras to be appled to the post process
  43208. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43209. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43211. * @param engine The engine which the post process will be applied. (default: current engine)
  43212. * @param reusable If the post process can be reused on the same frame. (default: false)
  43213. */
  43214. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43215. }
  43216. /**
  43217. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43218. */
  43219. export class StereoscopicInterlacePostProcess extends PostProcess {
  43220. private _stepSize;
  43221. private _passedProcess;
  43222. /**
  43223. * Initializes a StereoscopicInterlacePostProcess
  43224. * @param name The name of the effect.
  43225. * @param rigCameras The rig cameras to be appled to the post process
  43226. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43228. * @param engine The engine which the post process will be applied. (default: current engine)
  43229. * @param reusable If the post process can be reused on the same frame. (default: false)
  43230. */
  43231. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43232. }
  43233. }
  43234. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43235. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43236. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43237. import { Scene } from "babylonjs/scene";
  43238. import { Vector3 } from "babylonjs/Maths/math.vector";
  43239. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43240. /**
  43241. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43242. * @see http://doc.babylonjs.com/features/cameras
  43243. */
  43244. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43245. /**
  43246. * Creates a new StereoscopicArcRotateCamera
  43247. * @param name defines camera name
  43248. * @param alpha defines alpha angle (in radians)
  43249. * @param beta defines beta angle (in radians)
  43250. * @param radius defines radius
  43251. * @param target defines camera target
  43252. * @param interaxialDistance defines distance between each color axis
  43253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43254. * @param scene defines the hosting scene
  43255. */
  43256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43257. /**
  43258. * Gets camera class name
  43259. * @returns StereoscopicArcRotateCamera
  43260. */
  43261. getClassName(): string;
  43262. }
  43263. }
  43264. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43265. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43266. import { Scene } from "babylonjs/scene";
  43267. import { Vector3 } from "babylonjs/Maths/math.vector";
  43268. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43269. /**
  43270. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43271. * @see http://doc.babylonjs.com/features/cameras
  43272. */
  43273. export class StereoscopicFreeCamera extends FreeCamera {
  43274. /**
  43275. * Creates a new StereoscopicFreeCamera
  43276. * @param name defines camera name
  43277. * @param position defines initial position
  43278. * @param interaxialDistance defines distance between each color axis
  43279. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43280. * @param scene defines the hosting scene
  43281. */
  43282. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43283. /**
  43284. * Gets camera class name
  43285. * @returns StereoscopicFreeCamera
  43286. */
  43287. getClassName(): string;
  43288. }
  43289. }
  43290. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43291. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43292. import { Scene } from "babylonjs/scene";
  43293. import { Vector3 } from "babylonjs/Maths/math.vector";
  43294. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43295. /**
  43296. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43297. * @see http://doc.babylonjs.com/features/cameras
  43298. */
  43299. export class StereoscopicGamepadCamera extends GamepadCamera {
  43300. /**
  43301. * Creates a new StereoscopicGamepadCamera
  43302. * @param name defines camera name
  43303. * @param position defines initial position
  43304. * @param interaxialDistance defines distance between each color axis
  43305. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43306. * @param scene defines the hosting scene
  43307. */
  43308. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43309. /**
  43310. * Gets camera class name
  43311. * @returns StereoscopicGamepadCamera
  43312. */
  43313. getClassName(): string;
  43314. }
  43315. }
  43316. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43317. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43318. import { Scene } from "babylonjs/scene";
  43319. import { Vector3 } from "babylonjs/Maths/math.vector";
  43320. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43321. /**
  43322. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43323. * @see http://doc.babylonjs.com/features/cameras
  43324. */
  43325. export class StereoscopicUniversalCamera extends UniversalCamera {
  43326. /**
  43327. * Creates a new StereoscopicUniversalCamera
  43328. * @param name defines camera name
  43329. * @param position defines initial position
  43330. * @param interaxialDistance defines distance between each color axis
  43331. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43332. * @param scene defines the hosting scene
  43333. */
  43334. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43335. /**
  43336. * Gets camera class name
  43337. * @returns StereoscopicUniversalCamera
  43338. */
  43339. getClassName(): string;
  43340. }
  43341. }
  43342. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43343. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43344. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43345. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43346. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43347. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43348. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43349. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43350. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43351. }
  43352. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43353. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43354. import { Scene } from "babylonjs/scene";
  43355. import { Vector3 } from "babylonjs/Maths/math.vector";
  43356. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43357. /**
  43358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43362. */
  43363. export class VirtualJoysticksCamera extends FreeCamera {
  43364. /**
  43365. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43369. * @param name Define the name of the camera in the scene
  43370. * @param position Define the start position of the camera in the scene
  43371. * @param scene Define the scene the camera belongs to
  43372. */
  43373. constructor(name: string, position: Vector3, scene: Scene);
  43374. /**
  43375. * Gets the current object class name.
  43376. * @return the class name
  43377. */
  43378. getClassName(): string;
  43379. }
  43380. }
  43381. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43382. import { Matrix } from "babylonjs/Maths/math.vector";
  43383. /**
  43384. * This represents all the required metrics to create a VR camera.
  43385. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43386. */
  43387. export class VRCameraMetrics {
  43388. /**
  43389. * Define the horizontal resolution off the screen.
  43390. */
  43391. hResolution: number;
  43392. /**
  43393. * Define the vertical resolution off the screen.
  43394. */
  43395. vResolution: number;
  43396. /**
  43397. * Define the horizontal screen size.
  43398. */
  43399. hScreenSize: number;
  43400. /**
  43401. * Define the vertical screen size.
  43402. */
  43403. vScreenSize: number;
  43404. /**
  43405. * Define the vertical screen center position.
  43406. */
  43407. vScreenCenter: number;
  43408. /**
  43409. * Define the distance of the eyes to the screen.
  43410. */
  43411. eyeToScreenDistance: number;
  43412. /**
  43413. * Define the distance between both lenses
  43414. */
  43415. lensSeparationDistance: number;
  43416. /**
  43417. * Define the distance between both viewer's eyes.
  43418. */
  43419. interpupillaryDistance: number;
  43420. /**
  43421. * Define the distortion factor of the VR postprocess.
  43422. * Please, touch with care.
  43423. */
  43424. distortionK: number[];
  43425. /**
  43426. * Define the chromatic aberration correction factors for the VR post process.
  43427. */
  43428. chromaAbCorrection: number[];
  43429. /**
  43430. * Define the scale factor of the post process.
  43431. * The smaller the better but the slower.
  43432. */
  43433. postProcessScaleFactor: number;
  43434. /**
  43435. * Define an offset for the lens center.
  43436. */
  43437. lensCenterOffset: number;
  43438. /**
  43439. * Define if the current vr camera should compensate the distortion of the lense or not.
  43440. */
  43441. compensateDistortion: boolean;
  43442. /**
  43443. * Defines if multiview should be enabled when rendering (Default: false)
  43444. */
  43445. multiviewEnabled: boolean;
  43446. /**
  43447. * Gets the rendering aspect ratio based on the provided resolutions.
  43448. */
  43449. get aspectRatio(): number;
  43450. /**
  43451. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43452. */
  43453. get aspectRatioFov(): number;
  43454. /**
  43455. * @hidden
  43456. */
  43457. get leftHMatrix(): Matrix;
  43458. /**
  43459. * @hidden
  43460. */
  43461. get rightHMatrix(): Matrix;
  43462. /**
  43463. * @hidden
  43464. */
  43465. get leftPreViewMatrix(): Matrix;
  43466. /**
  43467. * @hidden
  43468. */
  43469. get rightPreViewMatrix(): Matrix;
  43470. /**
  43471. * Get the default VRMetrics based on the most generic setup.
  43472. * @returns the default vr metrics
  43473. */
  43474. static GetDefault(): VRCameraMetrics;
  43475. }
  43476. }
  43477. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43478. /** @hidden */
  43479. export var vrDistortionCorrectionPixelShader: {
  43480. name: string;
  43481. shader: string;
  43482. };
  43483. }
  43484. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43485. import { Camera } from "babylonjs/Cameras/camera";
  43486. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43487. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43488. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43489. /**
  43490. * VRDistortionCorrectionPostProcess used for mobile VR
  43491. */
  43492. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43493. private _isRightEye;
  43494. private _distortionFactors;
  43495. private _postProcessScaleFactor;
  43496. private _lensCenterOffset;
  43497. private _scaleIn;
  43498. private _scaleFactor;
  43499. private _lensCenter;
  43500. /**
  43501. * Initializes the VRDistortionCorrectionPostProcess
  43502. * @param name The name of the effect.
  43503. * @param camera The camera to apply the render pass to.
  43504. * @param isRightEye If this is for the right eye distortion
  43505. * @param vrMetrics All the required metrics for the VR camera
  43506. */
  43507. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43508. }
  43509. }
  43510. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43511. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43513. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43514. import { Scene } from "babylonjs/scene";
  43515. import { Vector3 } from "babylonjs/Maths/math.vector";
  43516. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43517. import "babylonjs/Cameras/RigModes/vrRigMode";
  43518. /**
  43519. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43520. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43521. */
  43522. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43523. /**
  43524. * Creates a new VRDeviceOrientationArcRotateCamera
  43525. * @param name defines camera name
  43526. * @param alpha defines the camera rotation along the logitudinal axis
  43527. * @param beta defines the camera rotation along the latitudinal axis
  43528. * @param radius defines the camera distance from its target
  43529. * @param target defines the camera target
  43530. * @param scene defines the scene the camera belongs to
  43531. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43532. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43533. */
  43534. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43535. /**
  43536. * Gets camera class name
  43537. * @returns VRDeviceOrientationArcRotateCamera
  43538. */
  43539. getClassName(): string;
  43540. }
  43541. }
  43542. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43543. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43544. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43545. import { Scene } from "babylonjs/scene";
  43546. import { Vector3 } from "babylonjs/Maths/math.vector";
  43547. import "babylonjs/Cameras/RigModes/vrRigMode";
  43548. /**
  43549. * Camera used to simulate VR rendering (based on FreeCamera)
  43550. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43551. */
  43552. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43553. /**
  43554. * Creates a new VRDeviceOrientationFreeCamera
  43555. * @param name defines camera name
  43556. * @param position defines the start position of the camera
  43557. * @param scene defines the scene the camera belongs to
  43558. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43559. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43560. */
  43561. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43562. /**
  43563. * Gets camera class name
  43564. * @returns VRDeviceOrientationFreeCamera
  43565. */
  43566. getClassName(): string;
  43567. }
  43568. }
  43569. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43570. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43571. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43572. import { Scene } from "babylonjs/scene";
  43573. import { Vector3 } from "babylonjs/Maths/math.vector";
  43574. import "babylonjs/Gamepads/gamepadSceneComponent";
  43575. /**
  43576. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43577. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43578. */
  43579. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43580. /**
  43581. * Creates a new VRDeviceOrientationGamepadCamera
  43582. * @param name defines camera name
  43583. * @param position defines the start position of the camera
  43584. * @param scene defines the scene the camera belongs to
  43585. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43586. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43587. */
  43588. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43589. /**
  43590. * Gets camera class name
  43591. * @returns VRDeviceOrientationGamepadCamera
  43592. */
  43593. getClassName(): string;
  43594. }
  43595. }
  43596. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43597. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43598. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43599. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43600. /** @hidden */
  43601. export var imageProcessingPixelShader: {
  43602. name: string;
  43603. shader: string;
  43604. };
  43605. }
  43606. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43607. import { Nullable } from "babylonjs/types";
  43608. import { Color4 } from "babylonjs/Maths/math.color";
  43609. import { Camera } from "babylonjs/Cameras/camera";
  43610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43611. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43612. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43614. import { Engine } from "babylonjs/Engines/engine";
  43615. import "babylonjs/Shaders/imageProcessing.fragment";
  43616. import "babylonjs/Shaders/postprocess.vertex";
  43617. /**
  43618. * ImageProcessingPostProcess
  43619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43620. */
  43621. export class ImageProcessingPostProcess extends PostProcess {
  43622. /**
  43623. * Default configuration related to image processing available in the PBR Material.
  43624. */
  43625. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43626. /**
  43627. * Gets the image processing configuration used either in this material.
  43628. */
  43629. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43630. /**
  43631. * Sets the Default image processing configuration used either in the this material.
  43632. *
  43633. * If sets to null, the scene one is in use.
  43634. */
  43635. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43636. /**
  43637. * Keep track of the image processing observer to allow dispose and replace.
  43638. */
  43639. private _imageProcessingObserver;
  43640. /**
  43641. * Attaches a new image processing configuration to the PBR Material.
  43642. * @param configuration
  43643. */
  43644. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43645. /**
  43646. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43647. */
  43648. get colorCurves(): Nullable<ColorCurves>;
  43649. /**
  43650. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43651. */
  43652. set colorCurves(value: Nullable<ColorCurves>);
  43653. /**
  43654. * Gets wether the color curves effect is enabled.
  43655. */
  43656. get colorCurvesEnabled(): boolean;
  43657. /**
  43658. * Sets wether the color curves effect is enabled.
  43659. */
  43660. set colorCurvesEnabled(value: boolean);
  43661. /**
  43662. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43663. */
  43664. get colorGradingTexture(): Nullable<BaseTexture>;
  43665. /**
  43666. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43667. */
  43668. set colorGradingTexture(value: Nullable<BaseTexture>);
  43669. /**
  43670. * Gets wether the color grading effect is enabled.
  43671. */
  43672. get colorGradingEnabled(): boolean;
  43673. /**
  43674. * Gets wether the color grading effect is enabled.
  43675. */
  43676. set colorGradingEnabled(value: boolean);
  43677. /**
  43678. * Gets exposure used in the effect.
  43679. */
  43680. get exposure(): number;
  43681. /**
  43682. * Sets exposure used in the effect.
  43683. */
  43684. set exposure(value: number);
  43685. /**
  43686. * Gets wether tonemapping is enabled or not.
  43687. */
  43688. get toneMappingEnabled(): boolean;
  43689. /**
  43690. * Sets wether tonemapping is enabled or not
  43691. */
  43692. set toneMappingEnabled(value: boolean);
  43693. /**
  43694. * Gets the type of tone mapping effect.
  43695. */
  43696. get toneMappingType(): number;
  43697. /**
  43698. * Sets the type of tone mapping effect.
  43699. */
  43700. set toneMappingType(value: number);
  43701. /**
  43702. * Gets contrast used in the effect.
  43703. */
  43704. get contrast(): number;
  43705. /**
  43706. * Sets contrast used in the effect.
  43707. */
  43708. set contrast(value: number);
  43709. /**
  43710. * Gets Vignette stretch size.
  43711. */
  43712. get vignetteStretch(): number;
  43713. /**
  43714. * Sets Vignette stretch size.
  43715. */
  43716. set vignetteStretch(value: number);
  43717. /**
  43718. * Gets Vignette centre X Offset.
  43719. */
  43720. get vignetteCentreX(): number;
  43721. /**
  43722. * Sets Vignette centre X Offset.
  43723. */
  43724. set vignetteCentreX(value: number);
  43725. /**
  43726. * Gets Vignette centre Y Offset.
  43727. */
  43728. get vignetteCentreY(): number;
  43729. /**
  43730. * Sets Vignette centre Y Offset.
  43731. */
  43732. set vignetteCentreY(value: number);
  43733. /**
  43734. * Gets Vignette weight or intensity of the vignette effect.
  43735. */
  43736. get vignetteWeight(): number;
  43737. /**
  43738. * Sets Vignette weight or intensity of the vignette effect.
  43739. */
  43740. set vignetteWeight(value: number);
  43741. /**
  43742. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43743. * if vignetteEnabled is set to true.
  43744. */
  43745. get vignetteColor(): Color4;
  43746. /**
  43747. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43748. * if vignetteEnabled is set to true.
  43749. */
  43750. set vignetteColor(value: Color4);
  43751. /**
  43752. * Gets Camera field of view used by the Vignette effect.
  43753. */
  43754. get vignetteCameraFov(): number;
  43755. /**
  43756. * Sets Camera field of view used by the Vignette effect.
  43757. */
  43758. set vignetteCameraFov(value: number);
  43759. /**
  43760. * Gets the vignette blend mode allowing different kind of effect.
  43761. */
  43762. get vignetteBlendMode(): number;
  43763. /**
  43764. * Sets the vignette blend mode allowing different kind of effect.
  43765. */
  43766. set vignetteBlendMode(value: number);
  43767. /**
  43768. * Gets wether the vignette effect is enabled.
  43769. */
  43770. get vignetteEnabled(): boolean;
  43771. /**
  43772. * Sets wether the vignette effect is enabled.
  43773. */
  43774. set vignetteEnabled(value: boolean);
  43775. private _fromLinearSpace;
  43776. /**
  43777. * Gets wether the input of the processing is in Gamma or Linear Space.
  43778. */
  43779. get fromLinearSpace(): boolean;
  43780. /**
  43781. * Sets wether the input of the processing is in Gamma or Linear Space.
  43782. */
  43783. set fromLinearSpace(value: boolean);
  43784. /**
  43785. * Defines cache preventing GC.
  43786. */
  43787. private _defines;
  43788. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43789. /**
  43790. * "ImageProcessingPostProcess"
  43791. * @returns "ImageProcessingPostProcess"
  43792. */
  43793. getClassName(): string;
  43794. protected _updateParameters(): void;
  43795. dispose(camera?: Camera): void;
  43796. }
  43797. }
  43798. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43799. import { Scene } from "babylonjs/scene";
  43800. import { Color3 } from "babylonjs/Maths/math.color";
  43801. import { Mesh } from "babylonjs/Meshes/mesh";
  43802. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43803. import { Nullable } from "babylonjs/types";
  43804. /**
  43805. * Class containing static functions to help procedurally build meshes
  43806. */
  43807. export class GroundBuilder {
  43808. /**
  43809. * Creates a ground mesh
  43810. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43811. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43813. * @param name defines the name of the mesh
  43814. * @param options defines the options used to create the mesh
  43815. * @param scene defines the hosting scene
  43816. * @returns the ground mesh
  43817. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43818. */
  43819. static CreateGround(name: string, options: {
  43820. width?: number;
  43821. height?: number;
  43822. subdivisions?: number;
  43823. subdivisionsX?: number;
  43824. subdivisionsY?: number;
  43825. updatable?: boolean;
  43826. }, scene: any): Mesh;
  43827. /**
  43828. * Creates a tiled ground mesh
  43829. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43830. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43831. * * 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
  43832. * * 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
  43833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43834. * @param name defines the name of the mesh
  43835. * @param options defines the options used to create the mesh
  43836. * @param scene defines the hosting scene
  43837. * @returns the tiled ground mesh
  43838. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43839. */
  43840. static CreateTiledGround(name: string, options: {
  43841. xmin: number;
  43842. zmin: number;
  43843. xmax: number;
  43844. zmax: number;
  43845. subdivisions?: {
  43846. w: number;
  43847. h: number;
  43848. };
  43849. precision?: {
  43850. w: number;
  43851. h: number;
  43852. };
  43853. updatable?: boolean;
  43854. }, scene?: Nullable<Scene>): Mesh;
  43855. /**
  43856. * Creates a ground mesh from a height map
  43857. * * The parameter `url` sets the URL of the height map image resource.
  43858. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43859. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43860. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43861. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43862. * * 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.
  43863. * * 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).
  43864. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43866. * @param name defines the name of the mesh
  43867. * @param url defines the url to the height map
  43868. * @param options defines the options used to create the mesh
  43869. * @param scene defines the hosting scene
  43870. * @returns the ground mesh
  43871. * @see https://doc.babylonjs.com/babylon101/height_map
  43872. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43873. */
  43874. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43875. width?: number;
  43876. height?: number;
  43877. subdivisions?: number;
  43878. minHeight?: number;
  43879. maxHeight?: number;
  43880. colorFilter?: Color3;
  43881. alphaFilter?: number;
  43882. updatable?: boolean;
  43883. onReady?: (mesh: GroundMesh) => void;
  43884. }, scene?: Nullable<Scene>): GroundMesh;
  43885. }
  43886. }
  43887. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43888. import { Vector4 } from "babylonjs/Maths/math.vector";
  43889. import { Mesh } from "babylonjs/Meshes/mesh";
  43890. /**
  43891. * Class containing static functions to help procedurally build meshes
  43892. */
  43893. export class TorusBuilder {
  43894. /**
  43895. * Creates a torus mesh
  43896. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43897. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43898. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43902. * @param name defines the name of the mesh
  43903. * @param options defines the options used to create the mesh
  43904. * @param scene defines the hosting scene
  43905. * @returns the torus mesh
  43906. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43907. */
  43908. static CreateTorus(name: string, options: {
  43909. diameter?: number;
  43910. thickness?: number;
  43911. tessellation?: number;
  43912. updatable?: boolean;
  43913. sideOrientation?: number;
  43914. frontUVs?: Vector4;
  43915. backUVs?: Vector4;
  43916. }, scene: any): Mesh;
  43917. }
  43918. }
  43919. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43920. import { Vector4 } from "babylonjs/Maths/math.vector";
  43921. import { Color4 } from "babylonjs/Maths/math.color";
  43922. import { Mesh } from "babylonjs/Meshes/mesh";
  43923. /**
  43924. * Class containing static functions to help procedurally build meshes
  43925. */
  43926. export class CylinderBuilder {
  43927. /**
  43928. * Creates a cylinder or a cone mesh
  43929. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43930. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43931. * * 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.
  43932. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43933. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43934. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43935. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43936. * * 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).
  43937. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43938. * * 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).
  43939. * * 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
  43940. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43941. * * 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
  43942. * * 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.
  43943. * * If `enclose` is false, a ring surface is one element.
  43944. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43945. * * 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
  43946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43949. * @param name defines the name of the mesh
  43950. * @param options defines the options used to create the mesh
  43951. * @param scene defines the hosting scene
  43952. * @returns the cylinder mesh
  43953. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43954. */
  43955. static CreateCylinder(name: string, options: {
  43956. height?: number;
  43957. diameterTop?: number;
  43958. diameterBottom?: number;
  43959. diameter?: number;
  43960. tessellation?: number;
  43961. subdivisions?: number;
  43962. arc?: number;
  43963. faceColors?: Color4[];
  43964. faceUV?: Vector4[];
  43965. updatable?: boolean;
  43966. hasRings?: boolean;
  43967. enclose?: boolean;
  43968. cap?: number;
  43969. sideOrientation?: number;
  43970. frontUVs?: Vector4;
  43971. backUVs?: Vector4;
  43972. }, scene: any): Mesh;
  43973. }
  43974. }
  43975. declare module "babylonjs/XR/webXRTypes" {
  43976. import { Nullable } from "babylonjs/types";
  43977. import { IDisposable } from "babylonjs/scene";
  43978. /**
  43979. * States of the webXR experience
  43980. */
  43981. export enum WebXRState {
  43982. /**
  43983. * Transitioning to being in XR mode
  43984. */
  43985. ENTERING_XR = 0,
  43986. /**
  43987. * Transitioning to non XR mode
  43988. */
  43989. EXITING_XR = 1,
  43990. /**
  43991. * In XR mode and presenting
  43992. */
  43993. IN_XR = 2,
  43994. /**
  43995. * Not entered XR mode
  43996. */
  43997. NOT_IN_XR = 3
  43998. }
  43999. /**
  44000. * Abstraction of the XR render target
  44001. */
  44002. export interface WebXRRenderTarget extends IDisposable {
  44003. /**
  44004. * xrpresent context of the canvas which can be used to display/mirror xr content
  44005. */
  44006. canvasContext: WebGLRenderingContext;
  44007. /**
  44008. * xr layer for the canvas
  44009. */
  44010. xrLayer: Nullable<XRWebGLLayer>;
  44011. /**
  44012. * Initializes the xr layer for the session
  44013. * @param xrSession xr session
  44014. * @returns a promise that will resolve once the XR Layer has been created
  44015. */
  44016. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44017. }
  44018. }
  44019. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44020. import { Nullable } from "babylonjs/types";
  44021. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44022. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44023. /**
  44024. * COnfiguration object for WebXR output canvas
  44025. */
  44026. export class WebXRManagedOutputCanvasOptions {
  44027. /**
  44028. * Options for this XR Layer output
  44029. */
  44030. canvasOptions?: XRWebGLLayerOptions;
  44031. /**
  44032. * CSS styling for a newly created canvas (if not provided)
  44033. */
  44034. newCanvasCssStyle?: string;
  44035. /**
  44036. * An optional canvas in case you wish to create it yourself and provide it here.
  44037. * If not provided, a new canvas will be created
  44038. */
  44039. canvasElement?: HTMLCanvasElement;
  44040. /**
  44041. * Get the default values of the configuration object
  44042. * @returns default values of this configuration object
  44043. */
  44044. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44045. }
  44046. /**
  44047. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44048. */
  44049. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44050. private _options;
  44051. private _engine;
  44052. private _canvas;
  44053. /**
  44054. * Rendering context of the canvas which can be used to display/mirror xr content
  44055. */
  44056. canvasContext: WebGLRenderingContext;
  44057. /**
  44058. * xr layer for the canvas
  44059. */
  44060. xrLayer: Nullable<XRWebGLLayer>;
  44061. /**
  44062. * Initializes the xr layer for the session
  44063. * @param xrSession xr session
  44064. * @returns a promise that will resolve once the XR Layer has been created
  44065. */
  44066. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44067. /**
  44068. * Initializes the canvas to be added/removed upon entering/exiting xr
  44069. * @param _xrSessionManager The XR Session manager
  44070. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44071. */
  44072. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44073. /**
  44074. * Disposes of the object
  44075. */
  44076. dispose(): void;
  44077. private _setManagedOutputCanvas;
  44078. private _addCanvas;
  44079. private _removeCanvas;
  44080. }
  44081. }
  44082. declare module "babylonjs/XR/webXRSessionManager" {
  44083. import { Observable } from "babylonjs/Misc/observable";
  44084. import { Nullable } from "babylonjs/types";
  44085. import { IDisposable, Scene } from "babylonjs/scene";
  44086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44087. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44088. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44089. /**
  44090. * Manages an XRSession to work with Babylon's engine
  44091. * @see https://doc.babylonjs.com/how_to/webxr
  44092. */
  44093. export class WebXRSessionManager implements IDisposable {
  44094. /** The scene which the session should be created for */
  44095. scene: Scene;
  44096. /**
  44097. * Fires every time a new xrFrame arrives which can be used to update the camera
  44098. */
  44099. onXRFrameObservable: Observable<XRFrame>;
  44100. /**
  44101. * Fires when the xr session is ended either by the device or manually done
  44102. */
  44103. onXRSessionEnded: Observable<any>;
  44104. /**
  44105. * Fires when the xr session is ended either by the device or manually done
  44106. */
  44107. onXRSessionInit: Observable<XRSession>;
  44108. /**
  44109. * Fires when the reference space changed
  44110. */
  44111. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44112. /**
  44113. * Underlying xr session
  44114. */
  44115. session: XRSession;
  44116. /**
  44117. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44118. * or get the offset the player is currently at.
  44119. */
  44120. viewerReferenceSpace: XRReferenceSpace;
  44121. private _referenceSpace;
  44122. /**
  44123. * The current reference space used in this session. This reference space can constantly change!
  44124. * It is mainly used to offset the camera's position.
  44125. */
  44126. get referenceSpace(): XRReferenceSpace;
  44127. /**
  44128. * Set a new reference space and triggers the observable
  44129. */
  44130. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44131. /**
  44132. * The base reference space from which the session started. good if you want to reset your
  44133. * reference space
  44134. */
  44135. baseReferenceSpace: XRReferenceSpace;
  44136. /**
  44137. * Used just in case of a failure to initialize an immersive session.
  44138. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44139. */
  44140. defaultHeightCompensation: number;
  44141. /**
  44142. * Current XR frame
  44143. */
  44144. currentFrame: Nullable<XRFrame>;
  44145. /** WebXR timestamp updated every frame */
  44146. currentTimestamp: number;
  44147. private _xrNavigator;
  44148. private baseLayer;
  44149. private _rttProvider;
  44150. private _sessionEnded;
  44151. /**
  44152. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44153. * @param scene The scene which the session should be created for
  44154. */
  44155. constructor(
  44156. /** The scene which the session should be created for */
  44157. scene: Scene);
  44158. /**
  44159. * Initializes the manager
  44160. * After initialization enterXR can be called to start an XR session
  44161. * @returns Promise which resolves after it is initialized
  44162. */
  44163. initializeAsync(): Promise<void>;
  44164. /**
  44165. * Initializes an xr session
  44166. * @param xrSessionMode mode to initialize
  44167. * @param xrSessionInit defines optional and required values to pass to the session builder
  44168. * @returns a promise which will resolve once the session has been initialized
  44169. */
  44170. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44171. /**
  44172. * Sets the reference space on the xr session
  44173. * @param referenceSpaceType space to set
  44174. * @returns a promise that will resolve once the reference space has been set
  44175. */
  44176. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44177. /**
  44178. * Resets the reference space to the one started the session
  44179. */
  44180. resetReferenceSpace(): void;
  44181. /**
  44182. * Updates the render state of the session
  44183. * @param state state to set
  44184. * @returns a promise that resolves once the render state has been updated
  44185. */
  44186. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44187. /**
  44188. * Starts rendering to the xr layer
  44189. */
  44190. runXRRenderLoop(): void;
  44191. /**
  44192. * Gets the correct render target texture to be rendered this frame for this eye
  44193. * @param eye the eye for which to get the render target
  44194. * @returns the render target for the specified eye
  44195. */
  44196. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44197. /**
  44198. * Stops the xrSession and restores the renderloop
  44199. * @returns Promise which resolves after it exits XR
  44200. */
  44201. exitXRAsync(): Promise<void>;
  44202. /**
  44203. * Checks if a session would be supported for the creation options specified
  44204. * @param sessionMode session mode to check if supported eg. immersive-vr
  44205. * @returns A Promise that resolves to true if supported and false if not
  44206. */
  44207. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44208. /**
  44209. * Creates a WebXRRenderTarget object for the XR session
  44210. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44211. * @param options optional options to provide when creating a new render target
  44212. * @returns a WebXR render target to which the session can render
  44213. */
  44214. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44215. /**
  44216. * @hidden
  44217. * Converts the render layer of xrSession to a render target
  44218. * @param session session to create render target for
  44219. * @param scene scene the new render target should be created for
  44220. * @param baseLayer the webgl layer to create the render target for
  44221. */
  44222. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44223. /**
  44224. * Disposes of the session manager
  44225. */
  44226. dispose(): void;
  44227. /**
  44228. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44229. * @param sessionMode defines the session to test
  44230. * @returns a promise with boolean as final value
  44231. */
  44232. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44233. }
  44234. }
  44235. declare module "babylonjs/XR/webXRCamera" {
  44236. import { Scene } from "babylonjs/scene";
  44237. import { Camera } from "babylonjs/Cameras/camera";
  44238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44239. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44240. /**
  44241. * WebXR Camera which holds the views for the xrSession
  44242. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44243. */
  44244. export class WebXRCamera extends FreeCamera {
  44245. private _xrSessionManager;
  44246. private _firstFrame;
  44247. private _referenceQuaternion;
  44248. private _referencedPosition;
  44249. private _xrInvPositionCache;
  44250. private _xrInvQuaternionCache;
  44251. /**
  44252. * Should position compensation execute on first frame.
  44253. * This is used when copying the position from a native (non XR) camera
  44254. */
  44255. compensateOnFirstFrame: boolean;
  44256. /**
  44257. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44258. * @param name the name of the camera
  44259. * @param scene the scene to add the camera to
  44260. * @param _xrSessionManager a constructed xr session manager
  44261. */
  44262. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44263. /**
  44264. * Return the user's height, unrelated to the current ground.
  44265. * This will be the y position of this camera, when ground level is 0.
  44266. */
  44267. get realWorldHeight(): number;
  44268. /** @hidden */
  44269. _updateForDualEyeDebugging(): void;
  44270. /**
  44271. * Sets this camera's transformation based on a non-vr camera
  44272. * @param otherCamera the non-vr camera to copy the transformation from
  44273. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44274. */
  44275. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44276. private _updateFromXRSession;
  44277. private _updateNumberOfRigCameras;
  44278. private _updateReferenceSpace;
  44279. private _updateReferenceSpaceOffset;
  44280. }
  44281. }
  44282. declare module "babylonjs/XR/webXRFeaturesManager" {
  44283. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44284. import { IDisposable } from "babylonjs/scene";
  44285. /**
  44286. * Defining the interface required for a (webxr) feature
  44287. */
  44288. export interface IWebXRFeature extends IDisposable {
  44289. /**
  44290. * Is this feature attached
  44291. */
  44292. attached: boolean;
  44293. /**
  44294. * Should auto-attach be disabled?
  44295. */
  44296. disableAutoAttach: boolean;
  44297. /**
  44298. * Attach the feature to the session
  44299. * Will usually be called by the features manager
  44300. *
  44301. * @param force should attachment be forced (even when already attached)
  44302. * @returns true if successful.
  44303. */
  44304. attach(force?: boolean): boolean;
  44305. /**
  44306. * Detach the feature from the session
  44307. * Will usually be called by the features manager
  44308. *
  44309. * @returns true if successful.
  44310. */
  44311. detach(): boolean;
  44312. }
  44313. /**
  44314. * A list of the currently available features without referencing them
  44315. */
  44316. export class WebXRFeatureName {
  44317. /**
  44318. * The name of the hit test feature
  44319. */
  44320. static HIT_TEST: string;
  44321. /**
  44322. * The name of the anchor system feature
  44323. */
  44324. static ANCHOR_SYSTEM: string;
  44325. /**
  44326. * The name of the background remover feature
  44327. */
  44328. static BACKGROUND_REMOVER: string;
  44329. /**
  44330. * The name of the pointer selection feature
  44331. */
  44332. static POINTER_SELECTION: string;
  44333. /**
  44334. * The name of the teleportation feature
  44335. */
  44336. static TELEPORTATION: string;
  44337. /**
  44338. * The name of the plane detection feature
  44339. */
  44340. static PLANE_DETECTION: string;
  44341. /**
  44342. * physics impostors for xr controllers feature
  44343. */
  44344. static PHYSICS_CONTROLLERS: string;
  44345. }
  44346. /**
  44347. * Defining the constructor of a feature. Used to register the modules.
  44348. */
  44349. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44350. /**
  44351. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44352. * It is mainly used in AR sessions.
  44353. *
  44354. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44355. */
  44356. export class WebXRFeaturesManager implements IDisposable {
  44357. private _xrSessionManager;
  44358. private static readonly _AvailableFeatures;
  44359. /**
  44360. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44361. * Mainly used internally.
  44362. *
  44363. * @param featureName the name of the feature to register
  44364. * @param constructorFunction the function used to construct the module
  44365. * @param version the (babylon) version of the module
  44366. * @param stable is that a stable version of this module
  44367. */
  44368. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44369. /**
  44370. * Returns a constructor of a specific feature.
  44371. *
  44372. * @param featureName the name of the feature to construct
  44373. * @param version the version of the feature to load
  44374. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44375. * @param options optional options provided to the module.
  44376. * @returns a function that, when called, will return a new instance of this feature
  44377. */
  44378. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44379. /**
  44380. * Return the latest unstable version of this feature
  44381. * @param featureName the name of the feature to search
  44382. * @returns the version number. if not found will return -1
  44383. */
  44384. static GetLatestVersionOfFeature(featureName: string): number;
  44385. /**
  44386. * Return the latest stable version of this feature
  44387. * @param featureName the name of the feature to search
  44388. * @returns the version number. if not found will return -1
  44389. */
  44390. static GetStableVersionOfFeature(featureName: string): number;
  44391. /**
  44392. * Can be used to return the list of features currently registered
  44393. *
  44394. * @returns an Array of available features
  44395. */
  44396. static GetAvailableFeatures(): string[];
  44397. /**
  44398. * Gets the versions available for a specific feature
  44399. * @param featureName the name of the feature
  44400. * @returns an array with the available versions
  44401. */
  44402. static GetAvailableVersions(featureName: string): string[];
  44403. private _features;
  44404. /**
  44405. * constructs a new features manages.
  44406. *
  44407. * @param _xrSessionManager an instance of WebXRSessionManager
  44408. */
  44409. constructor(_xrSessionManager: WebXRSessionManager);
  44410. /**
  44411. * 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.
  44412. * 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.
  44413. *
  44414. * @param featureName the name of the feature to load or the class of the feature
  44415. * @param version optional version to load. if not provided the latest version will be enabled
  44416. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44417. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44418. * @returns a new constructed feature or throws an error if feature not found.
  44419. */
  44420. enableFeature(featureName: string | {
  44421. Name: string;
  44422. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44423. /**
  44424. * Used to disable an already-enabled feature
  44425. * The feature will be disposed and will be recreated once enabled.
  44426. * @param featureName the feature to disable
  44427. * @returns true if disable was successful
  44428. */
  44429. disableFeature(featureName: string | {
  44430. Name: string;
  44431. }): boolean;
  44432. /**
  44433. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44434. * Can be used during a session to start a feature
  44435. * @param featureName the name of feature to attach
  44436. */
  44437. attachFeature(featureName: string): void;
  44438. /**
  44439. * Can be used inside a session or when the session ends to detach a specific feature
  44440. * @param featureName the name of the feature to detach
  44441. */
  44442. detachFeature(featureName: string): void;
  44443. /**
  44444. * Get the list of enabled features
  44445. * @returns an array of enabled features
  44446. */
  44447. getEnabledFeatures(): string[];
  44448. /**
  44449. * get the implementation of an enabled feature.
  44450. * @param featureName the name of the feature to load
  44451. * @returns the feature class, if found
  44452. */
  44453. getEnabledFeature(featureName: string): IWebXRFeature;
  44454. /**
  44455. * dispose this features manager
  44456. */
  44457. dispose(): void;
  44458. }
  44459. }
  44460. declare module "babylonjs/XR/webXRExperienceHelper" {
  44461. import { Observable } from "babylonjs/Misc/observable";
  44462. import { IDisposable, Scene } from "babylonjs/scene";
  44463. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44464. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44465. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44466. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44467. /**
  44468. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44469. * @see https://doc.babylonjs.com/how_to/webxr
  44470. */
  44471. export class WebXRExperienceHelper implements IDisposable {
  44472. private scene;
  44473. /**
  44474. * Camera used to render xr content
  44475. */
  44476. camera: WebXRCamera;
  44477. /**
  44478. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44479. */
  44480. state: WebXRState;
  44481. private _setState;
  44482. /**
  44483. * Fires when the state of the experience helper has changed
  44484. */
  44485. onStateChangedObservable: Observable<WebXRState>;
  44486. /**
  44487. * Observers registered here will be triggered after the camera's initial transformation is set
  44488. * This can be used to set a different ground level or an extra rotation.
  44489. *
  44490. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44491. * to the position set after this observable is done executing.
  44492. */
  44493. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44494. /** Session manager used to keep track of xr session */
  44495. sessionManager: WebXRSessionManager;
  44496. /** A features manager for this xr session */
  44497. featuresManager: WebXRFeaturesManager;
  44498. private _nonVRCamera;
  44499. private _originalSceneAutoClear;
  44500. private _supported;
  44501. /**
  44502. * Creates the experience helper
  44503. * @param scene the scene to attach the experience helper to
  44504. * @returns a promise for the experience helper
  44505. */
  44506. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44507. /**
  44508. * Creates a WebXRExperienceHelper
  44509. * @param scene The scene the helper should be created in
  44510. */
  44511. private constructor();
  44512. /**
  44513. * Exits XR mode and returns the scene to its original state
  44514. * @returns promise that resolves after xr mode has exited
  44515. */
  44516. exitXRAsync(): Promise<void>;
  44517. /**
  44518. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44519. * @param sessionMode options for the XR session
  44520. * @param referenceSpaceType frame of reference of the XR session
  44521. * @param renderTarget the output canvas that will be used to enter XR mode
  44522. * @returns promise that resolves after xr mode has entered
  44523. */
  44524. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44525. /**
  44526. * Disposes of the experience helper
  44527. */
  44528. dispose(): void;
  44529. private _nonXRToXRCamera;
  44530. }
  44531. }
  44532. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44533. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44534. import { Observable } from "babylonjs/Misc/observable";
  44535. import { IDisposable } from "babylonjs/scene";
  44536. /**
  44537. * X-Y values for axes in WebXR
  44538. */
  44539. export interface IWebXRMotionControllerAxesValue {
  44540. /**
  44541. * The value of the x axis
  44542. */
  44543. x: number;
  44544. /**
  44545. * The value of the y-axis
  44546. */
  44547. y: number;
  44548. }
  44549. /**
  44550. * changed / previous values for the values of this component
  44551. */
  44552. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44553. /**
  44554. * current (this frame) value
  44555. */
  44556. current: T;
  44557. /**
  44558. * previous (last change) value
  44559. */
  44560. previous: T;
  44561. }
  44562. /**
  44563. * Represents changes in the component between current frame and last values recorded
  44564. */
  44565. export interface IWebXRMotionControllerComponentChanges {
  44566. /**
  44567. * will be populated with previous and current values if touched changed
  44568. */
  44569. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44570. /**
  44571. * will be populated with previous and current values if pressed changed
  44572. */
  44573. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44574. /**
  44575. * will be populated with previous and current values if value changed
  44576. */
  44577. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44578. /**
  44579. * will be populated with previous and current values if axes changed
  44580. */
  44581. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44582. }
  44583. /**
  44584. * This class represents a single component (for example button or thumbstick) of a motion controller
  44585. */
  44586. export class WebXRControllerComponent implements IDisposable {
  44587. /**
  44588. * the id of this component
  44589. */
  44590. id: string;
  44591. /**
  44592. * the type of the component
  44593. */
  44594. type: MotionControllerComponentType;
  44595. private _buttonIndex;
  44596. private _axesIndices;
  44597. /**
  44598. * Thumbstick component type
  44599. */
  44600. static THUMBSTICK: MotionControllerComponentType;
  44601. /**
  44602. * Touchpad component type
  44603. */
  44604. static TOUCHPAD: MotionControllerComponentType;
  44605. /**
  44606. * trigger component type
  44607. */
  44608. static TRIGGER: MotionControllerComponentType;
  44609. /**
  44610. * squeeze component type
  44611. */
  44612. static SQUEEZE: MotionControllerComponentType;
  44613. /**
  44614. * button component type
  44615. */
  44616. static BUTTON: MotionControllerComponentType;
  44617. /**
  44618. * Observers registered here will be triggered when the state of a button changes
  44619. * State change is either pressed / touched / value
  44620. */
  44621. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44622. /**
  44623. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44624. * the axes data changes
  44625. */
  44626. onAxisValueChangedObservable: Observable<{
  44627. x: number;
  44628. y: number;
  44629. }>;
  44630. private _currentValue;
  44631. private _touched;
  44632. private _pressed;
  44633. private _axes;
  44634. private _changes;
  44635. private _hasChanges;
  44636. /**
  44637. * Return whether or not the component changed the last frame
  44638. */
  44639. get hasChanges(): boolean;
  44640. /**
  44641. * Creates a new component for a motion controller.
  44642. * It is created by the motion controller itself
  44643. *
  44644. * @param id the id of this component
  44645. * @param type the type of the component
  44646. * @param _buttonIndex index in the buttons array of the gamepad
  44647. * @param _axesIndices indices of the values in the axes array of the gamepad
  44648. */
  44649. constructor(
  44650. /**
  44651. * the id of this component
  44652. */
  44653. id: string,
  44654. /**
  44655. * the type of the component
  44656. */
  44657. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44658. /**
  44659. * Get the current value of this component
  44660. */
  44661. get value(): number;
  44662. /**
  44663. * is the button currently pressed
  44664. */
  44665. get pressed(): boolean;
  44666. /**
  44667. * is the button currently touched
  44668. */
  44669. get touched(): boolean;
  44670. /**
  44671. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44672. */
  44673. get axes(): IWebXRMotionControllerAxesValue;
  44674. /**
  44675. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44676. */
  44677. get changes(): IWebXRMotionControllerComponentChanges;
  44678. /**
  44679. * Is this component a button (hence - pressable)
  44680. * @returns true if can be pressed
  44681. */
  44682. isButton(): boolean;
  44683. /**
  44684. * Are there axes correlating to this component
  44685. * @return true is axes data is available
  44686. */
  44687. isAxes(): boolean;
  44688. /**
  44689. * update this component using the gamepad object it is in. Called on every frame
  44690. * @param nativeController the native gamepad controller object
  44691. */
  44692. update(nativeController: IMinimalMotionControllerObject): void;
  44693. /**
  44694. * Dispose this component
  44695. */
  44696. dispose(): void;
  44697. }
  44698. }
  44699. declare module "babylonjs/Loading/sceneLoader" {
  44700. import { Observable } from "babylonjs/Misc/observable";
  44701. import { Nullable } from "babylonjs/types";
  44702. import { Scene } from "babylonjs/scene";
  44703. import { Engine } from "babylonjs/Engines/engine";
  44704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44705. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44706. import { AssetContainer } from "babylonjs/assetContainer";
  44707. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44708. import { Skeleton } from "babylonjs/Bones/skeleton";
  44709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44710. import { WebRequest } from "babylonjs/Misc/webRequest";
  44711. /**
  44712. * Class used to represent data loading progression
  44713. */
  44714. export class SceneLoaderProgressEvent {
  44715. /** defines if data length to load can be evaluated */
  44716. readonly lengthComputable: boolean;
  44717. /** defines the loaded data length */
  44718. readonly loaded: number;
  44719. /** defines the data length to load */
  44720. readonly total: number;
  44721. /**
  44722. * Create a new progress event
  44723. * @param lengthComputable defines if data length to load can be evaluated
  44724. * @param loaded defines the loaded data length
  44725. * @param total defines the data length to load
  44726. */
  44727. constructor(
  44728. /** defines if data length to load can be evaluated */
  44729. lengthComputable: boolean,
  44730. /** defines the loaded data length */
  44731. loaded: number,
  44732. /** defines the data length to load */
  44733. total: number);
  44734. /**
  44735. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44736. * @param event defines the source event
  44737. * @returns a new SceneLoaderProgressEvent
  44738. */
  44739. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44740. }
  44741. /**
  44742. * Interface used by SceneLoader plugins to define supported file extensions
  44743. */
  44744. export interface ISceneLoaderPluginExtensions {
  44745. /**
  44746. * Defines the list of supported extensions
  44747. */
  44748. [extension: string]: {
  44749. isBinary: boolean;
  44750. };
  44751. }
  44752. /**
  44753. * Interface used by SceneLoader plugin factory
  44754. */
  44755. export interface ISceneLoaderPluginFactory {
  44756. /**
  44757. * Defines the name of the factory
  44758. */
  44759. name: string;
  44760. /**
  44761. * Function called to create a new plugin
  44762. * @return the new plugin
  44763. */
  44764. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44765. /**
  44766. * The callback that returns true if the data can be directly loaded.
  44767. * @param data string containing the file data
  44768. * @returns if the data can be loaded directly
  44769. */
  44770. canDirectLoad?(data: string): boolean;
  44771. }
  44772. /**
  44773. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44774. */
  44775. export interface ISceneLoaderPluginBase {
  44776. /**
  44777. * The friendly name of this plugin.
  44778. */
  44779. name: string;
  44780. /**
  44781. * The file extensions supported by this plugin.
  44782. */
  44783. extensions: string | ISceneLoaderPluginExtensions;
  44784. /**
  44785. * The callback called when loading from a url.
  44786. * @param scene scene loading this url
  44787. * @param url url to load
  44788. * @param onSuccess callback called when the file successfully loads
  44789. * @param onProgress callback called while file is loading (if the server supports this mode)
  44790. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44791. * @param onError callback called when the file fails to load
  44792. * @returns a file request object
  44793. */
  44794. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44795. /**
  44796. * The callback called when loading from a file object.
  44797. * @param scene scene loading this file
  44798. * @param file defines the file to load
  44799. * @param onSuccess defines the callback to call when data is loaded
  44800. * @param onProgress defines the callback to call during loading process
  44801. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44802. * @param onError defines the callback to call when an error occurs
  44803. * @returns a file request object
  44804. */
  44805. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44806. /**
  44807. * The callback that returns true if the data can be directly loaded.
  44808. * @param data string containing the file data
  44809. * @returns if the data can be loaded directly
  44810. */
  44811. canDirectLoad?(data: string): boolean;
  44812. /**
  44813. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44814. * @param scene scene loading this data
  44815. * @param data string containing the data
  44816. * @returns data to pass to the plugin
  44817. */
  44818. directLoad?(scene: Scene, data: string): any;
  44819. /**
  44820. * The callback that allows custom handling of the root url based on the response url.
  44821. * @param rootUrl the original root url
  44822. * @param responseURL the response url if available
  44823. * @returns the new root url
  44824. */
  44825. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44826. }
  44827. /**
  44828. * Interface used to define a SceneLoader plugin
  44829. */
  44830. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44831. /**
  44832. * Import meshes into a scene.
  44833. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44834. * @param scene The scene to import into
  44835. * @param data The data to import
  44836. * @param rootUrl The root url for scene and resources
  44837. * @param meshes The meshes array to import into
  44838. * @param particleSystems The particle systems array to import into
  44839. * @param skeletons The skeletons array to import into
  44840. * @param onError The callback when import fails
  44841. * @returns True if successful or false otherwise
  44842. */
  44843. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44844. /**
  44845. * Load into a scene.
  44846. * @param scene The scene to load into
  44847. * @param data The data to import
  44848. * @param rootUrl The root url for scene and resources
  44849. * @param onError The callback when import fails
  44850. * @returns True if successful or false otherwise
  44851. */
  44852. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44853. /**
  44854. * Load into an asset container.
  44855. * @param scene The scene to load into
  44856. * @param data The data to import
  44857. * @param rootUrl The root url for scene and resources
  44858. * @param onError The callback when import fails
  44859. * @returns The loaded asset container
  44860. */
  44861. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44862. }
  44863. /**
  44864. * Interface used to define an async SceneLoader plugin
  44865. */
  44866. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44867. /**
  44868. * Import meshes into a scene.
  44869. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44870. * @param scene The scene to import into
  44871. * @param data The data to import
  44872. * @param rootUrl The root url for scene and resources
  44873. * @param onProgress The callback when the load progresses
  44874. * @param fileName Defines the name of the file to load
  44875. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44876. */
  44877. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44878. meshes: AbstractMesh[];
  44879. particleSystems: IParticleSystem[];
  44880. skeletons: Skeleton[];
  44881. animationGroups: AnimationGroup[];
  44882. }>;
  44883. /**
  44884. * Load into a scene.
  44885. * @param scene The scene to load into
  44886. * @param data The data to import
  44887. * @param rootUrl The root url for scene and resources
  44888. * @param onProgress The callback when the load progresses
  44889. * @param fileName Defines the name of the file to load
  44890. * @returns Nothing
  44891. */
  44892. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44893. /**
  44894. * Load into an asset container.
  44895. * @param scene The scene to load into
  44896. * @param data The data to import
  44897. * @param rootUrl The root url for scene and resources
  44898. * @param onProgress The callback when the load progresses
  44899. * @param fileName Defines the name of the file to load
  44900. * @returns The loaded asset container
  44901. */
  44902. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44903. }
  44904. /**
  44905. * Mode that determines how to handle old animation groups before loading new ones.
  44906. */
  44907. export enum SceneLoaderAnimationGroupLoadingMode {
  44908. /**
  44909. * Reset all old animations to initial state then dispose them.
  44910. */
  44911. Clean = 0,
  44912. /**
  44913. * Stop all old animations.
  44914. */
  44915. Stop = 1,
  44916. /**
  44917. * Restart old animations from first frame.
  44918. */
  44919. Sync = 2,
  44920. /**
  44921. * Old animations remains untouched.
  44922. */
  44923. NoSync = 3
  44924. }
  44925. /**
  44926. * Class used to load scene from various file formats using registered plugins
  44927. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44928. */
  44929. export class SceneLoader {
  44930. /**
  44931. * No logging while loading
  44932. */
  44933. static readonly NO_LOGGING: number;
  44934. /**
  44935. * Minimal logging while loading
  44936. */
  44937. static readonly MINIMAL_LOGGING: number;
  44938. /**
  44939. * Summary logging while loading
  44940. */
  44941. static readonly SUMMARY_LOGGING: number;
  44942. /**
  44943. * Detailled logging while loading
  44944. */
  44945. static readonly DETAILED_LOGGING: number;
  44946. /**
  44947. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44948. */
  44949. static get ForceFullSceneLoadingForIncremental(): boolean;
  44950. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44951. /**
  44952. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44953. */
  44954. static get ShowLoadingScreen(): boolean;
  44955. static set ShowLoadingScreen(value: boolean);
  44956. /**
  44957. * Defines the current logging level (while loading the scene)
  44958. * @ignorenaming
  44959. */
  44960. static get loggingLevel(): number;
  44961. static set loggingLevel(value: number);
  44962. /**
  44963. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44964. */
  44965. static get CleanBoneMatrixWeights(): boolean;
  44966. static set CleanBoneMatrixWeights(value: boolean);
  44967. /**
  44968. * Event raised when a plugin is used to load a scene
  44969. */
  44970. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44971. private static _registeredPlugins;
  44972. private static _getDefaultPlugin;
  44973. private static _getPluginForExtension;
  44974. private static _getPluginForDirectLoad;
  44975. private static _getPluginForFilename;
  44976. private static _getDirectLoad;
  44977. private static _loadData;
  44978. private static _getFileInfo;
  44979. /**
  44980. * Gets a plugin that can load the given extension
  44981. * @param extension defines the extension to load
  44982. * @returns a plugin or null if none works
  44983. */
  44984. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44985. /**
  44986. * Gets a boolean indicating that the given extension can be loaded
  44987. * @param extension defines the extension to load
  44988. * @returns true if the extension is supported
  44989. */
  44990. static IsPluginForExtensionAvailable(extension: string): boolean;
  44991. /**
  44992. * Adds a new plugin to the list of registered plugins
  44993. * @param plugin defines the plugin to add
  44994. */
  44995. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44996. /**
  44997. * Import meshes into a scene
  44998. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44999. * @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)
  45000. * @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)
  45001. * @param scene the instance of BABYLON.Scene to append to
  45002. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45003. * @param onProgress a callback with a progress event for each file being loaded
  45004. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45005. * @param pluginExtension the extension used to determine the plugin
  45006. * @returns The loaded plugin
  45007. */
  45008. 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>;
  45009. /**
  45010. * Import meshes into a scene
  45011. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45012. * @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)
  45013. * @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)
  45014. * @param scene the instance of BABYLON.Scene to append to
  45015. * @param onProgress a callback with a progress event for each file being loaded
  45016. * @param pluginExtension the extension used to determine the plugin
  45017. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45018. */
  45019. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45020. meshes: AbstractMesh[];
  45021. particleSystems: IParticleSystem[];
  45022. skeletons: Skeleton[];
  45023. animationGroups: AnimationGroup[];
  45024. }>;
  45025. /**
  45026. * Load a scene
  45027. * @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)
  45028. * @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)
  45029. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45030. * @param onSuccess a callback with the scene when import succeeds
  45031. * @param onProgress a callback with a progress event for each file being loaded
  45032. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45033. * @param pluginExtension the extension used to determine the plugin
  45034. * @returns The loaded plugin
  45035. */
  45036. 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>;
  45037. /**
  45038. * Load a scene
  45039. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45040. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45041. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45042. * @param onProgress a callback with a progress event for each file being loaded
  45043. * @param pluginExtension the extension used to determine the plugin
  45044. * @returns The loaded scene
  45045. */
  45046. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45047. /**
  45048. * Append a scene
  45049. * @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)
  45050. * @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)
  45051. * @param scene is the instance of BABYLON.Scene to append to
  45052. * @param onSuccess a callback with the scene when import succeeds
  45053. * @param onProgress a callback with a progress event for each file being loaded
  45054. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45055. * @param pluginExtension the extension used to determine the plugin
  45056. * @returns The loaded plugin
  45057. */
  45058. 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>;
  45059. /**
  45060. * Append a scene
  45061. * @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)
  45062. * @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)
  45063. * @param scene is the instance of BABYLON.Scene to append to
  45064. * @param onProgress a callback with a progress event for each file being loaded
  45065. * @param pluginExtension the extension used to determine the plugin
  45066. * @returns The given scene
  45067. */
  45068. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45069. /**
  45070. * Load a scene into an asset container
  45071. * @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)
  45072. * @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)
  45073. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45074. * @param onSuccess a callback with the scene when import succeeds
  45075. * @param onProgress a callback with a progress event for each file being loaded
  45076. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45077. * @param pluginExtension the extension used to determine the plugin
  45078. * @returns The loaded plugin
  45079. */
  45080. 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>;
  45081. /**
  45082. * Load a scene into an asset container
  45083. * @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)
  45084. * @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)
  45085. * @param scene is the instance of Scene to append to
  45086. * @param onProgress a callback with a progress event for each file being loaded
  45087. * @param pluginExtension the extension used to determine the plugin
  45088. * @returns The loaded asset container
  45089. */
  45090. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45091. /**
  45092. * Import animations from a file into a scene
  45093. * @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)
  45094. * @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)
  45095. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45096. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45097. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45098. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45099. * @param onSuccess a callback with the scene when import succeeds
  45100. * @param onProgress a callback with a progress event for each file being loaded
  45101. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45102. */
  45103. 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;
  45104. /**
  45105. * Import animations from a file into a scene
  45106. * @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)
  45107. * @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)
  45108. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45109. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45110. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45111. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45112. * @param onSuccess a callback with the scene when import succeeds
  45113. * @param onProgress a callback with a progress event for each file being loaded
  45114. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45115. * @returns the updated scene with imported animations
  45116. */
  45117. 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>;
  45118. }
  45119. }
  45120. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45121. import { IDisposable, Scene } from "babylonjs/scene";
  45122. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45123. import { Observable } from "babylonjs/Misc/observable";
  45124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45125. import { Nullable } from "babylonjs/types";
  45126. /**
  45127. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45128. */
  45129. export type MotionControllerHandness = "none" | "left" | "right";
  45130. /**
  45131. * The type of components available in motion controllers.
  45132. * This is not the name of the component.
  45133. */
  45134. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45135. /**
  45136. * The state of a controller component
  45137. */
  45138. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45139. /**
  45140. * The schema of motion controller layout.
  45141. * No object will be initialized using this interface
  45142. * This is used just to define the profile.
  45143. */
  45144. export interface IMotionControllerLayout {
  45145. /**
  45146. * Defines the main button component id
  45147. */
  45148. selectComponentId: string;
  45149. /**
  45150. * Available components (unsorted)
  45151. */
  45152. components: {
  45153. /**
  45154. * A map of component Ids
  45155. */
  45156. [componentId: string]: {
  45157. /**
  45158. * The type of input the component outputs
  45159. */
  45160. type: MotionControllerComponentType;
  45161. /**
  45162. * The indices of this component in the gamepad object
  45163. */
  45164. gamepadIndices: {
  45165. /**
  45166. * Index of button
  45167. */
  45168. button?: number;
  45169. /**
  45170. * If available, index of x-axis
  45171. */
  45172. xAxis?: number;
  45173. /**
  45174. * If available, index of y-axis
  45175. */
  45176. yAxis?: number;
  45177. };
  45178. /**
  45179. * The mesh's root node name
  45180. */
  45181. rootNodeName: string;
  45182. /**
  45183. * Animation definitions for this model
  45184. */
  45185. visualResponses: {
  45186. [stateKey: string]: {
  45187. /**
  45188. * What property will be animated
  45189. */
  45190. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45191. /**
  45192. * What states influence this visual reponse
  45193. */
  45194. states: MotionControllerComponentStateType[];
  45195. /**
  45196. * Type of animation - movement or visibility
  45197. */
  45198. valueNodeProperty: "transform" | "visibility";
  45199. /**
  45200. * Base node name to move. Its position will be calculated according to the min and max nodes
  45201. */
  45202. valueNodeName?: string;
  45203. /**
  45204. * Minimum movement node
  45205. */
  45206. minNodeName?: string;
  45207. /**
  45208. * Max movement node
  45209. */
  45210. maxNodeName?: string;
  45211. };
  45212. };
  45213. /**
  45214. * If touch enabled, what is the name of node to display user feedback
  45215. */
  45216. touchPointNodeName?: string;
  45217. };
  45218. };
  45219. /**
  45220. * Is it xr standard mapping or not
  45221. */
  45222. gamepadMapping: "" | "xr-standard";
  45223. /**
  45224. * Base root node of this entire model
  45225. */
  45226. rootNodeName: string;
  45227. /**
  45228. * Path to load the assets. Usually relative to the base path
  45229. */
  45230. assetPath: string;
  45231. }
  45232. /**
  45233. * A definition for the layout map in the input profile
  45234. */
  45235. export interface IMotionControllerLayoutMap {
  45236. /**
  45237. * Layouts with handness type as a key
  45238. */
  45239. [handness: string]: IMotionControllerLayout;
  45240. }
  45241. /**
  45242. * The XR Input profile schema
  45243. * Profiles can be found here:
  45244. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45245. */
  45246. export interface IMotionControllerProfile {
  45247. /**
  45248. * The id of this profile
  45249. * correlates to the profile(s) in the xrInput.profiles array
  45250. */
  45251. profileId: string;
  45252. /**
  45253. * fallback profiles for this profileId
  45254. */
  45255. fallbackProfileIds: string[];
  45256. /**
  45257. * The layout map, with handness as key
  45258. */
  45259. layouts: IMotionControllerLayoutMap;
  45260. }
  45261. /**
  45262. * A helper-interface for the 3 meshes needed for controller button animation
  45263. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45264. */
  45265. export interface IMotionControllerButtonMeshMap {
  45266. /**
  45267. * The mesh that will be changed when value changes
  45268. */
  45269. valueMesh: AbstractMesh;
  45270. /**
  45271. * the mesh that defines the pressed value mesh position.
  45272. * This is used to find the max-position of this button
  45273. */
  45274. pressedMesh: AbstractMesh;
  45275. /**
  45276. * the mesh that defines the unpressed value mesh position.
  45277. * This is used to find the min (or initial) position of this button
  45278. */
  45279. unpressedMesh: AbstractMesh;
  45280. }
  45281. /**
  45282. * A helper-interface for the 3 meshes needed for controller axis animation.
  45283. * This will be expanded when touchpad animations are fully supported
  45284. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45285. */
  45286. export interface IMotionControllerMeshMap {
  45287. /**
  45288. * The mesh that will be changed when axis value changes
  45289. */
  45290. valueMesh: AbstractMesh;
  45291. /**
  45292. * the mesh that defines the minimum value mesh position.
  45293. */
  45294. minMesh?: AbstractMesh;
  45295. /**
  45296. * the mesh that defines the maximum value mesh position.
  45297. */
  45298. maxMesh?: AbstractMesh;
  45299. }
  45300. /**
  45301. * The elements needed for change-detection of the gamepad objects in motion controllers
  45302. */
  45303. export interface IMinimalMotionControllerObject {
  45304. /**
  45305. * An array of available buttons
  45306. */
  45307. buttons: Array<{
  45308. /**
  45309. * Value of the button/trigger
  45310. */
  45311. value: number;
  45312. /**
  45313. * If the button/trigger is currently touched
  45314. */
  45315. touched: boolean;
  45316. /**
  45317. * If the button/trigger is currently pressed
  45318. */
  45319. pressed: boolean;
  45320. }>;
  45321. /**
  45322. * Available axes of this controller
  45323. */
  45324. axes: number[];
  45325. }
  45326. /**
  45327. * An Abstract Motion controller
  45328. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45329. * Each component has an observable to check for changes in value and state
  45330. */
  45331. export abstract class WebXRAbstractMotionController implements IDisposable {
  45332. protected scene: Scene;
  45333. protected layout: IMotionControllerLayout;
  45334. /**
  45335. * The gamepad object correlating to this controller
  45336. */
  45337. gamepadObject: IMinimalMotionControllerObject;
  45338. /**
  45339. * handness (left/right/none) of this controller
  45340. */
  45341. handness: MotionControllerHandness;
  45342. /**
  45343. * The profile id of this motion controller
  45344. */
  45345. abstract profileId: string;
  45346. /**
  45347. * A map of components (WebXRControllerComponent) in this motion controller
  45348. * Components have a ComponentType and can also have both button and axis definitions
  45349. */
  45350. readonly components: {
  45351. [id: string]: WebXRControllerComponent;
  45352. };
  45353. /**
  45354. * Observers registered here will be triggered when the model of this controller is done loading
  45355. */
  45356. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45357. /**
  45358. * The root mesh of the model. It is null if the model was not yet initialized
  45359. */
  45360. rootMesh: Nullable<AbstractMesh>;
  45361. /**
  45362. * Disable the model's animation. Can be set at any time.
  45363. */
  45364. disableAnimation: boolean;
  45365. private _modelReady;
  45366. /**
  45367. * constructs a new abstract motion controller
  45368. * @param scene the scene to which the model of the controller will be added
  45369. * @param layout The profile layout to load
  45370. * @param gamepadObject The gamepad object correlating to this controller
  45371. * @param handness handness (left/right/none) of this controller
  45372. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45373. */
  45374. constructor(scene: Scene, layout: IMotionControllerLayout,
  45375. /**
  45376. * The gamepad object correlating to this controller
  45377. */
  45378. gamepadObject: IMinimalMotionControllerObject,
  45379. /**
  45380. * handness (left/right/none) of this controller
  45381. */
  45382. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45383. private _initComponent;
  45384. /**
  45385. * Update this model using the current XRFrame
  45386. * @param xrFrame the current xr frame to use and update the model
  45387. */
  45388. updateFromXRFrame(xrFrame: XRFrame): void;
  45389. /**
  45390. * Get the list of components available in this motion controller
  45391. * @returns an array of strings correlating to available components
  45392. */
  45393. getComponentIds(): string[];
  45394. /**
  45395. * Get the main (Select) component of this controller as defined in the layout
  45396. * @returns the main component of this controller
  45397. */
  45398. getMainComponent(): WebXRControllerComponent;
  45399. /**
  45400. * get a component based an its component id as defined in layout.components
  45401. * @param id the id of the component
  45402. * @returns the component correlates to the id or undefined if not found
  45403. */
  45404. getComponent(id: string): WebXRControllerComponent;
  45405. /**
  45406. * Get the first component of specific type
  45407. * @param type type of component to find
  45408. * @return a controller component or null if not found
  45409. */
  45410. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45411. /**
  45412. * Returns all components of specific type
  45413. * @param type the type to search for
  45414. * @return an array of components with this type
  45415. */
  45416. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45417. /**
  45418. * Loads the model correlating to this controller
  45419. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45420. * @returns A promise fulfilled with the result of the model loading
  45421. */
  45422. loadModel(): Promise<boolean>;
  45423. /**
  45424. * Update the model itself with the current frame data
  45425. * @param xrFrame the frame to use for updating the model mesh
  45426. */
  45427. protected updateModel(xrFrame: XRFrame): void;
  45428. /**
  45429. * Moves the axis on the controller mesh based on its current state
  45430. * @param axis the index of the axis
  45431. * @param axisValue the value of the axis which determines the meshes new position
  45432. * @hidden
  45433. */
  45434. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45435. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45436. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45437. private _getGenericFilenameAndPath;
  45438. private _getGenericParentMesh;
  45439. /**
  45440. * Get the filename and path for this controller's model
  45441. * @returns a map of filename and path
  45442. */
  45443. protected abstract _getFilenameAndPath(): {
  45444. filename: string;
  45445. path: string;
  45446. };
  45447. /**
  45448. * This function will be called after the model was successfully loaded and can be used
  45449. * for mesh transformations before it is available for the user
  45450. * @param meshes the loaded meshes
  45451. */
  45452. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45453. /**
  45454. * Set the root mesh for this controller. Important for the WebXR controller class
  45455. * @param meshes the loaded meshes
  45456. */
  45457. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45458. /**
  45459. * A function executed each frame that updates the mesh (if needed)
  45460. * @param xrFrame the current xrFrame
  45461. */
  45462. protected abstract _updateModel(xrFrame: XRFrame): void;
  45463. /**
  45464. * This function is called before the mesh is loaded. It checks for loading constraints.
  45465. * For example, this function can check if the GLB loader is available
  45466. * If this function returns false, the generic controller will be loaded instead
  45467. * @returns Is the client ready to load the mesh
  45468. */
  45469. protected abstract _getModelLoadingConstraints(): boolean;
  45470. /**
  45471. * Dispose this controller, the model mesh and all its components
  45472. */
  45473. dispose(): void;
  45474. }
  45475. }
  45476. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45477. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45479. import { Scene } from "babylonjs/scene";
  45480. /**
  45481. * A generic trigger-only motion controller for WebXR
  45482. */
  45483. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45484. /**
  45485. * Static version of the profile id of this controller
  45486. */
  45487. static ProfileId: string;
  45488. profileId: string;
  45489. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45490. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45491. protected _updateModel(): void;
  45492. protected _getFilenameAndPath(): {
  45493. filename: string;
  45494. path: string;
  45495. };
  45496. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45497. protected _getModelLoadingConstraints(): boolean;
  45498. }
  45499. }
  45500. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45501. import { Vector4 } from "babylonjs/Maths/math.vector";
  45502. import { Mesh } from "babylonjs/Meshes/mesh";
  45503. import { Scene } from "babylonjs/scene";
  45504. import { Nullable } from "babylonjs/types";
  45505. /**
  45506. * Class containing static functions to help procedurally build meshes
  45507. */
  45508. export class SphereBuilder {
  45509. /**
  45510. * Creates a sphere mesh
  45511. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45512. * * 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`)
  45513. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45514. * * 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
  45515. * * 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)
  45516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45519. * @param name defines the name of the mesh
  45520. * @param options defines the options used to create the mesh
  45521. * @param scene defines the hosting scene
  45522. * @returns the sphere mesh
  45523. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45524. */
  45525. static CreateSphere(name: string, options: {
  45526. segments?: number;
  45527. diameter?: number;
  45528. diameterX?: number;
  45529. diameterY?: number;
  45530. diameterZ?: number;
  45531. arc?: number;
  45532. slice?: number;
  45533. sideOrientation?: number;
  45534. frontUVs?: Vector4;
  45535. backUVs?: Vector4;
  45536. updatable?: boolean;
  45537. }, scene?: Nullable<Scene>): Mesh;
  45538. }
  45539. }
  45540. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45542. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45543. import { Scene } from "babylonjs/scene";
  45544. /**
  45545. * A profiled motion controller has its profile loaded from an online repository.
  45546. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45547. */
  45548. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45549. private _repositoryUrl;
  45550. /**
  45551. * The profile ID of this controller. Will be populated when the controller initializes.
  45552. */
  45553. profileId: string;
  45554. private _buttonMeshMapping;
  45555. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45556. protected _getFilenameAndPath(): {
  45557. filename: string;
  45558. path: string;
  45559. };
  45560. private _touchDots;
  45561. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45562. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45563. protected _updateModel(_xrFrame: XRFrame): void;
  45564. protected _getModelLoadingConstraints(): boolean;
  45565. dispose(): void;
  45566. }
  45567. }
  45568. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45569. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45570. import { Scene } from "babylonjs/scene";
  45571. /**
  45572. * A construction function type to create a new controller based on an xrInput object
  45573. */
  45574. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45575. /**
  45576. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45577. *
  45578. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45579. * it should be replaced with auto-loaded controllers.
  45580. *
  45581. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45582. */
  45583. export class WebXRMotionControllerManager {
  45584. /**
  45585. * The base URL of the online controller repository. Can be changed at any time.
  45586. */
  45587. static BaseRepositoryUrl: string;
  45588. /**
  45589. * Use the online repository, or use only locally-defined controllers
  45590. */
  45591. static UseOnlineRepository: boolean;
  45592. /**
  45593. * Which repository gets priority - local or online
  45594. */
  45595. static PrioritizeOnlineRepository: boolean;
  45596. private static _AvailableControllers;
  45597. private static _Fallbacks;
  45598. /**
  45599. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45600. *
  45601. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45602. *
  45603. * @param type the profile type to register
  45604. * @param constructFunction the function to be called when loading this profile
  45605. */
  45606. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45607. /**
  45608. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45609. * The order of search:
  45610. *
  45611. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45612. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45613. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45614. * 4) return the generic trigger controller if none were found
  45615. *
  45616. * @param xrInput the xrInput to which a new controller is initialized
  45617. * @param scene the scene to which the model will be added
  45618. * @param forceProfile force a certain profile for this controller
  45619. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45620. */
  45621. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45622. private static _LoadProfilesFromAvailableControllers;
  45623. private static _ProfilesList;
  45624. private static _ProfileLoadingPromises;
  45625. private static _LoadProfileFromRepository;
  45626. /**
  45627. * Clear the cache used for profile loading and reload when requested again
  45628. */
  45629. static ClearProfilesCache(): void;
  45630. /**
  45631. * Will update the list of profiles available in the repository
  45632. * @return a promise that resolves to a map of profiles available online
  45633. */
  45634. static UpdateProfilesList(): Promise<{
  45635. [profile: string]: string;
  45636. }>;
  45637. /**
  45638. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45639. * @param profileId the profile to which a fallback needs to be found
  45640. * @return an array with corresponding fallback profiles
  45641. */
  45642. static FindFallbackWithProfileId(profileId: string): string[];
  45643. /**
  45644. * Register a fallback to a specific profile.
  45645. * @param profileId the profileId that will receive the fallbacks
  45646. * @param fallbacks A list of fallback profiles
  45647. */
  45648. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45649. /**
  45650. * Register the default fallbacks.
  45651. * This function is called automatically when this file is imported.
  45652. */
  45653. static DefaultFallbacks(): void;
  45654. }
  45655. }
  45656. declare module "babylonjs/XR/webXRInputSource" {
  45657. import { Observable } from "babylonjs/Misc/observable";
  45658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45659. import { Ray } from "babylonjs/Culling/ray";
  45660. import { Scene } from "babylonjs/scene";
  45661. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45662. /**
  45663. * Configuration options for the WebXR controller creation
  45664. */
  45665. export interface IWebXRControllerOptions {
  45666. /**
  45667. * Force a specific controller type for this controller.
  45668. * This can be used when creating your own profile or when testing different controllers
  45669. */
  45670. forceControllerProfile?: string;
  45671. /**
  45672. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45673. */
  45674. doNotLoadControllerMesh?: boolean;
  45675. /**
  45676. * Should the controller mesh be animated when a user interacts with it
  45677. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45678. */
  45679. disableMotionControllerAnimation?: boolean;
  45680. }
  45681. /**
  45682. * Represents an XR controller
  45683. */
  45684. export class WebXRInputSource {
  45685. private _scene;
  45686. /** The underlying input source for the controller */
  45687. inputSource: XRInputSource;
  45688. private _options;
  45689. /**
  45690. * 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
  45691. */
  45692. grip?: AbstractMesh;
  45693. /**
  45694. * Pointer which can be used to select objects or attach a visible laser to
  45695. */
  45696. pointer: AbstractMesh;
  45697. /**
  45698. * If available, this is the gamepad object related to this controller.
  45699. * Using this object it is possible to get click events and trackpad changes of the
  45700. * webxr controller that is currently being used.
  45701. */
  45702. motionController?: WebXRAbstractMotionController;
  45703. /**
  45704. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45705. */
  45706. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45707. /**
  45708. * Will be triggered when the mesh associated with the motion controller is done loading.
  45709. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45710. * A shortened version of controller -> motion controller -> on mesh loaded.
  45711. */
  45712. onMeshLoadedObservable: Observable<AbstractMesh>;
  45713. /**
  45714. * Event that fires when the controller is removed/disposed.
  45715. * The object provided as event data is this controller, after associated assets were disposed.
  45716. * uniqueId is still available.
  45717. */
  45718. onDisposeObservable: Observable<WebXRInputSource>;
  45719. private _tmpQuaternion;
  45720. private _tmpVector;
  45721. private _uniqueId;
  45722. /**
  45723. * Creates the controller
  45724. * @see https://doc.babylonjs.com/how_to/webxr
  45725. * @param _scene the scene which the controller should be associated to
  45726. * @param inputSource the underlying input source for the controller
  45727. * @param _options options for this controller creation
  45728. */
  45729. constructor(_scene: Scene,
  45730. /** The underlying input source for the controller */
  45731. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45732. /**
  45733. * Get this controllers unique id
  45734. */
  45735. get uniqueId(): string;
  45736. /**
  45737. * Updates the controller pose based on the given XRFrame
  45738. * @param xrFrame xr frame to update the pose with
  45739. * @param referenceSpace reference space to use
  45740. */
  45741. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45742. /**
  45743. * Gets a world space ray coming from the pointer or grip
  45744. * @param result the resulting ray
  45745. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45746. */
  45747. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45748. /**
  45749. * Disposes of the object
  45750. */
  45751. dispose(): void;
  45752. }
  45753. }
  45754. declare module "babylonjs/XR/webXRInput" {
  45755. import { Observable } from "babylonjs/Misc/observable";
  45756. import { IDisposable } from "babylonjs/scene";
  45757. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45758. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45759. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45760. /**
  45761. * The schema for initialization options of the XR Input class
  45762. */
  45763. export interface IWebXRInputOptions {
  45764. /**
  45765. * If set to true no model will be automatically loaded
  45766. */
  45767. doNotLoadControllerMeshes?: boolean;
  45768. /**
  45769. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45770. * If not found, the xr input profile data will be used.
  45771. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45772. */
  45773. forceInputProfile?: string;
  45774. /**
  45775. * Do not send a request to the controlle repository to load the profile.
  45776. *
  45777. * Instead, use the controllers available in babylon itself.
  45778. */
  45779. disableOnlineControllerRepository?: boolean;
  45780. /**
  45781. * A custom URL for the controllers repository
  45782. */
  45783. customControllersRepositoryURL?: string;
  45784. /**
  45785. * Should the controller model's components not move according to the user input
  45786. */
  45787. disableControllerAnimation?: boolean;
  45788. }
  45789. /**
  45790. * XR input used to track XR inputs such as controllers/rays
  45791. */
  45792. export class WebXRInput implements IDisposable {
  45793. /**
  45794. * the xr session manager for this session
  45795. */
  45796. xrSessionManager: WebXRSessionManager;
  45797. /**
  45798. * the WebXR camera for this session. Mainly used for teleportation
  45799. */
  45800. xrCamera: WebXRCamera;
  45801. private readonly options;
  45802. /**
  45803. * XR controllers being tracked
  45804. */
  45805. controllers: Array<WebXRInputSource>;
  45806. private _frameObserver;
  45807. private _sessionEndedObserver;
  45808. private _sessionInitObserver;
  45809. /**
  45810. * Event when a controller has been connected/added
  45811. */
  45812. onControllerAddedObservable: Observable<WebXRInputSource>;
  45813. /**
  45814. * Event when a controller has been removed/disconnected
  45815. */
  45816. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45817. /**
  45818. * Initializes the WebXRInput
  45819. * @param xrSessionManager the xr session manager for this session
  45820. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45821. * @param options = initialization options for this xr input
  45822. */
  45823. constructor(
  45824. /**
  45825. * the xr session manager for this session
  45826. */
  45827. xrSessionManager: WebXRSessionManager,
  45828. /**
  45829. * the WebXR camera for this session. Mainly used for teleportation
  45830. */
  45831. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45832. private _onInputSourcesChange;
  45833. private _addAndRemoveControllers;
  45834. /**
  45835. * Disposes of the object
  45836. */
  45837. dispose(): void;
  45838. }
  45839. }
  45840. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45841. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45842. import { Observable, EventState } from "babylonjs/Misc/observable";
  45843. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45844. /**
  45845. * This is the base class for all WebXR features.
  45846. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45847. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45848. */
  45849. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45850. protected _xrSessionManager: WebXRSessionManager;
  45851. /**
  45852. * Construct a new (abstract) webxr feature
  45853. * @param _xrSessionManager the xr session manager for this feature
  45854. */
  45855. constructor(_xrSessionManager: WebXRSessionManager);
  45856. private _attached;
  45857. private _removeOnDetach;
  45858. /**
  45859. * Is this feature attached
  45860. */
  45861. get attached(): boolean;
  45862. /**
  45863. * Should auto-attach be disabled?
  45864. */
  45865. disableAutoAttach: boolean;
  45866. /**
  45867. * attach this feature
  45868. *
  45869. * @param force should attachment be forced (even when already attached)
  45870. * @returns true if successful, false is failed or already attached
  45871. */
  45872. attach(force?: boolean): boolean;
  45873. /**
  45874. * detach this feature.
  45875. *
  45876. * @returns true if successful, false if failed or already detached
  45877. */
  45878. detach(): boolean;
  45879. /**
  45880. * Dispose this feature and all of the resources attached
  45881. */
  45882. dispose(): void;
  45883. /**
  45884. * Code in this function will be executed on each xrFrame received from the browser.
  45885. * This function will not execute after the feature is detached.
  45886. * @param _xrFrame the current frame
  45887. */
  45888. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45889. /**
  45890. * This is used to register callbacks that will automatically be removed when detach is called.
  45891. * @param observable the observable to which the observer will be attached
  45892. * @param callback the callback to register
  45893. */
  45894. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45895. }
  45896. }
  45897. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45898. import { IDisposable, Scene } from "babylonjs/scene";
  45899. import { Nullable } from "babylonjs/types";
  45900. import { Observable } from "babylonjs/Misc/observable";
  45901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45902. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45903. import { Camera } from "babylonjs/Cameras/camera";
  45904. /**
  45905. * Renders a layer on top of an existing scene
  45906. */
  45907. export class UtilityLayerRenderer implements IDisposable {
  45908. /** the original scene that will be rendered on top of */
  45909. originalScene: Scene;
  45910. private _pointerCaptures;
  45911. private _lastPointerEvents;
  45912. private static _DefaultUtilityLayer;
  45913. private static _DefaultKeepDepthUtilityLayer;
  45914. private _sharedGizmoLight;
  45915. private _renderCamera;
  45916. /**
  45917. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45918. * @returns the camera that is used when rendering the utility layer
  45919. */
  45920. getRenderCamera(): Camera;
  45921. /**
  45922. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45923. * @param cam the camera that should be used when rendering the utility layer
  45924. */
  45925. setRenderCamera(cam: Nullable<Camera>): void;
  45926. /**
  45927. * @hidden
  45928. * Light which used by gizmos to get light shading
  45929. */
  45930. _getSharedGizmoLight(): HemisphericLight;
  45931. /**
  45932. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45933. */
  45934. pickUtilitySceneFirst: boolean;
  45935. /**
  45936. * 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)
  45937. */
  45938. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45939. /**
  45940. * 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)
  45941. */
  45942. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45943. /**
  45944. * The scene that is rendered on top of the original scene
  45945. */
  45946. utilityLayerScene: Scene;
  45947. /**
  45948. * If the utility layer should automatically be rendered on top of existing scene
  45949. */
  45950. shouldRender: boolean;
  45951. /**
  45952. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45953. */
  45954. onlyCheckPointerDownEvents: boolean;
  45955. /**
  45956. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45957. */
  45958. processAllEvents: boolean;
  45959. /**
  45960. * Observable raised when the pointer move from the utility layer scene to the main scene
  45961. */
  45962. onPointerOutObservable: Observable<number>;
  45963. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45964. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45965. private _afterRenderObserver;
  45966. private _sceneDisposeObserver;
  45967. private _originalPointerObserver;
  45968. /**
  45969. * Instantiates a UtilityLayerRenderer
  45970. * @param originalScene the original scene that will be rendered on top of
  45971. * @param handleEvents boolean indicating if the utility layer should handle events
  45972. */
  45973. constructor(
  45974. /** the original scene that will be rendered on top of */
  45975. originalScene: Scene, handleEvents?: boolean);
  45976. private _notifyObservers;
  45977. /**
  45978. * Renders the utility layers scene on top of the original scene
  45979. */
  45980. render(): void;
  45981. /**
  45982. * Disposes of the renderer
  45983. */
  45984. dispose(): void;
  45985. private _updateCamera;
  45986. }
  45987. }
  45988. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45989. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45990. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45991. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45992. import { Scene } from "babylonjs/scene";
  45993. import { Nullable } from "babylonjs/types";
  45994. import { Color3 } from "babylonjs/Maths/math.color";
  45995. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45996. /**
  45997. * Options interface for the pointer selection module
  45998. */
  45999. export interface IWebXRControllerPointerSelectionOptions {
  46000. /**
  46001. * the xr input to use with this pointer selection
  46002. */
  46003. xrInput: WebXRInput;
  46004. /**
  46005. * Different button type to use instead of the main component
  46006. */
  46007. overrideButtonId?: string;
  46008. /**
  46009. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46010. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46011. * 3000 means 3 seconds between pointing at something and selecting it
  46012. */
  46013. timeToSelect?: number;
  46014. /**
  46015. * 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)
  46016. * If not disabled, the last picked point will be used to execute a pointer up event
  46017. * If disabled, pointer up event will be triggered right after the pointer down event.
  46018. * Used in screen and gaze target ray mode only
  46019. */
  46020. disablePointerUpOnTouchOut: boolean;
  46021. /**
  46022. * For gaze mode (time to select instead of press)
  46023. */
  46024. forceGazeMode: boolean;
  46025. /**
  46026. * 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
  46027. * to start a new countdown to the pointer down event.
  46028. * Defaults to 1.
  46029. */
  46030. gazeModePointerMovedFactor?: number;
  46031. /**
  46032. * Should meshes created here be added to a utility layer or the main scene
  46033. */
  46034. useUtilityLayer?: boolean;
  46035. /**
  46036. * if provided, this scene will be used to render meshes.
  46037. */
  46038. customUtilityLayerScene?: Scene;
  46039. }
  46040. /**
  46041. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46042. */
  46043. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46044. private readonly _options;
  46045. /**
  46046. * The module's name
  46047. */
  46048. static readonly Name: string;
  46049. /**
  46050. * The (Babylon) version of this module.
  46051. * This is an integer representing the implementation version.
  46052. * This number does not correspond to the webxr specs version
  46053. */
  46054. static readonly Version: number;
  46055. /**
  46056. * This color will be set to the laser pointer when selection is triggered
  46057. */
  46058. laserPointerPickedColor: Color3;
  46059. /**
  46060. * This color will be applied to the selection ring when selection is triggered
  46061. */
  46062. selectionMeshPickedColor: Color3;
  46063. /**
  46064. * default color of the selection ring
  46065. */
  46066. selectionMeshDefaultColor: Color3;
  46067. /**
  46068. * Default color of the laser pointer
  46069. */
  46070. lasterPointerDefaultColor: Color3;
  46071. /**
  46072. * Should the laser pointer be displayed
  46073. */
  46074. displayLaserPointer: boolean;
  46075. /**
  46076. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46077. */
  46078. displaySelectionMesh: boolean;
  46079. /**
  46080. * Disable lighting on the laser pointer (so it will always be visible)
  46081. */
  46082. disablePointerLighting: boolean;
  46083. /**
  46084. * Disable lighting on the selection mesh (so it will always be visible)
  46085. */
  46086. disableSelectionMeshLighting: boolean;
  46087. private static _idCounter;
  46088. private _tmpRay;
  46089. private _controllers;
  46090. private _scene;
  46091. /**
  46092. * constructs a new background remover module
  46093. * @param _xrSessionManager the session manager for this module
  46094. * @param _options read-only options to be used in this module
  46095. */
  46096. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46097. /**
  46098. * attach this feature
  46099. * Will usually be called by the features manager
  46100. *
  46101. * @returns true if successful.
  46102. */
  46103. attach(): boolean;
  46104. /**
  46105. * detach this feature.
  46106. * Will usually be called by the features manager
  46107. *
  46108. * @returns true if successful.
  46109. */
  46110. detach(): boolean;
  46111. /**
  46112. * Get the xr controller that correlates to the pointer id in the pointer event
  46113. *
  46114. * @param id the pointer id to search for
  46115. * @returns the controller that correlates to this id or null if not found
  46116. */
  46117. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46118. protected _onXRFrame(_xrFrame: XRFrame): void;
  46119. private _attachController;
  46120. private _attachScreenRayMode;
  46121. private _attachGazeMode;
  46122. private _tmpVectorForPickCompare;
  46123. private _pickingMoved;
  46124. private _attachTrackedPointerRayMode;
  46125. private _detachController;
  46126. private _generateNewMeshPair;
  46127. private _convertNormalToDirectionOfRay;
  46128. private _updatePointerDistance;
  46129. }
  46130. }
  46131. declare module "babylonjs/XR/webXREnterExitUI" {
  46132. import { Nullable } from "babylonjs/types";
  46133. import { Observable } from "babylonjs/Misc/observable";
  46134. import { IDisposable, Scene } from "babylonjs/scene";
  46135. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46136. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46137. /**
  46138. * Button which can be used to enter a different mode of XR
  46139. */
  46140. export class WebXREnterExitUIButton {
  46141. /** button element */
  46142. element: HTMLElement;
  46143. /** XR initialization options for the button */
  46144. sessionMode: XRSessionMode;
  46145. /** Reference space type */
  46146. referenceSpaceType: XRReferenceSpaceType;
  46147. /**
  46148. * Creates a WebXREnterExitUIButton
  46149. * @param element button element
  46150. * @param sessionMode XR initialization session mode
  46151. * @param referenceSpaceType the type of reference space to be used
  46152. */
  46153. constructor(
  46154. /** button element */
  46155. element: HTMLElement,
  46156. /** XR initialization options for the button */
  46157. sessionMode: XRSessionMode,
  46158. /** Reference space type */
  46159. referenceSpaceType: XRReferenceSpaceType);
  46160. /**
  46161. * Overwritable function which can be used to update the button's visuals when the state changes
  46162. * @param activeButton the current active button in the UI
  46163. */
  46164. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46165. }
  46166. /**
  46167. * Options to create the webXR UI
  46168. */
  46169. export class WebXREnterExitUIOptions {
  46170. /**
  46171. * Context to enter xr with
  46172. */
  46173. renderTarget?: Nullable<WebXRRenderTarget>;
  46174. /**
  46175. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46176. */
  46177. customButtons?: Array<WebXREnterExitUIButton>;
  46178. /**
  46179. * A session mode to use when creating the default button.
  46180. * Default is immersive-vr
  46181. */
  46182. sessionMode?: XRSessionMode;
  46183. /**
  46184. * A reference space type to use when creating the default button.
  46185. * Default is local-floor
  46186. */
  46187. referenceSpaceType?: XRReferenceSpaceType;
  46188. }
  46189. /**
  46190. * UI to allow the user to enter/exit XR mode
  46191. */
  46192. export class WebXREnterExitUI implements IDisposable {
  46193. private scene;
  46194. /** version of the options passed to this UI */
  46195. options: WebXREnterExitUIOptions;
  46196. private _overlay;
  46197. private _buttons;
  46198. private _activeButton;
  46199. /**
  46200. * Fired every time the active button is changed.
  46201. *
  46202. * When xr is entered via a button that launches xr that button will be the callback parameter
  46203. *
  46204. * When exiting xr the callback parameter will be null)
  46205. */
  46206. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46207. /**
  46208. * Creates UI to allow the user to enter/exit XR mode
  46209. * @param scene the scene to add the ui to
  46210. * @param helper the xr experience helper to enter/exit xr with
  46211. * @param options options to configure the UI
  46212. * @returns the created ui
  46213. */
  46214. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46215. /**
  46216. *
  46217. * @param scene babylon scene object to use
  46218. * @param options (read-only) version of the options passed to this UI
  46219. */
  46220. private constructor();
  46221. private _updateButtons;
  46222. /**
  46223. * Disposes of the object
  46224. */
  46225. dispose(): void;
  46226. }
  46227. }
  46228. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46229. import { Vector3 } from "babylonjs/Maths/math.vector";
  46230. import { Color4 } from "babylonjs/Maths/math.color";
  46231. import { Nullable } from "babylonjs/types";
  46232. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46233. import { Scene } from "babylonjs/scene";
  46234. /**
  46235. * Class containing static functions to help procedurally build meshes
  46236. */
  46237. export class LinesBuilder {
  46238. /**
  46239. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46240. * * 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
  46241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46242. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46243. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46244. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46246. * * 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
  46247. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46250. * @param name defines the name of the new line system
  46251. * @param options defines the options used to create the line system
  46252. * @param scene defines the hosting scene
  46253. * @returns a new line system mesh
  46254. */
  46255. static CreateLineSystem(name: string, options: {
  46256. lines: Vector3[][];
  46257. updatable?: boolean;
  46258. instance?: Nullable<LinesMesh>;
  46259. colors?: Nullable<Color4[][]>;
  46260. useVertexAlpha?: boolean;
  46261. }, scene: Nullable<Scene>): LinesMesh;
  46262. /**
  46263. * Creates a line mesh
  46264. * 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
  46265. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46266. * * The parameter `points` is an array successive Vector3
  46267. * * 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
  46268. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46269. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46270. * * When updating an instance, remember that only point positions can change, not the number of points
  46271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46273. * @param name defines the name of the new line system
  46274. * @param options defines the options used to create the line system
  46275. * @param scene defines the hosting scene
  46276. * @returns a new line mesh
  46277. */
  46278. static CreateLines(name: string, options: {
  46279. points: Vector3[];
  46280. updatable?: boolean;
  46281. instance?: Nullable<LinesMesh>;
  46282. colors?: Color4[];
  46283. useVertexAlpha?: boolean;
  46284. }, scene?: Nullable<Scene>): LinesMesh;
  46285. /**
  46286. * Creates a dashed line mesh
  46287. * * 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
  46288. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46289. * * The parameter `points` is an array successive Vector3
  46290. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46291. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46292. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46293. * * 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
  46294. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46295. * * When updating an instance, remember that only point positions can change, not the number of points
  46296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46297. * @param name defines the name of the mesh
  46298. * @param options defines the options used to create the mesh
  46299. * @param scene defines the hosting scene
  46300. * @returns the dashed line mesh
  46301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46302. */
  46303. static CreateDashedLines(name: string, options: {
  46304. points: Vector3[];
  46305. dashSize?: number;
  46306. gapSize?: number;
  46307. dashNb?: number;
  46308. updatable?: boolean;
  46309. instance?: LinesMesh;
  46310. useVertexAlpha?: boolean;
  46311. }, scene?: Nullable<Scene>): LinesMesh;
  46312. }
  46313. }
  46314. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46315. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46316. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46317. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46319. import { Material } from "babylonjs/Materials/material";
  46320. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46321. import { Scene } from "babylonjs/scene";
  46322. /**
  46323. * The options container for the teleportation module
  46324. */
  46325. export interface IWebXRTeleportationOptions {
  46326. /**
  46327. * Babylon XR Input class for controller
  46328. */
  46329. xrInput: WebXRInput;
  46330. /**
  46331. * A list of meshes to use as floor meshes.
  46332. * Meshes can be added and removed after initializing the feature using the
  46333. * addFloorMesh and removeFloorMesh functions
  46334. * If empty, rotation will still work
  46335. */
  46336. floorMeshes?: AbstractMesh[];
  46337. /**
  46338. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46339. * If you want to support rotation, make sure your mesh has a direction indicator.
  46340. *
  46341. * When left untouched, the default mesh will be initialized.
  46342. */
  46343. teleportationTargetMesh?: AbstractMesh;
  46344. /**
  46345. * Values to configure the default target mesh
  46346. */
  46347. defaultTargetMeshOptions?: {
  46348. /**
  46349. * Fill color of the teleportation area
  46350. */
  46351. teleportationFillColor?: string;
  46352. /**
  46353. * Border color for the teleportation area
  46354. */
  46355. teleportationBorderColor?: string;
  46356. /**
  46357. * Disable the mesh's animation sequence
  46358. */
  46359. disableAnimation?: boolean;
  46360. /**
  46361. * Disable lighting on the material or the ring and arrow
  46362. */
  46363. disableLighting?: boolean;
  46364. /**
  46365. * Override the default material of the torus and arrow
  46366. */
  46367. torusArrowMaterial?: Material;
  46368. };
  46369. /**
  46370. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46371. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46372. */
  46373. useMainComponentOnly?: boolean;
  46374. /**
  46375. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46376. */
  46377. timeToTeleport?: number;
  46378. /**
  46379. * Should meshes created here be added to a utility layer or the main scene
  46380. */
  46381. useUtilityLayer?: boolean;
  46382. /**
  46383. * if provided, this scene will be used to render meshes.
  46384. */
  46385. customUtilityLayerScene?: Scene;
  46386. }
  46387. /**
  46388. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46389. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46390. * the input of the attached controllers.
  46391. */
  46392. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46393. private _options;
  46394. /**
  46395. * The module's name
  46396. */
  46397. static readonly Name: string;
  46398. /**
  46399. * The (Babylon) version of this module.
  46400. * This is an integer representing the implementation version.
  46401. * This number does not correspond to the webxr specs version
  46402. */
  46403. static readonly Version: number;
  46404. /**
  46405. * Is rotation enabled when moving forward?
  46406. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46407. */
  46408. rotationEnabled: boolean;
  46409. /**
  46410. * Should the module support parabolic ray on top of direct ray
  46411. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46412. * Very helpful when moving between floors / different heights
  46413. */
  46414. parabolicRayEnabled: boolean;
  46415. /**
  46416. * The distance from the user to the inspection point in the direction of the controller
  46417. * A higher number will allow the user to move further
  46418. * defaults to 5 (meters, in xr units)
  46419. */
  46420. parabolicCheckRadius: number;
  46421. /**
  46422. * How much rotation should be applied when rotating right and left
  46423. */
  46424. rotationAngle: number;
  46425. /**
  46426. * Is movement backwards enabled
  46427. */
  46428. backwardsMovementEnabled: boolean;
  46429. /**
  46430. * Distance to travel when moving backwards
  46431. */
  46432. backwardsTeleportationDistance: number;
  46433. /**
  46434. * Add a new mesh to the floor meshes array
  46435. * @param mesh the mesh to use as floor mesh
  46436. */
  46437. addFloorMesh(mesh: AbstractMesh): void;
  46438. /**
  46439. * Remove a mesh from the floor meshes array
  46440. * @param mesh the mesh to remove
  46441. */
  46442. removeFloorMesh(mesh: AbstractMesh): void;
  46443. /**
  46444. * Remove a mesh from the floor meshes array using its name
  46445. * @param name the mesh name to remove
  46446. */
  46447. removeFloorMeshByName(name: string): void;
  46448. private _tmpRay;
  46449. private _tmpVector;
  46450. private _floorMeshes;
  46451. private _controllers;
  46452. /**
  46453. * constructs a new anchor system
  46454. * @param _xrSessionManager an instance of WebXRSessionManager
  46455. * @param _options configuration object for this feature
  46456. */
  46457. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46458. private _selectionFeature;
  46459. /**
  46460. * This function sets a selection feature that will be disabled when
  46461. * the forward ray is shown and will be reattached when hidden.
  46462. * This is used to remove the selection rays when moving.
  46463. * @param selectionFeature the feature to disable when forward movement is enabled
  46464. */
  46465. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46466. attach(): boolean;
  46467. detach(): boolean;
  46468. dispose(): void;
  46469. protected _onXRFrame(_xrFrame: XRFrame): void;
  46470. private _currentTeleportationControllerId;
  46471. private _attachController;
  46472. private _teleportForward;
  46473. private _detachController;
  46474. private createDefaultTargetMesh;
  46475. private setTargetMeshVisibility;
  46476. private setTargetMeshPosition;
  46477. private _quadraticBezierCurve;
  46478. private _showParabolicPath;
  46479. }
  46480. }
  46481. declare module "babylonjs/XR/webXRDefaultExperience" {
  46482. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46483. import { Scene } from "babylonjs/scene";
  46484. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46485. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46486. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46487. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46489. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46490. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46491. /**
  46492. * Options for the default xr helper
  46493. */
  46494. export class WebXRDefaultExperienceOptions {
  46495. /**
  46496. * Floor meshes that will be used for teleporting
  46497. */
  46498. floorMeshes?: Array<AbstractMesh>;
  46499. /**
  46500. * Enable or disable default UI to enter XR
  46501. */
  46502. disableDefaultUI?: boolean;
  46503. /**
  46504. * optional configuration for the output canvas
  46505. */
  46506. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46507. /**
  46508. * optional UI options. This can be used among other to change session mode and reference space type
  46509. */
  46510. uiOptions?: WebXREnterExitUIOptions;
  46511. /**
  46512. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46513. */
  46514. inputOptions?: IWebXRInputOptions;
  46515. /**
  46516. * Should teleportation not initialize. defaults to false.
  46517. */
  46518. disableTeleportation?: boolean;
  46519. /**
  46520. * If set to true, the first frame will not be used to reset position
  46521. * The first frame is mainly used when copying transformation from the old camera
  46522. * Mainly used in AR
  46523. */
  46524. ignoreNativeCameraTransformation?: boolean;
  46525. /**
  46526. * When loading teleportation and pointer select, use stable versions instead of latest.
  46527. */
  46528. useStablePlugins?: boolean;
  46529. }
  46530. /**
  46531. * Default experience which provides a similar setup to the previous webVRExperience
  46532. */
  46533. export class WebXRDefaultExperience {
  46534. /**
  46535. * Base experience
  46536. */
  46537. baseExperience: WebXRExperienceHelper;
  46538. /**
  46539. * Input experience extension
  46540. */
  46541. input: WebXRInput;
  46542. /**
  46543. * Enables laser pointer and selection
  46544. */
  46545. pointerSelection: WebXRControllerPointerSelection;
  46546. /**
  46547. * Enables teleportation
  46548. */
  46549. teleportation: WebXRMotionControllerTeleportation;
  46550. /**
  46551. * Enables ui for entering/exiting xr
  46552. */
  46553. enterExitUI: WebXREnterExitUI;
  46554. /**
  46555. * Default target xr should render to
  46556. */
  46557. renderTarget: WebXRRenderTarget;
  46558. /**
  46559. * Creates the default xr experience
  46560. * @param scene scene
  46561. * @param options options for basic configuration
  46562. * @returns resulting WebXRDefaultExperience
  46563. */
  46564. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46565. private constructor();
  46566. /**
  46567. * DIsposes of the experience helper
  46568. */
  46569. dispose(): void;
  46570. }
  46571. }
  46572. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46573. import { Observable } from "babylonjs/Misc/observable";
  46574. import { Nullable } from "babylonjs/types";
  46575. import { Camera } from "babylonjs/Cameras/camera";
  46576. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46577. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46578. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46579. import { Scene } from "babylonjs/scene";
  46580. import { Vector3 } from "babylonjs/Maths/math.vector";
  46581. import { Color3 } from "babylonjs/Maths/math.color";
  46582. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46584. import { Mesh } from "babylonjs/Meshes/mesh";
  46585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46586. import { EasingFunction } from "babylonjs/Animations/easing";
  46587. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46588. import "babylonjs/Meshes/Builders/groundBuilder";
  46589. import "babylonjs/Meshes/Builders/torusBuilder";
  46590. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46591. import "babylonjs/Gamepads/gamepadSceneComponent";
  46592. import "babylonjs/Animations/animatable";
  46593. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46594. /**
  46595. * Options to modify the vr teleportation behavior.
  46596. */
  46597. export interface VRTeleportationOptions {
  46598. /**
  46599. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46600. */
  46601. floorMeshName?: string;
  46602. /**
  46603. * A list of meshes to be used as the teleportation floor. (default: empty)
  46604. */
  46605. floorMeshes?: Mesh[];
  46606. /**
  46607. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46608. */
  46609. teleportationMode?: number;
  46610. /**
  46611. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46612. */
  46613. teleportationTime?: number;
  46614. /**
  46615. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46616. */
  46617. teleportationSpeed?: number;
  46618. /**
  46619. * The easing function used in the animation or null for Linear. (default CircleEase)
  46620. */
  46621. easingFunction?: EasingFunction;
  46622. }
  46623. /**
  46624. * Options to modify the vr experience helper's behavior.
  46625. */
  46626. export interface VRExperienceHelperOptions extends WebVROptions {
  46627. /**
  46628. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46629. */
  46630. createDeviceOrientationCamera?: boolean;
  46631. /**
  46632. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46633. */
  46634. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46635. /**
  46636. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46637. */
  46638. laserToggle?: boolean;
  46639. /**
  46640. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46641. */
  46642. floorMeshes?: Mesh[];
  46643. /**
  46644. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46645. */
  46646. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46647. /**
  46648. * Defines if WebXR should be used instead of WebVR (if available)
  46649. */
  46650. useXR?: boolean;
  46651. }
  46652. /**
  46653. * Event containing information after VR has been entered
  46654. */
  46655. export class OnAfterEnteringVRObservableEvent {
  46656. /**
  46657. * If entering vr was successful
  46658. */
  46659. success: boolean;
  46660. }
  46661. /**
  46662. * Helps to quickly add VR support to an existing scene.
  46663. * See http://doc.babylonjs.com/how_to/webvr_helper
  46664. */
  46665. export class VRExperienceHelper {
  46666. /** Options to modify the vr experience helper's behavior. */
  46667. webVROptions: VRExperienceHelperOptions;
  46668. private _scene;
  46669. private _position;
  46670. private _btnVR;
  46671. private _btnVRDisplayed;
  46672. private _webVRsupported;
  46673. private _webVRready;
  46674. private _webVRrequesting;
  46675. private _webVRpresenting;
  46676. private _hasEnteredVR;
  46677. private _fullscreenVRpresenting;
  46678. private _inputElement;
  46679. private _webVRCamera;
  46680. private _vrDeviceOrientationCamera;
  46681. private _deviceOrientationCamera;
  46682. private _existingCamera;
  46683. private _onKeyDown;
  46684. private _onVrDisplayPresentChange;
  46685. private _onVRDisplayChanged;
  46686. private _onVRRequestPresentStart;
  46687. private _onVRRequestPresentComplete;
  46688. /**
  46689. * 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)
  46690. */
  46691. enableGazeEvenWhenNoPointerLock: boolean;
  46692. /**
  46693. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46694. */
  46695. exitVROnDoubleTap: boolean;
  46696. /**
  46697. * Observable raised right before entering VR.
  46698. */
  46699. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46700. /**
  46701. * Observable raised when entering VR has completed.
  46702. */
  46703. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46704. /**
  46705. * Observable raised when exiting VR.
  46706. */
  46707. onExitingVRObservable: Observable<VRExperienceHelper>;
  46708. /**
  46709. * Observable raised when controller mesh is loaded.
  46710. */
  46711. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46712. /** Return this.onEnteringVRObservable
  46713. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46714. */
  46715. get onEnteringVR(): Observable<VRExperienceHelper>;
  46716. /** Return this.onExitingVRObservable
  46717. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46718. */
  46719. get onExitingVR(): Observable<VRExperienceHelper>;
  46720. /** Return this.onControllerMeshLoadedObservable
  46721. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46722. */
  46723. get onControllerMeshLoaded(): Observable<WebVRController>;
  46724. private _rayLength;
  46725. private _useCustomVRButton;
  46726. private _teleportationRequested;
  46727. private _teleportActive;
  46728. private _floorMeshName;
  46729. private _floorMeshesCollection;
  46730. private _teleportationMode;
  46731. private _teleportationTime;
  46732. private _teleportationSpeed;
  46733. private _teleportationEasing;
  46734. private _rotationAllowed;
  46735. private _teleportBackwardsVector;
  46736. private _teleportationTarget;
  46737. private _isDefaultTeleportationTarget;
  46738. private _postProcessMove;
  46739. private _teleportationFillColor;
  46740. private _teleportationBorderColor;
  46741. private _rotationAngle;
  46742. private _haloCenter;
  46743. private _cameraGazer;
  46744. private _padSensibilityUp;
  46745. private _padSensibilityDown;
  46746. private _leftController;
  46747. private _rightController;
  46748. private _gazeColor;
  46749. private _laserColor;
  46750. private _pickedLaserColor;
  46751. private _pickedGazeColor;
  46752. /**
  46753. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46754. */
  46755. onNewMeshSelected: Observable<AbstractMesh>;
  46756. /**
  46757. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46758. * This observable will provide the mesh and the controller used to select the mesh
  46759. */
  46760. onMeshSelectedWithController: Observable<{
  46761. mesh: AbstractMesh;
  46762. controller: WebVRController;
  46763. }>;
  46764. /**
  46765. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46766. */
  46767. onNewMeshPicked: Observable<PickingInfo>;
  46768. private _circleEase;
  46769. /**
  46770. * Observable raised before camera teleportation
  46771. */
  46772. onBeforeCameraTeleport: Observable<Vector3>;
  46773. /**
  46774. * Observable raised after camera teleportation
  46775. */
  46776. onAfterCameraTeleport: Observable<Vector3>;
  46777. /**
  46778. * Observable raised when current selected mesh gets unselected
  46779. */
  46780. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46781. private _raySelectionPredicate;
  46782. /**
  46783. * To be optionaly changed by user to define custom ray selection
  46784. */
  46785. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46786. /**
  46787. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46788. */
  46789. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46790. /**
  46791. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46792. */
  46793. teleportationEnabled: boolean;
  46794. private _defaultHeight;
  46795. private _teleportationInitialized;
  46796. private _interactionsEnabled;
  46797. private _interactionsRequested;
  46798. private _displayGaze;
  46799. private _displayLaserPointer;
  46800. /**
  46801. * The mesh used to display where the user is going to teleport.
  46802. */
  46803. get teleportationTarget(): Mesh;
  46804. /**
  46805. * Sets the mesh to be used to display where the user is going to teleport.
  46806. */
  46807. set teleportationTarget(value: Mesh);
  46808. /**
  46809. * 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
  46810. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46811. * See http://doc.babylonjs.com/resources/baking_transformations
  46812. */
  46813. get gazeTrackerMesh(): Mesh;
  46814. set gazeTrackerMesh(value: Mesh);
  46815. /**
  46816. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46817. */
  46818. updateGazeTrackerScale: boolean;
  46819. /**
  46820. * If the gaze trackers color should be updated when selecting meshes
  46821. */
  46822. updateGazeTrackerColor: boolean;
  46823. /**
  46824. * If the controller laser color should be updated when selecting meshes
  46825. */
  46826. updateControllerLaserColor: boolean;
  46827. /**
  46828. * The gaze tracking mesh corresponding to the left controller
  46829. */
  46830. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46831. /**
  46832. * The gaze tracking mesh corresponding to the right controller
  46833. */
  46834. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46835. /**
  46836. * If the ray of the gaze should be displayed.
  46837. */
  46838. get displayGaze(): boolean;
  46839. /**
  46840. * Sets if the ray of the gaze should be displayed.
  46841. */
  46842. set displayGaze(value: boolean);
  46843. /**
  46844. * If the ray of the LaserPointer should be displayed.
  46845. */
  46846. get displayLaserPointer(): boolean;
  46847. /**
  46848. * Sets if the ray of the LaserPointer should be displayed.
  46849. */
  46850. set displayLaserPointer(value: boolean);
  46851. /**
  46852. * The deviceOrientationCamera used as the camera when not in VR.
  46853. */
  46854. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46855. /**
  46856. * Based on the current WebVR support, returns the current VR camera used.
  46857. */
  46858. get currentVRCamera(): Nullable<Camera>;
  46859. /**
  46860. * The webVRCamera which is used when in VR.
  46861. */
  46862. get webVRCamera(): WebVRFreeCamera;
  46863. /**
  46864. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46865. */
  46866. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46867. /**
  46868. * The html button that is used to trigger entering into VR.
  46869. */
  46870. get vrButton(): Nullable<HTMLButtonElement>;
  46871. private get _teleportationRequestInitiated();
  46872. /**
  46873. * Defines whether or not Pointer lock should be requested when switching to
  46874. * full screen.
  46875. */
  46876. requestPointerLockOnFullScreen: boolean;
  46877. /**
  46878. * If asking to force XR, this will be populated with the default xr experience
  46879. */
  46880. xr: WebXRDefaultExperience;
  46881. /**
  46882. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46883. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46884. */
  46885. xrTestDone: boolean;
  46886. /**
  46887. * Instantiates a VRExperienceHelper.
  46888. * Helps to quickly add VR support to an existing scene.
  46889. * @param scene The scene the VRExperienceHelper belongs to.
  46890. * @param webVROptions Options to modify the vr experience helper's behavior.
  46891. */
  46892. constructor(scene: Scene,
  46893. /** Options to modify the vr experience helper's behavior. */
  46894. webVROptions?: VRExperienceHelperOptions);
  46895. private completeVRInit;
  46896. private _onDefaultMeshLoaded;
  46897. private _onResize;
  46898. private _onFullscreenChange;
  46899. /**
  46900. * Gets a value indicating if we are currently in VR mode.
  46901. */
  46902. get isInVRMode(): boolean;
  46903. private onVrDisplayPresentChange;
  46904. private onVRDisplayChanged;
  46905. private moveButtonToBottomRight;
  46906. private displayVRButton;
  46907. private updateButtonVisibility;
  46908. private _cachedAngularSensibility;
  46909. /**
  46910. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46911. * Otherwise, will use the fullscreen API.
  46912. */
  46913. enterVR(): void;
  46914. /**
  46915. * Attempt to exit VR, or fullscreen.
  46916. */
  46917. exitVR(): void;
  46918. /**
  46919. * The position of the vr experience helper.
  46920. */
  46921. get position(): Vector3;
  46922. /**
  46923. * Sets the position of the vr experience helper.
  46924. */
  46925. set position(value: Vector3);
  46926. /**
  46927. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46928. */
  46929. enableInteractions(): void;
  46930. private get _noControllerIsActive();
  46931. private beforeRender;
  46932. private _isTeleportationFloor;
  46933. /**
  46934. * Adds a floor mesh to be used for teleportation.
  46935. * @param floorMesh the mesh to be used for teleportation.
  46936. */
  46937. addFloorMesh(floorMesh: Mesh): void;
  46938. /**
  46939. * Removes a floor mesh from being used for teleportation.
  46940. * @param floorMesh the mesh to be removed.
  46941. */
  46942. removeFloorMesh(floorMesh: Mesh): void;
  46943. /**
  46944. * Enables interactions and teleportation using the VR controllers and gaze.
  46945. * @param vrTeleportationOptions options to modify teleportation behavior.
  46946. */
  46947. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46948. private _onNewGamepadConnected;
  46949. private _tryEnableInteractionOnController;
  46950. private _onNewGamepadDisconnected;
  46951. private _enableInteractionOnController;
  46952. private _checkTeleportWithRay;
  46953. private _checkRotate;
  46954. private _checkTeleportBackwards;
  46955. private _enableTeleportationOnController;
  46956. private _createTeleportationCircles;
  46957. private _displayTeleportationTarget;
  46958. private _hideTeleportationTarget;
  46959. private _rotateCamera;
  46960. private _moveTeleportationSelectorTo;
  46961. private _workingVector;
  46962. private _workingQuaternion;
  46963. private _workingMatrix;
  46964. /**
  46965. * Time Constant Teleportation Mode
  46966. */
  46967. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46968. /**
  46969. * Speed Constant Teleportation Mode
  46970. */
  46971. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46972. /**
  46973. * Teleports the users feet to the desired location
  46974. * @param location The location where the user's feet should be placed
  46975. */
  46976. teleportCamera(location: Vector3): void;
  46977. private _convertNormalToDirectionOfRay;
  46978. private _castRayAndSelectObject;
  46979. private _notifySelectedMeshUnselected;
  46980. /**
  46981. * Permanently set new colors for the laser pointer
  46982. * @param color the new laser color
  46983. * @param pickedColor the new laser color when picked mesh detected
  46984. */
  46985. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46986. /**
  46987. * Set lighting enabled / disabled on the laser pointer of both controllers
  46988. * @param enabled should the lighting be enabled on the laser pointer
  46989. */
  46990. setLaserLightingState(enabled?: boolean): void;
  46991. /**
  46992. * Permanently set new colors for the gaze pointer
  46993. * @param color the new gaze color
  46994. * @param pickedColor the new gaze color when picked mesh detected
  46995. */
  46996. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46997. /**
  46998. * Sets the color of the laser ray from the vr controllers.
  46999. * @param color new color for the ray.
  47000. */
  47001. changeLaserColor(color: Color3): void;
  47002. /**
  47003. * Sets the color of the ray from the vr headsets gaze.
  47004. * @param color new color for the ray.
  47005. */
  47006. changeGazeColor(color: Color3): void;
  47007. /**
  47008. * Exits VR and disposes of the vr experience helper
  47009. */
  47010. dispose(): void;
  47011. /**
  47012. * Gets the name of the VRExperienceHelper class
  47013. * @returns "VRExperienceHelper"
  47014. */
  47015. getClassName(): string;
  47016. }
  47017. }
  47018. declare module "babylonjs/Cameras/VR/index" {
  47019. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47020. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47021. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47022. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47023. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47024. export * from "babylonjs/Cameras/VR/webVRCamera";
  47025. }
  47026. declare module "babylonjs/Cameras/RigModes/index" {
  47027. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47028. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47029. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47030. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47031. }
  47032. declare module "babylonjs/Cameras/index" {
  47033. export * from "babylonjs/Cameras/Inputs/index";
  47034. export * from "babylonjs/Cameras/cameraInputsManager";
  47035. export * from "babylonjs/Cameras/camera";
  47036. export * from "babylonjs/Cameras/targetCamera";
  47037. export * from "babylonjs/Cameras/freeCamera";
  47038. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47039. export * from "babylonjs/Cameras/touchCamera";
  47040. export * from "babylonjs/Cameras/arcRotateCamera";
  47041. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47042. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47043. export * from "babylonjs/Cameras/flyCamera";
  47044. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47045. export * from "babylonjs/Cameras/followCamera";
  47046. export * from "babylonjs/Cameras/followCameraInputsManager";
  47047. export * from "babylonjs/Cameras/gamepadCamera";
  47048. export * from "babylonjs/Cameras/Stereoscopic/index";
  47049. export * from "babylonjs/Cameras/universalCamera";
  47050. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47051. export * from "babylonjs/Cameras/VR/index";
  47052. export * from "babylonjs/Cameras/RigModes/index";
  47053. }
  47054. declare module "babylonjs/Collisions/index" {
  47055. export * from "babylonjs/Collisions/collider";
  47056. export * from "babylonjs/Collisions/collisionCoordinator";
  47057. export * from "babylonjs/Collisions/pickingInfo";
  47058. export * from "babylonjs/Collisions/intersectionInfo";
  47059. export * from "babylonjs/Collisions/meshCollisionData";
  47060. }
  47061. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47062. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47063. import { Vector3 } from "babylonjs/Maths/math.vector";
  47064. import { Ray } from "babylonjs/Culling/ray";
  47065. import { Plane } from "babylonjs/Maths/math.plane";
  47066. /**
  47067. * Contains an array of blocks representing the octree
  47068. */
  47069. export interface IOctreeContainer<T> {
  47070. /**
  47071. * Blocks within the octree
  47072. */
  47073. blocks: Array<OctreeBlock<T>>;
  47074. }
  47075. /**
  47076. * Class used to store a cell in an octree
  47077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47078. */
  47079. export class OctreeBlock<T> {
  47080. /**
  47081. * Gets the content of the current block
  47082. */
  47083. entries: T[];
  47084. /**
  47085. * Gets the list of block children
  47086. */
  47087. blocks: Array<OctreeBlock<T>>;
  47088. private _depth;
  47089. private _maxDepth;
  47090. private _capacity;
  47091. private _minPoint;
  47092. private _maxPoint;
  47093. private _boundingVectors;
  47094. private _creationFunc;
  47095. /**
  47096. * Creates a new block
  47097. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47098. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47099. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47100. * @param depth defines the current depth of this block in the octree
  47101. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47102. * @param creationFunc defines a callback to call when an element is added to the block
  47103. */
  47104. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47105. /**
  47106. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47107. */
  47108. get capacity(): number;
  47109. /**
  47110. * Gets the minimum vector (in world space) of the block's bounding box
  47111. */
  47112. get minPoint(): Vector3;
  47113. /**
  47114. * Gets the maximum vector (in world space) of the block's bounding box
  47115. */
  47116. get maxPoint(): Vector3;
  47117. /**
  47118. * Add a new element to this block
  47119. * @param entry defines the element to add
  47120. */
  47121. addEntry(entry: T): void;
  47122. /**
  47123. * Remove an element from this block
  47124. * @param entry defines the element to remove
  47125. */
  47126. removeEntry(entry: T): void;
  47127. /**
  47128. * Add an array of elements to this block
  47129. * @param entries defines the array of elements to add
  47130. */
  47131. addEntries(entries: T[]): void;
  47132. /**
  47133. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47134. * @param frustumPlanes defines the frustum planes to test
  47135. * @param selection defines the array to store current content if selection is positive
  47136. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47137. */
  47138. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47139. /**
  47140. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47141. * @param sphereCenter defines the bounding sphere center
  47142. * @param sphereRadius defines the bounding sphere radius
  47143. * @param selection defines the array to store current content if selection is positive
  47144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47145. */
  47146. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47147. /**
  47148. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47149. * @param ray defines the ray to test with
  47150. * @param selection defines the array to store current content if selection is positive
  47151. */
  47152. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47153. /**
  47154. * Subdivide the content into child blocks (this block will then be empty)
  47155. */
  47156. createInnerBlocks(): void;
  47157. /**
  47158. * @hidden
  47159. */
  47160. 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;
  47161. }
  47162. }
  47163. declare module "babylonjs/Culling/Octrees/octree" {
  47164. import { SmartArray } from "babylonjs/Misc/smartArray";
  47165. import { Vector3 } from "babylonjs/Maths/math.vector";
  47166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47168. import { Ray } from "babylonjs/Culling/ray";
  47169. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47170. import { Plane } from "babylonjs/Maths/math.plane";
  47171. /**
  47172. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47173. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47174. */
  47175. export class Octree<T> {
  47176. /** 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.) */
  47177. maxDepth: number;
  47178. /**
  47179. * Blocks within the octree containing objects
  47180. */
  47181. blocks: Array<OctreeBlock<T>>;
  47182. /**
  47183. * Content stored in the octree
  47184. */
  47185. dynamicContent: T[];
  47186. private _maxBlockCapacity;
  47187. private _selectionContent;
  47188. private _creationFunc;
  47189. /**
  47190. * Creates a octree
  47191. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47192. * @param creationFunc function to be used to instatiate the octree
  47193. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47194. * @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.)
  47195. */
  47196. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47197. /** 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.) */
  47198. maxDepth?: number);
  47199. /**
  47200. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47201. * @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);
  47202. * @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);
  47203. * @param entries meshes to be added to the octree blocks
  47204. */
  47205. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47206. /**
  47207. * Adds a mesh to the octree
  47208. * @param entry Mesh to add to the octree
  47209. */
  47210. addMesh(entry: T): void;
  47211. /**
  47212. * Remove an element from the octree
  47213. * @param entry defines the element to remove
  47214. */
  47215. removeMesh(entry: T): void;
  47216. /**
  47217. * Selects an array of meshes within the frustum
  47218. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47219. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47220. * @returns array of meshes within the frustum
  47221. */
  47222. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47223. /**
  47224. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47225. * @param sphereCenter defines the bounding sphere center
  47226. * @param sphereRadius defines the bounding sphere radius
  47227. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47228. * @returns an array of objects that intersect the sphere
  47229. */
  47230. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47231. /**
  47232. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47233. * @param ray defines the ray to test with
  47234. * @returns array of intersected objects
  47235. */
  47236. intersectsRay(ray: Ray): SmartArray<T>;
  47237. /**
  47238. * Adds a mesh into the octree block if it intersects the block
  47239. */
  47240. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47241. /**
  47242. * Adds a submesh into the octree block if it intersects the block
  47243. */
  47244. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47245. }
  47246. }
  47247. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47248. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47249. import { Scene } from "babylonjs/scene";
  47250. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47252. import { Ray } from "babylonjs/Culling/ray";
  47253. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47254. import { Collider } from "babylonjs/Collisions/collider";
  47255. module "babylonjs/scene" {
  47256. interface Scene {
  47257. /**
  47258. * @hidden
  47259. * Backing Filed
  47260. */
  47261. _selectionOctree: Octree<AbstractMesh>;
  47262. /**
  47263. * Gets the octree used to boost mesh selection (picking)
  47264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47265. */
  47266. selectionOctree: Octree<AbstractMesh>;
  47267. /**
  47268. * Creates or updates the octree used to boost selection (picking)
  47269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47270. * @param maxCapacity defines the maximum capacity per leaf
  47271. * @param maxDepth defines the maximum depth of the octree
  47272. * @returns an octree of AbstractMesh
  47273. */
  47274. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47275. }
  47276. }
  47277. module "babylonjs/Meshes/abstractMesh" {
  47278. interface AbstractMesh {
  47279. /**
  47280. * @hidden
  47281. * Backing Field
  47282. */
  47283. _submeshesOctree: Octree<SubMesh>;
  47284. /**
  47285. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47286. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47287. * @param maxCapacity defines the maximum size of each block (64 by default)
  47288. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47289. * @returns the new octree
  47290. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47292. */
  47293. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47294. }
  47295. }
  47296. /**
  47297. * Defines the octree scene component responsible to manage any octrees
  47298. * in a given scene.
  47299. */
  47300. export class OctreeSceneComponent {
  47301. /**
  47302. * The component name help to identify the component in the list of scene components.
  47303. */
  47304. readonly name: string;
  47305. /**
  47306. * The scene the component belongs to.
  47307. */
  47308. scene: Scene;
  47309. /**
  47310. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47311. */
  47312. readonly checksIsEnabled: boolean;
  47313. /**
  47314. * Creates a new instance of the component for the given scene
  47315. * @param scene Defines the scene to register the component in
  47316. */
  47317. constructor(scene: Scene);
  47318. /**
  47319. * Registers the component in a given scene
  47320. */
  47321. register(): void;
  47322. /**
  47323. * Return the list of active meshes
  47324. * @returns the list of active meshes
  47325. */
  47326. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47327. /**
  47328. * Return the list of active sub meshes
  47329. * @param mesh The mesh to get the candidates sub meshes from
  47330. * @returns the list of active sub meshes
  47331. */
  47332. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47333. private _tempRay;
  47334. /**
  47335. * Return the list of sub meshes intersecting with a given local ray
  47336. * @param mesh defines the mesh to find the submesh for
  47337. * @param localRay defines the ray in local space
  47338. * @returns the list of intersecting sub meshes
  47339. */
  47340. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47341. /**
  47342. * Return the list of sub meshes colliding with a collider
  47343. * @param mesh defines the mesh to find the submesh for
  47344. * @param collider defines the collider to evaluate the collision against
  47345. * @returns the list of colliding sub meshes
  47346. */
  47347. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47348. /**
  47349. * Rebuilds the elements related to this component in case of
  47350. * context lost for instance.
  47351. */
  47352. rebuild(): void;
  47353. /**
  47354. * Disposes the component and the associated ressources.
  47355. */
  47356. dispose(): void;
  47357. }
  47358. }
  47359. declare module "babylonjs/Culling/Octrees/index" {
  47360. export * from "babylonjs/Culling/Octrees/octree";
  47361. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47362. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47363. }
  47364. declare module "babylonjs/Culling/index" {
  47365. export * from "babylonjs/Culling/boundingBox";
  47366. export * from "babylonjs/Culling/boundingInfo";
  47367. export * from "babylonjs/Culling/boundingSphere";
  47368. export * from "babylonjs/Culling/Octrees/index";
  47369. export * from "babylonjs/Culling/ray";
  47370. }
  47371. declare module "babylonjs/Gizmos/gizmo" {
  47372. import { Nullable } from "babylonjs/types";
  47373. import { IDisposable } from "babylonjs/scene";
  47374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47375. import { Mesh } from "babylonjs/Meshes/mesh";
  47376. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47377. /**
  47378. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47379. */
  47380. export class Gizmo implements IDisposable {
  47381. /** The utility layer the gizmo will be added to */
  47382. gizmoLayer: UtilityLayerRenderer;
  47383. /**
  47384. * The root mesh of the gizmo
  47385. */
  47386. _rootMesh: Mesh;
  47387. private _attachedMesh;
  47388. /**
  47389. * Ratio for the scale of the gizmo (Default: 1)
  47390. */
  47391. scaleRatio: number;
  47392. /**
  47393. * If a custom mesh has been set (Default: false)
  47394. */
  47395. protected _customMeshSet: boolean;
  47396. /**
  47397. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47398. * * When set, interactions will be enabled
  47399. */
  47400. get attachedMesh(): Nullable<AbstractMesh>;
  47401. set attachedMesh(value: Nullable<AbstractMesh>);
  47402. /**
  47403. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47404. * @param mesh The mesh to replace the default mesh of the gizmo
  47405. */
  47406. setCustomMesh(mesh: Mesh): void;
  47407. /**
  47408. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47409. */
  47410. updateGizmoRotationToMatchAttachedMesh: boolean;
  47411. /**
  47412. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47413. */
  47414. updateGizmoPositionToMatchAttachedMesh: boolean;
  47415. /**
  47416. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47417. */
  47418. updateScale: boolean;
  47419. protected _interactionsEnabled: boolean;
  47420. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47421. private _beforeRenderObserver;
  47422. private _tempVector;
  47423. /**
  47424. * Creates a gizmo
  47425. * @param gizmoLayer The utility layer the gizmo will be added to
  47426. */
  47427. constructor(
  47428. /** The utility layer the gizmo will be added to */
  47429. gizmoLayer?: UtilityLayerRenderer);
  47430. /**
  47431. * Updates the gizmo to match the attached mesh's position/rotation
  47432. */
  47433. protected _update(): void;
  47434. /**
  47435. * Disposes of the gizmo
  47436. */
  47437. dispose(): void;
  47438. }
  47439. }
  47440. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47441. import { Observable } from "babylonjs/Misc/observable";
  47442. import { Nullable } from "babylonjs/types";
  47443. import { Vector3 } from "babylonjs/Maths/math.vector";
  47444. import { Color3 } from "babylonjs/Maths/math.color";
  47445. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47447. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47449. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47450. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47451. import { Scene } from "babylonjs/scene";
  47452. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47453. /**
  47454. * Single plane drag gizmo
  47455. */
  47456. export class PlaneDragGizmo extends Gizmo {
  47457. /**
  47458. * Drag behavior responsible for the gizmos dragging interactions
  47459. */
  47460. dragBehavior: PointerDragBehavior;
  47461. private _pointerObserver;
  47462. /**
  47463. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47464. */
  47465. snapDistance: number;
  47466. /**
  47467. * Event that fires each time the gizmo snaps to a new location.
  47468. * * snapDistance is the the change in distance
  47469. */
  47470. onSnapObservable: Observable<{
  47471. snapDistance: number;
  47472. }>;
  47473. private _plane;
  47474. private _coloredMaterial;
  47475. private _hoverMaterial;
  47476. private _isEnabled;
  47477. private _parent;
  47478. /** @hidden */
  47479. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47480. /** @hidden */
  47481. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47482. /**
  47483. * Creates a PlaneDragGizmo
  47484. * @param gizmoLayer The utility layer the gizmo will be added to
  47485. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47486. * @param color The color of the gizmo
  47487. */
  47488. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47489. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47490. /**
  47491. * If the gizmo is enabled
  47492. */
  47493. set isEnabled(value: boolean);
  47494. get isEnabled(): boolean;
  47495. /**
  47496. * Disposes of the gizmo
  47497. */
  47498. dispose(): void;
  47499. }
  47500. }
  47501. declare module "babylonjs/Gizmos/positionGizmo" {
  47502. import { Observable } from "babylonjs/Misc/observable";
  47503. import { Nullable } from "babylonjs/types";
  47504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47505. import { Mesh } from "babylonjs/Meshes/mesh";
  47506. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47507. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47508. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47509. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47510. /**
  47511. * Gizmo that enables dragging a mesh along 3 axis
  47512. */
  47513. export class PositionGizmo extends Gizmo {
  47514. /**
  47515. * Internal gizmo used for interactions on the x axis
  47516. */
  47517. xGizmo: AxisDragGizmo;
  47518. /**
  47519. * Internal gizmo used for interactions on the y axis
  47520. */
  47521. yGizmo: AxisDragGizmo;
  47522. /**
  47523. * Internal gizmo used for interactions on the z axis
  47524. */
  47525. zGizmo: AxisDragGizmo;
  47526. /**
  47527. * Internal gizmo used for interactions on the yz plane
  47528. */
  47529. xPlaneGizmo: PlaneDragGizmo;
  47530. /**
  47531. * Internal gizmo used for interactions on the xz plane
  47532. */
  47533. yPlaneGizmo: PlaneDragGizmo;
  47534. /**
  47535. * Internal gizmo used for interactions on the xy plane
  47536. */
  47537. zPlaneGizmo: PlaneDragGizmo;
  47538. /**
  47539. * private variables
  47540. */
  47541. private _meshAttached;
  47542. private _updateGizmoRotationToMatchAttachedMesh;
  47543. private _snapDistance;
  47544. private _scaleRatio;
  47545. /** Fires an event when any of it's sub gizmos are dragged */
  47546. onDragStartObservable: Observable<unknown>;
  47547. /** Fires an event when any of it's sub gizmos are released from dragging */
  47548. onDragEndObservable: Observable<unknown>;
  47549. /**
  47550. * If set to true, planar drag is enabled
  47551. */
  47552. private _planarGizmoEnabled;
  47553. get attachedMesh(): Nullable<AbstractMesh>;
  47554. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47555. /**
  47556. * Creates a PositionGizmo
  47557. * @param gizmoLayer The utility layer the gizmo will be added to
  47558. */
  47559. constructor(gizmoLayer?: UtilityLayerRenderer);
  47560. /**
  47561. * If the planar drag gizmo is enabled
  47562. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47563. */
  47564. set planarGizmoEnabled(value: boolean);
  47565. get planarGizmoEnabled(): boolean;
  47566. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47567. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47568. /**
  47569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47570. */
  47571. set snapDistance(value: number);
  47572. get snapDistance(): number;
  47573. /**
  47574. * Ratio for the scale of the gizmo (Default: 1)
  47575. */
  47576. set scaleRatio(value: number);
  47577. get scaleRatio(): number;
  47578. /**
  47579. * Disposes of the gizmo
  47580. */
  47581. dispose(): void;
  47582. /**
  47583. * CustomMeshes are not supported by this gizmo
  47584. * @param mesh The mesh to replace the default mesh of the gizmo
  47585. */
  47586. setCustomMesh(mesh: Mesh): void;
  47587. }
  47588. }
  47589. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47590. import { Observable } from "babylonjs/Misc/observable";
  47591. import { Nullable } from "babylonjs/types";
  47592. import { Vector3 } from "babylonjs/Maths/math.vector";
  47593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47595. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47596. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47597. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47598. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47599. import { Scene } from "babylonjs/scene";
  47600. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47601. import { Color3 } from "babylonjs/Maths/math.color";
  47602. /**
  47603. * Single axis drag gizmo
  47604. */
  47605. export class AxisDragGizmo extends Gizmo {
  47606. /**
  47607. * Drag behavior responsible for the gizmos dragging interactions
  47608. */
  47609. dragBehavior: PointerDragBehavior;
  47610. private _pointerObserver;
  47611. /**
  47612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47613. */
  47614. snapDistance: number;
  47615. /**
  47616. * Event that fires each time the gizmo snaps to a new location.
  47617. * * snapDistance is the the change in distance
  47618. */
  47619. onSnapObservable: Observable<{
  47620. snapDistance: number;
  47621. }>;
  47622. private _isEnabled;
  47623. private _parent;
  47624. private _arrow;
  47625. private _coloredMaterial;
  47626. private _hoverMaterial;
  47627. /** @hidden */
  47628. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47629. /** @hidden */
  47630. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47631. /**
  47632. * Creates an AxisDragGizmo
  47633. * @param gizmoLayer The utility layer the gizmo will be added to
  47634. * @param dragAxis The axis which the gizmo will be able to drag on
  47635. * @param color The color of the gizmo
  47636. */
  47637. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47639. /**
  47640. * If the gizmo is enabled
  47641. */
  47642. set isEnabled(value: boolean);
  47643. get isEnabled(): boolean;
  47644. /**
  47645. * Disposes of the gizmo
  47646. */
  47647. dispose(): void;
  47648. }
  47649. }
  47650. declare module "babylonjs/Debug/axesViewer" {
  47651. import { Vector3 } from "babylonjs/Maths/math.vector";
  47652. import { Nullable } from "babylonjs/types";
  47653. import { Scene } from "babylonjs/scene";
  47654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47655. /**
  47656. * The Axes viewer will show 3 axes in a specific point in space
  47657. */
  47658. export class AxesViewer {
  47659. private _xAxis;
  47660. private _yAxis;
  47661. private _zAxis;
  47662. private _scaleLinesFactor;
  47663. private _instanced;
  47664. /**
  47665. * Gets the hosting scene
  47666. */
  47667. scene: Scene;
  47668. /**
  47669. * Gets or sets a number used to scale line length
  47670. */
  47671. scaleLines: number;
  47672. /** Gets the node hierarchy used to render x-axis */
  47673. get xAxis(): TransformNode;
  47674. /** Gets the node hierarchy used to render y-axis */
  47675. get yAxis(): TransformNode;
  47676. /** Gets the node hierarchy used to render z-axis */
  47677. get zAxis(): TransformNode;
  47678. /**
  47679. * Creates a new AxesViewer
  47680. * @param scene defines the hosting scene
  47681. * @param scaleLines defines a number used to scale line length (1 by default)
  47682. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47683. * @param xAxis defines the node hierarchy used to render the x-axis
  47684. * @param yAxis defines the node hierarchy used to render the y-axis
  47685. * @param zAxis defines the node hierarchy used to render the z-axis
  47686. */
  47687. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47688. /**
  47689. * Force the viewer to update
  47690. * @param position defines the position of the viewer
  47691. * @param xaxis defines the x axis of the viewer
  47692. * @param yaxis defines the y axis of the viewer
  47693. * @param zaxis defines the z axis of the viewer
  47694. */
  47695. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47696. /**
  47697. * Creates an instance of this axes viewer.
  47698. * @returns a new axes viewer with instanced meshes
  47699. */
  47700. createInstance(): AxesViewer;
  47701. /** Releases resources */
  47702. dispose(): void;
  47703. private static _SetRenderingGroupId;
  47704. }
  47705. }
  47706. declare module "babylonjs/Debug/boneAxesViewer" {
  47707. import { Nullable } from "babylonjs/types";
  47708. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47709. import { Vector3 } from "babylonjs/Maths/math.vector";
  47710. import { Mesh } from "babylonjs/Meshes/mesh";
  47711. import { Bone } from "babylonjs/Bones/bone";
  47712. import { Scene } from "babylonjs/scene";
  47713. /**
  47714. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47715. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47716. */
  47717. export class BoneAxesViewer extends AxesViewer {
  47718. /**
  47719. * Gets or sets the target mesh where to display the axes viewer
  47720. */
  47721. mesh: Nullable<Mesh>;
  47722. /**
  47723. * Gets or sets the target bone where to display the axes viewer
  47724. */
  47725. bone: Nullable<Bone>;
  47726. /** Gets current position */
  47727. pos: Vector3;
  47728. /** Gets direction of X axis */
  47729. xaxis: Vector3;
  47730. /** Gets direction of Y axis */
  47731. yaxis: Vector3;
  47732. /** Gets direction of Z axis */
  47733. zaxis: Vector3;
  47734. /**
  47735. * Creates a new BoneAxesViewer
  47736. * @param scene defines the hosting scene
  47737. * @param bone defines the target bone
  47738. * @param mesh defines the target mesh
  47739. * @param scaleLines defines a scaling factor for line length (1 by default)
  47740. */
  47741. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47742. /**
  47743. * Force the viewer to update
  47744. */
  47745. update(): void;
  47746. /** Releases resources */
  47747. dispose(): void;
  47748. }
  47749. }
  47750. declare module "babylonjs/Debug/debugLayer" {
  47751. import { Scene } from "babylonjs/scene";
  47752. /**
  47753. * Interface used to define scene explorer extensibility option
  47754. */
  47755. export interface IExplorerExtensibilityOption {
  47756. /**
  47757. * Define the option label
  47758. */
  47759. label: string;
  47760. /**
  47761. * Defines the action to execute on click
  47762. */
  47763. action: (entity: any) => void;
  47764. }
  47765. /**
  47766. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47767. */
  47768. export interface IExplorerExtensibilityGroup {
  47769. /**
  47770. * Defines a predicate to test if a given type mut be extended
  47771. */
  47772. predicate: (entity: any) => boolean;
  47773. /**
  47774. * Gets the list of options added to a type
  47775. */
  47776. entries: IExplorerExtensibilityOption[];
  47777. }
  47778. /**
  47779. * Interface used to define the options to use to create the Inspector
  47780. */
  47781. export interface IInspectorOptions {
  47782. /**
  47783. * Display in overlay mode (default: false)
  47784. */
  47785. overlay?: boolean;
  47786. /**
  47787. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47788. */
  47789. globalRoot?: HTMLElement;
  47790. /**
  47791. * Display the Scene explorer
  47792. */
  47793. showExplorer?: boolean;
  47794. /**
  47795. * Display the property inspector
  47796. */
  47797. showInspector?: boolean;
  47798. /**
  47799. * Display in embed mode (both panes on the right)
  47800. */
  47801. embedMode?: boolean;
  47802. /**
  47803. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47804. */
  47805. handleResize?: boolean;
  47806. /**
  47807. * Allow the panes to popup (default: true)
  47808. */
  47809. enablePopup?: boolean;
  47810. /**
  47811. * Allow the panes to be closed by users (default: true)
  47812. */
  47813. enableClose?: boolean;
  47814. /**
  47815. * Optional list of extensibility entries
  47816. */
  47817. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47818. /**
  47819. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47820. */
  47821. inspectorURL?: string;
  47822. /**
  47823. * Optional initial tab (default to DebugLayerTab.Properties)
  47824. */
  47825. initialTab?: DebugLayerTab;
  47826. }
  47827. module "babylonjs/scene" {
  47828. interface Scene {
  47829. /**
  47830. * @hidden
  47831. * Backing field
  47832. */
  47833. _debugLayer: DebugLayer;
  47834. /**
  47835. * Gets the debug layer (aka Inspector) associated with the scene
  47836. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47837. */
  47838. debugLayer: DebugLayer;
  47839. }
  47840. }
  47841. /**
  47842. * Enum of inspector action tab
  47843. */
  47844. export enum DebugLayerTab {
  47845. /**
  47846. * Properties tag (default)
  47847. */
  47848. Properties = 0,
  47849. /**
  47850. * Debug tab
  47851. */
  47852. Debug = 1,
  47853. /**
  47854. * Statistics tab
  47855. */
  47856. Statistics = 2,
  47857. /**
  47858. * Tools tab
  47859. */
  47860. Tools = 3,
  47861. /**
  47862. * Settings tab
  47863. */
  47864. Settings = 4
  47865. }
  47866. /**
  47867. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47868. * what is happening in your scene
  47869. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47870. */
  47871. export class DebugLayer {
  47872. /**
  47873. * Define the url to get the inspector script from.
  47874. * By default it uses the babylonjs CDN.
  47875. * @ignoreNaming
  47876. */
  47877. static InspectorURL: string;
  47878. private _scene;
  47879. private BJSINSPECTOR;
  47880. private _onPropertyChangedObservable?;
  47881. /**
  47882. * Observable triggered when a property is changed through the inspector.
  47883. */
  47884. get onPropertyChangedObservable(): any;
  47885. /**
  47886. * Instantiates a new debug layer.
  47887. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47888. * what is happening in your scene
  47889. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47890. * @param scene Defines the scene to inspect
  47891. */
  47892. constructor(scene: Scene);
  47893. /** Creates the inspector window. */
  47894. private _createInspector;
  47895. /**
  47896. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47897. * @param entity defines the entity to select
  47898. * @param lineContainerTitle defines the specific block to highlight
  47899. */
  47900. select(entity: any, lineContainerTitle?: string): void;
  47901. /** Get the inspector from bundle or global */
  47902. private _getGlobalInspector;
  47903. /**
  47904. * Get if the inspector is visible or not.
  47905. * @returns true if visible otherwise, false
  47906. */
  47907. isVisible(): boolean;
  47908. /**
  47909. * Hide the inspector and close its window.
  47910. */
  47911. hide(): void;
  47912. /**
  47913. * Launch the debugLayer.
  47914. * @param config Define the configuration of the inspector
  47915. * @return a promise fulfilled when the debug layer is visible
  47916. */
  47917. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47918. }
  47919. }
  47920. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47921. import { Nullable } from "babylonjs/types";
  47922. import { Scene } from "babylonjs/scene";
  47923. import { Vector4 } from "babylonjs/Maths/math.vector";
  47924. import { Color4 } from "babylonjs/Maths/math.color";
  47925. import { Mesh } from "babylonjs/Meshes/mesh";
  47926. /**
  47927. * Class containing static functions to help procedurally build meshes
  47928. */
  47929. export class BoxBuilder {
  47930. /**
  47931. * Creates a box mesh
  47932. * * The parameter `size` sets the size (float) of each box side (default 1)
  47933. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47934. * * 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)
  47935. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47939. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47940. * @param name defines the name of the mesh
  47941. * @param options defines the options used to create the mesh
  47942. * @param scene defines the hosting scene
  47943. * @returns the box mesh
  47944. */
  47945. static CreateBox(name: string, options: {
  47946. size?: number;
  47947. width?: number;
  47948. height?: number;
  47949. depth?: number;
  47950. faceUV?: Vector4[];
  47951. faceColors?: Color4[];
  47952. sideOrientation?: number;
  47953. frontUVs?: Vector4;
  47954. backUVs?: Vector4;
  47955. wrap?: boolean;
  47956. topBaseAt?: number;
  47957. bottomBaseAt?: number;
  47958. updatable?: boolean;
  47959. }, scene?: Nullable<Scene>): Mesh;
  47960. }
  47961. }
  47962. declare module "babylonjs/Debug/physicsViewer" {
  47963. import { Nullable } from "babylonjs/types";
  47964. import { Scene } from "babylonjs/scene";
  47965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47966. import { Mesh } from "babylonjs/Meshes/mesh";
  47967. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47968. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47969. /**
  47970. * Used to show the physics impostor around the specific mesh
  47971. */
  47972. export class PhysicsViewer {
  47973. /** @hidden */
  47974. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47975. /** @hidden */
  47976. protected _meshes: Array<Nullable<AbstractMesh>>;
  47977. /** @hidden */
  47978. protected _scene: Nullable<Scene>;
  47979. /** @hidden */
  47980. protected _numMeshes: number;
  47981. /** @hidden */
  47982. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47983. private _renderFunction;
  47984. private _utilityLayer;
  47985. private _debugBoxMesh;
  47986. private _debugSphereMesh;
  47987. private _debugCylinderMesh;
  47988. private _debugMaterial;
  47989. private _debugMeshMeshes;
  47990. /**
  47991. * Creates a new PhysicsViewer
  47992. * @param scene defines the hosting scene
  47993. */
  47994. constructor(scene: Scene);
  47995. /** @hidden */
  47996. protected _updateDebugMeshes(): void;
  47997. /**
  47998. * Renders a specified physic impostor
  47999. * @param impostor defines the impostor to render
  48000. * @param targetMesh defines the mesh represented by the impostor
  48001. * @returns the new debug mesh used to render the impostor
  48002. */
  48003. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48004. /**
  48005. * Hides a specified physic impostor
  48006. * @param impostor defines the impostor to hide
  48007. */
  48008. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48009. private _getDebugMaterial;
  48010. private _getDebugBoxMesh;
  48011. private _getDebugSphereMesh;
  48012. private _getDebugCylinderMesh;
  48013. private _getDebugMeshMesh;
  48014. private _getDebugMesh;
  48015. /** Releases all resources */
  48016. dispose(): void;
  48017. }
  48018. }
  48019. declare module "babylonjs/Debug/rayHelper" {
  48020. import { Nullable } from "babylonjs/types";
  48021. import { Ray } from "babylonjs/Culling/ray";
  48022. import { Vector3 } from "babylonjs/Maths/math.vector";
  48023. import { Color3 } from "babylonjs/Maths/math.color";
  48024. import { Scene } from "babylonjs/scene";
  48025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48026. import "babylonjs/Meshes/Builders/linesBuilder";
  48027. /**
  48028. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48029. * in order to better appreciate the issue one might have.
  48030. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48031. */
  48032. export class RayHelper {
  48033. /**
  48034. * Defines the ray we are currently tryin to visualize.
  48035. */
  48036. ray: Nullable<Ray>;
  48037. private _renderPoints;
  48038. private _renderLine;
  48039. private _renderFunction;
  48040. private _scene;
  48041. private _updateToMeshFunction;
  48042. private _attachedToMesh;
  48043. private _meshSpaceDirection;
  48044. private _meshSpaceOrigin;
  48045. /**
  48046. * Helper function to create a colored helper in a scene in one line.
  48047. * @param ray Defines the ray we are currently tryin to visualize
  48048. * @param scene Defines the scene the ray is used in
  48049. * @param color Defines the color we want to see the ray in
  48050. * @returns The newly created ray helper.
  48051. */
  48052. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48053. /**
  48054. * Instantiate a new ray helper.
  48055. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48056. * in order to better appreciate the issue one might have.
  48057. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48058. * @param ray Defines the ray we are currently tryin to visualize
  48059. */
  48060. constructor(ray: Ray);
  48061. /**
  48062. * Shows the ray we are willing to debug.
  48063. * @param scene Defines the scene the ray needs to be rendered in
  48064. * @param color Defines the color the ray needs to be rendered in
  48065. */
  48066. show(scene: Scene, color?: Color3): void;
  48067. /**
  48068. * Hides the ray we are debugging.
  48069. */
  48070. hide(): void;
  48071. private _render;
  48072. /**
  48073. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48074. * @param mesh Defines the mesh we want the helper attached to
  48075. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48076. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48077. * @param length Defines the length of the ray
  48078. */
  48079. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48080. /**
  48081. * Detach the ray helper from the mesh it has previously been attached to.
  48082. */
  48083. detachFromMesh(): void;
  48084. private _updateToMesh;
  48085. /**
  48086. * Dispose the helper and release its associated resources.
  48087. */
  48088. dispose(): void;
  48089. }
  48090. }
  48091. declare module "babylonjs/Debug/skeletonViewer" {
  48092. import { Color3 } from "babylonjs/Maths/math.color";
  48093. import { Scene } from "babylonjs/scene";
  48094. import { Nullable } from "babylonjs/types";
  48095. import { Skeleton } from "babylonjs/Bones/skeleton";
  48096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48097. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48098. /**
  48099. * Class used to render a debug view of a given skeleton
  48100. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48101. */
  48102. export class SkeletonViewer {
  48103. /** defines the skeleton to render */
  48104. skeleton: Skeleton;
  48105. /** defines the mesh attached to the skeleton */
  48106. mesh: AbstractMesh;
  48107. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48108. autoUpdateBonesMatrices: boolean;
  48109. /** defines the rendering group id to use with the viewer */
  48110. renderingGroupId: number;
  48111. /** Gets or sets the color used to render the skeleton */
  48112. color: Color3;
  48113. private _scene;
  48114. private _debugLines;
  48115. private _debugMesh;
  48116. private _isEnabled;
  48117. private _renderFunction;
  48118. private _utilityLayer;
  48119. /**
  48120. * Returns the mesh used to render the bones
  48121. */
  48122. get debugMesh(): Nullable<LinesMesh>;
  48123. /**
  48124. * Creates a new SkeletonViewer
  48125. * @param skeleton defines the skeleton to render
  48126. * @param mesh defines the mesh attached to the skeleton
  48127. * @param scene defines the hosting scene
  48128. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48129. * @param renderingGroupId defines the rendering group id to use with the viewer
  48130. */
  48131. constructor(
  48132. /** defines the skeleton to render */
  48133. skeleton: Skeleton,
  48134. /** defines the mesh attached to the skeleton */
  48135. mesh: AbstractMesh, scene: Scene,
  48136. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48137. autoUpdateBonesMatrices?: boolean,
  48138. /** defines the rendering group id to use with the viewer */
  48139. renderingGroupId?: number);
  48140. /** Gets or sets a boolean indicating if the viewer is enabled */
  48141. set isEnabled(value: boolean);
  48142. get isEnabled(): boolean;
  48143. private _getBonePosition;
  48144. private _getLinesForBonesWithLength;
  48145. private _getLinesForBonesNoLength;
  48146. /** Update the viewer to sync with current skeleton state */
  48147. update(): void;
  48148. /** Release associated resources */
  48149. dispose(): void;
  48150. }
  48151. }
  48152. declare module "babylonjs/Debug/index" {
  48153. export * from "babylonjs/Debug/axesViewer";
  48154. export * from "babylonjs/Debug/boneAxesViewer";
  48155. export * from "babylonjs/Debug/debugLayer";
  48156. export * from "babylonjs/Debug/physicsViewer";
  48157. export * from "babylonjs/Debug/rayHelper";
  48158. export * from "babylonjs/Debug/skeletonViewer";
  48159. }
  48160. declare module "babylonjs/Engines/nullEngine" {
  48161. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48162. import { Scene } from "babylonjs/scene";
  48163. import { Engine } from "babylonjs/Engines/engine";
  48164. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48165. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48166. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48167. import { Effect } from "babylonjs/Materials/effect";
  48168. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48169. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48170. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48171. /**
  48172. * Options to create the null engine
  48173. */
  48174. export class NullEngineOptions {
  48175. /**
  48176. * Render width (Default: 512)
  48177. */
  48178. renderWidth: number;
  48179. /**
  48180. * Render height (Default: 256)
  48181. */
  48182. renderHeight: number;
  48183. /**
  48184. * Texture size (Default: 512)
  48185. */
  48186. textureSize: number;
  48187. /**
  48188. * If delta time between frames should be constant
  48189. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48190. */
  48191. deterministicLockstep: boolean;
  48192. /**
  48193. * Maximum about of steps between frames (Default: 4)
  48194. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48195. */
  48196. lockstepMaxSteps: number;
  48197. }
  48198. /**
  48199. * The null engine class provides support for headless version of babylon.js.
  48200. * This can be used in server side scenario or for testing purposes
  48201. */
  48202. export class NullEngine extends Engine {
  48203. private _options;
  48204. /**
  48205. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48206. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48207. * @returns true if engine is in deterministic lock step mode
  48208. */
  48209. isDeterministicLockStep(): boolean;
  48210. /**
  48211. * Gets the max steps when engine is running in deterministic lock step
  48212. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48213. * @returns the max steps
  48214. */
  48215. getLockstepMaxSteps(): number;
  48216. /**
  48217. * Gets the current hardware scaling level.
  48218. * By default the hardware scaling level is computed from the window device ratio.
  48219. * 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.
  48220. * @returns a number indicating the current hardware scaling level
  48221. */
  48222. getHardwareScalingLevel(): number;
  48223. constructor(options?: NullEngineOptions);
  48224. /**
  48225. * Creates a vertex buffer
  48226. * @param vertices the data for the vertex buffer
  48227. * @returns the new WebGL static buffer
  48228. */
  48229. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48230. /**
  48231. * Creates a new index buffer
  48232. * @param indices defines the content of the index buffer
  48233. * @param updatable defines if the index buffer must be updatable
  48234. * @returns a new webGL buffer
  48235. */
  48236. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48237. /**
  48238. * Clear the current render buffer or the current render target (if any is set up)
  48239. * @param color defines the color to use
  48240. * @param backBuffer defines if the back buffer must be cleared
  48241. * @param depth defines if the depth buffer must be cleared
  48242. * @param stencil defines if the stencil buffer must be cleared
  48243. */
  48244. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48245. /**
  48246. * Gets the current render width
  48247. * @param useScreen defines if screen size must be used (or the current render target if any)
  48248. * @returns a number defining the current render width
  48249. */
  48250. getRenderWidth(useScreen?: boolean): number;
  48251. /**
  48252. * Gets the current render height
  48253. * @param useScreen defines if screen size must be used (or the current render target if any)
  48254. * @returns a number defining the current render height
  48255. */
  48256. getRenderHeight(useScreen?: boolean): number;
  48257. /**
  48258. * Set the WebGL's viewport
  48259. * @param viewport defines the viewport element to be used
  48260. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48261. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48262. */
  48263. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48265. /**
  48266. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48267. * @param pipelineContext defines the pipeline context to use
  48268. * @param uniformsNames defines the list of uniform names
  48269. * @returns an array of webGL uniform locations
  48270. */
  48271. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48272. /**
  48273. * Gets the lsit of active attributes for a given webGL program
  48274. * @param pipelineContext defines the pipeline context to use
  48275. * @param attributesNames defines the list of attribute names to get
  48276. * @returns an array of indices indicating the offset of each attribute
  48277. */
  48278. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48279. /**
  48280. * Binds an effect to the webGL context
  48281. * @param effect defines the effect to bind
  48282. */
  48283. bindSamplers(effect: Effect): void;
  48284. /**
  48285. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48286. * @param effect defines the effect to activate
  48287. */
  48288. enableEffect(effect: Effect): void;
  48289. /**
  48290. * Set various states to the webGL context
  48291. * @param culling defines backface culling state
  48292. * @param zOffset defines the value to apply to zOffset (0 by default)
  48293. * @param force defines if states must be applied even if cache is up to date
  48294. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48295. */
  48296. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48297. /**
  48298. * Set the value of an uniform to an array of int32
  48299. * @param uniform defines the webGL uniform location where to store the value
  48300. * @param array defines the array of int32 to store
  48301. */
  48302. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48303. /**
  48304. * Set the value of an uniform to an array of int32 (stored as vec2)
  48305. * @param uniform defines the webGL uniform location where to store the value
  48306. * @param array defines the array of int32 to store
  48307. */
  48308. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48309. /**
  48310. * Set the value of an uniform to an array of int32 (stored as vec3)
  48311. * @param uniform defines the webGL uniform location where to store the value
  48312. * @param array defines the array of int32 to store
  48313. */
  48314. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48315. /**
  48316. * Set the value of an uniform to an array of int32 (stored as vec4)
  48317. * @param uniform defines the webGL uniform location where to store the value
  48318. * @param array defines the array of int32 to store
  48319. */
  48320. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48321. /**
  48322. * Set the value of an uniform to an array of float32
  48323. * @param uniform defines the webGL uniform location where to store the value
  48324. * @param array defines the array of float32 to store
  48325. */
  48326. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48327. /**
  48328. * Set the value of an uniform to an array of float32 (stored as vec2)
  48329. * @param uniform defines the webGL uniform location where to store the value
  48330. * @param array defines the array of float32 to store
  48331. */
  48332. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48333. /**
  48334. * Set the value of an uniform to an array of float32 (stored as vec3)
  48335. * @param uniform defines the webGL uniform location where to store the value
  48336. * @param array defines the array of float32 to store
  48337. */
  48338. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48339. /**
  48340. * Set the value of an uniform to an array of float32 (stored as vec4)
  48341. * @param uniform defines the webGL uniform location where to store the value
  48342. * @param array defines the array of float32 to store
  48343. */
  48344. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48345. /**
  48346. * Set the value of an uniform to an array of number
  48347. * @param uniform defines the webGL uniform location where to store the value
  48348. * @param array defines the array of number to store
  48349. */
  48350. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48351. /**
  48352. * Set the value of an uniform to an array of number (stored as vec2)
  48353. * @param uniform defines the webGL uniform location where to store the value
  48354. * @param array defines the array of number to store
  48355. */
  48356. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48357. /**
  48358. * Set the value of an uniform to an array of number (stored as vec3)
  48359. * @param uniform defines the webGL uniform location where to store the value
  48360. * @param array defines the array of number to store
  48361. */
  48362. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48363. /**
  48364. * Set the value of an uniform to an array of number (stored as vec4)
  48365. * @param uniform defines the webGL uniform location where to store the value
  48366. * @param array defines the array of number to store
  48367. */
  48368. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48369. /**
  48370. * Set the value of an uniform to an array of float32 (stored as matrices)
  48371. * @param uniform defines the webGL uniform location where to store the value
  48372. * @param matrices defines the array of float32 to store
  48373. */
  48374. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48375. /**
  48376. * Set the value of an uniform to a matrix (3x3)
  48377. * @param uniform defines the webGL uniform location where to store the value
  48378. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48379. */
  48380. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48381. /**
  48382. * Set the value of an uniform to a matrix (2x2)
  48383. * @param uniform defines the webGL uniform location where to store the value
  48384. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48385. */
  48386. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48387. /**
  48388. * Set the value of an uniform to a number (float)
  48389. * @param uniform defines the webGL uniform location where to store the value
  48390. * @param value defines the float number to store
  48391. */
  48392. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48393. /**
  48394. * Set the value of an uniform to a vec2
  48395. * @param uniform defines the webGL uniform location where to store the value
  48396. * @param x defines the 1st component of the value
  48397. * @param y defines the 2nd component of the value
  48398. */
  48399. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48400. /**
  48401. * Set the value of an uniform to a vec3
  48402. * @param uniform defines the webGL uniform location where to store the value
  48403. * @param x defines the 1st component of the value
  48404. * @param y defines the 2nd component of the value
  48405. * @param z defines the 3rd component of the value
  48406. */
  48407. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48408. /**
  48409. * Set the value of an uniform to a boolean
  48410. * @param uniform defines the webGL uniform location where to store the value
  48411. * @param bool defines the boolean to store
  48412. */
  48413. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48414. /**
  48415. * Set the value of an uniform to a vec4
  48416. * @param uniform defines the webGL uniform location where to store the value
  48417. * @param x defines the 1st component of the value
  48418. * @param y defines the 2nd component of the value
  48419. * @param z defines the 3rd component of the value
  48420. * @param w defines the 4th component of the value
  48421. */
  48422. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48423. /**
  48424. * Sets the current alpha mode
  48425. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48426. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48428. */
  48429. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48430. /**
  48431. * Bind webGl buffers directly to the webGL context
  48432. * @param vertexBuffers defines the vertex buffer to bind
  48433. * @param indexBuffer defines the index buffer to bind
  48434. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48435. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48436. * @param effect defines the effect associated with the vertex buffer
  48437. */
  48438. bindBuffers(vertexBuffers: {
  48439. [key: string]: VertexBuffer;
  48440. }, indexBuffer: DataBuffer, effect: Effect): void;
  48441. /**
  48442. * Force the entire cache to be cleared
  48443. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48444. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48445. */
  48446. wipeCaches(bruteForce?: boolean): void;
  48447. /**
  48448. * Send a draw order
  48449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48450. * @param indexStart defines the starting index
  48451. * @param indexCount defines the number of index to draw
  48452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48453. */
  48454. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48455. /**
  48456. * Draw a list of indexed primitives
  48457. * @param fillMode defines the primitive to use
  48458. * @param indexStart defines the starting index
  48459. * @param indexCount defines the number of index to draw
  48460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48461. */
  48462. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48463. /**
  48464. * Draw a list of unindexed primitives
  48465. * @param fillMode defines the primitive to use
  48466. * @param verticesStart defines the index of first vertex to draw
  48467. * @param verticesCount defines the count of vertices to draw
  48468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48469. */
  48470. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48471. /** @hidden */
  48472. _createTexture(): WebGLTexture;
  48473. /** @hidden */
  48474. _releaseTexture(texture: InternalTexture): void;
  48475. /**
  48476. * Usually called from Texture.ts.
  48477. * Passed information to create a WebGLTexture
  48478. * @param urlArg defines a value which contains one of the following:
  48479. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48480. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48481. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48482. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48483. * @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)
  48484. * @param scene needed for loading to the correct scene
  48485. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48486. * @param onLoad optional callback to be called upon successful completion
  48487. * @param onError optional callback to be called upon failure
  48488. * @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
  48489. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48490. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48491. * @param forcedExtension defines the extension to use to pick the right loader
  48492. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48493. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48494. */
  48495. 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;
  48496. /**
  48497. * Creates a new render target texture
  48498. * @param size defines the size of the texture
  48499. * @param options defines the options used to create the texture
  48500. * @returns a new render target texture stored in an InternalTexture
  48501. */
  48502. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48503. /**
  48504. * Update the sampling mode of a given texture
  48505. * @param samplingMode defines the required sampling mode
  48506. * @param texture defines the texture to update
  48507. */
  48508. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48509. /**
  48510. * Binds the frame buffer to the specified texture.
  48511. * @param texture The texture to render to or null for the default canvas
  48512. * @param faceIndex The face of the texture to render to in case of cube texture
  48513. * @param requiredWidth The width of the target to render to
  48514. * @param requiredHeight The height of the target to render to
  48515. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48516. * @param lodLevel defines le lod level to bind to the frame buffer
  48517. */
  48518. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48519. /**
  48520. * Unbind the current render target texture from the webGL context
  48521. * @param texture defines the render target texture to unbind
  48522. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48523. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48524. */
  48525. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48526. /**
  48527. * Creates a dynamic vertex buffer
  48528. * @param vertices the data for the dynamic vertex buffer
  48529. * @returns the new WebGL dynamic buffer
  48530. */
  48531. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48532. /**
  48533. * Update the content of a dynamic texture
  48534. * @param texture defines the texture to update
  48535. * @param canvas defines the canvas containing the source
  48536. * @param invertY defines if data must be stored with Y axis inverted
  48537. * @param premulAlpha defines if alpha is stored as premultiplied
  48538. * @param format defines the format of the data
  48539. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48540. */
  48541. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48542. /**
  48543. * Gets a boolean indicating if all created effects are ready
  48544. * @returns true if all effects are ready
  48545. */
  48546. areAllEffectsReady(): boolean;
  48547. /**
  48548. * @hidden
  48549. * Get the current error code of the webGL context
  48550. * @returns the error code
  48551. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48552. */
  48553. getError(): number;
  48554. /** @hidden */
  48555. _getUnpackAlignement(): number;
  48556. /** @hidden */
  48557. _unpackFlipY(value: boolean): void;
  48558. /**
  48559. * Update a dynamic index buffer
  48560. * @param indexBuffer defines the target index buffer
  48561. * @param indices defines the data to update
  48562. * @param offset defines the offset in the target index buffer where update should start
  48563. */
  48564. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48565. /**
  48566. * Updates a dynamic vertex buffer.
  48567. * @param vertexBuffer the vertex buffer to update
  48568. * @param vertices the data used to update the vertex buffer
  48569. * @param byteOffset the byte offset of the data (optional)
  48570. * @param byteLength the byte length of the data (optional)
  48571. */
  48572. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48573. /** @hidden */
  48574. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48575. /** @hidden */
  48576. _bindTexture(channel: number, texture: InternalTexture): void;
  48577. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48578. /**
  48579. * 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
  48580. */
  48581. releaseEffects(): void;
  48582. displayLoadingUI(): void;
  48583. hideLoadingUI(): void;
  48584. /** @hidden */
  48585. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48586. /** @hidden */
  48587. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48588. /** @hidden */
  48589. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48590. /** @hidden */
  48591. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48592. }
  48593. }
  48594. declare module "babylonjs/Instrumentation/timeToken" {
  48595. import { Nullable } from "babylonjs/types";
  48596. /**
  48597. * @hidden
  48598. **/
  48599. export class _TimeToken {
  48600. _startTimeQuery: Nullable<WebGLQuery>;
  48601. _endTimeQuery: Nullable<WebGLQuery>;
  48602. _timeElapsedQuery: Nullable<WebGLQuery>;
  48603. _timeElapsedQueryEnded: boolean;
  48604. }
  48605. }
  48606. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48607. import { Nullable, int } from "babylonjs/types";
  48608. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48609. /** @hidden */
  48610. export class _OcclusionDataStorage {
  48611. /** @hidden */
  48612. occlusionInternalRetryCounter: number;
  48613. /** @hidden */
  48614. isOcclusionQueryInProgress: boolean;
  48615. /** @hidden */
  48616. isOccluded: boolean;
  48617. /** @hidden */
  48618. occlusionRetryCount: number;
  48619. /** @hidden */
  48620. occlusionType: number;
  48621. /** @hidden */
  48622. occlusionQueryAlgorithmType: number;
  48623. }
  48624. module "babylonjs/Engines/engine" {
  48625. interface Engine {
  48626. /**
  48627. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48628. * @return the new query
  48629. */
  48630. createQuery(): WebGLQuery;
  48631. /**
  48632. * Delete and release a webGL query
  48633. * @param query defines the query to delete
  48634. * @return the current engine
  48635. */
  48636. deleteQuery(query: WebGLQuery): Engine;
  48637. /**
  48638. * Check if a given query has resolved and got its value
  48639. * @param query defines the query to check
  48640. * @returns true if the query got its value
  48641. */
  48642. isQueryResultAvailable(query: WebGLQuery): boolean;
  48643. /**
  48644. * Gets the value of a given query
  48645. * @param query defines the query to check
  48646. * @returns the value of the query
  48647. */
  48648. getQueryResult(query: WebGLQuery): number;
  48649. /**
  48650. * Initiates an occlusion query
  48651. * @param algorithmType defines the algorithm to use
  48652. * @param query defines the query to use
  48653. * @returns the current engine
  48654. * @see http://doc.babylonjs.com/features/occlusionquery
  48655. */
  48656. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48657. /**
  48658. * Ends an occlusion query
  48659. * @see http://doc.babylonjs.com/features/occlusionquery
  48660. * @param algorithmType defines the algorithm to use
  48661. * @returns the current engine
  48662. */
  48663. endOcclusionQuery(algorithmType: number): Engine;
  48664. /**
  48665. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48666. * Please note that only one query can be issued at a time
  48667. * @returns a time token used to track the time span
  48668. */
  48669. startTimeQuery(): Nullable<_TimeToken>;
  48670. /**
  48671. * Ends a time query
  48672. * @param token defines the token used to measure the time span
  48673. * @returns the time spent (in ns)
  48674. */
  48675. endTimeQuery(token: _TimeToken): int;
  48676. /** @hidden */
  48677. _currentNonTimestampToken: Nullable<_TimeToken>;
  48678. /** @hidden */
  48679. _createTimeQuery(): WebGLQuery;
  48680. /** @hidden */
  48681. _deleteTimeQuery(query: WebGLQuery): void;
  48682. /** @hidden */
  48683. _getGlAlgorithmType(algorithmType: number): number;
  48684. /** @hidden */
  48685. _getTimeQueryResult(query: WebGLQuery): any;
  48686. /** @hidden */
  48687. _getTimeQueryAvailability(query: WebGLQuery): any;
  48688. }
  48689. }
  48690. module "babylonjs/Meshes/abstractMesh" {
  48691. interface AbstractMesh {
  48692. /**
  48693. * Backing filed
  48694. * @hidden
  48695. */
  48696. __occlusionDataStorage: _OcclusionDataStorage;
  48697. /**
  48698. * Access property
  48699. * @hidden
  48700. */
  48701. _occlusionDataStorage: _OcclusionDataStorage;
  48702. /**
  48703. * 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.
  48704. * The default value is -1 which means don't break the query and wait till the result
  48705. * @see http://doc.babylonjs.com/features/occlusionquery
  48706. */
  48707. occlusionRetryCount: number;
  48708. /**
  48709. * 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:
  48710. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48711. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48712. * * 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.
  48713. * @see http://doc.babylonjs.com/features/occlusionquery
  48714. */
  48715. occlusionType: number;
  48716. /**
  48717. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48718. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48719. * * 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.
  48720. * @see http://doc.babylonjs.com/features/occlusionquery
  48721. */
  48722. occlusionQueryAlgorithmType: number;
  48723. /**
  48724. * 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
  48725. * @see http://doc.babylonjs.com/features/occlusionquery
  48726. */
  48727. isOccluded: boolean;
  48728. /**
  48729. * Flag to check the progress status of the query
  48730. * @see http://doc.babylonjs.com/features/occlusionquery
  48731. */
  48732. isOcclusionQueryInProgress: boolean;
  48733. }
  48734. }
  48735. }
  48736. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48737. import { Nullable } from "babylonjs/types";
  48738. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48739. /** @hidden */
  48740. export var _forceTransformFeedbackToBundle: boolean;
  48741. module "babylonjs/Engines/engine" {
  48742. interface Engine {
  48743. /**
  48744. * Creates a webGL transform feedback object
  48745. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48746. * @returns the webGL transform feedback object
  48747. */
  48748. createTransformFeedback(): WebGLTransformFeedback;
  48749. /**
  48750. * Delete a webGL transform feedback object
  48751. * @param value defines the webGL transform feedback object to delete
  48752. */
  48753. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48754. /**
  48755. * Bind a webGL transform feedback object to the webgl context
  48756. * @param value defines the webGL transform feedback object to bind
  48757. */
  48758. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48759. /**
  48760. * Begins a transform feedback operation
  48761. * @param usePoints defines if points or triangles must be used
  48762. */
  48763. beginTransformFeedback(usePoints: boolean): void;
  48764. /**
  48765. * Ends a transform feedback operation
  48766. */
  48767. endTransformFeedback(): void;
  48768. /**
  48769. * Specify the varyings to use with transform feedback
  48770. * @param program defines the associated webGL program
  48771. * @param value defines the list of strings representing the varying names
  48772. */
  48773. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48774. /**
  48775. * Bind a webGL buffer for a transform feedback operation
  48776. * @param value defines the webGL buffer to bind
  48777. */
  48778. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48779. }
  48780. }
  48781. }
  48782. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48783. import { Scene } from "babylonjs/scene";
  48784. import { Engine } from "babylonjs/Engines/engine";
  48785. import { Texture } from "babylonjs/Materials/Textures/texture";
  48786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48787. import "babylonjs/Engines/Extensions/engine.multiRender";
  48788. /**
  48789. * Creation options of the multi render target texture.
  48790. */
  48791. export interface IMultiRenderTargetOptions {
  48792. /**
  48793. * Define if the texture needs to create mip maps after render.
  48794. */
  48795. generateMipMaps?: boolean;
  48796. /**
  48797. * Define the types of all the draw buffers we want to create
  48798. */
  48799. types?: number[];
  48800. /**
  48801. * Define the sampling modes of all the draw buffers we want to create
  48802. */
  48803. samplingModes?: number[];
  48804. /**
  48805. * Define if a depth buffer is required
  48806. */
  48807. generateDepthBuffer?: boolean;
  48808. /**
  48809. * Define if a stencil buffer is required
  48810. */
  48811. generateStencilBuffer?: boolean;
  48812. /**
  48813. * Define if a depth texture is required instead of a depth buffer
  48814. */
  48815. generateDepthTexture?: boolean;
  48816. /**
  48817. * Define the number of desired draw buffers
  48818. */
  48819. textureCount?: number;
  48820. /**
  48821. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48822. */
  48823. doNotChangeAspectRatio?: boolean;
  48824. /**
  48825. * Define the default type of the buffers we are creating
  48826. */
  48827. defaultType?: number;
  48828. }
  48829. /**
  48830. * A multi render target, like a render target provides the ability to render to a texture.
  48831. * Unlike the render target, it can render to several draw buffers in one draw.
  48832. * This is specially interesting in deferred rendering or for any effects requiring more than
  48833. * just one color from a single pass.
  48834. */
  48835. export class MultiRenderTarget extends RenderTargetTexture {
  48836. private _internalTextures;
  48837. private _textures;
  48838. private _multiRenderTargetOptions;
  48839. /**
  48840. * Get if draw buffers are currently supported by the used hardware and browser.
  48841. */
  48842. get isSupported(): boolean;
  48843. /**
  48844. * Get the list of textures generated by the multi render target.
  48845. */
  48846. get textures(): Texture[];
  48847. /**
  48848. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48849. */
  48850. get depthTexture(): Texture;
  48851. /**
  48852. * Set the wrapping mode on U 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 wrapU(wrap: number);
  48856. /**
  48857. * Set the wrapping mode on V of all the textures we are rendering to.
  48858. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48859. */
  48860. set wrapV(wrap: number);
  48861. /**
  48862. * Instantiate a new multi render target texture.
  48863. * A multi render target, like a render target provides the ability to render to a texture.
  48864. * Unlike the render target, it can render to several draw buffers in one draw.
  48865. * This is specially interesting in deferred rendering or for any effects requiring more than
  48866. * just one color from a single pass.
  48867. * @param name Define the name of the texture
  48868. * @param size Define the size of the buffers to render to
  48869. * @param count Define the number of target we are rendering into
  48870. * @param scene Define the scene the texture belongs to
  48871. * @param options Define the options used to create the multi render target
  48872. */
  48873. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48874. /** @hidden */
  48875. _rebuild(): void;
  48876. private _createInternalTextures;
  48877. private _createTextures;
  48878. /**
  48879. * Define the number of samples used if MSAA is enabled.
  48880. */
  48881. get samples(): number;
  48882. set samples(value: number);
  48883. /**
  48884. * Resize all the textures in the multi render target.
  48885. * Be carrefull as it will recreate all the data in the new texture.
  48886. * @param size Define the new size
  48887. */
  48888. resize(size: any): void;
  48889. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48890. /**
  48891. * Dispose the render targets and their associated resources
  48892. */
  48893. dispose(): void;
  48894. /**
  48895. * Release all the underlying texture used as draw buffers.
  48896. */
  48897. releaseInternalTextures(): void;
  48898. }
  48899. }
  48900. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48902. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48903. import { Nullable } from "babylonjs/types";
  48904. module "babylonjs/Engines/thinEngine" {
  48905. interface ThinEngine {
  48906. /**
  48907. * Unbind a list of render target textures from the webGL context
  48908. * This is used only when drawBuffer extension or webGL2 are active
  48909. * @param textures defines the render target textures to unbind
  48910. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48911. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48912. */
  48913. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48914. /**
  48915. * Create a multi render target texture
  48916. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48917. * @param size defines the size of the texture
  48918. * @param options defines the creation options
  48919. * @returns the cube texture as an InternalTexture
  48920. */
  48921. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48922. /**
  48923. * Update the sample count for a given multiple render target texture
  48924. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48925. * @param textures defines the textures to update
  48926. * @param samples defines the sample count to set
  48927. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48928. */
  48929. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48930. }
  48931. }
  48932. }
  48933. declare module "babylonjs/Engines/Extensions/engine.views" {
  48934. import { Camera } from "babylonjs/Cameras/camera";
  48935. import { Nullable } from "babylonjs/types";
  48936. /**
  48937. * Class used to define an additional view for the engine
  48938. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48939. */
  48940. export class EngineView {
  48941. /** Defines the canvas where to render the view */
  48942. target: HTMLCanvasElement;
  48943. /** Defines an optional camera used to render the view (will use active camera else) */
  48944. camera?: Camera;
  48945. }
  48946. module "babylonjs/Engines/engine" {
  48947. interface Engine {
  48948. /**
  48949. * Gets or sets the HTML element to use for attaching events
  48950. */
  48951. inputElement: Nullable<HTMLElement>;
  48952. /**
  48953. * Gets the current engine view
  48954. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48955. */
  48956. activeView: Nullable<EngineView>;
  48957. /** Gets or sets the list of views */
  48958. views: EngineView[];
  48959. /**
  48960. * Register a new child canvas
  48961. * @param canvas defines the canvas to register
  48962. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48963. * @returns the associated view
  48964. */
  48965. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48966. /**
  48967. * Remove a registered child canvas
  48968. * @param canvas defines the canvas to remove
  48969. * @returns the current engine
  48970. */
  48971. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48972. }
  48973. }
  48974. }
  48975. declare module "babylonjs/Engines/Extensions/index" {
  48976. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48977. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48978. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48979. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48980. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48981. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48982. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48983. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48984. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48985. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48986. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48987. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48988. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48989. export * from "babylonjs/Engines/Extensions/engine.views";
  48990. }
  48991. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48992. import { Nullable } from "babylonjs/types";
  48993. /**
  48994. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48995. */
  48996. export interface CubeMapInfo {
  48997. /**
  48998. * The pixel array for the front face.
  48999. * This is stored in format, left to right, up to down format.
  49000. */
  49001. front: Nullable<ArrayBufferView>;
  49002. /**
  49003. * The pixel array for the back face.
  49004. * This is stored in format, left to right, up to down format.
  49005. */
  49006. back: Nullable<ArrayBufferView>;
  49007. /**
  49008. * The pixel array for the left face.
  49009. * This is stored in format, left to right, up to down format.
  49010. */
  49011. left: Nullable<ArrayBufferView>;
  49012. /**
  49013. * The pixel array for the right face.
  49014. * This is stored in format, left to right, up to down format.
  49015. */
  49016. right: Nullable<ArrayBufferView>;
  49017. /**
  49018. * The pixel array for the up face.
  49019. * This is stored in format, left to right, up to down format.
  49020. */
  49021. up: Nullable<ArrayBufferView>;
  49022. /**
  49023. * The pixel array for the down face.
  49024. * This is stored in format, left to right, up to down format.
  49025. */
  49026. down: Nullable<ArrayBufferView>;
  49027. /**
  49028. * The size of the cubemap stored.
  49029. *
  49030. * Each faces will be size * size pixels.
  49031. */
  49032. size: number;
  49033. /**
  49034. * The format of the texture.
  49035. *
  49036. * RGBA, RGB.
  49037. */
  49038. format: number;
  49039. /**
  49040. * The type of the texture data.
  49041. *
  49042. * UNSIGNED_INT, FLOAT.
  49043. */
  49044. type: number;
  49045. /**
  49046. * Specifies whether the texture is in gamma space.
  49047. */
  49048. gammaSpace: boolean;
  49049. }
  49050. /**
  49051. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49052. */
  49053. export class PanoramaToCubeMapTools {
  49054. private static FACE_FRONT;
  49055. private static FACE_BACK;
  49056. private static FACE_RIGHT;
  49057. private static FACE_LEFT;
  49058. private static FACE_DOWN;
  49059. private static FACE_UP;
  49060. /**
  49061. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49062. *
  49063. * @param float32Array The source data.
  49064. * @param inputWidth The width of the input panorama.
  49065. * @param inputHeight The height of the input panorama.
  49066. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49067. * @return The cubemap data
  49068. */
  49069. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49070. private static CreateCubemapTexture;
  49071. private static CalcProjectionSpherical;
  49072. }
  49073. }
  49074. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49075. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49077. import { Nullable } from "babylonjs/types";
  49078. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49079. /**
  49080. * Helper class dealing with the extraction of spherical polynomial dataArray
  49081. * from a cube map.
  49082. */
  49083. export class CubeMapToSphericalPolynomialTools {
  49084. private static FileFaces;
  49085. /**
  49086. * Converts a texture to the according Spherical Polynomial data.
  49087. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49088. *
  49089. * @param texture The texture to extract the information from.
  49090. * @return The Spherical Polynomial data.
  49091. */
  49092. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49093. /**
  49094. * Converts a cubemap to the according Spherical Polynomial data.
  49095. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49096. *
  49097. * @param cubeInfo The Cube map to extract the information from.
  49098. * @return The Spherical Polynomial data.
  49099. */
  49100. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49101. }
  49102. }
  49103. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49104. import { Nullable } from "babylonjs/types";
  49105. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49106. module "babylonjs/Materials/Textures/baseTexture" {
  49107. interface BaseTexture {
  49108. /**
  49109. * Get the polynomial representation of the texture data.
  49110. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49111. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49112. */
  49113. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49114. }
  49115. }
  49116. }
  49117. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49118. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49119. /** @hidden */
  49120. export var rgbdEncodePixelShader: {
  49121. name: string;
  49122. shader: string;
  49123. };
  49124. }
  49125. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49126. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49127. /** @hidden */
  49128. export var rgbdDecodePixelShader: {
  49129. name: string;
  49130. shader: string;
  49131. };
  49132. }
  49133. declare module "babylonjs/Misc/environmentTextureTools" {
  49134. import { Nullable } from "babylonjs/types";
  49135. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49136. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49137. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49138. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49139. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49140. import "babylonjs/Shaders/rgbdEncode.fragment";
  49141. import "babylonjs/Shaders/rgbdDecode.fragment";
  49142. /**
  49143. * Raw texture data and descriptor sufficient for WebGL texture upload
  49144. */
  49145. export interface EnvironmentTextureInfo {
  49146. /**
  49147. * Version of the environment map
  49148. */
  49149. version: number;
  49150. /**
  49151. * Width of image
  49152. */
  49153. width: number;
  49154. /**
  49155. * Irradiance information stored in the file.
  49156. */
  49157. irradiance: any;
  49158. /**
  49159. * Specular information stored in the file.
  49160. */
  49161. specular: any;
  49162. }
  49163. /**
  49164. * Defines One Image in the file. It requires only the position in the file
  49165. * as well as the length.
  49166. */
  49167. interface BufferImageData {
  49168. /**
  49169. * Length of the image data.
  49170. */
  49171. length: number;
  49172. /**
  49173. * Position of the data from the null terminator delimiting the end of the JSON.
  49174. */
  49175. position: number;
  49176. }
  49177. /**
  49178. * Defines the specular data enclosed in the file.
  49179. * This corresponds to the version 1 of the data.
  49180. */
  49181. export interface EnvironmentTextureSpecularInfoV1 {
  49182. /**
  49183. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49184. */
  49185. specularDataPosition?: number;
  49186. /**
  49187. * This contains all the images data needed to reconstruct the cubemap.
  49188. */
  49189. mipmaps: Array<BufferImageData>;
  49190. /**
  49191. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49192. */
  49193. lodGenerationScale: number;
  49194. }
  49195. /**
  49196. * Sets of helpers addressing the serialization and deserialization of environment texture
  49197. * stored in a BabylonJS env file.
  49198. * Those files are usually stored as .env files.
  49199. */
  49200. export class EnvironmentTextureTools {
  49201. /**
  49202. * Magic number identifying the env file.
  49203. */
  49204. private static _MagicBytes;
  49205. /**
  49206. * Gets the environment info from an env file.
  49207. * @param data The array buffer containing the .env bytes.
  49208. * @returns the environment file info (the json header) if successfully parsed.
  49209. */
  49210. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49211. /**
  49212. * Creates an environment texture from a loaded cube texture.
  49213. * @param texture defines the cube texture to convert in env file
  49214. * @return a promise containing the environment data if succesfull.
  49215. */
  49216. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49217. /**
  49218. * Creates a JSON representation of the spherical data.
  49219. * @param texture defines the texture containing the polynomials
  49220. * @return the JSON representation of the spherical info
  49221. */
  49222. private static _CreateEnvTextureIrradiance;
  49223. /**
  49224. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49225. * @param data the image data
  49226. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49227. * @return the views described by info providing access to the underlying buffer
  49228. */
  49229. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49230. /**
  49231. * Uploads the texture info contained in the env file to the GPU.
  49232. * @param texture defines the internal texture to upload to
  49233. * @param data defines the data to load
  49234. * @param info defines the texture info retrieved through the GetEnvInfo method
  49235. * @returns a promise
  49236. */
  49237. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49238. private static _OnImageReadyAsync;
  49239. /**
  49240. * Uploads the levels of image data to the GPU.
  49241. * @param texture defines the internal texture to upload to
  49242. * @param imageData defines the array buffer views of image data [mipmap][face]
  49243. * @returns a promise
  49244. */
  49245. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49246. /**
  49247. * Uploads spherical polynomials information to the texture.
  49248. * @param texture defines the texture we are trying to upload the information to
  49249. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49250. */
  49251. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49252. /** @hidden */
  49253. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49254. }
  49255. }
  49256. declare module "babylonjs/Maths/math.vertexFormat" {
  49257. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49258. /**
  49259. * Contains position and normal vectors for a vertex
  49260. */
  49261. export class PositionNormalVertex {
  49262. /** the position of the vertex (defaut: 0,0,0) */
  49263. position: Vector3;
  49264. /** the normal of the vertex (defaut: 0,1,0) */
  49265. normal: Vector3;
  49266. /**
  49267. * Creates a PositionNormalVertex
  49268. * @param position the position of the vertex (defaut: 0,0,0)
  49269. * @param normal the normal of the vertex (defaut: 0,1,0)
  49270. */
  49271. constructor(
  49272. /** the position of the vertex (defaut: 0,0,0) */
  49273. position?: Vector3,
  49274. /** the normal of the vertex (defaut: 0,1,0) */
  49275. normal?: Vector3);
  49276. /**
  49277. * Clones the PositionNormalVertex
  49278. * @returns the cloned PositionNormalVertex
  49279. */
  49280. clone(): PositionNormalVertex;
  49281. }
  49282. /**
  49283. * Contains position, normal and uv vectors for a vertex
  49284. */
  49285. export class PositionNormalTextureVertex {
  49286. /** the position of the vertex (defaut: 0,0,0) */
  49287. position: Vector3;
  49288. /** the normal of the vertex (defaut: 0,1,0) */
  49289. normal: Vector3;
  49290. /** the uv of the vertex (default: 0,0) */
  49291. uv: Vector2;
  49292. /**
  49293. * Creates a PositionNormalTextureVertex
  49294. * @param position the position of the vertex (defaut: 0,0,0)
  49295. * @param normal the normal of the vertex (defaut: 0,1,0)
  49296. * @param uv the uv of the vertex (default: 0,0)
  49297. */
  49298. constructor(
  49299. /** the position of the vertex (defaut: 0,0,0) */
  49300. position?: Vector3,
  49301. /** the normal of the vertex (defaut: 0,1,0) */
  49302. normal?: Vector3,
  49303. /** the uv of the vertex (default: 0,0) */
  49304. uv?: Vector2);
  49305. /**
  49306. * Clones the PositionNormalTextureVertex
  49307. * @returns the cloned PositionNormalTextureVertex
  49308. */
  49309. clone(): PositionNormalTextureVertex;
  49310. }
  49311. }
  49312. declare module "babylonjs/Maths/math" {
  49313. export * from "babylonjs/Maths/math.axis";
  49314. export * from "babylonjs/Maths/math.color";
  49315. export * from "babylonjs/Maths/math.constants";
  49316. export * from "babylonjs/Maths/math.frustum";
  49317. export * from "babylonjs/Maths/math.path";
  49318. export * from "babylonjs/Maths/math.plane";
  49319. export * from "babylonjs/Maths/math.size";
  49320. export * from "babylonjs/Maths/math.vector";
  49321. export * from "babylonjs/Maths/math.vertexFormat";
  49322. export * from "babylonjs/Maths/math.viewport";
  49323. }
  49324. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49325. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49326. /** @hidden */
  49327. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49328. private _genericAttributeLocation;
  49329. private _varyingLocationCount;
  49330. private _varyingLocationMap;
  49331. private _replacements;
  49332. private _textureCount;
  49333. private _uniforms;
  49334. lineProcessor(line: string): string;
  49335. attributeProcessor(attribute: string): string;
  49336. varyingProcessor(varying: string, isFragment: boolean): string;
  49337. uniformProcessor(uniform: string): string;
  49338. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49339. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49340. }
  49341. }
  49342. declare module "babylonjs/Engines/nativeEngine" {
  49343. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49344. import { Engine } from "babylonjs/Engines/engine";
  49345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49348. import { Effect } from "babylonjs/Materials/effect";
  49349. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49350. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49351. import { IColor4Like } from "babylonjs/Maths/math.like";
  49352. import { Scene } from "babylonjs/scene";
  49353. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49354. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49355. /**
  49356. * Container for accessors for natively-stored mesh data buffers.
  49357. */
  49358. class NativeDataBuffer extends DataBuffer {
  49359. /**
  49360. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49361. */
  49362. nativeIndexBuffer?: any;
  49363. /**
  49364. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49365. */
  49366. nativeVertexBuffer?: any;
  49367. }
  49368. /** @hidden */
  49369. class NativeTexture extends InternalTexture {
  49370. getInternalTexture(): InternalTexture;
  49371. getViewCount(): number;
  49372. }
  49373. /** @hidden */
  49374. export class NativeEngine extends Engine {
  49375. private readonly _native;
  49376. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49377. private readonly INVALID_HANDLE;
  49378. getHardwareScalingLevel(): number;
  49379. constructor();
  49380. /**
  49381. * Can be used to override the current requestAnimationFrame requester.
  49382. * @hidden
  49383. */
  49384. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49385. /**
  49386. * Override default engine behavior.
  49387. * @param color
  49388. * @param backBuffer
  49389. * @param depth
  49390. * @param stencil
  49391. */
  49392. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49393. /**
  49394. * Gets host document
  49395. * @returns the host document object
  49396. */
  49397. getHostDocument(): Nullable<Document>;
  49398. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49399. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49400. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49401. recordVertexArrayObject(vertexBuffers: {
  49402. [key: string]: VertexBuffer;
  49403. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49404. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49405. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49406. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49407. /**
  49408. * Draw a list of indexed primitives
  49409. * @param fillMode defines the primitive to use
  49410. * @param indexStart defines the starting index
  49411. * @param indexCount defines the number of index to draw
  49412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49413. */
  49414. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49415. /**
  49416. * Draw a list of unindexed primitives
  49417. * @param fillMode defines the primitive to use
  49418. * @param verticesStart defines the index of first vertex to draw
  49419. * @param verticesCount defines the count of vertices to draw
  49420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49421. */
  49422. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49423. createPipelineContext(): IPipelineContext;
  49424. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49425. /** @hidden */
  49426. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49427. /** @hidden */
  49428. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49429. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49430. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49431. protected _setProgram(program: WebGLProgram): void;
  49432. _releaseEffect(effect: Effect): void;
  49433. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49434. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49435. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49436. bindSamplers(effect: Effect): void;
  49437. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49438. getRenderWidth(useScreen?: boolean): number;
  49439. getRenderHeight(useScreen?: boolean): number;
  49440. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49441. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49442. /**
  49443. * Set the z offset to apply to current rendering
  49444. * @param value defines the offset to apply
  49445. */
  49446. setZOffset(value: number): void;
  49447. /**
  49448. * Gets the current value of the zOffset
  49449. * @returns the current zOffset state
  49450. */
  49451. getZOffset(): number;
  49452. /**
  49453. * Enable or disable depth buffering
  49454. * @param enable defines the state to set
  49455. */
  49456. setDepthBuffer(enable: boolean): void;
  49457. /**
  49458. * Gets a boolean indicating if depth writing is enabled
  49459. * @returns the current depth writing state
  49460. */
  49461. getDepthWrite(): boolean;
  49462. /**
  49463. * Enable or disable depth writing
  49464. * @param enable defines the state to set
  49465. */
  49466. setDepthWrite(enable: boolean): void;
  49467. /**
  49468. * Enable or disable color writing
  49469. * @param enable defines the state to set
  49470. */
  49471. setColorWrite(enable: boolean): void;
  49472. /**
  49473. * Gets a boolean indicating if color writing is enabled
  49474. * @returns the current color writing state
  49475. */
  49476. getColorWrite(): boolean;
  49477. /**
  49478. * Sets alpha constants used by some alpha blending modes
  49479. * @param r defines the red component
  49480. * @param g defines the green component
  49481. * @param b defines the blue component
  49482. * @param a defines the alpha component
  49483. */
  49484. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49485. /**
  49486. * Sets the current alpha mode
  49487. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49488. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49489. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49490. */
  49491. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49492. /**
  49493. * Gets the current alpha mode
  49494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49495. * @returns the current alpha mode
  49496. */
  49497. getAlphaMode(): number;
  49498. setInt(uniform: WebGLUniformLocation, int: number): void;
  49499. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49500. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49501. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49502. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49503. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49504. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49505. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49506. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49507. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49508. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49509. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49510. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49511. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49512. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49513. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49514. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49515. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49516. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49517. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49518. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49519. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49520. wipeCaches(bruteForce?: boolean): void;
  49521. _createTexture(): WebGLTexture;
  49522. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49523. /**
  49524. * Usually called from BABYLON.Texture.ts.
  49525. * Passed information to create a WebGLTexture
  49526. * @param urlArg defines a value which contains one of the following:
  49527. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49528. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49529. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49530. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49531. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49532. * @param scene needed for loading to the correct scene
  49533. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49534. * @param onLoad optional callback to be called upon successful completion
  49535. * @param onError optional callback to be called upon failure
  49536. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49537. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49538. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49539. * @param forcedExtension defines the extension to use to pick the right loader
  49540. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49541. */
  49542. 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;
  49543. /**
  49544. * Creates a cube texture
  49545. * @param rootUrl defines the url where the files to load is located
  49546. * @param scene defines the current scene
  49547. * @param files defines the list of files to load (1 per face)
  49548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49549. * @param onLoad defines an optional callback raised when the texture is loaded
  49550. * @param onError defines an optional callback raised if there is an issue to load the texture
  49551. * @param format defines the format of the data
  49552. * @param forcedExtension defines the extension to use to pick the right loader
  49553. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49556. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49557. * @returns the cube texture as an InternalTexture
  49558. */
  49559. 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;
  49560. private _getSamplingFilter;
  49561. private static _GetNativeTextureFormat;
  49562. createRenderTargetTexture(size: number | {
  49563. width: number;
  49564. height: number;
  49565. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49566. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49567. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49568. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49569. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49570. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49571. /**
  49572. * Updates a dynamic vertex buffer.
  49573. * @param vertexBuffer the vertex buffer to update
  49574. * @param data the data used to update the vertex buffer
  49575. * @param byteOffset the byte offset of the data (optional)
  49576. * @param byteLength the byte length of the data (optional)
  49577. */
  49578. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49579. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49580. private _updateAnisotropicLevel;
  49581. private _getAddressMode;
  49582. /** @hidden */
  49583. _bindTexture(channel: number, texture: InternalTexture): void;
  49584. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49585. releaseEffects(): void;
  49586. /** @hidden */
  49587. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49588. /** @hidden */
  49589. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49590. /** @hidden */
  49591. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49592. /** @hidden */
  49593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49594. }
  49595. }
  49596. declare module "babylonjs/Engines/index" {
  49597. export * from "babylonjs/Engines/constants";
  49598. export * from "babylonjs/Engines/engineCapabilities";
  49599. export * from "babylonjs/Engines/instancingAttributeInfo";
  49600. export * from "babylonjs/Engines/thinEngine";
  49601. export * from "babylonjs/Engines/engine";
  49602. export * from "babylonjs/Engines/engineStore";
  49603. export * from "babylonjs/Engines/nullEngine";
  49604. export * from "babylonjs/Engines/Extensions/index";
  49605. export * from "babylonjs/Engines/IPipelineContext";
  49606. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49607. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49608. export * from "babylonjs/Engines/nativeEngine";
  49609. }
  49610. declare module "babylonjs/Events/clipboardEvents" {
  49611. /**
  49612. * Gather the list of clipboard event types as constants.
  49613. */
  49614. export class ClipboardEventTypes {
  49615. /**
  49616. * The clipboard event is fired when a copy command is active (pressed).
  49617. */
  49618. static readonly COPY: number;
  49619. /**
  49620. * The clipboard event is fired when a cut command is active (pressed).
  49621. */
  49622. static readonly CUT: number;
  49623. /**
  49624. * The clipboard event is fired when a paste command is active (pressed).
  49625. */
  49626. static readonly PASTE: number;
  49627. }
  49628. /**
  49629. * This class is used to store clipboard related info for the onClipboardObservable event.
  49630. */
  49631. export class ClipboardInfo {
  49632. /**
  49633. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49634. */
  49635. type: number;
  49636. /**
  49637. * Defines the related dom event
  49638. */
  49639. event: ClipboardEvent;
  49640. /**
  49641. *Creates an instance of ClipboardInfo.
  49642. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49643. * @param event Defines the related dom event
  49644. */
  49645. constructor(
  49646. /**
  49647. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49648. */
  49649. type: number,
  49650. /**
  49651. * Defines the related dom event
  49652. */
  49653. event: ClipboardEvent);
  49654. /**
  49655. * Get the clipboard event's type from the keycode.
  49656. * @param keyCode Defines the keyCode for the current keyboard event.
  49657. * @return {number}
  49658. */
  49659. static GetTypeFromCharacter(keyCode: number): number;
  49660. }
  49661. }
  49662. declare module "babylonjs/Events/index" {
  49663. export * from "babylonjs/Events/keyboardEvents";
  49664. export * from "babylonjs/Events/pointerEvents";
  49665. export * from "babylonjs/Events/clipboardEvents";
  49666. }
  49667. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49668. import { Scene } from "babylonjs/scene";
  49669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49673. /**
  49674. * Google Daydream controller
  49675. */
  49676. export class DaydreamController extends WebVRController {
  49677. /**
  49678. * Base Url for the controller model.
  49679. */
  49680. static MODEL_BASE_URL: string;
  49681. /**
  49682. * File name for the controller model.
  49683. */
  49684. static MODEL_FILENAME: string;
  49685. /**
  49686. * Gamepad Id prefix used to identify Daydream Controller.
  49687. */
  49688. static readonly GAMEPAD_ID_PREFIX: string;
  49689. /**
  49690. * Creates a new DaydreamController from a gamepad
  49691. * @param vrGamepad the gamepad that the controller should be created from
  49692. */
  49693. constructor(vrGamepad: any);
  49694. /**
  49695. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49696. * @param scene scene in which to add meshes
  49697. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49698. */
  49699. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49700. /**
  49701. * Called once for each button that changed state since the last frame
  49702. * @param buttonIdx Which button index changed
  49703. * @param state New state of the button
  49704. * @param changes Which properties on the state changed since last frame
  49705. */
  49706. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49707. }
  49708. }
  49709. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49710. import { Scene } from "babylonjs/scene";
  49711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49712. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49713. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49714. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49715. /**
  49716. * Gear VR Controller
  49717. */
  49718. export class GearVRController extends WebVRController {
  49719. /**
  49720. * Base Url for the controller model.
  49721. */
  49722. static MODEL_BASE_URL: string;
  49723. /**
  49724. * File name for the controller model.
  49725. */
  49726. static MODEL_FILENAME: string;
  49727. /**
  49728. * Gamepad Id prefix used to identify this controller.
  49729. */
  49730. static readonly GAMEPAD_ID_PREFIX: string;
  49731. private readonly _buttonIndexToObservableNameMap;
  49732. /**
  49733. * Creates a new GearVRController from a gamepad
  49734. * @param vrGamepad the gamepad that the controller should be created from
  49735. */
  49736. constructor(vrGamepad: any);
  49737. /**
  49738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49739. * @param scene scene in which to add meshes
  49740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49741. */
  49742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49743. /**
  49744. * Called once for each button that changed state since the last frame
  49745. * @param buttonIdx Which button index changed
  49746. * @param state New state of the button
  49747. * @param changes Which properties on the state changed since last frame
  49748. */
  49749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49750. }
  49751. }
  49752. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49753. import { Scene } from "babylonjs/scene";
  49754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49755. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49756. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49757. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49758. /**
  49759. * Generic Controller
  49760. */
  49761. export class GenericController extends WebVRController {
  49762. /**
  49763. * Base Url for the controller model.
  49764. */
  49765. static readonly MODEL_BASE_URL: string;
  49766. /**
  49767. * File name for the controller model.
  49768. */
  49769. static readonly MODEL_FILENAME: string;
  49770. /**
  49771. * Creates a new GenericController from a gamepad
  49772. * @param vrGamepad the gamepad that the controller should be created from
  49773. */
  49774. constructor(vrGamepad: any);
  49775. /**
  49776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49777. * @param scene scene in which to add meshes
  49778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49779. */
  49780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49781. /**
  49782. * Called once for each button that changed state since the last frame
  49783. * @param buttonIdx Which button index changed
  49784. * @param state New state of the button
  49785. * @param changes Which properties on the state changed since last frame
  49786. */
  49787. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49788. }
  49789. }
  49790. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49791. import { Observable } from "babylonjs/Misc/observable";
  49792. import { Scene } from "babylonjs/scene";
  49793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49794. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49795. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49796. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49797. /**
  49798. * Oculus Touch Controller
  49799. */
  49800. export class OculusTouchController extends WebVRController {
  49801. /**
  49802. * Base Url for the controller model.
  49803. */
  49804. static MODEL_BASE_URL: string;
  49805. /**
  49806. * File name for the left controller model.
  49807. */
  49808. static MODEL_LEFT_FILENAME: string;
  49809. /**
  49810. * File name for the right controller model.
  49811. */
  49812. static MODEL_RIGHT_FILENAME: string;
  49813. /**
  49814. * Base Url for the Quest controller model.
  49815. */
  49816. static QUEST_MODEL_BASE_URL: string;
  49817. /**
  49818. * @hidden
  49819. * If the controllers are running on a device that needs the updated Quest controller models
  49820. */
  49821. static _IsQuest: boolean;
  49822. /**
  49823. * Fired when the secondary trigger on this controller is modified
  49824. */
  49825. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49826. /**
  49827. * Fired when the thumb rest on this controller is modified
  49828. */
  49829. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49830. /**
  49831. * Creates a new OculusTouchController from a gamepad
  49832. * @param vrGamepad the gamepad that the controller should be created from
  49833. */
  49834. constructor(vrGamepad: any);
  49835. /**
  49836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49837. * @param scene scene in which to add meshes
  49838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49839. */
  49840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49841. /**
  49842. * Fired when the A button on this controller is modified
  49843. */
  49844. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49845. /**
  49846. * Fired when the B button on this controller is modified
  49847. */
  49848. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49849. /**
  49850. * Fired when the X button on this controller is modified
  49851. */
  49852. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49853. /**
  49854. * Fired when the Y button on this controller is modified
  49855. */
  49856. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49857. /**
  49858. * Called once for each button that changed state since the last frame
  49859. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49860. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49861. * 2) secondary trigger (same)
  49862. * 3) A (right) X (left), touch, pressed = value
  49863. * 4) B / Y
  49864. * 5) thumb rest
  49865. * @param buttonIdx Which button index changed
  49866. * @param state New state of the button
  49867. * @param changes Which properties on the state changed since last frame
  49868. */
  49869. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49870. }
  49871. }
  49872. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49873. import { Scene } from "babylonjs/scene";
  49874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49877. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49878. import { Observable } from "babylonjs/Misc/observable";
  49879. /**
  49880. * Vive Controller
  49881. */
  49882. export class ViveController extends WebVRController {
  49883. /**
  49884. * Base Url for the controller model.
  49885. */
  49886. static MODEL_BASE_URL: string;
  49887. /**
  49888. * File name for the controller model.
  49889. */
  49890. static MODEL_FILENAME: string;
  49891. /**
  49892. * Creates a new ViveController from a gamepad
  49893. * @param vrGamepad the gamepad that the controller should be created from
  49894. */
  49895. constructor(vrGamepad: any);
  49896. /**
  49897. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49898. * @param scene scene in which to add meshes
  49899. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49900. */
  49901. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49902. /**
  49903. * Fired when the left button on this controller is modified
  49904. */
  49905. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49906. /**
  49907. * Fired when the right button on this controller is modified
  49908. */
  49909. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49910. /**
  49911. * Fired when the menu button on this controller is modified
  49912. */
  49913. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49914. /**
  49915. * Called once for each button that changed state since the last frame
  49916. * Vive mapping:
  49917. * 0: touchpad
  49918. * 1: trigger
  49919. * 2: left AND right buttons
  49920. * 3: menu button
  49921. * @param buttonIdx Which button index changed
  49922. * @param state New state of the button
  49923. * @param changes Which properties on the state changed since last frame
  49924. */
  49925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49926. }
  49927. }
  49928. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49929. import { Observable } from "babylonjs/Misc/observable";
  49930. import { Scene } from "babylonjs/scene";
  49931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49932. import { Ray } from "babylonjs/Culling/ray";
  49933. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49934. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49935. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49936. /**
  49937. * Defines the WindowsMotionController object that the state of the windows motion controller
  49938. */
  49939. export class WindowsMotionController extends WebVRController {
  49940. /**
  49941. * The base url used to load the left and right controller models
  49942. */
  49943. static MODEL_BASE_URL: string;
  49944. /**
  49945. * The name of the left controller model file
  49946. */
  49947. static MODEL_LEFT_FILENAME: string;
  49948. /**
  49949. * The name of the right controller model file
  49950. */
  49951. static MODEL_RIGHT_FILENAME: string;
  49952. /**
  49953. * The controller name prefix for this controller type
  49954. */
  49955. static readonly GAMEPAD_ID_PREFIX: string;
  49956. /**
  49957. * The controller id pattern for this controller type
  49958. */
  49959. private static readonly GAMEPAD_ID_PATTERN;
  49960. private _loadedMeshInfo;
  49961. protected readonly _mapping: {
  49962. buttons: string[];
  49963. buttonMeshNames: {
  49964. 'trigger': string;
  49965. 'menu': string;
  49966. 'grip': string;
  49967. 'thumbstick': string;
  49968. 'trackpad': string;
  49969. };
  49970. buttonObservableNames: {
  49971. 'trigger': string;
  49972. 'menu': string;
  49973. 'grip': string;
  49974. 'thumbstick': string;
  49975. 'trackpad': string;
  49976. };
  49977. axisMeshNames: string[];
  49978. pointingPoseMeshName: string;
  49979. };
  49980. /**
  49981. * Fired when the trackpad on this controller is clicked
  49982. */
  49983. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49984. /**
  49985. * Fired when the trackpad on this controller is modified
  49986. */
  49987. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49988. /**
  49989. * The current x and y values of this controller's trackpad
  49990. */
  49991. trackpad: StickValues;
  49992. /**
  49993. * Creates a new WindowsMotionController from a gamepad
  49994. * @param vrGamepad the gamepad that the controller should be created from
  49995. */
  49996. constructor(vrGamepad: any);
  49997. /**
  49998. * Fired when the trigger on this controller is modified
  49999. */
  50000. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50001. /**
  50002. * Fired when the menu button on this controller is modified
  50003. */
  50004. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50005. /**
  50006. * Fired when the grip button on this controller is modified
  50007. */
  50008. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50009. /**
  50010. * Fired when the thumbstick button on this controller is modified
  50011. */
  50012. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50013. /**
  50014. * Fired when the touchpad button on this controller is modified
  50015. */
  50016. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50017. /**
  50018. * Fired when the touchpad values on this controller are modified
  50019. */
  50020. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50021. protected _updateTrackpad(): void;
  50022. /**
  50023. * Called once per frame by the engine.
  50024. */
  50025. update(): void;
  50026. /**
  50027. * Called once for each button that changed state since the last frame
  50028. * @param buttonIdx Which button index changed
  50029. * @param state New state of the button
  50030. * @param changes Which properties on the state changed since last frame
  50031. */
  50032. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50033. /**
  50034. * Moves the buttons on the controller mesh based on their current state
  50035. * @param buttonName the name of the button to move
  50036. * @param buttonValue the value of the button which determines the buttons new position
  50037. */
  50038. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50039. /**
  50040. * Moves the axis on the controller mesh based on its current state
  50041. * @param axis the index of the axis
  50042. * @param axisValue the value of the axis which determines the meshes new position
  50043. * @hidden
  50044. */
  50045. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50046. /**
  50047. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50048. * @param scene scene in which to add meshes
  50049. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50050. */
  50051. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50052. /**
  50053. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50054. * can be transformed by button presses and axes values, based on this._mapping.
  50055. *
  50056. * @param scene scene in which the meshes exist
  50057. * @param meshes list of meshes that make up the controller model to process
  50058. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50059. */
  50060. private processModel;
  50061. private createMeshInfo;
  50062. /**
  50063. * Gets the ray of the controller in the direction the controller is pointing
  50064. * @param length the length the resulting ray should be
  50065. * @returns a ray in the direction the controller is pointing
  50066. */
  50067. getForwardRay(length?: number): Ray;
  50068. /**
  50069. * Disposes of the controller
  50070. */
  50071. dispose(): void;
  50072. }
  50073. /**
  50074. * This class represents a new windows motion controller in XR.
  50075. */
  50076. export class XRWindowsMotionController extends WindowsMotionController {
  50077. /**
  50078. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50079. */
  50080. protected readonly _mapping: {
  50081. buttons: string[];
  50082. buttonMeshNames: {
  50083. 'trigger': string;
  50084. 'menu': string;
  50085. 'grip': string;
  50086. 'thumbstick': string;
  50087. 'trackpad': string;
  50088. };
  50089. buttonObservableNames: {
  50090. 'trigger': string;
  50091. 'menu': string;
  50092. 'grip': string;
  50093. 'thumbstick': string;
  50094. 'trackpad': string;
  50095. };
  50096. axisMeshNames: string[];
  50097. pointingPoseMeshName: string;
  50098. };
  50099. /**
  50100. * Construct a new XR-Based windows motion controller
  50101. *
  50102. * @param gamepadInfo the gamepad object from the browser
  50103. */
  50104. constructor(gamepadInfo: any);
  50105. /**
  50106. * holds the thumbstick values (X,Y)
  50107. */
  50108. thumbstickValues: StickValues;
  50109. /**
  50110. * Fired when the thumbstick on this controller is clicked
  50111. */
  50112. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50113. /**
  50114. * Fired when the thumbstick on this controller is modified
  50115. */
  50116. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50117. /**
  50118. * Fired when the touchpad button on this controller is modified
  50119. */
  50120. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50121. /**
  50122. * Fired when the touchpad values on this controller are modified
  50123. */
  50124. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50125. /**
  50126. * Fired when the thumbstick button on this controller is modified
  50127. * here to prevent breaking changes
  50128. */
  50129. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50130. /**
  50131. * updating the thumbstick(!) and not the trackpad.
  50132. * This is named this way due to the difference between WebVR and XR and to avoid
  50133. * changing the parent class.
  50134. */
  50135. protected _updateTrackpad(): void;
  50136. /**
  50137. * Disposes the class with joy
  50138. */
  50139. dispose(): void;
  50140. }
  50141. }
  50142. declare module "babylonjs/Gamepads/Controllers/index" {
  50143. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50144. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50145. export * from "babylonjs/Gamepads/Controllers/genericController";
  50146. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50147. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50148. export * from "babylonjs/Gamepads/Controllers/viveController";
  50149. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50150. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50151. }
  50152. declare module "babylonjs/Gamepads/index" {
  50153. export * from "babylonjs/Gamepads/Controllers/index";
  50154. export * from "babylonjs/Gamepads/gamepad";
  50155. export * from "babylonjs/Gamepads/gamepadManager";
  50156. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50157. export * from "babylonjs/Gamepads/xboxGamepad";
  50158. export * from "babylonjs/Gamepads/dualShockGamepad";
  50159. }
  50160. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50161. import { Scene } from "babylonjs/scene";
  50162. import { Vector4 } from "babylonjs/Maths/math.vector";
  50163. import { Color4 } from "babylonjs/Maths/math.color";
  50164. import { Mesh } from "babylonjs/Meshes/mesh";
  50165. import { Nullable } from "babylonjs/types";
  50166. /**
  50167. * Class containing static functions to help procedurally build meshes
  50168. */
  50169. export class PolyhedronBuilder {
  50170. /**
  50171. * Creates a polyhedron mesh
  50172. * * 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
  50173. * * The parameter `size` (positive float, default 1) sets the polygon size
  50174. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50175. * * 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`
  50176. * * 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
  50177. * * 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)`)
  50178. * * 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
  50179. * * 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
  50180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50183. * @param name defines the name of the mesh
  50184. * @param options defines the options used to create the mesh
  50185. * @param scene defines the hosting scene
  50186. * @returns the polyhedron mesh
  50187. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50188. */
  50189. static CreatePolyhedron(name: string, options: {
  50190. type?: number;
  50191. size?: number;
  50192. sizeX?: number;
  50193. sizeY?: number;
  50194. sizeZ?: number;
  50195. custom?: any;
  50196. faceUV?: Vector4[];
  50197. faceColors?: Color4[];
  50198. flat?: boolean;
  50199. updatable?: boolean;
  50200. sideOrientation?: number;
  50201. frontUVs?: Vector4;
  50202. backUVs?: Vector4;
  50203. }, scene?: Nullable<Scene>): Mesh;
  50204. }
  50205. }
  50206. declare module "babylonjs/Gizmos/scaleGizmo" {
  50207. import { Observable } from "babylonjs/Misc/observable";
  50208. import { Nullable } from "babylonjs/types";
  50209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50210. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50211. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50212. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50213. /**
  50214. * Gizmo that enables scaling a mesh along 3 axis
  50215. */
  50216. export class ScaleGizmo extends Gizmo {
  50217. /**
  50218. * Internal gizmo used for interactions on the x axis
  50219. */
  50220. xGizmo: AxisScaleGizmo;
  50221. /**
  50222. * Internal gizmo used for interactions on the y axis
  50223. */
  50224. yGizmo: AxisScaleGizmo;
  50225. /**
  50226. * Internal gizmo used for interactions on the z axis
  50227. */
  50228. zGizmo: AxisScaleGizmo;
  50229. /**
  50230. * Internal gizmo used to scale all axis equally
  50231. */
  50232. uniformScaleGizmo: AxisScaleGizmo;
  50233. private _meshAttached;
  50234. private _updateGizmoRotationToMatchAttachedMesh;
  50235. private _snapDistance;
  50236. private _scaleRatio;
  50237. private _uniformScalingMesh;
  50238. private _octahedron;
  50239. private _sensitivity;
  50240. /** Fires an event when any of it's sub gizmos are dragged */
  50241. onDragStartObservable: Observable<unknown>;
  50242. /** Fires an event when any of it's sub gizmos are released from dragging */
  50243. onDragEndObservable: Observable<unknown>;
  50244. get attachedMesh(): Nullable<AbstractMesh>;
  50245. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50246. /**
  50247. * Creates a ScaleGizmo
  50248. * @param gizmoLayer The utility layer the gizmo will be added to
  50249. */
  50250. constructor(gizmoLayer?: UtilityLayerRenderer);
  50251. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50252. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50253. /**
  50254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50255. */
  50256. set snapDistance(value: number);
  50257. get snapDistance(): number;
  50258. /**
  50259. * Ratio for the scale of the gizmo (Default: 1)
  50260. */
  50261. set scaleRatio(value: number);
  50262. get scaleRatio(): number;
  50263. /**
  50264. * Sensitivity factor for dragging (Default: 1)
  50265. */
  50266. set sensitivity(value: number);
  50267. get sensitivity(): number;
  50268. /**
  50269. * Disposes of the gizmo
  50270. */
  50271. dispose(): void;
  50272. }
  50273. }
  50274. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50275. import { Observable } from "babylonjs/Misc/observable";
  50276. import { Nullable } from "babylonjs/types";
  50277. import { Vector3 } from "babylonjs/Maths/math.vector";
  50278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50279. import { Mesh } from "babylonjs/Meshes/mesh";
  50280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50283. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50284. import { Color3 } from "babylonjs/Maths/math.color";
  50285. /**
  50286. * Single axis scale gizmo
  50287. */
  50288. export class AxisScaleGizmo extends Gizmo {
  50289. /**
  50290. * Drag behavior responsible for the gizmos dragging interactions
  50291. */
  50292. dragBehavior: PointerDragBehavior;
  50293. private _pointerObserver;
  50294. /**
  50295. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50296. */
  50297. snapDistance: number;
  50298. /**
  50299. * Event that fires each time the gizmo snaps to a new location.
  50300. * * snapDistance is the the change in distance
  50301. */
  50302. onSnapObservable: Observable<{
  50303. snapDistance: number;
  50304. }>;
  50305. /**
  50306. * If the scaling operation should be done on all axis (default: false)
  50307. */
  50308. uniformScaling: boolean;
  50309. /**
  50310. * Custom sensitivity value for the drag strength
  50311. */
  50312. sensitivity: number;
  50313. private _isEnabled;
  50314. private _parent;
  50315. private _arrow;
  50316. private _coloredMaterial;
  50317. private _hoverMaterial;
  50318. /**
  50319. * Creates an AxisScaleGizmo
  50320. * @param gizmoLayer The utility layer the gizmo will be added to
  50321. * @param dragAxis The axis which the gizmo will be able to scale on
  50322. * @param color The color of the gizmo
  50323. */
  50324. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50325. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50326. /**
  50327. * If the gizmo is enabled
  50328. */
  50329. set isEnabled(value: boolean);
  50330. get isEnabled(): boolean;
  50331. /**
  50332. * Disposes of the gizmo
  50333. */
  50334. dispose(): void;
  50335. /**
  50336. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50337. * @param mesh The mesh to replace the default mesh of the gizmo
  50338. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50339. */
  50340. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50341. }
  50342. }
  50343. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50344. import { Observable } from "babylonjs/Misc/observable";
  50345. import { Nullable } from "babylonjs/types";
  50346. import { Vector3 } from "babylonjs/Maths/math.vector";
  50347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50348. import { Mesh } from "babylonjs/Meshes/mesh";
  50349. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50350. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50351. import { Color3 } from "babylonjs/Maths/math.color";
  50352. import "babylonjs/Meshes/Builders/boxBuilder";
  50353. /**
  50354. * Bounding box gizmo
  50355. */
  50356. export class BoundingBoxGizmo extends Gizmo {
  50357. private _lineBoundingBox;
  50358. private _rotateSpheresParent;
  50359. private _scaleBoxesParent;
  50360. private _boundingDimensions;
  50361. private _renderObserver;
  50362. private _pointerObserver;
  50363. private _scaleDragSpeed;
  50364. private _tmpQuaternion;
  50365. private _tmpVector;
  50366. private _tmpRotationMatrix;
  50367. /**
  50368. * 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)
  50369. */
  50370. ignoreChildren: boolean;
  50371. /**
  50372. * 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)
  50373. */
  50374. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50375. /**
  50376. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50377. */
  50378. rotationSphereSize: number;
  50379. /**
  50380. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50381. */
  50382. scaleBoxSize: number;
  50383. /**
  50384. * 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)
  50385. */
  50386. fixedDragMeshScreenSize: boolean;
  50387. /**
  50388. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50389. */
  50390. fixedDragMeshScreenSizeDistanceFactor: number;
  50391. /**
  50392. * Fired when a rotation sphere or scale box is dragged
  50393. */
  50394. onDragStartObservable: Observable<{}>;
  50395. /**
  50396. * Fired when a scale box is dragged
  50397. */
  50398. onScaleBoxDragObservable: Observable<{}>;
  50399. /**
  50400. * Fired when a scale box drag is ended
  50401. */
  50402. onScaleBoxDragEndObservable: Observable<{}>;
  50403. /**
  50404. * Fired when a rotation sphere is dragged
  50405. */
  50406. onRotationSphereDragObservable: Observable<{}>;
  50407. /**
  50408. * Fired when a rotation sphere drag is ended
  50409. */
  50410. onRotationSphereDragEndObservable: Observable<{}>;
  50411. /**
  50412. * 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)
  50413. */
  50414. scalePivot: Nullable<Vector3>;
  50415. /**
  50416. * Mesh used as a pivot to rotate the attached mesh
  50417. */
  50418. private _anchorMesh;
  50419. private _existingMeshScale;
  50420. private _dragMesh;
  50421. private pointerDragBehavior;
  50422. private coloredMaterial;
  50423. private hoverColoredMaterial;
  50424. /**
  50425. * Sets the color of the bounding box gizmo
  50426. * @param color the color to set
  50427. */
  50428. setColor(color: Color3): void;
  50429. /**
  50430. * Creates an BoundingBoxGizmo
  50431. * @param gizmoLayer The utility layer the gizmo will be added to
  50432. * @param color The color of the gizmo
  50433. */
  50434. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50435. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50436. private _selectNode;
  50437. /**
  50438. * Updates the bounding box information for the Gizmo
  50439. */
  50440. updateBoundingBox(): void;
  50441. private _updateRotationSpheres;
  50442. private _updateScaleBoxes;
  50443. /**
  50444. * Enables rotation on the specified axis and disables rotation on the others
  50445. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50446. */
  50447. setEnabledRotationAxis(axis: string): void;
  50448. /**
  50449. * Enables/disables scaling
  50450. * @param enable if scaling should be enabled
  50451. */
  50452. setEnabledScaling(enable: boolean): void;
  50453. private _updateDummy;
  50454. /**
  50455. * Enables a pointer drag behavior on the bounding box of the gizmo
  50456. */
  50457. enableDragBehavior(): void;
  50458. /**
  50459. * Disposes of the gizmo
  50460. */
  50461. dispose(): void;
  50462. /**
  50463. * 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)
  50464. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50465. * @returns the bounding box mesh with the passed in mesh as a child
  50466. */
  50467. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50468. /**
  50469. * CustomMeshes are not supported by this gizmo
  50470. * @param mesh The mesh to replace the default mesh of the gizmo
  50471. */
  50472. setCustomMesh(mesh: Mesh): void;
  50473. }
  50474. }
  50475. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50476. import { Observable } from "babylonjs/Misc/observable";
  50477. import { Nullable } from "babylonjs/types";
  50478. import { Vector3 } from "babylonjs/Maths/math.vector";
  50479. import { Color3 } from "babylonjs/Maths/math.color";
  50480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50481. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50482. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50484. import "babylonjs/Meshes/Builders/linesBuilder";
  50485. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50486. /**
  50487. * Single plane rotation gizmo
  50488. */
  50489. export class PlaneRotationGizmo extends Gizmo {
  50490. /**
  50491. * Drag behavior responsible for the gizmos dragging interactions
  50492. */
  50493. dragBehavior: PointerDragBehavior;
  50494. private _pointerObserver;
  50495. /**
  50496. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50497. */
  50498. snapDistance: number;
  50499. /**
  50500. * Event that fires each time the gizmo snaps to a new location.
  50501. * * snapDistance is the the change in distance
  50502. */
  50503. onSnapObservable: Observable<{
  50504. snapDistance: number;
  50505. }>;
  50506. private _isEnabled;
  50507. private _parent;
  50508. /**
  50509. * Creates a PlaneRotationGizmo
  50510. * @param gizmoLayer The utility layer the gizmo will be added to
  50511. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50512. * @param color The color of the gizmo
  50513. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50514. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50515. */
  50516. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50517. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50518. /**
  50519. * If the gizmo is enabled
  50520. */
  50521. set isEnabled(value: boolean);
  50522. get isEnabled(): boolean;
  50523. /**
  50524. * Disposes of the gizmo
  50525. */
  50526. dispose(): void;
  50527. }
  50528. }
  50529. declare module "babylonjs/Gizmos/rotationGizmo" {
  50530. import { Observable } from "babylonjs/Misc/observable";
  50531. import { Nullable } from "babylonjs/types";
  50532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50533. import { Mesh } from "babylonjs/Meshes/mesh";
  50534. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50535. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50536. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50537. /**
  50538. * Gizmo that enables rotating a mesh along 3 axis
  50539. */
  50540. export class RotationGizmo extends Gizmo {
  50541. /**
  50542. * Internal gizmo used for interactions on the x axis
  50543. */
  50544. xGizmo: PlaneRotationGizmo;
  50545. /**
  50546. * Internal gizmo used for interactions on the y axis
  50547. */
  50548. yGizmo: PlaneRotationGizmo;
  50549. /**
  50550. * Internal gizmo used for interactions on the z axis
  50551. */
  50552. zGizmo: PlaneRotationGizmo;
  50553. /** Fires an event when any of it's sub gizmos are dragged */
  50554. onDragStartObservable: Observable<unknown>;
  50555. /** Fires an event when any of it's sub gizmos are released from dragging */
  50556. onDragEndObservable: Observable<unknown>;
  50557. private _meshAttached;
  50558. get attachedMesh(): Nullable<AbstractMesh>;
  50559. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50560. /**
  50561. * Creates a RotationGizmo
  50562. * @param gizmoLayer The utility layer the gizmo will be added to
  50563. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50564. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50565. */
  50566. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50567. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50568. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50569. /**
  50570. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50571. */
  50572. set snapDistance(value: number);
  50573. get snapDistance(): number;
  50574. /**
  50575. * Ratio for the scale of the gizmo (Default: 1)
  50576. */
  50577. set scaleRatio(value: number);
  50578. get scaleRatio(): number;
  50579. /**
  50580. * Disposes of the gizmo
  50581. */
  50582. dispose(): void;
  50583. /**
  50584. * CustomMeshes are not supported by this gizmo
  50585. * @param mesh The mesh to replace the default mesh of the gizmo
  50586. */
  50587. setCustomMesh(mesh: Mesh): void;
  50588. }
  50589. }
  50590. declare module "babylonjs/Gizmos/gizmoManager" {
  50591. import { Observable } from "babylonjs/Misc/observable";
  50592. import { Nullable } from "babylonjs/types";
  50593. import { Scene, IDisposable } from "babylonjs/scene";
  50594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50595. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50596. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50597. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50598. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50599. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50600. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50601. /**
  50602. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50603. */
  50604. export class GizmoManager implements IDisposable {
  50605. private scene;
  50606. /**
  50607. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50608. */
  50609. gizmos: {
  50610. positionGizmo: Nullable<PositionGizmo>;
  50611. rotationGizmo: Nullable<RotationGizmo>;
  50612. scaleGizmo: Nullable<ScaleGizmo>;
  50613. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50614. };
  50615. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50616. clearGizmoOnEmptyPointerEvent: boolean;
  50617. /** Fires an event when the manager is attached to a mesh */
  50618. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50619. private _gizmosEnabled;
  50620. private _pointerObserver;
  50621. private _attachedMesh;
  50622. private _boundingBoxColor;
  50623. private _defaultUtilityLayer;
  50624. private _defaultKeepDepthUtilityLayer;
  50625. /**
  50626. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50627. */
  50628. boundingBoxDragBehavior: SixDofDragBehavior;
  50629. /**
  50630. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50631. */
  50632. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50633. /**
  50634. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50635. */
  50636. usePointerToAttachGizmos: boolean;
  50637. /**
  50638. * Utility layer that the bounding box gizmo belongs to
  50639. */
  50640. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50641. /**
  50642. * Utility layer that all gizmos besides bounding box belong to
  50643. */
  50644. get utilityLayer(): UtilityLayerRenderer;
  50645. /**
  50646. * Instatiates a gizmo manager
  50647. * @param scene the scene to overlay the gizmos on top of
  50648. */
  50649. constructor(scene: Scene);
  50650. /**
  50651. * Attaches a set of gizmos to the specified mesh
  50652. * @param mesh The mesh the gizmo's should be attached to
  50653. */
  50654. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50655. /**
  50656. * If the position gizmo is enabled
  50657. */
  50658. set positionGizmoEnabled(value: boolean);
  50659. get positionGizmoEnabled(): boolean;
  50660. /**
  50661. * If the rotation gizmo is enabled
  50662. */
  50663. set rotationGizmoEnabled(value: boolean);
  50664. get rotationGizmoEnabled(): boolean;
  50665. /**
  50666. * If the scale gizmo is enabled
  50667. */
  50668. set scaleGizmoEnabled(value: boolean);
  50669. get scaleGizmoEnabled(): boolean;
  50670. /**
  50671. * If the boundingBox gizmo is enabled
  50672. */
  50673. set boundingBoxGizmoEnabled(value: boolean);
  50674. get boundingBoxGizmoEnabled(): boolean;
  50675. /**
  50676. * Disposes of the gizmo manager
  50677. */
  50678. dispose(): void;
  50679. }
  50680. }
  50681. declare module "babylonjs/Lights/directionalLight" {
  50682. import { Camera } from "babylonjs/Cameras/camera";
  50683. import { Scene } from "babylonjs/scene";
  50684. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50686. import { Light } from "babylonjs/Lights/light";
  50687. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50688. import { Effect } from "babylonjs/Materials/effect";
  50689. /**
  50690. * A directional light is defined by a direction (what a surprise!).
  50691. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50692. * 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.
  50693. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50694. */
  50695. export class DirectionalLight extends ShadowLight {
  50696. private _shadowFrustumSize;
  50697. /**
  50698. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50699. */
  50700. get shadowFrustumSize(): number;
  50701. /**
  50702. * Specifies a fix frustum size for the shadow generation.
  50703. */
  50704. set shadowFrustumSize(value: number);
  50705. private _shadowOrthoScale;
  50706. /**
  50707. * Gets the shadow projection scale against the optimal computed one.
  50708. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50709. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50710. */
  50711. get shadowOrthoScale(): number;
  50712. /**
  50713. * Sets the shadow projection scale against the optimal computed one.
  50714. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50715. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50716. */
  50717. set shadowOrthoScale(value: number);
  50718. /**
  50719. * Automatically compute the projection matrix to best fit (including all the casters)
  50720. * on each frame.
  50721. */
  50722. autoUpdateExtends: boolean;
  50723. /**
  50724. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50725. * on each frame. autoUpdateExtends must be set to true for this to work
  50726. */
  50727. autoCalcShadowZBounds: boolean;
  50728. private _orthoLeft;
  50729. private _orthoRight;
  50730. private _orthoTop;
  50731. private _orthoBottom;
  50732. /**
  50733. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50734. * The directional light is emitted from everywhere in the given direction.
  50735. * It can cast shadows.
  50736. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50737. * @param name The friendly name of the light
  50738. * @param direction The direction of the light
  50739. * @param scene The scene the light belongs to
  50740. */
  50741. constructor(name: string, direction: Vector3, scene: Scene);
  50742. /**
  50743. * Returns the string "DirectionalLight".
  50744. * @return The class name
  50745. */
  50746. getClassName(): string;
  50747. /**
  50748. * Returns the integer 1.
  50749. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50750. */
  50751. getTypeID(): number;
  50752. /**
  50753. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50757. /**
  50758. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50762. /**
  50763. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50764. * Returns the DirectionalLight Shadow projection matrix.
  50765. */
  50766. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50767. protected _buildUniformLayout(): void;
  50768. /**
  50769. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50770. * @param effect The effect to update
  50771. * @param lightIndex The index of the light in the effect to update
  50772. * @returns The directional light
  50773. */
  50774. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50775. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50776. /**
  50777. * Gets the minZ used for shadow according to both the scene and the light.
  50778. *
  50779. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50780. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50781. * @param activeCamera The camera we are returning the min for
  50782. * @returns the depth min z
  50783. */
  50784. getDepthMinZ(activeCamera: Camera): number;
  50785. /**
  50786. * Gets the maxZ used for shadow according to both the scene and the light.
  50787. *
  50788. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50789. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50790. * @param activeCamera The camera we are returning the max for
  50791. * @returns the depth max z
  50792. */
  50793. getDepthMaxZ(activeCamera: Camera): number;
  50794. /**
  50795. * Prepares the list of defines specific to the light type.
  50796. * @param defines the list of defines
  50797. * @param lightIndex defines the index of the light for the effect
  50798. */
  50799. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50800. }
  50801. }
  50802. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50803. import { Mesh } from "babylonjs/Meshes/mesh";
  50804. /**
  50805. * Class containing static functions to help procedurally build meshes
  50806. */
  50807. export class HemisphereBuilder {
  50808. /**
  50809. * Creates a hemisphere mesh
  50810. * @param name defines the name of the mesh
  50811. * @param options defines the options used to create the mesh
  50812. * @param scene defines the hosting scene
  50813. * @returns the hemisphere mesh
  50814. */
  50815. static CreateHemisphere(name: string, options: {
  50816. segments?: number;
  50817. diameter?: number;
  50818. sideOrientation?: number;
  50819. }, scene: any): Mesh;
  50820. }
  50821. }
  50822. declare module "babylonjs/Lights/spotLight" {
  50823. import { Nullable } from "babylonjs/types";
  50824. import { Scene } from "babylonjs/scene";
  50825. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50827. import { Effect } from "babylonjs/Materials/effect";
  50828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50829. import { Light } from "babylonjs/Lights/light";
  50830. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50831. /**
  50832. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50833. * These values define a cone of light starting from the position, emitting toward the direction.
  50834. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50835. * and the exponent defines the speed of the decay of the light with distance (reach).
  50836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50837. */
  50838. export class SpotLight extends ShadowLight {
  50839. private _angle;
  50840. private _innerAngle;
  50841. private _cosHalfAngle;
  50842. private _lightAngleScale;
  50843. private _lightAngleOffset;
  50844. /**
  50845. * Gets the cone angle of the spot light in Radians.
  50846. */
  50847. get angle(): number;
  50848. /**
  50849. * Sets the cone angle of the spot light in Radians.
  50850. */
  50851. set angle(value: number);
  50852. /**
  50853. * Only used in gltf falloff mode, this defines the angle where
  50854. * the directional falloff will start before cutting at angle which could be seen
  50855. * as outer angle.
  50856. */
  50857. get innerAngle(): number;
  50858. /**
  50859. * Only used in gltf falloff mode, this defines the angle where
  50860. * the directional falloff will start before cutting at angle which could be seen
  50861. * as outer angle.
  50862. */
  50863. set innerAngle(value: number);
  50864. private _shadowAngleScale;
  50865. /**
  50866. * Allows scaling the angle of the light for shadow generation only.
  50867. */
  50868. get shadowAngleScale(): number;
  50869. /**
  50870. * Allows scaling the angle of the light for shadow generation only.
  50871. */
  50872. set shadowAngleScale(value: number);
  50873. /**
  50874. * The light decay speed with the distance from the emission spot.
  50875. */
  50876. exponent: number;
  50877. private _projectionTextureMatrix;
  50878. /**
  50879. * Allows reading the projecton texture
  50880. */
  50881. get projectionTextureMatrix(): Matrix;
  50882. protected _projectionTextureLightNear: number;
  50883. /**
  50884. * Gets the near clip of the Spotlight for texture projection.
  50885. */
  50886. get projectionTextureLightNear(): number;
  50887. /**
  50888. * Sets the near clip of the Spotlight for texture projection.
  50889. */
  50890. set projectionTextureLightNear(value: number);
  50891. protected _projectionTextureLightFar: number;
  50892. /**
  50893. * Gets the far clip of the Spotlight for texture projection.
  50894. */
  50895. get projectionTextureLightFar(): number;
  50896. /**
  50897. * Sets the far clip of the Spotlight for texture projection.
  50898. */
  50899. set projectionTextureLightFar(value: number);
  50900. protected _projectionTextureUpDirection: Vector3;
  50901. /**
  50902. * Gets the Up vector of the Spotlight for texture projection.
  50903. */
  50904. get projectionTextureUpDirection(): Vector3;
  50905. /**
  50906. * Sets the Up vector of the Spotlight for texture projection.
  50907. */
  50908. set projectionTextureUpDirection(value: Vector3);
  50909. private _projectionTexture;
  50910. /**
  50911. * Gets the projection texture of the light.
  50912. */
  50913. get projectionTexture(): Nullable<BaseTexture>;
  50914. /**
  50915. * Sets the projection texture of the light.
  50916. */
  50917. set projectionTexture(value: Nullable<BaseTexture>);
  50918. private _projectionTextureViewLightDirty;
  50919. private _projectionTextureProjectionLightDirty;
  50920. private _projectionTextureDirty;
  50921. private _projectionTextureViewTargetVector;
  50922. private _projectionTextureViewLightMatrix;
  50923. private _projectionTextureProjectionLightMatrix;
  50924. private _projectionTextureScalingMatrix;
  50925. /**
  50926. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50927. * It can cast shadows.
  50928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50929. * @param name The light friendly name
  50930. * @param position The position of the spot light in the scene
  50931. * @param direction The direction of the light in the scene
  50932. * @param angle The cone angle of the light in Radians
  50933. * @param exponent The light decay speed with the distance from the emission spot
  50934. * @param scene The scene the lights belongs to
  50935. */
  50936. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50937. /**
  50938. * Returns the string "SpotLight".
  50939. * @returns the class name
  50940. */
  50941. getClassName(): string;
  50942. /**
  50943. * Returns the integer 2.
  50944. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50945. */
  50946. getTypeID(): number;
  50947. /**
  50948. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50949. */
  50950. protected _setDirection(value: Vector3): void;
  50951. /**
  50952. * Overrides the position setter to recompute the projection texture view light Matrix.
  50953. */
  50954. protected _setPosition(value: Vector3): void;
  50955. /**
  50956. * 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.
  50957. * Returns the SpotLight.
  50958. */
  50959. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50960. protected _computeProjectionTextureViewLightMatrix(): void;
  50961. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50962. /**
  50963. * Main function for light texture projection matrix computing.
  50964. */
  50965. protected _computeProjectionTextureMatrix(): void;
  50966. protected _buildUniformLayout(): void;
  50967. private _computeAngleValues;
  50968. /**
  50969. * Sets the passed Effect "effect" with the Light textures.
  50970. * @param effect The effect to update
  50971. * @param lightIndex The index of the light in the effect to update
  50972. * @returns The light
  50973. */
  50974. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50975. /**
  50976. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50977. * @param effect The effect to update
  50978. * @param lightIndex The index of the light in the effect to update
  50979. * @returns The spot light
  50980. */
  50981. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50982. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50983. /**
  50984. * Disposes the light and the associated resources.
  50985. */
  50986. dispose(): void;
  50987. /**
  50988. * Prepares the list of defines specific to the light type.
  50989. * @param defines the list of defines
  50990. * @param lightIndex defines the index of the light for the effect
  50991. */
  50992. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50993. }
  50994. }
  50995. declare module "babylonjs/Gizmos/lightGizmo" {
  50996. import { Nullable } from "babylonjs/types";
  50997. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50998. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50999. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51000. import { Light } from "babylonjs/Lights/light";
  51001. /**
  51002. * Gizmo that enables viewing a light
  51003. */
  51004. export class LightGizmo extends Gizmo {
  51005. private _lightMesh;
  51006. private _material;
  51007. private _cachedPosition;
  51008. private _cachedForward;
  51009. private _attachedMeshParent;
  51010. /**
  51011. * Creates a LightGizmo
  51012. * @param gizmoLayer The utility layer the gizmo will be added to
  51013. */
  51014. constructor(gizmoLayer?: UtilityLayerRenderer);
  51015. private _light;
  51016. /**
  51017. * The light that the gizmo is attached to
  51018. */
  51019. set light(light: Nullable<Light>);
  51020. get light(): Nullable<Light>;
  51021. /**
  51022. * Gets the material used to render the light gizmo
  51023. */
  51024. get material(): StandardMaterial;
  51025. /**
  51026. * @hidden
  51027. * Updates the gizmo to match the attached mesh's position/rotation
  51028. */
  51029. protected _update(): void;
  51030. private static _Scale;
  51031. /**
  51032. * Creates the lines for a light mesh
  51033. */
  51034. private static _CreateLightLines;
  51035. /**
  51036. * Disposes of the light gizmo
  51037. */
  51038. dispose(): void;
  51039. private static _CreateHemisphericLightMesh;
  51040. private static _CreatePointLightMesh;
  51041. private static _CreateSpotLightMesh;
  51042. private static _CreateDirectionalLightMesh;
  51043. }
  51044. }
  51045. declare module "babylonjs/Gizmos/index" {
  51046. export * from "babylonjs/Gizmos/axisDragGizmo";
  51047. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51048. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51049. export * from "babylonjs/Gizmos/gizmo";
  51050. export * from "babylonjs/Gizmos/gizmoManager";
  51051. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51052. export * from "babylonjs/Gizmos/positionGizmo";
  51053. export * from "babylonjs/Gizmos/rotationGizmo";
  51054. export * from "babylonjs/Gizmos/scaleGizmo";
  51055. export * from "babylonjs/Gizmos/lightGizmo";
  51056. export * from "babylonjs/Gizmos/planeDragGizmo";
  51057. }
  51058. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51059. /** @hidden */
  51060. export var backgroundFragmentDeclaration: {
  51061. name: string;
  51062. shader: string;
  51063. };
  51064. }
  51065. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51066. /** @hidden */
  51067. export var backgroundUboDeclaration: {
  51068. name: string;
  51069. shader: string;
  51070. };
  51071. }
  51072. declare module "babylonjs/Shaders/background.fragment" {
  51073. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51074. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51075. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51076. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51077. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51078. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51079. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51080. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51081. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51082. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51083. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51084. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51086. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51087. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51088. /** @hidden */
  51089. export var backgroundPixelShader: {
  51090. name: string;
  51091. shader: string;
  51092. };
  51093. }
  51094. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51095. /** @hidden */
  51096. export var backgroundVertexDeclaration: {
  51097. name: string;
  51098. shader: string;
  51099. };
  51100. }
  51101. declare module "babylonjs/Shaders/background.vertex" {
  51102. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51103. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51105. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51106. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51107. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51108. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51109. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51110. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51112. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51113. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51114. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51115. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51116. /** @hidden */
  51117. export var backgroundVertexShader: {
  51118. name: string;
  51119. shader: string;
  51120. };
  51121. }
  51122. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51123. import { Nullable, int, float } from "babylonjs/types";
  51124. import { Scene } from "babylonjs/scene";
  51125. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51128. import { Mesh } from "babylonjs/Meshes/mesh";
  51129. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51130. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51131. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51133. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51134. import { Color3 } from "babylonjs/Maths/math.color";
  51135. import "babylonjs/Shaders/background.fragment";
  51136. import "babylonjs/Shaders/background.vertex";
  51137. /**
  51138. * Background material used to create an efficient environement around your scene.
  51139. */
  51140. export class BackgroundMaterial extends PushMaterial {
  51141. /**
  51142. * Standard reflectance value at parallel view angle.
  51143. */
  51144. static StandardReflectance0: number;
  51145. /**
  51146. * Standard reflectance value at grazing angle.
  51147. */
  51148. static StandardReflectance90: number;
  51149. protected _primaryColor: Color3;
  51150. /**
  51151. * Key light Color (multiply against the environement texture)
  51152. */
  51153. primaryColor: Color3;
  51154. protected __perceptualColor: Nullable<Color3>;
  51155. /**
  51156. * Experimental Internal Use Only.
  51157. *
  51158. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51159. * This acts as a helper to set the primary color to a more "human friendly" value.
  51160. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51161. * output color as close as possible from the chosen value.
  51162. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51163. * part of lighting setup.)
  51164. */
  51165. get _perceptualColor(): Nullable<Color3>;
  51166. set _perceptualColor(value: Nullable<Color3>);
  51167. protected _primaryColorShadowLevel: float;
  51168. /**
  51169. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51170. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51171. */
  51172. get primaryColorShadowLevel(): float;
  51173. set primaryColorShadowLevel(value: float);
  51174. protected _primaryColorHighlightLevel: float;
  51175. /**
  51176. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51177. * The primary color is used at the level chosen to define what the white area would look.
  51178. */
  51179. get primaryColorHighlightLevel(): float;
  51180. set primaryColorHighlightLevel(value: float);
  51181. protected _reflectionTexture: Nullable<BaseTexture>;
  51182. /**
  51183. * Reflection Texture used in the material.
  51184. * Should be author in a specific way for the best result (refer to the documentation).
  51185. */
  51186. reflectionTexture: Nullable<BaseTexture>;
  51187. protected _reflectionBlur: float;
  51188. /**
  51189. * Reflection Texture level of blur.
  51190. *
  51191. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51192. * texture twice.
  51193. */
  51194. reflectionBlur: float;
  51195. protected _diffuseTexture: Nullable<BaseTexture>;
  51196. /**
  51197. * Diffuse Texture used in the material.
  51198. * Should be author in a specific way for the best result (refer to the documentation).
  51199. */
  51200. diffuseTexture: Nullable<BaseTexture>;
  51201. protected _shadowLights: Nullable<IShadowLight[]>;
  51202. /**
  51203. * Specify the list of lights casting shadow on the material.
  51204. * All scene shadow lights will be included if null.
  51205. */
  51206. shadowLights: Nullable<IShadowLight[]>;
  51207. protected _shadowLevel: float;
  51208. /**
  51209. * Helps adjusting the shadow to a softer level if required.
  51210. * 0 means black shadows and 1 means no shadows.
  51211. */
  51212. shadowLevel: float;
  51213. protected _sceneCenter: Vector3;
  51214. /**
  51215. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51216. * It is usually zero but might be interesting to modify according to your setup.
  51217. */
  51218. sceneCenter: Vector3;
  51219. protected _opacityFresnel: boolean;
  51220. /**
  51221. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51222. * This helps ensuring a nice transition when the camera goes under the ground.
  51223. */
  51224. opacityFresnel: boolean;
  51225. protected _reflectionFresnel: boolean;
  51226. /**
  51227. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51228. * This helps adding a mirror texture on the ground.
  51229. */
  51230. reflectionFresnel: boolean;
  51231. protected _reflectionFalloffDistance: number;
  51232. /**
  51233. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51234. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51235. */
  51236. reflectionFalloffDistance: number;
  51237. protected _reflectionAmount: number;
  51238. /**
  51239. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51240. */
  51241. reflectionAmount: number;
  51242. protected _reflectionReflectance0: number;
  51243. /**
  51244. * This specifies the weight of the reflection at grazing angle.
  51245. */
  51246. reflectionReflectance0: number;
  51247. protected _reflectionReflectance90: number;
  51248. /**
  51249. * This specifies the weight of the reflection at a perpendicular point of view.
  51250. */
  51251. reflectionReflectance90: number;
  51252. /**
  51253. * Sets the reflection reflectance fresnel values according to the default standard
  51254. * empirically know to work well :-)
  51255. */
  51256. set reflectionStandardFresnelWeight(value: number);
  51257. protected _useRGBColor: boolean;
  51258. /**
  51259. * Helps to directly use the maps channels instead of their level.
  51260. */
  51261. useRGBColor: boolean;
  51262. protected _enableNoise: boolean;
  51263. /**
  51264. * This helps reducing the banding effect that could occur on the background.
  51265. */
  51266. enableNoise: boolean;
  51267. /**
  51268. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51269. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51270. * Recommended to be keep at 1.0 except for special cases.
  51271. */
  51272. get fovMultiplier(): number;
  51273. set fovMultiplier(value: number);
  51274. private _fovMultiplier;
  51275. /**
  51276. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51277. */
  51278. useEquirectangularFOV: boolean;
  51279. private _maxSimultaneousLights;
  51280. /**
  51281. * Number of Simultaneous lights allowed on the material.
  51282. */
  51283. maxSimultaneousLights: int;
  51284. /**
  51285. * Default configuration related to image processing available in the Background Material.
  51286. */
  51287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51288. /**
  51289. * Keep track of the image processing observer to allow dispose and replace.
  51290. */
  51291. private _imageProcessingObserver;
  51292. /**
  51293. * Attaches a new image processing configuration to the PBR Material.
  51294. * @param configuration (if null the scene configuration will be use)
  51295. */
  51296. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51297. /**
  51298. * Gets the image processing configuration used either in this material.
  51299. */
  51300. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51301. /**
  51302. * Sets the Default image processing configuration used either in the this material.
  51303. *
  51304. * If sets to null, the scene one is in use.
  51305. */
  51306. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51307. /**
  51308. * Gets wether the color curves effect is enabled.
  51309. */
  51310. get cameraColorCurvesEnabled(): boolean;
  51311. /**
  51312. * Sets wether the color curves effect is enabled.
  51313. */
  51314. set cameraColorCurvesEnabled(value: boolean);
  51315. /**
  51316. * Gets wether the color grading effect is enabled.
  51317. */
  51318. get cameraColorGradingEnabled(): boolean;
  51319. /**
  51320. * Gets wether the color grading effect is enabled.
  51321. */
  51322. set cameraColorGradingEnabled(value: boolean);
  51323. /**
  51324. * Gets wether tonemapping is enabled or not.
  51325. */
  51326. get cameraToneMappingEnabled(): boolean;
  51327. /**
  51328. * Sets wether tonemapping is enabled or not
  51329. */
  51330. set cameraToneMappingEnabled(value: boolean);
  51331. /**
  51332. * The camera exposure used on this material.
  51333. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51334. * This corresponds to a photographic exposure.
  51335. */
  51336. get cameraExposure(): float;
  51337. /**
  51338. * The camera exposure used on this material.
  51339. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51340. * This corresponds to a photographic exposure.
  51341. */
  51342. set cameraExposure(value: float);
  51343. /**
  51344. * Gets The camera contrast used on this material.
  51345. */
  51346. get cameraContrast(): float;
  51347. /**
  51348. * Sets The camera contrast used on this material.
  51349. */
  51350. set cameraContrast(value: float);
  51351. /**
  51352. * Gets the Color Grading 2D Lookup Texture.
  51353. */
  51354. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51355. /**
  51356. * Sets the Color Grading 2D Lookup Texture.
  51357. */
  51358. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51359. /**
  51360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51362. * 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;
  51363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51364. */
  51365. get cameraColorCurves(): Nullable<ColorCurves>;
  51366. /**
  51367. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51368. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51369. * 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;
  51370. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51371. */
  51372. set cameraColorCurves(value: Nullable<ColorCurves>);
  51373. /**
  51374. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51375. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51376. */
  51377. switchToBGR: boolean;
  51378. private _renderTargets;
  51379. private _reflectionControls;
  51380. private _white;
  51381. private _primaryShadowColor;
  51382. private _primaryHighlightColor;
  51383. /**
  51384. * Instantiates a Background Material in the given scene
  51385. * @param name The friendly name of the material
  51386. * @param scene The scene to add the material to
  51387. */
  51388. constructor(name: string, scene: Scene);
  51389. /**
  51390. * Gets a boolean indicating that current material needs to register RTT
  51391. */
  51392. get hasRenderTargetTextures(): boolean;
  51393. /**
  51394. * The entire material has been created in order to prevent overdraw.
  51395. * @returns false
  51396. */
  51397. needAlphaTesting(): boolean;
  51398. /**
  51399. * The entire material has been created in order to prevent overdraw.
  51400. * @returns true if blending is enable
  51401. */
  51402. needAlphaBlending(): boolean;
  51403. /**
  51404. * Checks wether the material is ready to be rendered for a given mesh.
  51405. * @param mesh The mesh to render
  51406. * @param subMesh The submesh to check against
  51407. * @param useInstances Specify wether or not the material is used with instances
  51408. * @returns true if all the dependencies are ready (Textures, Effects...)
  51409. */
  51410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51411. /**
  51412. * Compute the primary color according to the chosen perceptual color.
  51413. */
  51414. private _computePrimaryColorFromPerceptualColor;
  51415. /**
  51416. * Compute the highlights and shadow colors according to their chosen levels.
  51417. */
  51418. private _computePrimaryColors;
  51419. /**
  51420. * Build the uniform buffer used in the material.
  51421. */
  51422. buildUniformLayout(): void;
  51423. /**
  51424. * Unbind the material.
  51425. */
  51426. unbind(): void;
  51427. /**
  51428. * Bind only the world matrix to the material.
  51429. * @param world The world matrix to bind.
  51430. */
  51431. bindOnlyWorldMatrix(world: Matrix): void;
  51432. /**
  51433. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51434. * @param world The world matrix to bind.
  51435. * @param subMesh The submesh to bind for.
  51436. */
  51437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51438. /**
  51439. * Checks to see if a texture is used in the material.
  51440. * @param texture - Base texture to use.
  51441. * @returns - Boolean specifying if a texture is used in the material.
  51442. */
  51443. hasTexture(texture: BaseTexture): boolean;
  51444. /**
  51445. * Dispose the material.
  51446. * @param forceDisposeEffect Force disposal of the associated effect.
  51447. * @param forceDisposeTextures Force disposal of the associated textures.
  51448. */
  51449. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51450. /**
  51451. * Clones the material.
  51452. * @param name The cloned name.
  51453. * @returns The cloned material.
  51454. */
  51455. clone(name: string): BackgroundMaterial;
  51456. /**
  51457. * Serializes the current material to its JSON representation.
  51458. * @returns The JSON representation.
  51459. */
  51460. serialize(): any;
  51461. /**
  51462. * Gets the class name of the material
  51463. * @returns "BackgroundMaterial"
  51464. */
  51465. getClassName(): string;
  51466. /**
  51467. * Parse a JSON input to create back a background material.
  51468. * @param source The JSON data to parse
  51469. * @param scene The scene to create the parsed material in
  51470. * @param rootUrl The root url of the assets the material depends upon
  51471. * @returns the instantiated BackgroundMaterial.
  51472. */
  51473. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51474. }
  51475. }
  51476. declare module "babylonjs/Helpers/environmentHelper" {
  51477. import { Observable } from "babylonjs/Misc/observable";
  51478. import { Nullable } from "babylonjs/types";
  51479. import { Scene } from "babylonjs/scene";
  51480. import { Vector3 } from "babylonjs/Maths/math.vector";
  51481. import { Color3 } from "babylonjs/Maths/math.color";
  51482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51483. import { Mesh } from "babylonjs/Meshes/mesh";
  51484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51485. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51486. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51487. import "babylonjs/Meshes/Builders/planeBuilder";
  51488. import "babylonjs/Meshes/Builders/boxBuilder";
  51489. /**
  51490. * Represents the different options available during the creation of
  51491. * a Environment helper.
  51492. *
  51493. * This can control the default ground, skybox and image processing setup of your scene.
  51494. */
  51495. export interface IEnvironmentHelperOptions {
  51496. /**
  51497. * Specifies whether or not to create a ground.
  51498. * True by default.
  51499. */
  51500. createGround: boolean;
  51501. /**
  51502. * Specifies the ground size.
  51503. * 15 by default.
  51504. */
  51505. groundSize: number;
  51506. /**
  51507. * The texture used on the ground for the main color.
  51508. * Comes from the BabylonJS CDN by default.
  51509. *
  51510. * Remarks: Can be either a texture or a url.
  51511. */
  51512. groundTexture: string | BaseTexture;
  51513. /**
  51514. * The color mixed in the ground texture by default.
  51515. * BabylonJS clearColor by default.
  51516. */
  51517. groundColor: Color3;
  51518. /**
  51519. * Specifies the ground opacity.
  51520. * 1 by default.
  51521. */
  51522. groundOpacity: number;
  51523. /**
  51524. * Enables the ground to receive shadows.
  51525. * True by default.
  51526. */
  51527. enableGroundShadow: boolean;
  51528. /**
  51529. * Helps preventing the shadow to be fully black on the ground.
  51530. * 0.5 by default.
  51531. */
  51532. groundShadowLevel: number;
  51533. /**
  51534. * Creates a mirror texture attach to the ground.
  51535. * false by default.
  51536. */
  51537. enableGroundMirror: boolean;
  51538. /**
  51539. * Specifies the ground mirror size ratio.
  51540. * 0.3 by default as the default kernel is 64.
  51541. */
  51542. groundMirrorSizeRatio: number;
  51543. /**
  51544. * Specifies the ground mirror blur kernel size.
  51545. * 64 by default.
  51546. */
  51547. groundMirrorBlurKernel: number;
  51548. /**
  51549. * Specifies the ground mirror visibility amount.
  51550. * 1 by default
  51551. */
  51552. groundMirrorAmount: number;
  51553. /**
  51554. * Specifies the ground mirror reflectance weight.
  51555. * This uses the standard weight of the background material to setup the fresnel effect
  51556. * of the mirror.
  51557. * 1 by default.
  51558. */
  51559. groundMirrorFresnelWeight: number;
  51560. /**
  51561. * Specifies the ground mirror Falloff distance.
  51562. * This can helps reducing the size of the reflection.
  51563. * 0 by Default.
  51564. */
  51565. groundMirrorFallOffDistance: number;
  51566. /**
  51567. * Specifies the ground mirror texture type.
  51568. * Unsigned Int by Default.
  51569. */
  51570. groundMirrorTextureType: number;
  51571. /**
  51572. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51573. * the shown objects.
  51574. */
  51575. groundYBias: number;
  51576. /**
  51577. * Specifies whether or not to create a skybox.
  51578. * True by default.
  51579. */
  51580. createSkybox: boolean;
  51581. /**
  51582. * Specifies the skybox size.
  51583. * 20 by default.
  51584. */
  51585. skyboxSize: number;
  51586. /**
  51587. * The texture used on the skybox for the main color.
  51588. * Comes from the BabylonJS CDN by default.
  51589. *
  51590. * Remarks: Can be either a texture or a url.
  51591. */
  51592. skyboxTexture: string | BaseTexture;
  51593. /**
  51594. * The color mixed in the skybox texture by default.
  51595. * BabylonJS clearColor by default.
  51596. */
  51597. skyboxColor: Color3;
  51598. /**
  51599. * The background rotation around the Y axis of the scene.
  51600. * This helps aligning the key lights of your scene with the background.
  51601. * 0 by default.
  51602. */
  51603. backgroundYRotation: number;
  51604. /**
  51605. * Compute automatically the size of the elements to best fit with the scene.
  51606. */
  51607. sizeAuto: boolean;
  51608. /**
  51609. * Default position of the rootMesh if autoSize is not true.
  51610. */
  51611. rootPosition: Vector3;
  51612. /**
  51613. * Sets up the image processing in the scene.
  51614. * true by default.
  51615. */
  51616. setupImageProcessing: boolean;
  51617. /**
  51618. * The texture used as your environment texture in the scene.
  51619. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51620. *
  51621. * Remarks: Can be either a texture or a url.
  51622. */
  51623. environmentTexture: string | BaseTexture;
  51624. /**
  51625. * The value of the exposure to apply to the scene.
  51626. * 0.6 by default if setupImageProcessing is true.
  51627. */
  51628. cameraExposure: number;
  51629. /**
  51630. * The value of the contrast to apply to the scene.
  51631. * 1.6 by default if setupImageProcessing is true.
  51632. */
  51633. cameraContrast: number;
  51634. /**
  51635. * Specifies whether or not tonemapping should be enabled in the scene.
  51636. * true by default if setupImageProcessing is true.
  51637. */
  51638. toneMappingEnabled: boolean;
  51639. }
  51640. /**
  51641. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51642. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51643. * It also helps with the default setup of your imageProcessing configuration.
  51644. */
  51645. export class EnvironmentHelper {
  51646. /**
  51647. * Default ground texture URL.
  51648. */
  51649. private static _groundTextureCDNUrl;
  51650. /**
  51651. * Default skybox texture URL.
  51652. */
  51653. private static _skyboxTextureCDNUrl;
  51654. /**
  51655. * Default environment texture URL.
  51656. */
  51657. private static _environmentTextureCDNUrl;
  51658. /**
  51659. * Creates the default options for the helper.
  51660. */
  51661. private static _getDefaultOptions;
  51662. private _rootMesh;
  51663. /**
  51664. * Gets the root mesh created by the helper.
  51665. */
  51666. get rootMesh(): Mesh;
  51667. private _skybox;
  51668. /**
  51669. * Gets the skybox created by the helper.
  51670. */
  51671. get skybox(): Nullable<Mesh>;
  51672. private _skyboxTexture;
  51673. /**
  51674. * Gets the skybox texture created by the helper.
  51675. */
  51676. get skyboxTexture(): Nullable<BaseTexture>;
  51677. private _skyboxMaterial;
  51678. /**
  51679. * Gets the skybox material created by the helper.
  51680. */
  51681. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51682. private _ground;
  51683. /**
  51684. * Gets the ground mesh created by the helper.
  51685. */
  51686. get ground(): Nullable<Mesh>;
  51687. private _groundTexture;
  51688. /**
  51689. * Gets the ground texture created by the helper.
  51690. */
  51691. get groundTexture(): Nullable<BaseTexture>;
  51692. private _groundMirror;
  51693. /**
  51694. * Gets the ground mirror created by the helper.
  51695. */
  51696. get groundMirror(): Nullable<MirrorTexture>;
  51697. /**
  51698. * Gets the ground mirror render list to helps pushing the meshes
  51699. * you wish in the ground reflection.
  51700. */
  51701. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51702. private _groundMaterial;
  51703. /**
  51704. * Gets the ground material created by the helper.
  51705. */
  51706. get groundMaterial(): Nullable<BackgroundMaterial>;
  51707. /**
  51708. * Stores the creation options.
  51709. */
  51710. private readonly _scene;
  51711. private _options;
  51712. /**
  51713. * This observable will be notified with any error during the creation of the environment,
  51714. * mainly texture creation errors.
  51715. */
  51716. onErrorObservable: Observable<{
  51717. message?: string;
  51718. exception?: any;
  51719. }>;
  51720. /**
  51721. * constructor
  51722. * @param options Defines the options we want to customize the helper
  51723. * @param scene The scene to add the material to
  51724. */
  51725. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51726. /**
  51727. * Updates the background according to the new options
  51728. * @param options
  51729. */
  51730. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51731. /**
  51732. * Sets the primary color of all the available elements.
  51733. * @param color the main color to affect to the ground and the background
  51734. */
  51735. setMainColor(color: Color3): void;
  51736. /**
  51737. * Setup the image processing according to the specified options.
  51738. */
  51739. private _setupImageProcessing;
  51740. /**
  51741. * Setup the environment texture according to the specified options.
  51742. */
  51743. private _setupEnvironmentTexture;
  51744. /**
  51745. * Setup the background according to the specified options.
  51746. */
  51747. private _setupBackground;
  51748. /**
  51749. * Get the scene sizes according to the setup.
  51750. */
  51751. private _getSceneSize;
  51752. /**
  51753. * Setup the ground according to the specified options.
  51754. */
  51755. private _setupGround;
  51756. /**
  51757. * Setup the ground material according to the specified options.
  51758. */
  51759. private _setupGroundMaterial;
  51760. /**
  51761. * Setup the ground diffuse texture according to the specified options.
  51762. */
  51763. private _setupGroundDiffuseTexture;
  51764. /**
  51765. * Setup the ground mirror texture according to the specified options.
  51766. */
  51767. private _setupGroundMirrorTexture;
  51768. /**
  51769. * Setup the ground to receive the mirror texture.
  51770. */
  51771. private _setupMirrorInGroundMaterial;
  51772. /**
  51773. * Setup the skybox according to the specified options.
  51774. */
  51775. private _setupSkybox;
  51776. /**
  51777. * Setup the skybox material according to the specified options.
  51778. */
  51779. private _setupSkyboxMaterial;
  51780. /**
  51781. * Setup the skybox reflection texture according to the specified options.
  51782. */
  51783. private _setupSkyboxReflectionTexture;
  51784. private _errorHandler;
  51785. /**
  51786. * Dispose all the elements created by the Helper.
  51787. */
  51788. dispose(): void;
  51789. }
  51790. }
  51791. declare module "babylonjs/Helpers/photoDome" {
  51792. import { Observable } from "babylonjs/Misc/observable";
  51793. import { Nullable } from "babylonjs/types";
  51794. import { Scene } from "babylonjs/scene";
  51795. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51796. import { Mesh } from "babylonjs/Meshes/mesh";
  51797. import { Texture } from "babylonjs/Materials/Textures/texture";
  51798. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51799. import "babylonjs/Meshes/Builders/sphereBuilder";
  51800. /**
  51801. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51802. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51803. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51804. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51805. */
  51806. export class PhotoDome extends TransformNode {
  51807. /**
  51808. * Define the image as a Monoscopic panoramic 360 image.
  51809. */
  51810. static readonly MODE_MONOSCOPIC: number;
  51811. /**
  51812. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51813. */
  51814. static readonly MODE_TOPBOTTOM: number;
  51815. /**
  51816. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51817. */
  51818. static readonly MODE_SIDEBYSIDE: number;
  51819. private _useDirectMapping;
  51820. /**
  51821. * The texture being displayed on the sphere
  51822. */
  51823. protected _photoTexture: Texture;
  51824. /**
  51825. * Gets or sets the texture being displayed on the sphere
  51826. */
  51827. get photoTexture(): Texture;
  51828. set photoTexture(value: Texture);
  51829. /**
  51830. * Observable raised when an error occured while loading the 360 image
  51831. */
  51832. onLoadErrorObservable: Observable<string>;
  51833. /**
  51834. * The skybox material
  51835. */
  51836. protected _material: BackgroundMaterial;
  51837. /**
  51838. * The surface used for the skybox
  51839. */
  51840. protected _mesh: Mesh;
  51841. /**
  51842. * Gets the mesh used for the skybox.
  51843. */
  51844. get mesh(): Mesh;
  51845. /**
  51846. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51847. * Also see the options.resolution property.
  51848. */
  51849. get fovMultiplier(): number;
  51850. set fovMultiplier(value: number);
  51851. private _imageMode;
  51852. /**
  51853. * Gets or set the current video mode for the video. It can be:
  51854. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51855. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51856. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51857. */
  51858. get imageMode(): number;
  51859. set imageMode(value: number);
  51860. /**
  51861. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51862. * @param name Element's name, child elements will append suffixes for their own names.
  51863. * @param urlsOfPhoto defines the url of the photo to display
  51864. * @param options defines an object containing optional or exposed sub element properties
  51865. * @param onError defines a callback called when an error occured while loading the texture
  51866. */
  51867. constructor(name: string, urlOfPhoto: string, options: {
  51868. resolution?: number;
  51869. size?: number;
  51870. useDirectMapping?: boolean;
  51871. faceForward?: boolean;
  51872. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51873. private _onBeforeCameraRenderObserver;
  51874. private _changeImageMode;
  51875. /**
  51876. * Releases resources associated with this node.
  51877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51879. */
  51880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51881. }
  51882. }
  51883. declare module "babylonjs/Misc/rgbdTextureTools" {
  51884. import "babylonjs/Shaders/rgbdDecode.fragment";
  51885. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51886. import { Texture } from "babylonjs/Materials/Textures/texture";
  51887. /**
  51888. * Class used to host RGBD texture specific utilities
  51889. */
  51890. export class RGBDTextureTools {
  51891. /**
  51892. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51893. * @param texture the texture to expand.
  51894. */
  51895. static ExpandRGBDTexture(texture: Texture): void;
  51896. }
  51897. }
  51898. declare module "babylonjs/Misc/brdfTextureTools" {
  51899. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51900. import { Scene } from "babylonjs/scene";
  51901. /**
  51902. * Class used to host texture specific utilities
  51903. */
  51904. export class BRDFTextureTools {
  51905. /**
  51906. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51907. * @param scene defines the hosting scene
  51908. * @returns the environment BRDF texture
  51909. */
  51910. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51911. private static _environmentBRDFBase64Texture;
  51912. }
  51913. }
  51914. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51915. import { Nullable } from "babylonjs/types";
  51916. import { Color3 } from "babylonjs/Maths/math.color";
  51917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51918. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51919. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51920. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51921. import { Engine } from "babylonjs/Engines/engine";
  51922. import { Scene } from "babylonjs/scene";
  51923. /**
  51924. * @hidden
  51925. */
  51926. export interface IMaterialClearCoatDefines {
  51927. CLEARCOAT: boolean;
  51928. CLEARCOAT_DEFAULTIOR: boolean;
  51929. CLEARCOAT_TEXTURE: boolean;
  51930. CLEARCOAT_TEXTUREDIRECTUV: number;
  51931. CLEARCOAT_BUMP: boolean;
  51932. CLEARCOAT_BUMPDIRECTUV: number;
  51933. CLEARCOAT_TINT: boolean;
  51934. CLEARCOAT_TINT_TEXTURE: boolean;
  51935. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51936. /** @hidden */
  51937. _areTexturesDirty: boolean;
  51938. }
  51939. /**
  51940. * Define the code related to the clear coat parameters of the pbr material.
  51941. */
  51942. export class PBRClearCoatConfiguration {
  51943. /**
  51944. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51945. * The default fits with a polyurethane material.
  51946. */
  51947. private static readonly _DefaultIndexOfRefraction;
  51948. private _isEnabled;
  51949. /**
  51950. * Defines if the clear coat is enabled in the material.
  51951. */
  51952. isEnabled: boolean;
  51953. /**
  51954. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51955. */
  51956. intensity: number;
  51957. /**
  51958. * Defines the clear coat layer roughness.
  51959. */
  51960. roughness: number;
  51961. private _indexOfRefraction;
  51962. /**
  51963. * Defines the index of refraction of the clear coat.
  51964. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51965. * The default fits with a polyurethane material.
  51966. * Changing the default value is more performance intensive.
  51967. */
  51968. indexOfRefraction: number;
  51969. private _texture;
  51970. /**
  51971. * Stores the clear coat values in a texture.
  51972. */
  51973. texture: Nullable<BaseTexture>;
  51974. private _bumpTexture;
  51975. /**
  51976. * Define the clear coat specific bump texture.
  51977. */
  51978. bumpTexture: Nullable<BaseTexture>;
  51979. private _isTintEnabled;
  51980. /**
  51981. * Defines if the clear coat tint is enabled in the material.
  51982. */
  51983. isTintEnabled: boolean;
  51984. /**
  51985. * Defines the clear coat tint of the material.
  51986. * This is only use if tint is enabled
  51987. */
  51988. tintColor: Color3;
  51989. /**
  51990. * Defines the distance at which the tint color should be found in the
  51991. * clear coat media.
  51992. * This is only use if tint is enabled
  51993. */
  51994. tintColorAtDistance: number;
  51995. /**
  51996. * Defines the clear coat layer thickness.
  51997. * This is only use if tint is enabled
  51998. */
  51999. tintThickness: number;
  52000. private _tintTexture;
  52001. /**
  52002. * Stores the clear tint values in a texture.
  52003. * rgb is tint
  52004. * a is a thickness factor
  52005. */
  52006. tintTexture: Nullable<BaseTexture>;
  52007. /** @hidden */
  52008. private _internalMarkAllSubMeshesAsTexturesDirty;
  52009. /** @hidden */
  52010. _markAllSubMeshesAsTexturesDirty(): void;
  52011. /**
  52012. * Instantiate a new istance of clear coat configuration.
  52013. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52014. */
  52015. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52016. /**
  52017. * Gets wehter the submesh is ready to be used or not.
  52018. * @param defines the list of "defines" to update.
  52019. * @param scene defines the scene the material belongs to.
  52020. * @param engine defines the engine the material belongs to.
  52021. * @param disableBumpMap defines wether the material disables bump or not.
  52022. * @returns - boolean indicating that the submesh is ready or not.
  52023. */
  52024. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52025. /**
  52026. * Checks to see if a texture is used in the material.
  52027. * @param defines the list of "defines" to update.
  52028. * @param scene defines the scene to the material belongs to.
  52029. */
  52030. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52031. /**
  52032. * Binds the material data.
  52033. * @param uniformBuffer defines the Uniform buffer to fill in.
  52034. * @param scene defines the scene the material belongs to.
  52035. * @param engine defines the engine the material belongs to.
  52036. * @param disableBumpMap defines wether the material disables bump or not.
  52037. * @param isFrozen defines wether the material is frozen or not.
  52038. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52039. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52040. */
  52041. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52042. /**
  52043. * Checks to see if a texture is used in the material.
  52044. * @param texture - Base texture to use.
  52045. * @returns - Boolean specifying if a texture is used in the material.
  52046. */
  52047. hasTexture(texture: BaseTexture): boolean;
  52048. /**
  52049. * Returns an array of the actively used textures.
  52050. * @param activeTextures Array of BaseTextures
  52051. */
  52052. getActiveTextures(activeTextures: BaseTexture[]): void;
  52053. /**
  52054. * Returns the animatable textures.
  52055. * @param animatables Array of animatable textures.
  52056. */
  52057. getAnimatables(animatables: IAnimatable[]): void;
  52058. /**
  52059. * Disposes the resources of the material.
  52060. * @param forceDisposeTextures - Forces the disposal of all textures.
  52061. */
  52062. dispose(forceDisposeTextures?: boolean): void;
  52063. /**
  52064. * Get the current class name of the texture useful for serialization or dynamic coding.
  52065. * @returns "PBRClearCoatConfiguration"
  52066. */
  52067. getClassName(): string;
  52068. /**
  52069. * Add fallbacks to the effect fallbacks list.
  52070. * @param defines defines the Base texture to use.
  52071. * @param fallbacks defines the current fallback list.
  52072. * @param currentRank defines the current fallback rank.
  52073. * @returns the new fallback rank.
  52074. */
  52075. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52076. /**
  52077. * Add the required uniforms to the current list.
  52078. * @param uniforms defines the current uniform list.
  52079. */
  52080. static AddUniforms(uniforms: string[]): void;
  52081. /**
  52082. * Add the required samplers to the current list.
  52083. * @param samplers defines the current sampler list.
  52084. */
  52085. static AddSamplers(samplers: string[]): void;
  52086. /**
  52087. * Add the required uniforms to the current buffer.
  52088. * @param uniformBuffer defines the current uniform buffer.
  52089. */
  52090. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52091. /**
  52092. * Makes a duplicate of the current configuration into another one.
  52093. * @param clearCoatConfiguration define the config where to copy the info
  52094. */
  52095. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52096. /**
  52097. * Serializes this clear coat configuration.
  52098. * @returns - An object with the serialized config.
  52099. */
  52100. serialize(): any;
  52101. /**
  52102. * Parses a anisotropy Configuration from a serialized object.
  52103. * @param source - Serialized object.
  52104. * @param scene Defines the scene we are parsing for
  52105. * @param rootUrl Defines the rootUrl to load from
  52106. */
  52107. parse(source: any, scene: Scene, rootUrl: string): void;
  52108. }
  52109. }
  52110. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52111. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52113. import { Vector2 } from "babylonjs/Maths/math.vector";
  52114. import { Scene } from "babylonjs/scene";
  52115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52116. import { Nullable } from "babylonjs/types";
  52117. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52118. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52119. /**
  52120. * @hidden
  52121. */
  52122. export interface IMaterialAnisotropicDefines {
  52123. ANISOTROPIC: boolean;
  52124. ANISOTROPIC_TEXTURE: boolean;
  52125. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52126. MAINUV1: boolean;
  52127. _areTexturesDirty: boolean;
  52128. _needUVs: boolean;
  52129. }
  52130. /**
  52131. * Define the code related to the anisotropic parameters of the pbr material.
  52132. */
  52133. export class PBRAnisotropicConfiguration {
  52134. private _isEnabled;
  52135. /**
  52136. * Defines if the anisotropy is enabled in the material.
  52137. */
  52138. isEnabled: boolean;
  52139. /**
  52140. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52141. */
  52142. intensity: number;
  52143. /**
  52144. * Defines if the effect is along the tangents, bitangents or in between.
  52145. * By default, the effect is "strectching" the highlights along the tangents.
  52146. */
  52147. direction: Vector2;
  52148. private _texture;
  52149. /**
  52150. * Stores the anisotropy values in a texture.
  52151. * rg is direction (like normal from -1 to 1)
  52152. * b is a intensity
  52153. */
  52154. texture: Nullable<BaseTexture>;
  52155. /** @hidden */
  52156. private _internalMarkAllSubMeshesAsTexturesDirty;
  52157. /** @hidden */
  52158. _markAllSubMeshesAsTexturesDirty(): void;
  52159. /**
  52160. * Instantiate a new istance of anisotropy configuration.
  52161. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52162. */
  52163. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52164. /**
  52165. * Specifies that the submesh is ready to be used.
  52166. * @param defines the list of "defines" to update.
  52167. * @param scene defines the scene the material belongs to.
  52168. * @returns - boolean indicating that the submesh is ready or not.
  52169. */
  52170. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52171. /**
  52172. * Checks to see if a texture is used in the material.
  52173. * @param defines the list of "defines" to update.
  52174. * @param mesh the mesh we are preparing the defines for.
  52175. * @param scene defines the scene the material belongs to.
  52176. */
  52177. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52178. /**
  52179. * Binds the material data.
  52180. * @param uniformBuffer defines the Uniform buffer to fill in.
  52181. * @param scene defines the scene the material belongs to.
  52182. * @param isFrozen defines wether the material is frozen or not.
  52183. */
  52184. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52185. /**
  52186. * Checks to see if a texture is used in the material.
  52187. * @param texture - Base texture to use.
  52188. * @returns - Boolean specifying if a texture is used in the material.
  52189. */
  52190. hasTexture(texture: BaseTexture): boolean;
  52191. /**
  52192. * Returns an array of the actively used textures.
  52193. * @param activeTextures Array of BaseTextures
  52194. */
  52195. getActiveTextures(activeTextures: BaseTexture[]): void;
  52196. /**
  52197. * Returns the animatable textures.
  52198. * @param animatables Array of animatable textures.
  52199. */
  52200. getAnimatables(animatables: IAnimatable[]): void;
  52201. /**
  52202. * Disposes the resources of the material.
  52203. * @param forceDisposeTextures - Forces the disposal of all textures.
  52204. */
  52205. dispose(forceDisposeTextures?: boolean): void;
  52206. /**
  52207. * Get the current class name of the texture useful for serialization or dynamic coding.
  52208. * @returns "PBRAnisotropicConfiguration"
  52209. */
  52210. getClassName(): string;
  52211. /**
  52212. * Add fallbacks to the effect fallbacks list.
  52213. * @param defines defines the Base texture to use.
  52214. * @param fallbacks defines the current fallback list.
  52215. * @param currentRank defines the current fallback rank.
  52216. * @returns the new fallback rank.
  52217. */
  52218. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52219. /**
  52220. * Add the required uniforms to the current list.
  52221. * @param uniforms defines the current uniform list.
  52222. */
  52223. static AddUniforms(uniforms: string[]): void;
  52224. /**
  52225. * Add the required uniforms to the current buffer.
  52226. * @param uniformBuffer defines the current uniform buffer.
  52227. */
  52228. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52229. /**
  52230. * Add the required samplers to the current list.
  52231. * @param samplers defines the current sampler list.
  52232. */
  52233. static AddSamplers(samplers: string[]): void;
  52234. /**
  52235. * Makes a duplicate of the current configuration into another one.
  52236. * @param anisotropicConfiguration define the config where to copy the info
  52237. */
  52238. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52239. /**
  52240. * Serializes this anisotropy configuration.
  52241. * @returns - An object with the serialized config.
  52242. */
  52243. serialize(): any;
  52244. /**
  52245. * Parses a anisotropy Configuration from a serialized object.
  52246. * @param source - Serialized object.
  52247. * @param scene Defines the scene we are parsing for
  52248. * @param rootUrl Defines the rootUrl to load from
  52249. */
  52250. parse(source: any, scene: Scene, rootUrl: string): void;
  52251. }
  52252. }
  52253. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52254. import { Scene } from "babylonjs/scene";
  52255. /**
  52256. * @hidden
  52257. */
  52258. export interface IMaterialBRDFDefines {
  52259. BRDF_V_HEIGHT_CORRELATED: boolean;
  52260. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52261. SPHERICAL_HARMONICS: boolean;
  52262. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52263. /** @hidden */
  52264. _areMiscDirty: boolean;
  52265. }
  52266. /**
  52267. * Define the code related to the BRDF parameters of the pbr material.
  52268. */
  52269. export class PBRBRDFConfiguration {
  52270. /**
  52271. * Default value used for the energy conservation.
  52272. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52273. */
  52274. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52275. /**
  52276. * Default value used for the Smith Visibility Height Correlated mode.
  52277. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52278. */
  52279. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52280. /**
  52281. * Default value used for the IBL diffuse part.
  52282. * This can help switching back to the polynomials mode globally which is a tiny bit
  52283. * less GPU intensive at the drawback of a lower quality.
  52284. */
  52285. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52286. /**
  52287. * Default value used for activating energy conservation for the specular workflow.
  52288. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52289. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52290. */
  52291. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52292. private _useEnergyConservation;
  52293. /**
  52294. * Defines if the material uses energy conservation.
  52295. */
  52296. useEnergyConservation: boolean;
  52297. private _useSmithVisibilityHeightCorrelated;
  52298. /**
  52299. * LEGACY Mode set to false
  52300. * Defines if the material uses height smith correlated visibility term.
  52301. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52302. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52303. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52304. * Not relying on height correlated will also disable energy conservation.
  52305. */
  52306. useSmithVisibilityHeightCorrelated: boolean;
  52307. private _useSphericalHarmonics;
  52308. /**
  52309. * LEGACY Mode set to false
  52310. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52311. * diffuse part of the IBL.
  52312. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52313. * to the ground truth.
  52314. */
  52315. useSphericalHarmonics: boolean;
  52316. private _useSpecularGlossinessInputEnergyConservation;
  52317. /**
  52318. * Defines if the material uses energy conservation, when the specular workflow is active.
  52319. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52320. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52321. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52322. */
  52323. useSpecularGlossinessInputEnergyConservation: boolean;
  52324. /** @hidden */
  52325. private _internalMarkAllSubMeshesAsMiscDirty;
  52326. /** @hidden */
  52327. _markAllSubMeshesAsMiscDirty(): void;
  52328. /**
  52329. * Instantiate a new istance of clear coat configuration.
  52330. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52331. */
  52332. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52333. /**
  52334. * Checks to see if a texture is used in the material.
  52335. * @param defines the list of "defines" to update.
  52336. */
  52337. prepareDefines(defines: IMaterialBRDFDefines): void;
  52338. /**
  52339. * Get the current class name of the texture useful for serialization or dynamic coding.
  52340. * @returns "PBRClearCoatConfiguration"
  52341. */
  52342. getClassName(): string;
  52343. /**
  52344. * Makes a duplicate of the current configuration into another one.
  52345. * @param brdfConfiguration define the config where to copy the info
  52346. */
  52347. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52348. /**
  52349. * Serializes this BRDF configuration.
  52350. * @returns - An object with the serialized config.
  52351. */
  52352. serialize(): any;
  52353. /**
  52354. * Parses a anisotropy Configuration from a serialized object.
  52355. * @param source - Serialized object.
  52356. * @param scene Defines the scene we are parsing for
  52357. * @param rootUrl Defines the rootUrl to load from
  52358. */
  52359. parse(source: any, scene: Scene, rootUrl: string): void;
  52360. }
  52361. }
  52362. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52363. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52364. import { Color3 } from "babylonjs/Maths/math.color";
  52365. import { Scene } from "babylonjs/scene";
  52366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52367. import { Nullable } from "babylonjs/types";
  52368. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52369. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52370. /**
  52371. * @hidden
  52372. */
  52373. export interface IMaterialSheenDefines {
  52374. SHEEN: boolean;
  52375. SHEEN_TEXTURE: boolean;
  52376. SHEEN_TEXTUREDIRECTUV: number;
  52377. SHEEN_LINKWITHALBEDO: boolean;
  52378. /** @hidden */
  52379. _areTexturesDirty: boolean;
  52380. }
  52381. /**
  52382. * Define the code related to the Sheen parameters of the pbr material.
  52383. */
  52384. export class PBRSheenConfiguration {
  52385. private _isEnabled;
  52386. /**
  52387. * Defines if the material uses sheen.
  52388. */
  52389. isEnabled: boolean;
  52390. private _linkSheenWithAlbedo;
  52391. /**
  52392. * Defines if the sheen is linked to the sheen color.
  52393. */
  52394. linkSheenWithAlbedo: boolean;
  52395. /**
  52396. * Defines the sheen intensity.
  52397. */
  52398. intensity: number;
  52399. /**
  52400. * Defines the sheen color.
  52401. */
  52402. color: Color3;
  52403. private _texture;
  52404. /**
  52405. * Stores the sheen tint values in a texture.
  52406. * rgb is tint
  52407. * a is a intensity
  52408. */
  52409. texture: Nullable<BaseTexture>;
  52410. /** @hidden */
  52411. private _internalMarkAllSubMeshesAsTexturesDirty;
  52412. /** @hidden */
  52413. _markAllSubMeshesAsTexturesDirty(): void;
  52414. /**
  52415. * Instantiate a new istance of clear coat configuration.
  52416. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52417. */
  52418. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52419. /**
  52420. * Specifies that the submesh is ready to be used.
  52421. * @param defines the list of "defines" to update.
  52422. * @param scene defines the scene the material belongs to.
  52423. * @returns - boolean indicating that the submesh is ready or not.
  52424. */
  52425. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52426. /**
  52427. * Checks to see if a texture is used in the material.
  52428. * @param defines the list of "defines" to update.
  52429. * @param scene defines the scene the material belongs to.
  52430. */
  52431. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52432. /**
  52433. * Binds the material data.
  52434. * @param uniformBuffer defines the Uniform buffer to fill in.
  52435. * @param scene defines the scene the material belongs to.
  52436. * @param isFrozen defines wether the material is frozen or not.
  52437. */
  52438. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52439. /**
  52440. * Checks to see if a texture is used in the material.
  52441. * @param texture - Base texture to use.
  52442. * @returns - Boolean specifying if a texture is used in the material.
  52443. */
  52444. hasTexture(texture: BaseTexture): boolean;
  52445. /**
  52446. * Returns an array of the actively used textures.
  52447. * @param activeTextures Array of BaseTextures
  52448. */
  52449. getActiveTextures(activeTextures: BaseTexture[]): void;
  52450. /**
  52451. * Returns the animatable textures.
  52452. * @param animatables Array of animatable textures.
  52453. */
  52454. getAnimatables(animatables: IAnimatable[]): void;
  52455. /**
  52456. * Disposes the resources of the material.
  52457. * @param forceDisposeTextures - Forces the disposal of all textures.
  52458. */
  52459. dispose(forceDisposeTextures?: boolean): void;
  52460. /**
  52461. * Get the current class name of the texture useful for serialization or dynamic coding.
  52462. * @returns "PBRSheenConfiguration"
  52463. */
  52464. getClassName(): string;
  52465. /**
  52466. * Add fallbacks to the effect fallbacks list.
  52467. * @param defines defines the Base texture to use.
  52468. * @param fallbacks defines the current fallback list.
  52469. * @param currentRank defines the current fallback rank.
  52470. * @returns the new fallback rank.
  52471. */
  52472. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52473. /**
  52474. * Add the required uniforms to the current list.
  52475. * @param uniforms defines the current uniform list.
  52476. */
  52477. static AddUniforms(uniforms: string[]): void;
  52478. /**
  52479. * Add the required uniforms to the current buffer.
  52480. * @param uniformBuffer defines the current uniform buffer.
  52481. */
  52482. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52483. /**
  52484. * Add the required samplers to the current list.
  52485. * @param samplers defines the current sampler list.
  52486. */
  52487. static AddSamplers(samplers: string[]): void;
  52488. /**
  52489. * Makes a duplicate of the current configuration into another one.
  52490. * @param sheenConfiguration define the config where to copy the info
  52491. */
  52492. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52493. /**
  52494. * Serializes this BRDF configuration.
  52495. * @returns - An object with the serialized config.
  52496. */
  52497. serialize(): any;
  52498. /**
  52499. * Parses a anisotropy Configuration from a serialized object.
  52500. * @param source - Serialized object.
  52501. * @param scene Defines the scene we are parsing for
  52502. * @param rootUrl Defines the rootUrl to load from
  52503. */
  52504. parse(source: any, scene: Scene, rootUrl: string): void;
  52505. }
  52506. }
  52507. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52508. import { Nullable } from "babylonjs/types";
  52509. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52510. import { Color3 } from "babylonjs/Maths/math.color";
  52511. import { SmartArray } from "babylonjs/Misc/smartArray";
  52512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52514. import { Effect } from "babylonjs/Materials/effect";
  52515. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52516. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52517. import { Engine } from "babylonjs/Engines/engine";
  52518. import { Scene } from "babylonjs/scene";
  52519. /**
  52520. * @hidden
  52521. */
  52522. export interface IMaterialSubSurfaceDefines {
  52523. SUBSURFACE: boolean;
  52524. SS_REFRACTION: boolean;
  52525. SS_TRANSLUCENCY: boolean;
  52526. SS_SCATERRING: boolean;
  52527. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52528. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52529. SS_REFRACTIONMAP_3D: boolean;
  52530. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52531. SS_LODINREFRACTIONALPHA: boolean;
  52532. SS_GAMMAREFRACTION: boolean;
  52533. SS_RGBDREFRACTION: boolean;
  52534. SS_LINEARSPECULARREFRACTION: boolean;
  52535. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52536. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52537. /** @hidden */
  52538. _areTexturesDirty: boolean;
  52539. }
  52540. /**
  52541. * Define the code related to the sub surface parameters of the pbr material.
  52542. */
  52543. export class PBRSubSurfaceConfiguration {
  52544. private _isRefractionEnabled;
  52545. /**
  52546. * Defines if the refraction is enabled in the material.
  52547. */
  52548. isRefractionEnabled: boolean;
  52549. private _isTranslucencyEnabled;
  52550. /**
  52551. * Defines if the translucency is enabled in the material.
  52552. */
  52553. isTranslucencyEnabled: boolean;
  52554. private _isScatteringEnabled;
  52555. /**
  52556. * Defines the refraction intensity of the material.
  52557. * The refraction when enabled replaces the Diffuse part of the material.
  52558. * The intensity helps transitionning between diffuse and refraction.
  52559. */
  52560. refractionIntensity: number;
  52561. /**
  52562. * Defines the translucency intensity of the material.
  52563. * When translucency has been enabled, this defines how much of the "translucency"
  52564. * is addded to the diffuse part of the material.
  52565. */
  52566. translucencyIntensity: number;
  52567. /**
  52568. * Defines the scattering intensity of the material.
  52569. * When scattering has been enabled, this defines how much of the "scattered light"
  52570. * is addded to the diffuse part of the material.
  52571. */
  52572. scatteringIntensity: number;
  52573. private _thicknessTexture;
  52574. /**
  52575. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52576. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52577. * 0 would mean minimumThickness
  52578. * 1 would mean maximumThickness
  52579. * The other channels might be use as a mask to vary the different effects intensity.
  52580. */
  52581. thicknessTexture: Nullable<BaseTexture>;
  52582. private _refractionTexture;
  52583. /**
  52584. * Defines the texture to use for refraction.
  52585. */
  52586. refractionTexture: Nullable<BaseTexture>;
  52587. private _indexOfRefraction;
  52588. /**
  52589. * Defines the index of refraction used in the material.
  52590. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52591. */
  52592. indexOfRefraction: number;
  52593. private _invertRefractionY;
  52594. /**
  52595. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52596. */
  52597. invertRefractionY: boolean;
  52598. private _linkRefractionWithTransparency;
  52599. /**
  52600. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52601. * Materials half opaque for instance using refraction could benefit from this control.
  52602. */
  52603. linkRefractionWithTransparency: boolean;
  52604. /**
  52605. * Defines the minimum thickness stored in the thickness map.
  52606. * If no thickness map is defined, this value will be used to simulate thickness.
  52607. */
  52608. minimumThickness: number;
  52609. /**
  52610. * Defines the maximum thickness stored in the thickness map.
  52611. */
  52612. maximumThickness: number;
  52613. /**
  52614. * Defines the volume tint of the material.
  52615. * This is used for both translucency and scattering.
  52616. */
  52617. tintColor: Color3;
  52618. /**
  52619. * Defines the distance at which the tint color should be found in the media.
  52620. * This is used for refraction only.
  52621. */
  52622. tintColorAtDistance: number;
  52623. /**
  52624. * Defines how far each channel transmit through the media.
  52625. * It is defined as a color to simplify it selection.
  52626. */
  52627. diffusionDistance: Color3;
  52628. private _useMaskFromThicknessTexture;
  52629. /**
  52630. * Stores the intensity of the different subsurface effects in the thickness texture.
  52631. * * the green channel is the translucency intensity.
  52632. * * the blue channel is the scattering intensity.
  52633. * * the alpha channel is the refraction intensity.
  52634. */
  52635. useMaskFromThicknessTexture: boolean;
  52636. /** @hidden */
  52637. private _internalMarkAllSubMeshesAsTexturesDirty;
  52638. /** @hidden */
  52639. _markAllSubMeshesAsTexturesDirty(): void;
  52640. /**
  52641. * Instantiate a new istance of sub surface configuration.
  52642. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52643. */
  52644. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52645. /**
  52646. * Gets wehter the submesh is ready to be used or not.
  52647. * @param defines the list of "defines" to update.
  52648. * @param scene defines the scene the material belongs to.
  52649. * @returns - boolean indicating that the submesh is ready or not.
  52650. */
  52651. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52652. /**
  52653. * Checks to see if a texture is used in the material.
  52654. * @param defines the list of "defines" to update.
  52655. * @param scene defines the scene to the material belongs to.
  52656. */
  52657. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52658. /**
  52659. * Binds the material data.
  52660. * @param uniformBuffer defines the Uniform buffer to fill in.
  52661. * @param scene defines the scene the material belongs to.
  52662. * @param engine defines the engine the material belongs to.
  52663. * @param isFrozen defines wether the material is frozen or not.
  52664. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52665. */
  52666. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52667. /**
  52668. * Unbinds the material from the mesh.
  52669. * @param activeEffect defines the effect that should be unbound from.
  52670. * @returns true if unbound, otherwise false
  52671. */
  52672. unbind(activeEffect: Effect): boolean;
  52673. /**
  52674. * Returns the texture used for refraction or null if none is used.
  52675. * @param scene defines the scene the material belongs to.
  52676. * @returns - Refraction texture if present. If no refraction texture and refraction
  52677. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52678. */
  52679. private _getRefractionTexture;
  52680. /**
  52681. * Returns true if alpha blending should be disabled.
  52682. */
  52683. get disableAlphaBlending(): boolean;
  52684. /**
  52685. * Fills the list of render target textures.
  52686. * @param renderTargets the list of render targets to update
  52687. */
  52688. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52689. /**
  52690. * Checks to see if a texture is used in the material.
  52691. * @param texture - Base texture to use.
  52692. * @returns - Boolean specifying if a texture is used in the material.
  52693. */
  52694. hasTexture(texture: BaseTexture): boolean;
  52695. /**
  52696. * Gets a boolean indicating that current material needs to register RTT
  52697. * @returns true if this uses a render target otherwise false.
  52698. */
  52699. hasRenderTargetTextures(): boolean;
  52700. /**
  52701. * Returns an array of the actively used textures.
  52702. * @param activeTextures Array of BaseTextures
  52703. */
  52704. getActiveTextures(activeTextures: BaseTexture[]): void;
  52705. /**
  52706. * Returns the animatable textures.
  52707. * @param animatables Array of animatable textures.
  52708. */
  52709. getAnimatables(animatables: IAnimatable[]): void;
  52710. /**
  52711. * Disposes the resources of the material.
  52712. * @param forceDisposeTextures - Forces the disposal of all textures.
  52713. */
  52714. dispose(forceDisposeTextures?: boolean): void;
  52715. /**
  52716. * Get the current class name of the texture useful for serialization or dynamic coding.
  52717. * @returns "PBRSubSurfaceConfiguration"
  52718. */
  52719. getClassName(): string;
  52720. /**
  52721. * Add fallbacks to the effect fallbacks list.
  52722. * @param defines defines the Base texture to use.
  52723. * @param fallbacks defines the current fallback list.
  52724. * @param currentRank defines the current fallback rank.
  52725. * @returns the new fallback rank.
  52726. */
  52727. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52728. /**
  52729. * Add the required uniforms to the current list.
  52730. * @param uniforms defines the current uniform list.
  52731. */
  52732. static AddUniforms(uniforms: string[]): void;
  52733. /**
  52734. * Add the required samplers to the current list.
  52735. * @param samplers defines the current sampler list.
  52736. */
  52737. static AddSamplers(samplers: string[]): void;
  52738. /**
  52739. * Add the required uniforms to the current buffer.
  52740. * @param uniformBuffer defines the current uniform buffer.
  52741. */
  52742. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52743. /**
  52744. * Makes a duplicate of the current configuration into another one.
  52745. * @param configuration define the config where to copy the info
  52746. */
  52747. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52748. /**
  52749. * Serializes this Sub Surface configuration.
  52750. * @returns - An object with the serialized config.
  52751. */
  52752. serialize(): any;
  52753. /**
  52754. * Parses a anisotropy Configuration from a serialized object.
  52755. * @param source - Serialized object.
  52756. * @param scene Defines the scene we are parsing for
  52757. * @param rootUrl Defines the rootUrl to load from
  52758. */
  52759. parse(source: any, scene: Scene, rootUrl: string): void;
  52760. }
  52761. }
  52762. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52763. /** @hidden */
  52764. export var pbrFragmentDeclaration: {
  52765. name: string;
  52766. shader: string;
  52767. };
  52768. }
  52769. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52770. /** @hidden */
  52771. export var pbrUboDeclaration: {
  52772. name: string;
  52773. shader: string;
  52774. };
  52775. }
  52776. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52777. /** @hidden */
  52778. export var pbrFragmentExtraDeclaration: {
  52779. name: string;
  52780. shader: string;
  52781. };
  52782. }
  52783. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52784. /** @hidden */
  52785. export var pbrFragmentSamplersDeclaration: {
  52786. name: string;
  52787. shader: string;
  52788. };
  52789. }
  52790. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52791. /** @hidden */
  52792. export var pbrHelperFunctions: {
  52793. name: string;
  52794. shader: string;
  52795. };
  52796. }
  52797. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52798. /** @hidden */
  52799. export var harmonicsFunctions: {
  52800. name: string;
  52801. shader: string;
  52802. };
  52803. }
  52804. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52805. /** @hidden */
  52806. export var pbrDirectLightingSetupFunctions: {
  52807. name: string;
  52808. shader: string;
  52809. };
  52810. }
  52811. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52812. /** @hidden */
  52813. export var pbrDirectLightingFalloffFunctions: {
  52814. name: string;
  52815. shader: string;
  52816. };
  52817. }
  52818. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52819. /** @hidden */
  52820. export var pbrBRDFFunctions: {
  52821. name: string;
  52822. shader: string;
  52823. };
  52824. }
  52825. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52826. /** @hidden */
  52827. export var pbrDirectLightingFunctions: {
  52828. name: string;
  52829. shader: string;
  52830. };
  52831. }
  52832. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52833. /** @hidden */
  52834. export var pbrIBLFunctions: {
  52835. name: string;
  52836. shader: string;
  52837. };
  52838. }
  52839. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52840. /** @hidden */
  52841. export var pbrDebug: {
  52842. name: string;
  52843. shader: string;
  52844. };
  52845. }
  52846. declare module "babylonjs/Shaders/pbr.fragment" {
  52847. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52848. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52849. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52850. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52851. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52853. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52854. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52855. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52856. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52858. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52859. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52860. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52861. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52864. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52865. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52866. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52869. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52870. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52871. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52872. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52873. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52874. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52875. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52876. /** @hidden */
  52877. export var pbrPixelShader: {
  52878. name: string;
  52879. shader: string;
  52880. };
  52881. }
  52882. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52883. /** @hidden */
  52884. export var pbrVertexDeclaration: {
  52885. name: string;
  52886. shader: string;
  52887. };
  52888. }
  52889. declare module "babylonjs/Shaders/pbr.vertex" {
  52890. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52891. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52893. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52896. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52905. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52906. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52907. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52908. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52909. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52910. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52911. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52912. /** @hidden */
  52913. export var pbrVertexShader: {
  52914. name: string;
  52915. shader: string;
  52916. };
  52917. }
  52918. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52919. import { Nullable } from "babylonjs/types";
  52920. import { Scene } from "babylonjs/scene";
  52921. import { Matrix } from "babylonjs/Maths/math.vector";
  52922. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52924. import { Mesh } from "babylonjs/Meshes/mesh";
  52925. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52926. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52927. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52928. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52929. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52930. import { Color3 } from "babylonjs/Maths/math.color";
  52931. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52932. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52933. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52934. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52936. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52937. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52938. import "babylonjs/Shaders/pbr.fragment";
  52939. import "babylonjs/Shaders/pbr.vertex";
  52940. /**
  52941. * Manages the defines for the PBR Material.
  52942. * @hidden
  52943. */
  52944. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52945. PBR: boolean;
  52946. MAINUV1: boolean;
  52947. MAINUV2: boolean;
  52948. UV1: boolean;
  52949. UV2: boolean;
  52950. ALBEDO: boolean;
  52951. ALBEDODIRECTUV: number;
  52952. VERTEXCOLOR: boolean;
  52953. AMBIENT: boolean;
  52954. AMBIENTDIRECTUV: number;
  52955. AMBIENTINGRAYSCALE: boolean;
  52956. OPACITY: boolean;
  52957. VERTEXALPHA: boolean;
  52958. OPACITYDIRECTUV: number;
  52959. OPACITYRGB: boolean;
  52960. ALPHATEST: boolean;
  52961. DEPTHPREPASS: boolean;
  52962. ALPHABLEND: boolean;
  52963. ALPHAFROMALBEDO: boolean;
  52964. ALPHATESTVALUE: string;
  52965. SPECULAROVERALPHA: boolean;
  52966. RADIANCEOVERALPHA: boolean;
  52967. ALPHAFRESNEL: boolean;
  52968. LINEARALPHAFRESNEL: boolean;
  52969. PREMULTIPLYALPHA: boolean;
  52970. EMISSIVE: boolean;
  52971. EMISSIVEDIRECTUV: number;
  52972. REFLECTIVITY: boolean;
  52973. REFLECTIVITYDIRECTUV: number;
  52974. SPECULARTERM: boolean;
  52975. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52976. MICROSURFACEAUTOMATIC: boolean;
  52977. LODBASEDMICROSFURACE: boolean;
  52978. MICROSURFACEMAP: boolean;
  52979. MICROSURFACEMAPDIRECTUV: number;
  52980. METALLICWORKFLOW: boolean;
  52981. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52982. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52983. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52984. AOSTOREINMETALMAPRED: boolean;
  52985. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52986. ENVIRONMENTBRDF: boolean;
  52987. ENVIRONMENTBRDF_RGBD: boolean;
  52988. NORMAL: boolean;
  52989. TANGENT: boolean;
  52990. BUMP: boolean;
  52991. BUMPDIRECTUV: number;
  52992. OBJECTSPACE_NORMALMAP: boolean;
  52993. PARALLAX: boolean;
  52994. PARALLAXOCCLUSION: boolean;
  52995. NORMALXYSCALE: boolean;
  52996. LIGHTMAP: boolean;
  52997. LIGHTMAPDIRECTUV: number;
  52998. USELIGHTMAPASSHADOWMAP: boolean;
  52999. GAMMALIGHTMAP: boolean;
  53000. RGBDLIGHTMAP: boolean;
  53001. REFLECTION: boolean;
  53002. REFLECTIONMAP_3D: boolean;
  53003. REFLECTIONMAP_SPHERICAL: boolean;
  53004. REFLECTIONMAP_PLANAR: boolean;
  53005. REFLECTIONMAP_CUBIC: boolean;
  53006. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53007. REFLECTIONMAP_PROJECTION: boolean;
  53008. REFLECTIONMAP_SKYBOX: boolean;
  53009. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  53010. REFLECTIONMAP_EXPLICIT: boolean;
  53011. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53012. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53013. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53014. INVERTCUBICMAP: boolean;
  53015. USESPHERICALFROMREFLECTIONMAP: boolean;
  53016. USEIRRADIANCEMAP: boolean;
  53017. SPHERICAL_HARMONICS: boolean;
  53018. USESPHERICALINVERTEX: boolean;
  53019. REFLECTIONMAP_OPPOSITEZ: boolean;
  53020. LODINREFLECTIONALPHA: boolean;
  53021. GAMMAREFLECTION: boolean;
  53022. RGBDREFLECTION: boolean;
  53023. LINEARSPECULARREFLECTION: boolean;
  53024. RADIANCEOCCLUSION: boolean;
  53025. HORIZONOCCLUSION: boolean;
  53026. INSTANCES: boolean;
  53027. NUM_BONE_INFLUENCERS: number;
  53028. BonesPerMesh: number;
  53029. BONETEXTURE: boolean;
  53030. NONUNIFORMSCALING: boolean;
  53031. MORPHTARGETS: boolean;
  53032. MORPHTARGETS_NORMAL: boolean;
  53033. MORPHTARGETS_TANGENT: boolean;
  53034. MORPHTARGETS_UV: boolean;
  53035. NUM_MORPH_INFLUENCERS: number;
  53036. IMAGEPROCESSING: boolean;
  53037. VIGNETTE: boolean;
  53038. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53039. VIGNETTEBLENDMODEOPAQUE: boolean;
  53040. TONEMAPPING: boolean;
  53041. TONEMAPPING_ACES: boolean;
  53042. CONTRAST: boolean;
  53043. COLORCURVES: boolean;
  53044. COLORGRADING: boolean;
  53045. COLORGRADING3D: boolean;
  53046. SAMPLER3DGREENDEPTH: boolean;
  53047. SAMPLER3DBGRMAP: boolean;
  53048. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53049. EXPOSURE: boolean;
  53050. MULTIVIEW: boolean;
  53051. USEPHYSICALLIGHTFALLOFF: boolean;
  53052. USEGLTFLIGHTFALLOFF: boolean;
  53053. TWOSIDEDLIGHTING: boolean;
  53054. SHADOWFLOAT: boolean;
  53055. CLIPPLANE: boolean;
  53056. CLIPPLANE2: boolean;
  53057. CLIPPLANE3: boolean;
  53058. CLIPPLANE4: boolean;
  53059. CLIPPLANE5: boolean;
  53060. CLIPPLANE6: boolean;
  53061. POINTSIZE: boolean;
  53062. FOG: boolean;
  53063. LOGARITHMICDEPTH: boolean;
  53064. FORCENORMALFORWARD: boolean;
  53065. SPECULARAA: boolean;
  53066. CLEARCOAT: boolean;
  53067. CLEARCOAT_DEFAULTIOR: boolean;
  53068. CLEARCOAT_TEXTURE: boolean;
  53069. CLEARCOAT_TEXTUREDIRECTUV: number;
  53070. CLEARCOAT_BUMP: boolean;
  53071. CLEARCOAT_BUMPDIRECTUV: number;
  53072. CLEARCOAT_TINT: boolean;
  53073. CLEARCOAT_TINT_TEXTURE: boolean;
  53074. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53075. ANISOTROPIC: boolean;
  53076. ANISOTROPIC_TEXTURE: boolean;
  53077. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53078. BRDF_V_HEIGHT_CORRELATED: boolean;
  53079. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53080. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53081. SHEEN: boolean;
  53082. SHEEN_TEXTURE: boolean;
  53083. SHEEN_TEXTUREDIRECTUV: number;
  53084. SHEEN_LINKWITHALBEDO: boolean;
  53085. SUBSURFACE: boolean;
  53086. SS_REFRACTION: boolean;
  53087. SS_TRANSLUCENCY: boolean;
  53088. SS_SCATERRING: boolean;
  53089. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53090. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53091. SS_REFRACTIONMAP_3D: boolean;
  53092. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53093. SS_LODINREFRACTIONALPHA: boolean;
  53094. SS_GAMMAREFRACTION: boolean;
  53095. SS_RGBDREFRACTION: boolean;
  53096. SS_LINEARSPECULARREFRACTION: boolean;
  53097. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53098. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53099. UNLIT: boolean;
  53100. DEBUGMODE: number;
  53101. /**
  53102. * Initializes the PBR Material defines.
  53103. */
  53104. constructor();
  53105. /**
  53106. * Resets the PBR Material defines.
  53107. */
  53108. reset(): void;
  53109. }
  53110. /**
  53111. * The Physically based material base class of BJS.
  53112. *
  53113. * This offers the main features of a standard PBR material.
  53114. * For more information, please refer to the documentation :
  53115. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53116. */
  53117. export abstract class PBRBaseMaterial extends PushMaterial {
  53118. /**
  53119. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53120. */
  53121. static readonly PBRMATERIAL_OPAQUE: number;
  53122. /**
  53123. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53124. */
  53125. static readonly PBRMATERIAL_ALPHATEST: number;
  53126. /**
  53127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53128. */
  53129. static readonly PBRMATERIAL_ALPHABLEND: number;
  53130. /**
  53131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53132. * They are also discarded below the alpha cutoff threshold to improve performances.
  53133. */
  53134. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53135. /**
  53136. * Defines the default value of how much AO map is occluding the analytical lights
  53137. * (point spot...).
  53138. */
  53139. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53140. /**
  53141. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53142. */
  53143. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53144. /**
  53145. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53146. * to enhance interoperability with other engines.
  53147. */
  53148. static readonly LIGHTFALLOFF_GLTF: number;
  53149. /**
  53150. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53151. * to enhance interoperability with other materials.
  53152. */
  53153. static readonly LIGHTFALLOFF_STANDARD: number;
  53154. /**
  53155. * Intensity of the direct lights e.g. the four lights available in your scene.
  53156. * This impacts both the direct diffuse and specular highlights.
  53157. */
  53158. protected _directIntensity: number;
  53159. /**
  53160. * Intensity of the emissive part of the material.
  53161. * This helps controlling the emissive effect without modifying the emissive color.
  53162. */
  53163. protected _emissiveIntensity: number;
  53164. /**
  53165. * Intensity of the environment e.g. how much the environment will light the object
  53166. * either through harmonics for rough material or through the refelction for shiny ones.
  53167. */
  53168. protected _environmentIntensity: number;
  53169. /**
  53170. * This is a special control allowing the reduction of the specular highlights coming from the
  53171. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53172. */
  53173. protected _specularIntensity: number;
  53174. /**
  53175. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53176. */
  53177. private _lightingInfos;
  53178. /**
  53179. * Debug Control allowing disabling the bump map on this material.
  53180. */
  53181. protected _disableBumpMap: boolean;
  53182. /**
  53183. * AKA Diffuse Texture in standard nomenclature.
  53184. */
  53185. protected _albedoTexture: Nullable<BaseTexture>;
  53186. /**
  53187. * AKA Occlusion Texture in other nomenclature.
  53188. */
  53189. protected _ambientTexture: Nullable<BaseTexture>;
  53190. /**
  53191. * AKA Occlusion Texture Intensity in other nomenclature.
  53192. */
  53193. protected _ambientTextureStrength: number;
  53194. /**
  53195. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53196. * 1 means it completely occludes it
  53197. * 0 mean it has no impact
  53198. */
  53199. protected _ambientTextureImpactOnAnalyticalLights: number;
  53200. /**
  53201. * Stores the alpha values in a texture.
  53202. */
  53203. protected _opacityTexture: Nullable<BaseTexture>;
  53204. /**
  53205. * Stores the reflection values in a texture.
  53206. */
  53207. protected _reflectionTexture: Nullable<BaseTexture>;
  53208. /**
  53209. * Stores the emissive values in a texture.
  53210. */
  53211. protected _emissiveTexture: Nullable<BaseTexture>;
  53212. /**
  53213. * AKA Specular texture in other nomenclature.
  53214. */
  53215. protected _reflectivityTexture: Nullable<BaseTexture>;
  53216. /**
  53217. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53218. */
  53219. protected _metallicTexture: Nullable<BaseTexture>;
  53220. /**
  53221. * Specifies the metallic scalar of the metallic/roughness workflow.
  53222. * Can also be used to scale the metalness values of the metallic texture.
  53223. */
  53224. protected _metallic: Nullable<number>;
  53225. /**
  53226. * Specifies the roughness scalar of the metallic/roughness workflow.
  53227. * Can also be used to scale the roughness values of the metallic texture.
  53228. */
  53229. protected _roughness: Nullable<number>;
  53230. /**
  53231. * Specifies the an F0 factor to help configuring the material F0.
  53232. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53233. * to 0.5 the previously hard coded value stays the same.
  53234. * Can also be used to scale the F0 values of the metallic texture.
  53235. */
  53236. protected _metallicF0Factor: number;
  53237. /**
  53238. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53239. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53240. * your expectation as it multiplies with the texture data.
  53241. */
  53242. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53243. /**
  53244. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53245. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53246. */
  53247. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53248. /**
  53249. * Stores surface normal data used to displace a mesh in a texture.
  53250. */
  53251. protected _bumpTexture: Nullable<BaseTexture>;
  53252. /**
  53253. * Stores the pre-calculated light information of a mesh in a texture.
  53254. */
  53255. protected _lightmapTexture: Nullable<BaseTexture>;
  53256. /**
  53257. * The color of a material in ambient lighting.
  53258. */
  53259. protected _ambientColor: Color3;
  53260. /**
  53261. * AKA Diffuse Color in other nomenclature.
  53262. */
  53263. protected _albedoColor: Color3;
  53264. /**
  53265. * AKA Specular Color in other nomenclature.
  53266. */
  53267. protected _reflectivityColor: Color3;
  53268. /**
  53269. * The color applied when light is reflected from a material.
  53270. */
  53271. protected _reflectionColor: Color3;
  53272. /**
  53273. * The color applied when light is emitted from a material.
  53274. */
  53275. protected _emissiveColor: Color3;
  53276. /**
  53277. * AKA Glossiness in other nomenclature.
  53278. */
  53279. protected _microSurface: number;
  53280. /**
  53281. * Specifies that the material will use the light map as a show map.
  53282. */
  53283. protected _useLightmapAsShadowmap: boolean;
  53284. /**
  53285. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53286. * makes the reflect vector face the model (under horizon).
  53287. */
  53288. protected _useHorizonOcclusion: boolean;
  53289. /**
  53290. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53291. * too much the area relying on ambient texture to define their ambient occlusion.
  53292. */
  53293. protected _useRadianceOcclusion: boolean;
  53294. /**
  53295. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53296. */
  53297. protected _useAlphaFromAlbedoTexture: boolean;
  53298. /**
  53299. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53301. */
  53302. protected _useSpecularOverAlpha: boolean;
  53303. /**
  53304. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53305. */
  53306. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53307. /**
  53308. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53309. */
  53310. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53311. /**
  53312. * Specifies if the metallic texture contains the roughness information in its green channel.
  53313. */
  53314. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53315. /**
  53316. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53317. */
  53318. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53319. /**
  53320. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53321. */
  53322. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53323. /**
  53324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53325. */
  53326. protected _useAmbientInGrayScale: boolean;
  53327. /**
  53328. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53329. * The material will try to infer what glossiness each pixel should be.
  53330. */
  53331. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53332. /**
  53333. * Defines the falloff type used in this material.
  53334. * It by default is Physical.
  53335. */
  53336. protected _lightFalloff: number;
  53337. /**
  53338. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53339. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53340. */
  53341. protected _useRadianceOverAlpha: boolean;
  53342. /**
  53343. * Allows using an object space normal map (instead of tangent space).
  53344. */
  53345. protected _useObjectSpaceNormalMap: boolean;
  53346. /**
  53347. * Allows using the bump map in parallax mode.
  53348. */
  53349. protected _useParallax: boolean;
  53350. /**
  53351. * Allows using the bump map in parallax occlusion mode.
  53352. */
  53353. protected _useParallaxOcclusion: boolean;
  53354. /**
  53355. * Controls the scale bias of the parallax mode.
  53356. */
  53357. protected _parallaxScaleBias: number;
  53358. /**
  53359. * If sets to true, disables all the lights affecting the material.
  53360. */
  53361. protected _disableLighting: boolean;
  53362. /**
  53363. * Number of Simultaneous lights allowed on the material.
  53364. */
  53365. protected _maxSimultaneousLights: number;
  53366. /**
  53367. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53368. */
  53369. protected _invertNormalMapX: boolean;
  53370. /**
  53371. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53372. */
  53373. protected _invertNormalMapY: boolean;
  53374. /**
  53375. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53376. */
  53377. protected _twoSidedLighting: boolean;
  53378. /**
  53379. * Defines the alpha limits in alpha test mode.
  53380. */
  53381. protected _alphaCutOff: number;
  53382. /**
  53383. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53384. */
  53385. protected _forceAlphaTest: 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 is converted to gamma to compute the fresnel)
  53389. */
  53390. protected _useAlphaFresnel: boolean;
  53391. /**
  53392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53393. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53394. */
  53395. protected _useLinearAlphaFresnel: boolean;
  53396. /**
  53397. * The transparency mode of the material.
  53398. */
  53399. protected _transparencyMode: Nullable<number>;
  53400. /**
  53401. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53402. * from cos thetav and roughness:
  53403. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53404. */
  53405. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53406. /**
  53407. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53408. */
  53409. protected _forceIrradianceInFragment: boolean;
  53410. /**
  53411. * Force normal to face away from face.
  53412. */
  53413. protected _forceNormalForward: boolean;
  53414. /**
  53415. * Enables specular anti aliasing in the PBR shader.
  53416. * It will both interacts on the Geometry for analytical and IBL lighting.
  53417. * It also prefilter the roughness map based on the bump values.
  53418. */
  53419. protected _enableSpecularAntiAliasing: boolean;
  53420. /**
  53421. * Default configuration related to image processing available in the PBR Material.
  53422. */
  53423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53424. /**
  53425. * Keep track of the image processing observer to allow dispose and replace.
  53426. */
  53427. private _imageProcessingObserver;
  53428. /**
  53429. * Attaches a new image processing configuration to the PBR Material.
  53430. * @param configuration
  53431. */
  53432. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53433. /**
  53434. * Stores the available render targets.
  53435. */
  53436. private _renderTargets;
  53437. /**
  53438. * Sets the global ambient color for the material used in lighting calculations.
  53439. */
  53440. private _globalAmbientColor;
  53441. /**
  53442. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53443. */
  53444. private _useLogarithmicDepth;
  53445. /**
  53446. * If set to true, no lighting calculations will be applied.
  53447. */
  53448. private _unlit;
  53449. private _debugMode;
  53450. /**
  53451. * @hidden
  53452. * This is reserved for the inspector.
  53453. * Defines the material debug mode.
  53454. * It helps seeing only some components of the material while troubleshooting.
  53455. */
  53456. debugMode: number;
  53457. /**
  53458. * @hidden
  53459. * This is reserved for the inspector.
  53460. * Specify from where on screen the debug mode should start.
  53461. * The value goes from -1 (full screen) to 1 (not visible)
  53462. * It helps with side by side comparison against the final render
  53463. * This defaults to -1
  53464. */
  53465. private debugLimit;
  53466. /**
  53467. * @hidden
  53468. * This is reserved for the inspector.
  53469. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53470. * You can use the factor to better multiply the final value.
  53471. */
  53472. private debugFactor;
  53473. /**
  53474. * Defines the clear coat layer parameters for the material.
  53475. */
  53476. readonly clearCoat: PBRClearCoatConfiguration;
  53477. /**
  53478. * Defines the anisotropic parameters for the material.
  53479. */
  53480. readonly anisotropy: PBRAnisotropicConfiguration;
  53481. /**
  53482. * Defines the BRDF parameters for the material.
  53483. */
  53484. readonly brdf: PBRBRDFConfiguration;
  53485. /**
  53486. * Defines the Sheen parameters for the material.
  53487. */
  53488. readonly sheen: PBRSheenConfiguration;
  53489. /**
  53490. * Defines the SubSurface parameters for the material.
  53491. */
  53492. readonly subSurface: PBRSubSurfaceConfiguration;
  53493. /**
  53494. * Custom callback helping to override the default shader used in the material.
  53495. */
  53496. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53497. protected _rebuildInParallel: boolean;
  53498. /**
  53499. * Instantiates a new PBRMaterial instance.
  53500. *
  53501. * @param name The material name
  53502. * @param scene The scene the material will be use in.
  53503. */
  53504. constructor(name: string, scene: Scene);
  53505. /**
  53506. * Gets a boolean indicating that current material needs to register RTT
  53507. */
  53508. get hasRenderTargetTextures(): boolean;
  53509. /**
  53510. * Gets the name of the material class.
  53511. */
  53512. getClassName(): string;
  53513. /**
  53514. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53515. */
  53516. get useLogarithmicDepth(): boolean;
  53517. /**
  53518. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53519. */
  53520. set useLogarithmicDepth(value: boolean);
  53521. /**
  53522. * Gets the current transparency mode.
  53523. */
  53524. get transparencyMode(): Nullable<number>;
  53525. /**
  53526. * Sets the transparency mode of the material.
  53527. *
  53528. * | Value | Type | Description |
  53529. * | ----- | ----------------------------------- | ----------- |
  53530. * | 0 | OPAQUE | |
  53531. * | 1 | ALPHATEST | |
  53532. * | 2 | ALPHABLEND | |
  53533. * | 3 | ALPHATESTANDBLEND | |
  53534. *
  53535. */
  53536. set transparencyMode(value: Nullable<number>);
  53537. /**
  53538. * Returns true if alpha blending should be disabled.
  53539. */
  53540. private get _disableAlphaBlending();
  53541. /**
  53542. * Specifies whether or not this material should be rendered in alpha blend mode.
  53543. */
  53544. needAlphaBlending(): boolean;
  53545. /**
  53546. * Specifies if the mesh will require alpha blending.
  53547. * @param mesh - BJS mesh.
  53548. */
  53549. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53550. /**
  53551. * Specifies whether or not this material should be rendered in alpha test mode.
  53552. */
  53553. needAlphaTesting(): boolean;
  53554. /**
  53555. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53556. */
  53557. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53558. /**
  53559. * Gets the texture used for the alpha test.
  53560. */
  53561. getAlphaTestTexture(): Nullable<BaseTexture>;
  53562. /**
  53563. * Specifies that the submesh is ready to be used.
  53564. * @param mesh - BJS mesh.
  53565. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53566. * @param useInstances - Specifies that instances should be used.
  53567. * @returns - boolean indicating that the submesh is ready or not.
  53568. */
  53569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53570. /**
  53571. * Specifies if the material uses metallic roughness workflow.
  53572. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53573. */
  53574. isMetallicWorkflow(): boolean;
  53575. private _prepareEffect;
  53576. private _prepareDefines;
  53577. /**
  53578. * Force shader compilation
  53579. */
  53580. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53581. /**
  53582. * Initializes the uniform buffer layout for the shader.
  53583. */
  53584. buildUniformLayout(): void;
  53585. /**
  53586. * Unbinds the material from the mesh
  53587. */
  53588. unbind(): void;
  53589. /**
  53590. * Binds the submesh data.
  53591. * @param world - The world matrix.
  53592. * @param mesh - The BJS mesh.
  53593. * @param subMesh - A submesh of the BJS mesh.
  53594. */
  53595. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53596. /**
  53597. * Returns the animatable textures.
  53598. * @returns - Array of animatable textures.
  53599. */
  53600. getAnimatables(): IAnimatable[];
  53601. /**
  53602. * Returns the texture used for reflections.
  53603. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53604. */
  53605. private _getReflectionTexture;
  53606. /**
  53607. * Returns an array of the actively used textures.
  53608. * @returns - Array of BaseTextures
  53609. */
  53610. getActiveTextures(): BaseTexture[];
  53611. /**
  53612. * Checks to see if a texture is used in the material.
  53613. * @param texture - Base texture to use.
  53614. * @returns - Boolean specifying if a texture is used in the material.
  53615. */
  53616. hasTexture(texture: BaseTexture): boolean;
  53617. /**
  53618. * Disposes the resources of the material.
  53619. * @param forceDisposeEffect - Forces the disposal of effects.
  53620. * @param forceDisposeTextures - Forces the disposal of all textures.
  53621. */
  53622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53623. }
  53624. }
  53625. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53626. import { Nullable } from "babylonjs/types";
  53627. import { Scene } from "babylonjs/scene";
  53628. import { Color3 } from "babylonjs/Maths/math.color";
  53629. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53630. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53632. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53633. /**
  53634. * The Physically based material of BJS.
  53635. *
  53636. * This offers the main features of a standard PBR material.
  53637. * For more information, please refer to the documentation :
  53638. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53639. */
  53640. export class PBRMaterial extends PBRBaseMaterial {
  53641. /**
  53642. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53643. */
  53644. static readonly PBRMATERIAL_OPAQUE: number;
  53645. /**
  53646. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53647. */
  53648. static readonly PBRMATERIAL_ALPHATEST: number;
  53649. /**
  53650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53651. */
  53652. static readonly PBRMATERIAL_ALPHABLEND: number;
  53653. /**
  53654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53655. * They are also discarded below the alpha cutoff threshold to improve performances.
  53656. */
  53657. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53658. /**
  53659. * Defines the default value of how much AO map is occluding the analytical lights
  53660. * (point spot...).
  53661. */
  53662. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53663. /**
  53664. * Intensity of the direct lights e.g. the four lights available in your scene.
  53665. * This impacts both the direct diffuse and specular highlights.
  53666. */
  53667. directIntensity: number;
  53668. /**
  53669. * Intensity of the emissive part of the material.
  53670. * This helps controlling the emissive effect without modifying the emissive color.
  53671. */
  53672. emissiveIntensity: number;
  53673. /**
  53674. * Intensity of the environment e.g. how much the environment will light the object
  53675. * either through harmonics for rough material or through the refelction for shiny ones.
  53676. */
  53677. environmentIntensity: number;
  53678. /**
  53679. * This is a special control allowing the reduction of the specular highlights coming from the
  53680. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53681. */
  53682. specularIntensity: number;
  53683. /**
  53684. * Debug Control allowing disabling the bump map on this material.
  53685. */
  53686. disableBumpMap: boolean;
  53687. /**
  53688. * AKA Diffuse Texture in standard nomenclature.
  53689. */
  53690. albedoTexture: BaseTexture;
  53691. /**
  53692. * AKA Occlusion Texture in other nomenclature.
  53693. */
  53694. ambientTexture: BaseTexture;
  53695. /**
  53696. * AKA Occlusion Texture Intensity in other nomenclature.
  53697. */
  53698. ambientTextureStrength: number;
  53699. /**
  53700. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53701. * 1 means it completely occludes it
  53702. * 0 mean it has no impact
  53703. */
  53704. ambientTextureImpactOnAnalyticalLights: number;
  53705. /**
  53706. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53707. */
  53708. opacityTexture: BaseTexture;
  53709. /**
  53710. * Stores the reflection values in a texture.
  53711. */
  53712. reflectionTexture: Nullable<BaseTexture>;
  53713. /**
  53714. * Stores the emissive values in a texture.
  53715. */
  53716. emissiveTexture: BaseTexture;
  53717. /**
  53718. * AKA Specular texture in other nomenclature.
  53719. */
  53720. reflectivityTexture: BaseTexture;
  53721. /**
  53722. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53723. */
  53724. metallicTexture: BaseTexture;
  53725. /**
  53726. * Specifies the metallic scalar of the metallic/roughness workflow.
  53727. * Can also be used to scale the metalness values of the metallic texture.
  53728. */
  53729. metallic: Nullable<number>;
  53730. /**
  53731. * Specifies the roughness scalar of the metallic/roughness workflow.
  53732. * Can also be used to scale the roughness values of the metallic texture.
  53733. */
  53734. roughness: Nullable<number>;
  53735. /**
  53736. * Specifies the an F0 factor to help configuring the material F0.
  53737. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53738. * to 0.5 the previously hard coded value stays the same.
  53739. * Can also be used to scale the F0 values of the metallic texture.
  53740. */
  53741. metallicF0Factor: number;
  53742. /**
  53743. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53744. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53745. * your expectation as it multiplies with the texture data.
  53746. */
  53747. useMetallicF0FactorFromMetallicTexture: boolean;
  53748. /**
  53749. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53750. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53751. */
  53752. microSurfaceTexture: BaseTexture;
  53753. /**
  53754. * Stores surface normal data used to displace a mesh in a texture.
  53755. */
  53756. bumpTexture: BaseTexture;
  53757. /**
  53758. * Stores the pre-calculated light information of a mesh in a texture.
  53759. */
  53760. lightmapTexture: BaseTexture;
  53761. /**
  53762. * Stores the refracted light information in a texture.
  53763. */
  53764. get refractionTexture(): Nullable<BaseTexture>;
  53765. set refractionTexture(value: Nullable<BaseTexture>);
  53766. /**
  53767. * The color of a material in ambient lighting.
  53768. */
  53769. ambientColor: Color3;
  53770. /**
  53771. * AKA Diffuse Color in other nomenclature.
  53772. */
  53773. albedoColor: Color3;
  53774. /**
  53775. * AKA Specular Color in other nomenclature.
  53776. */
  53777. reflectivityColor: Color3;
  53778. /**
  53779. * The color reflected from the material.
  53780. */
  53781. reflectionColor: Color3;
  53782. /**
  53783. * The color emitted from the material.
  53784. */
  53785. emissiveColor: Color3;
  53786. /**
  53787. * AKA Glossiness in other nomenclature.
  53788. */
  53789. microSurface: number;
  53790. /**
  53791. * source material index of refraction (IOR)' / 'destination material IOR.
  53792. */
  53793. get indexOfRefraction(): number;
  53794. set indexOfRefraction(value: number);
  53795. /**
  53796. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53797. */
  53798. get invertRefractionY(): boolean;
  53799. set invertRefractionY(value: boolean);
  53800. /**
  53801. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53802. * Materials half opaque for instance using refraction could benefit from this control.
  53803. */
  53804. get linkRefractionWithTransparency(): boolean;
  53805. set linkRefractionWithTransparency(value: boolean);
  53806. /**
  53807. * If true, the light map contains occlusion information instead of lighting info.
  53808. */
  53809. useLightmapAsShadowmap: boolean;
  53810. /**
  53811. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53812. */
  53813. useAlphaFromAlbedoTexture: boolean;
  53814. /**
  53815. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53816. */
  53817. forceAlphaTest: boolean;
  53818. /**
  53819. * Defines the alpha limits in alpha test mode.
  53820. */
  53821. alphaCutOff: number;
  53822. /**
  53823. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53824. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53825. */
  53826. useSpecularOverAlpha: boolean;
  53827. /**
  53828. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53829. */
  53830. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53831. /**
  53832. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53833. */
  53834. useRoughnessFromMetallicTextureAlpha: boolean;
  53835. /**
  53836. * Specifies if the metallic texture contains the roughness information in its green channel.
  53837. */
  53838. useRoughnessFromMetallicTextureGreen: boolean;
  53839. /**
  53840. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53841. */
  53842. useMetallnessFromMetallicTextureBlue: boolean;
  53843. /**
  53844. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53845. */
  53846. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53847. /**
  53848. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53849. */
  53850. useAmbientInGrayScale: boolean;
  53851. /**
  53852. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53853. * The material will try to infer what glossiness each pixel should be.
  53854. */
  53855. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53856. /**
  53857. * BJS is using an harcoded light falloff based on a manually sets up range.
  53858. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53859. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53860. */
  53861. get usePhysicalLightFalloff(): boolean;
  53862. /**
  53863. * BJS is using an harcoded light falloff based on a manually sets up range.
  53864. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53865. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53866. */
  53867. set usePhysicalLightFalloff(value: 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. get useGLTFLightFalloff(): boolean;
  53873. /**
  53874. * In order to support the falloff compatibility with gltf, a special mode has been added
  53875. * to reproduce the gltf light falloff.
  53876. */
  53877. set useGLTFLightFalloff(value: boolean);
  53878. /**
  53879. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53880. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53881. */
  53882. useRadianceOverAlpha: boolean;
  53883. /**
  53884. * Allows using an object space normal map (instead of tangent space).
  53885. */
  53886. useObjectSpaceNormalMap: boolean;
  53887. /**
  53888. * Allows using the bump map in parallax mode.
  53889. */
  53890. useParallax: boolean;
  53891. /**
  53892. * Allows using the bump map in parallax occlusion mode.
  53893. */
  53894. useParallaxOcclusion: boolean;
  53895. /**
  53896. * Controls the scale bias of the parallax mode.
  53897. */
  53898. parallaxScaleBias: number;
  53899. /**
  53900. * If sets to true, disables all the lights affecting the material.
  53901. */
  53902. disableLighting: boolean;
  53903. /**
  53904. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53905. */
  53906. forceIrradianceInFragment: boolean;
  53907. /**
  53908. * Number of Simultaneous lights allowed on the material.
  53909. */
  53910. maxSimultaneousLights: number;
  53911. /**
  53912. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53913. */
  53914. invertNormalMapX: boolean;
  53915. /**
  53916. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53917. */
  53918. invertNormalMapY: boolean;
  53919. /**
  53920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53921. */
  53922. twoSidedLighting: 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 is converted to gamma to compute the fresnel)
  53926. */
  53927. useAlphaFresnel: boolean;
  53928. /**
  53929. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53930. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53931. */
  53932. useLinearAlphaFresnel: boolean;
  53933. /**
  53934. * Let user defines the brdf lookup texture used for IBL.
  53935. * A default 8bit version is embedded but you could point at :
  53936. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53937. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53938. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53939. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53940. */
  53941. environmentBRDFTexture: Nullable<BaseTexture>;
  53942. /**
  53943. * Force normal to face away from face.
  53944. */
  53945. forceNormalForward: boolean;
  53946. /**
  53947. * Enables specular anti aliasing in the PBR shader.
  53948. * It will both interacts on the Geometry for analytical and IBL lighting.
  53949. * It also prefilter the roughness map based on the bump values.
  53950. */
  53951. enableSpecularAntiAliasing: boolean;
  53952. /**
  53953. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53954. * makes the reflect vector face the model (under horizon).
  53955. */
  53956. useHorizonOcclusion: boolean;
  53957. /**
  53958. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53959. * too much the area relying on ambient texture to define their ambient occlusion.
  53960. */
  53961. useRadianceOcclusion: boolean;
  53962. /**
  53963. * If set to true, no lighting calculations will be applied.
  53964. */
  53965. unlit: boolean;
  53966. /**
  53967. * Gets the image processing configuration used either in this material.
  53968. */
  53969. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53970. /**
  53971. * Sets the Default image processing configuration used either in the this material.
  53972. *
  53973. * If sets to null, the scene one is in use.
  53974. */
  53975. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53976. /**
  53977. * Gets wether the color curves effect is enabled.
  53978. */
  53979. get cameraColorCurvesEnabled(): boolean;
  53980. /**
  53981. * Sets wether the color curves effect is enabled.
  53982. */
  53983. set cameraColorCurvesEnabled(value: boolean);
  53984. /**
  53985. * Gets wether the color grading effect is enabled.
  53986. */
  53987. get cameraColorGradingEnabled(): boolean;
  53988. /**
  53989. * Gets wether the color grading effect is enabled.
  53990. */
  53991. set cameraColorGradingEnabled(value: boolean);
  53992. /**
  53993. * Gets wether tonemapping is enabled or not.
  53994. */
  53995. get cameraToneMappingEnabled(): boolean;
  53996. /**
  53997. * Sets wether tonemapping is enabled or not
  53998. */
  53999. set cameraToneMappingEnabled(value: boolean);
  54000. /**
  54001. * The camera exposure used on this material.
  54002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54003. * This corresponds to a photographic exposure.
  54004. */
  54005. get cameraExposure(): number;
  54006. /**
  54007. * The camera exposure used on this material.
  54008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54009. * This corresponds to a photographic exposure.
  54010. */
  54011. set cameraExposure(value: number);
  54012. /**
  54013. * Gets The camera contrast used on this material.
  54014. */
  54015. get cameraContrast(): number;
  54016. /**
  54017. * Sets The camera contrast used on this material.
  54018. */
  54019. set cameraContrast(value: number);
  54020. /**
  54021. * Gets the Color Grading 2D Lookup Texture.
  54022. */
  54023. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54024. /**
  54025. * Sets the Color Grading 2D Lookup Texture.
  54026. */
  54027. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54028. /**
  54029. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54030. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54031. * 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;
  54032. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54033. */
  54034. get cameraColorCurves(): Nullable<ColorCurves>;
  54035. /**
  54036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54038. * 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;
  54039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54040. */
  54041. set cameraColorCurves(value: Nullable<ColorCurves>);
  54042. /**
  54043. * Instantiates a new PBRMaterial instance.
  54044. *
  54045. * @param name The material name
  54046. * @param scene The scene the material will be use in.
  54047. */
  54048. constructor(name: string, scene: Scene);
  54049. /**
  54050. * Returns the name of this material class.
  54051. */
  54052. getClassName(): string;
  54053. /**
  54054. * Makes a duplicate of the current material.
  54055. * @param name - name to use for the new material.
  54056. */
  54057. clone(name: string): PBRMaterial;
  54058. /**
  54059. * Serializes this PBR Material.
  54060. * @returns - An object with the serialized material.
  54061. */
  54062. serialize(): any;
  54063. /**
  54064. * Parses a PBR Material from a serialized object.
  54065. * @param source - Serialized object.
  54066. * @param scene - BJS scene instance.
  54067. * @param rootUrl - url for the scene object
  54068. * @returns - PBRMaterial
  54069. */
  54070. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54071. }
  54072. }
  54073. declare module "babylonjs/Misc/dds" {
  54074. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54076. import { Nullable } from "babylonjs/types";
  54077. import { Scene } from "babylonjs/scene";
  54078. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54079. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54080. /**
  54081. * Direct draw surface info
  54082. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54083. */
  54084. export interface DDSInfo {
  54085. /**
  54086. * Width of the texture
  54087. */
  54088. width: number;
  54089. /**
  54090. * Width of the texture
  54091. */
  54092. height: number;
  54093. /**
  54094. * Number of Mipmaps for the texture
  54095. * @see https://en.wikipedia.org/wiki/Mipmap
  54096. */
  54097. mipmapCount: number;
  54098. /**
  54099. * If the textures format is a known fourCC format
  54100. * @see https://www.fourcc.org/
  54101. */
  54102. isFourCC: boolean;
  54103. /**
  54104. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54105. */
  54106. isRGB: boolean;
  54107. /**
  54108. * If the texture is a lumincance format
  54109. */
  54110. isLuminance: boolean;
  54111. /**
  54112. * If this is a cube texture
  54113. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54114. */
  54115. isCube: boolean;
  54116. /**
  54117. * If the texture is a compressed format eg. FOURCC_DXT1
  54118. */
  54119. isCompressed: boolean;
  54120. /**
  54121. * The dxgiFormat of the texture
  54122. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54123. */
  54124. dxgiFormat: number;
  54125. /**
  54126. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54127. */
  54128. textureType: number;
  54129. /**
  54130. * Sphericle polynomial created for the dds texture
  54131. */
  54132. sphericalPolynomial?: SphericalPolynomial;
  54133. }
  54134. /**
  54135. * Class used to provide DDS decompression tools
  54136. */
  54137. export class DDSTools {
  54138. /**
  54139. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54140. */
  54141. static StoreLODInAlphaChannel: boolean;
  54142. /**
  54143. * Gets DDS information from an array buffer
  54144. * @param data defines the array buffer view to read data from
  54145. * @returns the DDS information
  54146. */
  54147. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54148. private static _FloatView;
  54149. private static _Int32View;
  54150. private static _ToHalfFloat;
  54151. private static _FromHalfFloat;
  54152. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54153. private static _GetHalfFloatRGBAArrayBuffer;
  54154. private static _GetFloatRGBAArrayBuffer;
  54155. private static _GetFloatAsUIntRGBAArrayBuffer;
  54156. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54157. private static _GetRGBAArrayBuffer;
  54158. private static _ExtractLongWordOrder;
  54159. private static _GetRGBArrayBuffer;
  54160. private static _GetLuminanceArrayBuffer;
  54161. /**
  54162. * Uploads DDS Levels to a Babylon Texture
  54163. * @hidden
  54164. */
  54165. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54166. }
  54167. module "babylonjs/Engines/thinEngine" {
  54168. interface ThinEngine {
  54169. /**
  54170. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54171. * @param rootUrl defines the url where the file to load is located
  54172. * @param scene defines the current scene
  54173. * @param lodScale defines scale to apply to the mip map selection
  54174. * @param lodOffset defines offset to apply to the mip map selection
  54175. * @param onLoad defines an optional callback raised when the texture is loaded
  54176. * @param onError defines an optional callback raised if there is an issue to load the texture
  54177. * @param format defines the format of the data
  54178. * @param forcedExtension defines the extension to use to pick the right loader
  54179. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54180. * @returns the cube texture as an InternalTexture
  54181. */
  54182. 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;
  54183. }
  54184. }
  54185. }
  54186. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54187. import { Nullable } from "babylonjs/types";
  54188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54189. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54190. /**
  54191. * Implementation of the DDS Texture Loader.
  54192. * @hidden
  54193. */
  54194. export class _DDSTextureLoader implements IInternalTextureLoader {
  54195. /**
  54196. * Defines wether the loader supports cascade loading the different faces.
  54197. */
  54198. readonly supportCascades: boolean;
  54199. /**
  54200. * This returns if the loader support the current file information.
  54201. * @param extension defines the file extension of the file being loaded
  54202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54203. * @param fallback defines the fallback internal texture if any
  54204. * @param isBase64 defines whether the texture is encoded as a base64
  54205. * @param isBuffer defines whether the texture data are stored as a buffer
  54206. * @returns true if the loader can load the specified file
  54207. */
  54208. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54209. /**
  54210. * Transform the url before loading if required.
  54211. * @param rootUrl the url of the texture
  54212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54213. * @returns the transformed texture
  54214. */
  54215. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54216. /**
  54217. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54218. * @param rootUrl the url of the texture
  54219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54220. * @returns the fallback texture
  54221. */
  54222. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54223. /**
  54224. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54225. * @param data contains the texture data
  54226. * @param texture defines the BabylonJS internal texture
  54227. * @param createPolynomials will be true if polynomials have been requested
  54228. * @param onLoad defines the callback to trigger once the texture is ready
  54229. * @param onError defines the callback to trigger in case of error
  54230. */
  54231. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54232. /**
  54233. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54234. * @param data contains the texture data
  54235. * @param texture defines the BabylonJS internal texture
  54236. * @param callback defines the method to call once ready to upload
  54237. */
  54238. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54239. }
  54240. }
  54241. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54242. import { Nullable } from "babylonjs/types";
  54243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54244. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54245. /**
  54246. * Implementation of the ENV Texture Loader.
  54247. * @hidden
  54248. */
  54249. export class _ENVTextureLoader implements IInternalTextureLoader {
  54250. /**
  54251. * Defines wether the loader supports cascade loading the different faces.
  54252. */
  54253. readonly supportCascades: boolean;
  54254. /**
  54255. * This returns if the loader support the current file information.
  54256. * @param extension defines the file extension of the file being loaded
  54257. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54258. * @param fallback defines the fallback internal texture if any
  54259. * @param isBase64 defines whether the texture is encoded as a base64
  54260. * @param isBuffer defines whether the texture data are stored as a buffer
  54261. * @returns true if the loader can load the specified file
  54262. */
  54263. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54264. /**
  54265. * Transform the url before loading if required.
  54266. * @param rootUrl the url of the texture
  54267. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54268. * @returns the transformed texture
  54269. */
  54270. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54271. /**
  54272. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54273. * @param rootUrl the url of the texture
  54274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54275. * @returns the fallback texture
  54276. */
  54277. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54278. /**
  54279. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54280. * @param data contains the texture data
  54281. * @param texture defines the BabylonJS internal texture
  54282. * @param createPolynomials will be true if polynomials have been requested
  54283. * @param onLoad defines the callback to trigger once the texture is ready
  54284. * @param onError defines the callback to trigger in case of error
  54285. */
  54286. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54287. /**
  54288. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54289. * @param data contains the texture data
  54290. * @param texture defines the BabylonJS internal texture
  54291. * @param callback defines the method to call once ready to upload
  54292. */
  54293. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54294. }
  54295. }
  54296. declare module "babylonjs/Misc/khronosTextureContainer" {
  54297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54298. /**
  54299. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54300. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54301. */
  54302. export class KhronosTextureContainer {
  54303. /** contents of the KTX container file */
  54304. data: ArrayBufferView;
  54305. private static HEADER_LEN;
  54306. private static COMPRESSED_2D;
  54307. private static COMPRESSED_3D;
  54308. private static TEX_2D;
  54309. private static TEX_3D;
  54310. /**
  54311. * Gets the openGL type
  54312. */
  54313. glType: number;
  54314. /**
  54315. * Gets the openGL type size
  54316. */
  54317. glTypeSize: number;
  54318. /**
  54319. * Gets the openGL format
  54320. */
  54321. glFormat: number;
  54322. /**
  54323. * Gets the openGL internal format
  54324. */
  54325. glInternalFormat: number;
  54326. /**
  54327. * Gets the base internal format
  54328. */
  54329. glBaseInternalFormat: number;
  54330. /**
  54331. * Gets image width in pixel
  54332. */
  54333. pixelWidth: number;
  54334. /**
  54335. * Gets image height in pixel
  54336. */
  54337. pixelHeight: number;
  54338. /**
  54339. * Gets image depth in pixels
  54340. */
  54341. pixelDepth: number;
  54342. /**
  54343. * Gets the number of array elements
  54344. */
  54345. numberOfArrayElements: number;
  54346. /**
  54347. * Gets the number of faces
  54348. */
  54349. numberOfFaces: number;
  54350. /**
  54351. * Gets the number of mipmap levels
  54352. */
  54353. numberOfMipmapLevels: number;
  54354. /**
  54355. * Gets the bytes of key value data
  54356. */
  54357. bytesOfKeyValueData: number;
  54358. /**
  54359. * Gets the load type
  54360. */
  54361. loadType: number;
  54362. /**
  54363. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54364. */
  54365. isInvalid: boolean;
  54366. /**
  54367. * Creates a new KhronosTextureContainer
  54368. * @param data contents of the KTX container file
  54369. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54370. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54371. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54372. */
  54373. constructor(
  54374. /** contents of the KTX container file */
  54375. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54376. /**
  54377. * Uploads KTX content to a Babylon Texture.
  54378. * It is assumed that the texture has already been created & is currently bound
  54379. * @hidden
  54380. */
  54381. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54382. private _upload2DCompressedLevels;
  54383. }
  54384. }
  54385. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54386. import { Nullable } from "babylonjs/types";
  54387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54388. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54389. /**
  54390. * Implementation of the KTX Texture Loader.
  54391. * @hidden
  54392. */
  54393. export class _KTXTextureLoader implements IInternalTextureLoader {
  54394. /**
  54395. * Defines wether the loader supports cascade loading the different faces.
  54396. */
  54397. readonly supportCascades: boolean;
  54398. /**
  54399. * This returns if the loader support the current file information.
  54400. * @param extension defines the file extension of the file being loaded
  54401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54402. * @param fallback defines the fallback internal texture if any
  54403. * @param isBase64 defines whether the texture is encoded as a base64
  54404. * @param isBuffer defines whether the texture data are stored as a buffer
  54405. * @returns true if the loader can load the specified file
  54406. */
  54407. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54408. /**
  54409. * Transform the url before loading if required.
  54410. * @param rootUrl the url of the texture
  54411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54412. * @returns the transformed texture
  54413. */
  54414. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54415. /**
  54416. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54417. * @param rootUrl the url of the texture
  54418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54419. * @returns the fallback texture
  54420. */
  54421. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54422. /**
  54423. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54424. * @param data contains the texture data
  54425. * @param texture defines the BabylonJS internal texture
  54426. * @param createPolynomials will be true if polynomials have been requested
  54427. * @param onLoad defines the callback to trigger once the texture is ready
  54428. * @param onError defines the callback to trigger in case of error
  54429. */
  54430. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54431. /**
  54432. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54433. * @param data contains the texture data
  54434. * @param texture defines the BabylonJS internal texture
  54435. * @param callback defines the method to call once ready to upload
  54436. */
  54437. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54438. }
  54439. }
  54440. declare module "babylonjs/Helpers/sceneHelpers" {
  54441. import { Nullable } from "babylonjs/types";
  54442. import { Mesh } from "babylonjs/Meshes/mesh";
  54443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54444. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54445. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54446. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54447. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54448. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54449. import "babylonjs/Meshes/Builders/boxBuilder";
  54450. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54451. /** @hidden */
  54452. export var _forceSceneHelpersToBundle: boolean;
  54453. module "babylonjs/scene" {
  54454. interface Scene {
  54455. /**
  54456. * Creates a default light for the scene.
  54457. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54458. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54459. */
  54460. createDefaultLight(replace?: boolean): void;
  54461. /**
  54462. * Creates a default camera for the scene.
  54463. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54464. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54465. * @param replace has default false, when true replaces the active camera in the scene
  54466. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54467. */
  54468. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54469. /**
  54470. * Creates a default camera and a default light.
  54471. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54472. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54473. * @param replace has the default false, when true replaces the active camera/light in the scene
  54474. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54475. */
  54476. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54477. /**
  54478. * Creates a new sky box
  54479. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54480. * @param environmentTexture defines the texture to use as environment texture
  54481. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54482. * @param scale defines the overall scale of the skybox
  54483. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54484. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54485. * @returns a new mesh holding the sky box
  54486. */
  54487. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54488. /**
  54489. * Creates a new environment
  54490. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54491. * @param options defines the options you can use to configure the environment
  54492. * @returns the new EnvironmentHelper
  54493. */
  54494. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54495. /**
  54496. * Creates a new VREXperienceHelper
  54497. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54498. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54499. * @returns a new VREXperienceHelper
  54500. */
  54501. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54502. /**
  54503. * Creates a new WebXRDefaultExperience
  54504. * @see http://doc.babylonjs.com/how_to/webxr
  54505. * @param options experience options
  54506. * @returns a promise for a new WebXRDefaultExperience
  54507. */
  54508. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54509. }
  54510. }
  54511. }
  54512. declare module "babylonjs/Helpers/videoDome" {
  54513. import { Scene } from "babylonjs/scene";
  54514. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54515. import { Mesh } from "babylonjs/Meshes/mesh";
  54516. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54517. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54518. import "babylonjs/Meshes/Builders/sphereBuilder";
  54519. /**
  54520. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54521. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54522. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54523. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54524. */
  54525. export class VideoDome extends TransformNode {
  54526. /**
  54527. * Define the video source as a Monoscopic panoramic 360 video.
  54528. */
  54529. static readonly MODE_MONOSCOPIC: number;
  54530. /**
  54531. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54532. */
  54533. static readonly MODE_TOPBOTTOM: number;
  54534. /**
  54535. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54536. */
  54537. static readonly MODE_SIDEBYSIDE: number;
  54538. private _halfDome;
  54539. private _useDirectMapping;
  54540. /**
  54541. * The video texture being displayed on the sphere
  54542. */
  54543. protected _videoTexture: VideoTexture;
  54544. /**
  54545. * Gets the video texture being displayed on the sphere
  54546. */
  54547. get videoTexture(): VideoTexture;
  54548. /**
  54549. * The skybox material
  54550. */
  54551. protected _material: BackgroundMaterial;
  54552. /**
  54553. * The surface used for the skybox
  54554. */
  54555. protected _mesh: Mesh;
  54556. /**
  54557. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54558. */
  54559. private _halfDomeMask;
  54560. /**
  54561. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54562. * Also see the options.resolution property.
  54563. */
  54564. get fovMultiplier(): number;
  54565. set fovMultiplier(value: number);
  54566. private _videoMode;
  54567. /**
  54568. * Gets or set the current video mode for the video. It can be:
  54569. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54570. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54571. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54572. */
  54573. get videoMode(): number;
  54574. set videoMode(value: number);
  54575. /**
  54576. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54577. *
  54578. */
  54579. get halfDome(): boolean;
  54580. /**
  54581. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54582. */
  54583. set halfDome(enabled: boolean);
  54584. /**
  54585. * Oberserver used in Stereoscopic VR Mode.
  54586. */
  54587. private _onBeforeCameraRenderObserver;
  54588. /**
  54589. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54590. * @param name Element's name, child elements will append suffixes for their own names.
  54591. * @param urlsOrVideo defines the url(s) or the video element to use
  54592. * @param options An object containing optional or exposed sub element properties
  54593. */
  54594. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54595. resolution?: number;
  54596. clickToPlay?: boolean;
  54597. autoPlay?: boolean;
  54598. loop?: boolean;
  54599. size?: number;
  54600. poster?: string;
  54601. faceForward?: boolean;
  54602. useDirectMapping?: boolean;
  54603. halfDomeMode?: boolean;
  54604. }, scene: Scene);
  54605. private _changeVideoMode;
  54606. /**
  54607. * Releases resources associated with this node.
  54608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54610. */
  54611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54612. }
  54613. }
  54614. declare module "babylonjs/Helpers/index" {
  54615. export * from "babylonjs/Helpers/environmentHelper";
  54616. export * from "babylonjs/Helpers/photoDome";
  54617. export * from "babylonjs/Helpers/sceneHelpers";
  54618. export * from "babylonjs/Helpers/videoDome";
  54619. }
  54620. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54621. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54622. import { IDisposable } from "babylonjs/scene";
  54623. import { Engine } from "babylonjs/Engines/engine";
  54624. /**
  54625. * This class can be used to get instrumentation data from a Babylon engine
  54626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54627. */
  54628. export class EngineInstrumentation implements IDisposable {
  54629. /**
  54630. * Define the instrumented engine.
  54631. */
  54632. engine: Engine;
  54633. private _captureGPUFrameTime;
  54634. private _gpuFrameTimeToken;
  54635. private _gpuFrameTime;
  54636. private _captureShaderCompilationTime;
  54637. private _shaderCompilationTime;
  54638. private _onBeginFrameObserver;
  54639. private _onEndFrameObserver;
  54640. private _onBeforeShaderCompilationObserver;
  54641. private _onAfterShaderCompilationObserver;
  54642. /**
  54643. * Gets the perf counter used for GPU frame time
  54644. */
  54645. get gpuFrameTimeCounter(): PerfCounter;
  54646. /**
  54647. * Gets the GPU frame time capture status
  54648. */
  54649. get captureGPUFrameTime(): boolean;
  54650. /**
  54651. * Enable or disable the GPU frame time capture
  54652. */
  54653. set captureGPUFrameTime(value: boolean);
  54654. /**
  54655. * Gets the perf counter used for shader compilation time
  54656. */
  54657. get shaderCompilationTimeCounter(): PerfCounter;
  54658. /**
  54659. * Gets the shader compilation time capture status
  54660. */
  54661. get captureShaderCompilationTime(): boolean;
  54662. /**
  54663. * Enable or disable the shader compilation time capture
  54664. */
  54665. set captureShaderCompilationTime(value: boolean);
  54666. /**
  54667. * Instantiates a new engine instrumentation.
  54668. * This class can be used to get instrumentation data from a Babylon engine
  54669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54670. * @param engine Defines the engine to instrument
  54671. */
  54672. constructor(
  54673. /**
  54674. * Define the instrumented engine.
  54675. */
  54676. engine: Engine);
  54677. /**
  54678. * Dispose and release associated resources.
  54679. */
  54680. dispose(): void;
  54681. }
  54682. }
  54683. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54684. import { Scene, IDisposable } from "babylonjs/scene";
  54685. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54686. /**
  54687. * This class can be used to get instrumentation data from a Babylon engine
  54688. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54689. */
  54690. export class SceneInstrumentation implements IDisposable {
  54691. /**
  54692. * Defines the scene to instrument
  54693. */
  54694. scene: Scene;
  54695. private _captureActiveMeshesEvaluationTime;
  54696. private _activeMeshesEvaluationTime;
  54697. private _captureRenderTargetsRenderTime;
  54698. private _renderTargetsRenderTime;
  54699. private _captureFrameTime;
  54700. private _frameTime;
  54701. private _captureRenderTime;
  54702. private _renderTime;
  54703. private _captureInterFrameTime;
  54704. private _interFrameTime;
  54705. private _captureParticlesRenderTime;
  54706. private _particlesRenderTime;
  54707. private _captureSpritesRenderTime;
  54708. private _spritesRenderTime;
  54709. private _capturePhysicsTime;
  54710. private _physicsTime;
  54711. private _captureAnimationsTime;
  54712. private _animationsTime;
  54713. private _captureCameraRenderTime;
  54714. private _cameraRenderTime;
  54715. private _onBeforeActiveMeshesEvaluationObserver;
  54716. private _onAfterActiveMeshesEvaluationObserver;
  54717. private _onBeforeRenderTargetsRenderObserver;
  54718. private _onAfterRenderTargetsRenderObserver;
  54719. private _onAfterRenderObserver;
  54720. private _onBeforeDrawPhaseObserver;
  54721. private _onAfterDrawPhaseObserver;
  54722. private _onBeforeAnimationsObserver;
  54723. private _onBeforeParticlesRenderingObserver;
  54724. private _onAfterParticlesRenderingObserver;
  54725. private _onBeforeSpritesRenderingObserver;
  54726. private _onAfterSpritesRenderingObserver;
  54727. private _onBeforePhysicsObserver;
  54728. private _onAfterPhysicsObserver;
  54729. private _onAfterAnimationsObserver;
  54730. private _onBeforeCameraRenderObserver;
  54731. private _onAfterCameraRenderObserver;
  54732. /**
  54733. * Gets the perf counter used for active meshes evaluation time
  54734. */
  54735. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54736. /**
  54737. * Gets the active meshes evaluation time capture status
  54738. */
  54739. get captureActiveMeshesEvaluationTime(): boolean;
  54740. /**
  54741. * Enable or disable the active meshes evaluation time capture
  54742. */
  54743. set captureActiveMeshesEvaluationTime(value: boolean);
  54744. /**
  54745. * Gets the perf counter used for render targets render time
  54746. */
  54747. get renderTargetsRenderTimeCounter(): PerfCounter;
  54748. /**
  54749. * Gets the render targets render time capture status
  54750. */
  54751. get captureRenderTargetsRenderTime(): boolean;
  54752. /**
  54753. * Enable or disable the render targets render time capture
  54754. */
  54755. set captureRenderTargetsRenderTime(value: boolean);
  54756. /**
  54757. * Gets the perf counter used for particles render time
  54758. */
  54759. get particlesRenderTimeCounter(): PerfCounter;
  54760. /**
  54761. * Gets the particles render time capture status
  54762. */
  54763. get captureParticlesRenderTime(): boolean;
  54764. /**
  54765. * Enable or disable the particles render time capture
  54766. */
  54767. set captureParticlesRenderTime(value: boolean);
  54768. /**
  54769. * Gets the perf counter used for sprites render time
  54770. */
  54771. get spritesRenderTimeCounter(): PerfCounter;
  54772. /**
  54773. * Gets the sprites render time capture status
  54774. */
  54775. get captureSpritesRenderTime(): boolean;
  54776. /**
  54777. * Enable or disable the sprites render time capture
  54778. */
  54779. set captureSpritesRenderTime(value: boolean);
  54780. /**
  54781. * Gets the perf counter used for physics time
  54782. */
  54783. get physicsTimeCounter(): PerfCounter;
  54784. /**
  54785. * Gets the physics time capture status
  54786. */
  54787. get capturePhysicsTime(): boolean;
  54788. /**
  54789. * Enable or disable the physics time capture
  54790. */
  54791. set capturePhysicsTime(value: boolean);
  54792. /**
  54793. * Gets the perf counter used for animations time
  54794. */
  54795. get animationsTimeCounter(): PerfCounter;
  54796. /**
  54797. * Gets the animations time capture status
  54798. */
  54799. get captureAnimationsTime(): boolean;
  54800. /**
  54801. * Enable or disable the animations time capture
  54802. */
  54803. set captureAnimationsTime(value: boolean);
  54804. /**
  54805. * Gets the perf counter used for frame time capture
  54806. */
  54807. get frameTimeCounter(): PerfCounter;
  54808. /**
  54809. * Gets the frame time capture status
  54810. */
  54811. get captureFrameTime(): boolean;
  54812. /**
  54813. * Enable or disable the frame time capture
  54814. */
  54815. set captureFrameTime(value: boolean);
  54816. /**
  54817. * Gets the perf counter used for inter-frames time capture
  54818. */
  54819. get interFrameTimeCounter(): PerfCounter;
  54820. /**
  54821. * Gets the inter-frames time capture status
  54822. */
  54823. get captureInterFrameTime(): boolean;
  54824. /**
  54825. * Enable or disable the inter-frames time capture
  54826. */
  54827. set captureInterFrameTime(value: boolean);
  54828. /**
  54829. * Gets the perf counter used for render time capture
  54830. */
  54831. get renderTimeCounter(): PerfCounter;
  54832. /**
  54833. * Gets the render time capture status
  54834. */
  54835. get captureRenderTime(): boolean;
  54836. /**
  54837. * Enable or disable the render time capture
  54838. */
  54839. set captureRenderTime(value: boolean);
  54840. /**
  54841. * Gets the perf counter used for camera render time capture
  54842. */
  54843. get cameraRenderTimeCounter(): PerfCounter;
  54844. /**
  54845. * Gets the camera render time capture status
  54846. */
  54847. get captureCameraRenderTime(): boolean;
  54848. /**
  54849. * Enable or disable the camera render time capture
  54850. */
  54851. set captureCameraRenderTime(value: boolean);
  54852. /**
  54853. * Gets the perf counter used for draw calls
  54854. */
  54855. get drawCallsCounter(): PerfCounter;
  54856. /**
  54857. * Instantiates a new scene instrumentation.
  54858. * This class can be used to get instrumentation data from a Babylon engine
  54859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54860. * @param scene Defines the scene to instrument
  54861. */
  54862. constructor(
  54863. /**
  54864. * Defines the scene to instrument
  54865. */
  54866. scene: Scene);
  54867. /**
  54868. * Dispose and release associated resources.
  54869. */
  54870. dispose(): void;
  54871. }
  54872. }
  54873. declare module "babylonjs/Instrumentation/index" {
  54874. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54875. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54876. export * from "babylonjs/Instrumentation/timeToken";
  54877. }
  54878. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54879. /** @hidden */
  54880. export var glowMapGenerationPixelShader: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54886. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54887. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54889. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54891. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54892. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54893. /** @hidden */
  54894. export var glowMapGenerationVertexShader: {
  54895. name: string;
  54896. shader: string;
  54897. };
  54898. }
  54899. declare module "babylonjs/Layers/effectLayer" {
  54900. import { Observable } from "babylonjs/Misc/observable";
  54901. import { Nullable } from "babylonjs/types";
  54902. import { Camera } from "babylonjs/Cameras/camera";
  54903. import { Scene } from "babylonjs/scene";
  54904. import { ISize } from "babylonjs/Maths/math.size";
  54905. import { Color4 } from "babylonjs/Maths/math.color";
  54906. import { Engine } from "babylonjs/Engines/engine";
  54907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54909. import { Mesh } from "babylonjs/Meshes/mesh";
  54910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54912. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54913. import { Effect } from "babylonjs/Materials/effect";
  54914. import { Material } from "babylonjs/Materials/material";
  54915. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54916. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54917. /**
  54918. * Effect layer options. This helps customizing the behaviour
  54919. * of the effect layer.
  54920. */
  54921. export interface IEffectLayerOptions {
  54922. /**
  54923. * Multiplication factor apply to the canvas size to compute the render target size
  54924. * used to generated the objects (the smaller the faster).
  54925. */
  54926. mainTextureRatio: number;
  54927. /**
  54928. * Enforces a fixed size texture to ensure effect stability across devices.
  54929. */
  54930. mainTextureFixedSize?: number;
  54931. /**
  54932. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54933. */
  54934. alphaBlendingMode: number;
  54935. /**
  54936. * The camera attached to the layer.
  54937. */
  54938. camera: Nullable<Camera>;
  54939. /**
  54940. * The rendering group to draw the layer in.
  54941. */
  54942. renderingGroupId: number;
  54943. }
  54944. /**
  54945. * The effect layer Helps adding post process effect blended with the main pass.
  54946. *
  54947. * This can be for instance use to generate glow or higlight effects on the scene.
  54948. *
  54949. * The effect layer class can not be used directly and is intented to inherited from to be
  54950. * customized per effects.
  54951. */
  54952. export abstract class EffectLayer {
  54953. private _vertexBuffers;
  54954. private _indexBuffer;
  54955. private _cachedDefines;
  54956. private _effectLayerMapGenerationEffect;
  54957. private _effectLayerOptions;
  54958. private _mergeEffect;
  54959. protected _scene: Scene;
  54960. protected _engine: Engine;
  54961. protected _maxSize: number;
  54962. protected _mainTextureDesiredSize: ISize;
  54963. protected _mainTexture: RenderTargetTexture;
  54964. protected _shouldRender: boolean;
  54965. protected _postProcesses: PostProcess[];
  54966. protected _textures: BaseTexture[];
  54967. protected _emissiveTextureAndColor: {
  54968. texture: Nullable<BaseTexture>;
  54969. color: Color4;
  54970. };
  54971. /**
  54972. * The name of the layer
  54973. */
  54974. name: string;
  54975. /**
  54976. * The clear color of the texture used to generate the glow map.
  54977. */
  54978. neutralColor: Color4;
  54979. /**
  54980. * Specifies whether the highlight layer is enabled or not.
  54981. */
  54982. isEnabled: boolean;
  54983. /**
  54984. * Gets the camera attached to the layer.
  54985. */
  54986. get camera(): Nullable<Camera>;
  54987. /**
  54988. * Gets the rendering group id the layer should render in.
  54989. */
  54990. get renderingGroupId(): number;
  54991. set renderingGroupId(renderingGroupId: number);
  54992. /**
  54993. * An event triggered when the effect layer has been disposed.
  54994. */
  54995. onDisposeObservable: Observable<EffectLayer>;
  54996. /**
  54997. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54998. */
  54999. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55000. /**
  55001. * An event triggered when the generated texture is being merged in the scene.
  55002. */
  55003. onBeforeComposeObservable: Observable<EffectLayer>;
  55004. /**
  55005. * An event triggered when the mesh is rendered into the effect render target.
  55006. */
  55007. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55008. /**
  55009. * An event triggered after the mesh has been rendered into the effect render target.
  55010. */
  55011. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55012. /**
  55013. * An event triggered when the generated texture has been merged in the scene.
  55014. */
  55015. onAfterComposeObservable: Observable<EffectLayer>;
  55016. /**
  55017. * An event triggered when the efffect layer changes its size.
  55018. */
  55019. onSizeChangedObservable: Observable<EffectLayer>;
  55020. /** @hidden */
  55021. static _SceneComponentInitialization: (scene: Scene) => void;
  55022. /**
  55023. * Instantiates a new effect Layer and references it in the scene.
  55024. * @param name The name of the layer
  55025. * @param scene The scene to use the layer in
  55026. */
  55027. constructor(
  55028. /** The Friendly of the effect in the scene */
  55029. name: string, scene: Scene);
  55030. /**
  55031. * Get the effect name of the layer.
  55032. * @return The effect name
  55033. */
  55034. abstract getEffectName(): string;
  55035. /**
  55036. * Checks for the readiness of the element composing the layer.
  55037. * @param subMesh the mesh to check for
  55038. * @param useInstances specify whether or not to use instances to render the mesh
  55039. * @return true if ready otherwise, false
  55040. */
  55041. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55042. /**
  55043. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55044. * @returns true if the effect requires stencil during the main canvas render pass.
  55045. */
  55046. abstract needStencil(): boolean;
  55047. /**
  55048. * Create the merge effect. This is the shader use to blit the information back
  55049. * to the main canvas at the end of the scene rendering.
  55050. * @returns The effect containing the shader used to merge the effect on the main canvas
  55051. */
  55052. protected abstract _createMergeEffect(): Effect;
  55053. /**
  55054. * Creates the render target textures and post processes used in the effect layer.
  55055. */
  55056. protected abstract _createTextureAndPostProcesses(): void;
  55057. /**
  55058. * Implementation specific of rendering the generating effect on the main canvas.
  55059. * @param effect The effect used to render through
  55060. */
  55061. protected abstract _internalRender(effect: Effect): void;
  55062. /**
  55063. * Sets the required values for both the emissive texture and and the main color.
  55064. */
  55065. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55066. /**
  55067. * Free any resources and references associated to a mesh.
  55068. * Internal use
  55069. * @param mesh The mesh to free.
  55070. */
  55071. abstract _disposeMesh(mesh: Mesh): void;
  55072. /**
  55073. * Serializes this layer (Glow or Highlight for example)
  55074. * @returns a serialized layer object
  55075. */
  55076. abstract serialize?(): any;
  55077. /**
  55078. * Initializes the effect layer with the required options.
  55079. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55080. */
  55081. protected _init(options: Partial<IEffectLayerOptions>): void;
  55082. /**
  55083. * Generates the index buffer of the full screen quad blending to the main canvas.
  55084. */
  55085. private _generateIndexBuffer;
  55086. /**
  55087. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55088. */
  55089. private _generateVertexBuffer;
  55090. /**
  55091. * Sets the main texture desired size which is the closest power of two
  55092. * of the engine canvas size.
  55093. */
  55094. private _setMainTextureSize;
  55095. /**
  55096. * Creates the main texture for the effect layer.
  55097. */
  55098. protected _createMainTexture(): void;
  55099. /**
  55100. * Adds specific effects defines.
  55101. * @param defines The defines to add specifics to.
  55102. */
  55103. protected _addCustomEffectDefines(defines: string[]): void;
  55104. /**
  55105. * Checks for the readiness of the element composing the layer.
  55106. * @param subMesh the mesh to check for
  55107. * @param useInstances specify whether or not to use instances to render the mesh
  55108. * @param emissiveTexture the associated emissive texture used to generate the glow
  55109. * @return true if ready otherwise, false
  55110. */
  55111. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55112. /**
  55113. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55114. */
  55115. render(): void;
  55116. /**
  55117. * Determine if a given mesh will be used in the current effect.
  55118. * @param mesh mesh to test
  55119. * @returns true if the mesh will be used
  55120. */
  55121. hasMesh(mesh: AbstractMesh): boolean;
  55122. /**
  55123. * Returns true if the layer contains information to display, otherwise false.
  55124. * @returns true if the glow layer should be rendered
  55125. */
  55126. shouldRender(): boolean;
  55127. /**
  55128. * Returns true if the mesh should render, otherwise false.
  55129. * @param mesh The mesh to render
  55130. * @returns true if it should render otherwise false
  55131. */
  55132. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55133. /**
  55134. * Returns true if the mesh can be rendered, otherwise false.
  55135. * @param mesh The mesh to render
  55136. * @param material The material used on the mesh
  55137. * @returns true if it can be rendered otherwise false
  55138. */
  55139. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55140. /**
  55141. * Returns true if the mesh should render, otherwise false.
  55142. * @param mesh The mesh to render
  55143. * @returns true if it should render otherwise false
  55144. */
  55145. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55146. /**
  55147. * Renders the submesh passed in parameter to the generation map.
  55148. */
  55149. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55150. /**
  55151. * Defines whether the current material of the mesh should be use to render the effect.
  55152. * @param mesh defines the current mesh to render
  55153. */
  55154. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55155. /**
  55156. * Rebuild the required buffers.
  55157. * @hidden Internal use only.
  55158. */
  55159. _rebuild(): void;
  55160. /**
  55161. * Dispose only the render target textures and post process.
  55162. */
  55163. private _disposeTextureAndPostProcesses;
  55164. /**
  55165. * Dispose the highlight layer and free resources.
  55166. */
  55167. dispose(): void;
  55168. /**
  55169. * Gets the class name of the effect layer
  55170. * @returns the string with the class name of the effect layer
  55171. */
  55172. getClassName(): string;
  55173. /**
  55174. * Creates an effect layer from parsed effect layer data
  55175. * @param parsedEffectLayer defines effect layer data
  55176. * @param scene defines the current scene
  55177. * @param rootUrl defines the root URL containing the effect layer information
  55178. * @returns a parsed effect Layer
  55179. */
  55180. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55181. }
  55182. }
  55183. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55184. import { Scene } from "babylonjs/scene";
  55185. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55186. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55187. import { AbstractScene } from "babylonjs/abstractScene";
  55188. module "babylonjs/abstractScene" {
  55189. interface AbstractScene {
  55190. /**
  55191. * The list of effect layers (highlights/glow) added to the scene
  55192. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55193. * @see http://doc.babylonjs.com/how_to/glow_layer
  55194. */
  55195. effectLayers: Array<EffectLayer>;
  55196. /**
  55197. * Removes the given effect layer from this scene.
  55198. * @param toRemove defines the effect layer to remove
  55199. * @returns the index of the removed effect layer
  55200. */
  55201. removeEffectLayer(toRemove: EffectLayer): number;
  55202. /**
  55203. * Adds the given effect layer to this scene
  55204. * @param newEffectLayer defines the effect layer to add
  55205. */
  55206. addEffectLayer(newEffectLayer: EffectLayer): void;
  55207. }
  55208. }
  55209. /**
  55210. * Defines the layer scene component responsible to manage any effect layers
  55211. * in a given scene.
  55212. */
  55213. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55214. /**
  55215. * The component name helpfull to identify the component in the list of scene components.
  55216. */
  55217. readonly name: string;
  55218. /**
  55219. * The scene the component belongs to.
  55220. */
  55221. scene: Scene;
  55222. private _engine;
  55223. private _renderEffects;
  55224. private _needStencil;
  55225. private _previousStencilState;
  55226. /**
  55227. * Creates a new instance of the component for the given scene
  55228. * @param scene Defines the scene to register the component in
  55229. */
  55230. constructor(scene: Scene);
  55231. /**
  55232. * Registers the component in a given scene
  55233. */
  55234. register(): void;
  55235. /**
  55236. * Rebuilds the elements related to this component in case of
  55237. * context lost for instance.
  55238. */
  55239. rebuild(): void;
  55240. /**
  55241. * Serializes the component data to the specified json object
  55242. * @param serializationObject The object to serialize to
  55243. */
  55244. serialize(serializationObject: any): void;
  55245. /**
  55246. * Adds all the elements from the container to the scene
  55247. * @param container the container holding the elements
  55248. */
  55249. addFromContainer(container: AbstractScene): void;
  55250. /**
  55251. * Removes all the elements in the container from the scene
  55252. * @param container contains the elements to remove
  55253. * @param dispose if the removed element should be disposed (default: false)
  55254. */
  55255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55256. /**
  55257. * Disposes the component and the associated ressources.
  55258. */
  55259. dispose(): void;
  55260. private _isReadyForMesh;
  55261. private _renderMainTexture;
  55262. private _setStencil;
  55263. private _setStencilBack;
  55264. private _draw;
  55265. private _drawCamera;
  55266. private _drawRenderingGroup;
  55267. }
  55268. }
  55269. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55270. /** @hidden */
  55271. export var glowMapMergePixelShader: {
  55272. name: string;
  55273. shader: string;
  55274. };
  55275. }
  55276. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55277. /** @hidden */
  55278. export var glowMapMergeVertexShader: {
  55279. name: string;
  55280. shader: string;
  55281. };
  55282. }
  55283. declare module "babylonjs/Layers/glowLayer" {
  55284. import { Nullable } from "babylonjs/types";
  55285. import { Camera } from "babylonjs/Cameras/camera";
  55286. import { Scene } from "babylonjs/scene";
  55287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55289. import { Mesh } from "babylonjs/Meshes/mesh";
  55290. import { Texture } from "babylonjs/Materials/Textures/texture";
  55291. import { Effect } from "babylonjs/Materials/effect";
  55292. import { Material } from "babylonjs/Materials/material";
  55293. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55294. import { Color4 } from "babylonjs/Maths/math.color";
  55295. import "babylonjs/Shaders/glowMapMerge.fragment";
  55296. import "babylonjs/Shaders/glowMapMerge.vertex";
  55297. import "babylonjs/Layers/effectLayerSceneComponent";
  55298. module "babylonjs/abstractScene" {
  55299. interface AbstractScene {
  55300. /**
  55301. * Return a the first highlight layer of the scene with a given name.
  55302. * @param name The name of the highlight layer to look for.
  55303. * @return The highlight layer if found otherwise null.
  55304. */
  55305. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55306. }
  55307. }
  55308. /**
  55309. * Glow layer options. This helps customizing the behaviour
  55310. * of the glow layer.
  55311. */
  55312. export interface IGlowLayerOptions {
  55313. /**
  55314. * Multiplication factor apply to the canvas size to compute the render target size
  55315. * used to generated the glowing objects (the smaller the faster).
  55316. */
  55317. mainTextureRatio: number;
  55318. /**
  55319. * Enforces a fixed size texture to ensure resize independant blur.
  55320. */
  55321. mainTextureFixedSize?: number;
  55322. /**
  55323. * How big is the kernel of the blur texture.
  55324. */
  55325. blurKernelSize: number;
  55326. /**
  55327. * The camera attached to the layer.
  55328. */
  55329. camera: Nullable<Camera>;
  55330. /**
  55331. * Enable MSAA by chosing the number of samples.
  55332. */
  55333. mainTextureSamples?: number;
  55334. /**
  55335. * The rendering group to draw the layer in.
  55336. */
  55337. renderingGroupId: number;
  55338. }
  55339. /**
  55340. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55341. *
  55342. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55343. *
  55344. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55345. */
  55346. export class GlowLayer extends EffectLayer {
  55347. /**
  55348. * Effect Name of the layer.
  55349. */
  55350. static readonly EffectName: string;
  55351. /**
  55352. * The default blur kernel size used for the glow.
  55353. */
  55354. static DefaultBlurKernelSize: number;
  55355. /**
  55356. * The default texture size ratio used for the glow.
  55357. */
  55358. static DefaultTextureRatio: number;
  55359. /**
  55360. * Sets the kernel size of the blur.
  55361. */
  55362. set blurKernelSize(value: number);
  55363. /**
  55364. * Gets the kernel size of the blur.
  55365. */
  55366. get blurKernelSize(): number;
  55367. /**
  55368. * Sets the glow intensity.
  55369. */
  55370. set intensity(value: number);
  55371. /**
  55372. * Gets the glow intensity.
  55373. */
  55374. get intensity(): number;
  55375. private _options;
  55376. private _intensity;
  55377. private _horizontalBlurPostprocess1;
  55378. private _verticalBlurPostprocess1;
  55379. private _horizontalBlurPostprocess2;
  55380. private _verticalBlurPostprocess2;
  55381. private _blurTexture1;
  55382. private _blurTexture2;
  55383. private _postProcesses1;
  55384. private _postProcesses2;
  55385. private _includedOnlyMeshes;
  55386. private _excludedMeshes;
  55387. private _meshesUsingTheirOwnMaterials;
  55388. /**
  55389. * Callback used to let the user override the color selection on a per mesh basis
  55390. */
  55391. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55392. /**
  55393. * Callback used to let the user override the texture selection on a per mesh basis
  55394. */
  55395. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55396. /**
  55397. * Instantiates a new glow Layer and references it to the scene.
  55398. * @param name The name of the layer
  55399. * @param scene The scene to use the layer in
  55400. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55401. */
  55402. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55403. /**
  55404. * Get the effect name of the layer.
  55405. * @return The effect name
  55406. */
  55407. getEffectName(): string;
  55408. /**
  55409. * Create the merge effect. This is the shader use to blit the information back
  55410. * to the main canvas at the end of the scene rendering.
  55411. */
  55412. protected _createMergeEffect(): Effect;
  55413. /**
  55414. * Creates the render target textures and post processes used in the glow layer.
  55415. */
  55416. protected _createTextureAndPostProcesses(): void;
  55417. /**
  55418. * Checks for the readiness of the element composing the layer.
  55419. * @param subMesh the mesh to check for
  55420. * @param useInstances specify wether or not to use instances to render the mesh
  55421. * @param emissiveTexture the associated emissive texture used to generate the glow
  55422. * @return true if ready otherwise, false
  55423. */
  55424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55425. /**
  55426. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55427. */
  55428. needStencil(): boolean;
  55429. /**
  55430. * Returns true if the mesh can be rendered, otherwise false.
  55431. * @param mesh The mesh to render
  55432. * @param material The material used on the mesh
  55433. * @returns true if it can be rendered otherwise false
  55434. */
  55435. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55436. /**
  55437. * Implementation specific of rendering the generating effect on the main canvas.
  55438. * @param effect The effect used to render through
  55439. */
  55440. protected _internalRender(effect: Effect): void;
  55441. /**
  55442. * Sets the required values for both the emissive texture and and the main color.
  55443. */
  55444. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55445. /**
  55446. * Returns true if the mesh should render, otherwise false.
  55447. * @param mesh The mesh to render
  55448. * @returns true if it should render otherwise false
  55449. */
  55450. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55451. /**
  55452. * Adds specific effects defines.
  55453. * @param defines The defines to add specifics to.
  55454. */
  55455. protected _addCustomEffectDefines(defines: string[]): void;
  55456. /**
  55457. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55458. * @param mesh The mesh to exclude from the glow layer
  55459. */
  55460. addExcludedMesh(mesh: Mesh): void;
  55461. /**
  55462. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55463. * @param mesh The mesh to remove
  55464. */
  55465. removeExcludedMesh(mesh: Mesh): void;
  55466. /**
  55467. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55468. * @param mesh The mesh to include in the glow layer
  55469. */
  55470. addIncludedOnlyMesh(mesh: Mesh): void;
  55471. /**
  55472. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55473. * @param mesh The mesh to remove
  55474. */
  55475. removeIncludedOnlyMesh(mesh: Mesh): void;
  55476. /**
  55477. * Determine if a given mesh will be used in the glow layer
  55478. * @param mesh The mesh to test
  55479. * @returns true if the mesh will be highlighted by the current glow layer
  55480. */
  55481. hasMesh(mesh: AbstractMesh): boolean;
  55482. /**
  55483. * Defines whether the current material of the mesh should be use to render the effect.
  55484. * @param mesh defines the current mesh to render
  55485. */
  55486. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55487. /**
  55488. * Add a mesh to be rendered through its own material and not with emissive only.
  55489. * @param mesh The mesh for which we need to use its material
  55490. */
  55491. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55492. /**
  55493. * Remove a mesh from being rendered through its own material and not with emissive only.
  55494. * @param mesh The mesh for which we need to not use its material
  55495. */
  55496. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55497. /**
  55498. * Free any resources and references associated to a mesh.
  55499. * Internal use
  55500. * @param mesh The mesh to free.
  55501. * @hidden
  55502. */
  55503. _disposeMesh(mesh: Mesh): void;
  55504. /**
  55505. * Gets the class name of the effect layer
  55506. * @returns the string with the class name of the effect layer
  55507. */
  55508. getClassName(): string;
  55509. /**
  55510. * Serializes this glow layer
  55511. * @returns a serialized glow layer object
  55512. */
  55513. serialize(): any;
  55514. /**
  55515. * Creates a Glow Layer from parsed glow layer data
  55516. * @param parsedGlowLayer defines glow layer data
  55517. * @param scene defines the current scene
  55518. * @param rootUrl defines the root URL containing the glow layer information
  55519. * @returns a parsed Glow Layer
  55520. */
  55521. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55522. }
  55523. }
  55524. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55525. /** @hidden */
  55526. export var glowBlurPostProcessPixelShader: {
  55527. name: string;
  55528. shader: string;
  55529. };
  55530. }
  55531. declare module "babylonjs/Layers/highlightLayer" {
  55532. import { Observable } from "babylonjs/Misc/observable";
  55533. import { Nullable } from "babylonjs/types";
  55534. import { Camera } from "babylonjs/Cameras/camera";
  55535. import { Scene } from "babylonjs/scene";
  55536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55538. import { Mesh } from "babylonjs/Meshes/mesh";
  55539. import { Effect } from "babylonjs/Materials/effect";
  55540. import { Material } from "babylonjs/Materials/material";
  55541. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55542. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55543. import "babylonjs/Shaders/glowMapMerge.fragment";
  55544. import "babylonjs/Shaders/glowMapMerge.vertex";
  55545. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55546. module "babylonjs/abstractScene" {
  55547. interface AbstractScene {
  55548. /**
  55549. * Return a the first highlight layer of the scene with a given name.
  55550. * @param name The name of the highlight layer to look for.
  55551. * @return The highlight layer if found otherwise null.
  55552. */
  55553. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55554. }
  55555. }
  55556. /**
  55557. * Highlight layer options. This helps customizing the behaviour
  55558. * of the highlight layer.
  55559. */
  55560. export interface IHighlightLayerOptions {
  55561. /**
  55562. * Multiplication factor apply to the canvas size to compute the render target size
  55563. * used to generated the glowing objects (the smaller the faster).
  55564. */
  55565. mainTextureRatio: number;
  55566. /**
  55567. * Enforces a fixed size texture to ensure resize independant blur.
  55568. */
  55569. mainTextureFixedSize?: number;
  55570. /**
  55571. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55572. * of the picture to blur (the smaller the faster).
  55573. */
  55574. blurTextureSizeRatio: number;
  55575. /**
  55576. * How big in texel of the blur texture is the vertical blur.
  55577. */
  55578. blurVerticalSize: number;
  55579. /**
  55580. * How big in texel of the blur texture is the horizontal blur.
  55581. */
  55582. blurHorizontalSize: number;
  55583. /**
  55584. * Alpha blending mode used to apply the blur. Default is combine.
  55585. */
  55586. alphaBlendingMode: number;
  55587. /**
  55588. * The camera attached to the layer.
  55589. */
  55590. camera: Nullable<Camera>;
  55591. /**
  55592. * Should we display highlight as a solid stroke?
  55593. */
  55594. isStroke?: boolean;
  55595. /**
  55596. * The rendering group to draw the layer in.
  55597. */
  55598. renderingGroupId: number;
  55599. }
  55600. /**
  55601. * The highlight layer Helps adding a glow effect around a mesh.
  55602. *
  55603. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55604. * glowy meshes to your scene.
  55605. *
  55606. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55607. */
  55608. export class HighlightLayer extends EffectLayer {
  55609. name: string;
  55610. /**
  55611. * Effect Name of the highlight layer.
  55612. */
  55613. static readonly EffectName: string;
  55614. /**
  55615. * The neutral color used during the preparation of the glow effect.
  55616. * This is black by default as the blend operation is a blend operation.
  55617. */
  55618. static NeutralColor: Color4;
  55619. /**
  55620. * Stencil value used for glowing meshes.
  55621. */
  55622. static GlowingMeshStencilReference: number;
  55623. /**
  55624. * Stencil value used for the other meshes in the scene.
  55625. */
  55626. static NormalMeshStencilReference: number;
  55627. /**
  55628. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55629. */
  55630. innerGlow: boolean;
  55631. /**
  55632. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55633. */
  55634. outerGlow: boolean;
  55635. /**
  55636. * Specifies the horizontal size of the blur.
  55637. */
  55638. set blurHorizontalSize(value: number);
  55639. /**
  55640. * Specifies the vertical size of the blur.
  55641. */
  55642. set blurVerticalSize(value: number);
  55643. /**
  55644. * Gets the horizontal size of the blur.
  55645. */
  55646. get blurHorizontalSize(): number;
  55647. /**
  55648. * Gets the vertical size of the blur.
  55649. */
  55650. get blurVerticalSize(): number;
  55651. /**
  55652. * An event triggered when the highlight layer is being blurred.
  55653. */
  55654. onBeforeBlurObservable: Observable<HighlightLayer>;
  55655. /**
  55656. * An event triggered when the highlight layer has been blurred.
  55657. */
  55658. onAfterBlurObservable: Observable<HighlightLayer>;
  55659. private _instanceGlowingMeshStencilReference;
  55660. private _options;
  55661. private _downSamplePostprocess;
  55662. private _horizontalBlurPostprocess;
  55663. private _verticalBlurPostprocess;
  55664. private _blurTexture;
  55665. private _meshes;
  55666. private _excludedMeshes;
  55667. /**
  55668. * Instantiates a new highlight Layer and references it to the scene..
  55669. * @param name The name of the layer
  55670. * @param scene The scene to use the layer in
  55671. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55672. */
  55673. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55674. /**
  55675. * Get the effect name of the layer.
  55676. * @return The effect name
  55677. */
  55678. getEffectName(): string;
  55679. /**
  55680. * Create the merge effect. This is the shader use to blit the information back
  55681. * to the main canvas at the end of the scene rendering.
  55682. */
  55683. protected _createMergeEffect(): Effect;
  55684. /**
  55685. * Creates the render target textures and post processes used in the highlight layer.
  55686. */
  55687. protected _createTextureAndPostProcesses(): void;
  55688. /**
  55689. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55690. */
  55691. needStencil(): boolean;
  55692. /**
  55693. * Checks for the readiness of the element composing the layer.
  55694. * @param subMesh the mesh to check for
  55695. * @param useInstances specify wether or not to use instances to render the mesh
  55696. * @param emissiveTexture the associated emissive texture used to generate the glow
  55697. * @return true if ready otherwise, false
  55698. */
  55699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55700. /**
  55701. * Implementation specific of rendering the generating effect on the main canvas.
  55702. * @param effect The effect used to render through
  55703. */
  55704. protected _internalRender(effect: Effect): void;
  55705. /**
  55706. * Returns true if the layer contains information to display, otherwise false.
  55707. */
  55708. shouldRender(): boolean;
  55709. /**
  55710. * Returns true if the mesh should render, otherwise false.
  55711. * @param mesh The mesh to render
  55712. * @returns true if it should render otherwise false
  55713. */
  55714. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55715. /**
  55716. * Sets the required values for both the emissive texture and and the main color.
  55717. */
  55718. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55719. /**
  55720. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55721. * @param mesh The mesh to exclude from the highlight layer
  55722. */
  55723. addExcludedMesh(mesh: Mesh): void;
  55724. /**
  55725. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55726. * @param mesh The mesh to highlight
  55727. */
  55728. removeExcludedMesh(mesh: Mesh): void;
  55729. /**
  55730. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55731. * @param mesh mesh to test
  55732. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55733. */
  55734. hasMesh(mesh: AbstractMesh): boolean;
  55735. /**
  55736. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55737. * @param mesh The mesh to highlight
  55738. * @param color The color of the highlight
  55739. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55740. */
  55741. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55742. /**
  55743. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55744. * @param mesh The mesh to highlight
  55745. */
  55746. removeMesh(mesh: Mesh): void;
  55747. /**
  55748. * Force the stencil to the normal expected value for none glowing parts
  55749. */
  55750. private _defaultStencilReference;
  55751. /**
  55752. * Free any resources and references associated to a mesh.
  55753. * Internal use
  55754. * @param mesh The mesh to free.
  55755. * @hidden
  55756. */
  55757. _disposeMesh(mesh: Mesh): void;
  55758. /**
  55759. * Dispose the highlight layer and free resources.
  55760. */
  55761. dispose(): void;
  55762. /**
  55763. * Gets the class name of the effect layer
  55764. * @returns the string with the class name of the effect layer
  55765. */
  55766. getClassName(): string;
  55767. /**
  55768. * Serializes this Highlight layer
  55769. * @returns a serialized Highlight layer object
  55770. */
  55771. serialize(): any;
  55772. /**
  55773. * Creates a Highlight layer from parsed Highlight layer data
  55774. * @param parsedHightlightLayer defines the Highlight layer data
  55775. * @param scene defines the current scene
  55776. * @param rootUrl defines the root URL containing the Highlight layer information
  55777. * @returns a parsed Highlight layer
  55778. */
  55779. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55780. }
  55781. }
  55782. declare module "babylonjs/Layers/layerSceneComponent" {
  55783. import { Scene } from "babylonjs/scene";
  55784. import { ISceneComponent } from "babylonjs/sceneComponent";
  55785. import { Layer } from "babylonjs/Layers/layer";
  55786. import { AbstractScene } from "babylonjs/abstractScene";
  55787. module "babylonjs/abstractScene" {
  55788. interface AbstractScene {
  55789. /**
  55790. * The list of layers (background and foreground) of the scene
  55791. */
  55792. layers: Array<Layer>;
  55793. }
  55794. }
  55795. /**
  55796. * Defines the layer scene component responsible to manage any layers
  55797. * in a given scene.
  55798. */
  55799. export class LayerSceneComponent implements ISceneComponent {
  55800. /**
  55801. * The component name helpfull to identify the component in the list of scene components.
  55802. */
  55803. readonly name: string;
  55804. /**
  55805. * The scene the component belongs to.
  55806. */
  55807. scene: Scene;
  55808. private _engine;
  55809. /**
  55810. * Creates a new instance of the component for the given scene
  55811. * @param scene Defines the scene to register the component in
  55812. */
  55813. constructor(scene: Scene);
  55814. /**
  55815. * Registers the component in a given scene
  55816. */
  55817. register(): void;
  55818. /**
  55819. * Rebuilds the elements related to this component in case of
  55820. * context lost for instance.
  55821. */
  55822. rebuild(): void;
  55823. /**
  55824. * Disposes the component and the associated ressources.
  55825. */
  55826. dispose(): void;
  55827. private _draw;
  55828. private _drawCameraPredicate;
  55829. private _drawCameraBackground;
  55830. private _drawCameraForeground;
  55831. private _drawRenderTargetPredicate;
  55832. private _drawRenderTargetBackground;
  55833. private _drawRenderTargetForeground;
  55834. /**
  55835. * Adds all the elements from the container to the scene
  55836. * @param container the container holding the elements
  55837. */
  55838. addFromContainer(container: AbstractScene): void;
  55839. /**
  55840. * Removes all the elements in the container from the scene
  55841. * @param container contains the elements to remove
  55842. * @param dispose if the removed element should be disposed (default: false)
  55843. */
  55844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55845. }
  55846. }
  55847. declare module "babylonjs/Shaders/layer.fragment" {
  55848. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55849. /** @hidden */
  55850. export var layerPixelShader: {
  55851. name: string;
  55852. shader: string;
  55853. };
  55854. }
  55855. declare module "babylonjs/Shaders/layer.vertex" {
  55856. /** @hidden */
  55857. export var layerVertexShader: {
  55858. name: string;
  55859. shader: string;
  55860. };
  55861. }
  55862. declare module "babylonjs/Layers/layer" {
  55863. import { Observable } from "babylonjs/Misc/observable";
  55864. import { Nullable } from "babylonjs/types";
  55865. import { Scene } from "babylonjs/scene";
  55866. import { Vector2 } from "babylonjs/Maths/math.vector";
  55867. import { Color4 } from "babylonjs/Maths/math.color";
  55868. import { Texture } from "babylonjs/Materials/Textures/texture";
  55869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55870. import "babylonjs/Shaders/layer.fragment";
  55871. import "babylonjs/Shaders/layer.vertex";
  55872. /**
  55873. * This represents a full screen 2d layer.
  55874. * This can be useful to display a picture in the background of your scene for instance.
  55875. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55876. */
  55877. export class Layer {
  55878. /**
  55879. * Define the name of the layer.
  55880. */
  55881. name: string;
  55882. /**
  55883. * Define the texture the layer should display.
  55884. */
  55885. texture: Nullable<Texture>;
  55886. /**
  55887. * Is the layer in background or foreground.
  55888. */
  55889. isBackground: boolean;
  55890. /**
  55891. * Define the color of the layer (instead of texture).
  55892. */
  55893. color: Color4;
  55894. /**
  55895. * Define the scale of the layer in order to zoom in out of the texture.
  55896. */
  55897. scale: Vector2;
  55898. /**
  55899. * Define an offset for the layer in order to shift the texture.
  55900. */
  55901. offset: Vector2;
  55902. /**
  55903. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55904. */
  55905. alphaBlendingMode: number;
  55906. /**
  55907. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55908. * Alpha test will not mix with the background color in case of transparency.
  55909. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55910. */
  55911. alphaTest: boolean;
  55912. /**
  55913. * Define a mask to restrict the layer to only some of the scene cameras.
  55914. */
  55915. layerMask: number;
  55916. /**
  55917. * Define the list of render target the layer is visible into.
  55918. */
  55919. renderTargetTextures: RenderTargetTexture[];
  55920. /**
  55921. * Define if the layer is only used in renderTarget or if it also
  55922. * renders in the main frame buffer of the canvas.
  55923. */
  55924. renderOnlyInRenderTargetTextures: boolean;
  55925. private _scene;
  55926. private _vertexBuffers;
  55927. private _indexBuffer;
  55928. private _effect;
  55929. private _previousDefines;
  55930. /**
  55931. * An event triggered when the layer is disposed.
  55932. */
  55933. onDisposeObservable: Observable<Layer>;
  55934. private _onDisposeObserver;
  55935. /**
  55936. * Back compatibility with callback before the onDisposeObservable existed.
  55937. * The set callback will be triggered when the layer has been disposed.
  55938. */
  55939. set onDispose(callback: () => void);
  55940. /**
  55941. * An event triggered before rendering the scene
  55942. */
  55943. onBeforeRenderObservable: Observable<Layer>;
  55944. private _onBeforeRenderObserver;
  55945. /**
  55946. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55947. * The set callback will be triggered just before rendering the layer.
  55948. */
  55949. set onBeforeRender(callback: () => void);
  55950. /**
  55951. * An event triggered after rendering the scene
  55952. */
  55953. onAfterRenderObservable: Observable<Layer>;
  55954. private _onAfterRenderObserver;
  55955. /**
  55956. * Back compatibility with callback before the onAfterRenderObservable existed.
  55957. * The set callback will be triggered just after rendering the layer.
  55958. */
  55959. set onAfterRender(callback: () => void);
  55960. /**
  55961. * Instantiates a new layer.
  55962. * This represents a full screen 2d layer.
  55963. * This can be useful to display a picture in the background of your scene for instance.
  55964. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55965. * @param name Define the name of the layer in the scene
  55966. * @param imgUrl Define the url of the texture to display in the layer
  55967. * @param scene Define the scene the layer belongs to
  55968. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55969. * @param color Defines a color for the layer
  55970. */
  55971. constructor(
  55972. /**
  55973. * Define the name of the layer.
  55974. */
  55975. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55976. private _createIndexBuffer;
  55977. /** @hidden */
  55978. _rebuild(): void;
  55979. /**
  55980. * Renders the layer in the scene.
  55981. */
  55982. render(): void;
  55983. /**
  55984. * Disposes and releases the associated ressources.
  55985. */
  55986. dispose(): void;
  55987. }
  55988. }
  55989. declare module "babylonjs/Layers/index" {
  55990. export * from "babylonjs/Layers/effectLayer";
  55991. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55992. export * from "babylonjs/Layers/glowLayer";
  55993. export * from "babylonjs/Layers/highlightLayer";
  55994. export * from "babylonjs/Layers/layer";
  55995. export * from "babylonjs/Layers/layerSceneComponent";
  55996. }
  55997. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55998. /** @hidden */
  55999. export var lensFlarePixelShader: {
  56000. name: string;
  56001. shader: string;
  56002. };
  56003. }
  56004. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56005. /** @hidden */
  56006. export var lensFlareVertexShader: {
  56007. name: string;
  56008. shader: string;
  56009. };
  56010. }
  56011. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56012. import { Scene } from "babylonjs/scene";
  56013. import { Vector3 } from "babylonjs/Maths/math.vector";
  56014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56015. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56016. import "babylonjs/Shaders/lensFlare.fragment";
  56017. import "babylonjs/Shaders/lensFlare.vertex";
  56018. import { Viewport } from "babylonjs/Maths/math.viewport";
  56019. /**
  56020. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56021. * It is usually composed of several `lensFlare`.
  56022. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56023. */
  56024. export class LensFlareSystem {
  56025. /**
  56026. * Define the name of the lens flare system
  56027. */
  56028. name: string;
  56029. /**
  56030. * List of lens flares used in this system.
  56031. */
  56032. lensFlares: LensFlare[];
  56033. /**
  56034. * Define a limit from the border the lens flare can be visible.
  56035. */
  56036. borderLimit: number;
  56037. /**
  56038. * Define a viewport border we do not want to see the lens flare in.
  56039. */
  56040. viewportBorder: number;
  56041. /**
  56042. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56043. */
  56044. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56045. /**
  56046. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56047. */
  56048. layerMask: number;
  56049. /**
  56050. * Define the id of the lens flare system in the scene.
  56051. * (equal to name by default)
  56052. */
  56053. id: string;
  56054. private _scene;
  56055. private _emitter;
  56056. private _vertexBuffers;
  56057. private _indexBuffer;
  56058. private _effect;
  56059. private _positionX;
  56060. private _positionY;
  56061. private _isEnabled;
  56062. /** @hidden */
  56063. static _SceneComponentInitialization: (scene: Scene) => void;
  56064. /**
  56065. * Instantiates a lens flare system.
  56066. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56067. * It is usually composed of several `lensFlare`.
  56068. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56069. * @param name Define the name of the lens flare system in the scene
  56070. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56071. * @param scene Define the scene the lens flare system belongs to
  56072. */
  56073. constructor(
  56074. /**
  56075. * Define the name of the lens flare system
  56076. */
  56077. name: string, emitter: any, scene: Scene);
  56078. /**
  56079. * Define if the lens flare system is enabled.
  56080. */
  56081. get isEnabled(): boolean;
  56082. set isEnabled(value: boolean);
  56083. /**
  56084. * Get the scene the effects belongs to.
  56085. * @returns the scene holding the lens flare system
  56086. */
  56087. getScene(): Scene;
  56088. /**
  56089. * Get the emitter of the lens flare system.
  56090. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56091. * @returns the emitter of the lens flare system
  56092. */
  56093. getEmitter(): any;
  56094. /**
  56095. * Set the emitter of the lens flare system.
  56096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56097. * @param newEmitter Define the new emitter of the system
  56098. */
  56099. setEmitter(newEmitter: any): void;
  56100. /**
  56101. * Get the lens flare system emitter position.
  56102. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56103. * @returns the position
  56104. */
  56105. getEmitterPosition(): Vector3;
  56106. /**
  56107. * @hidden
  56108. */
  56109. computeEffectivePosition(globalViewport: Viewport): boolean;
  56110. /** @hidden */
  56111. _isVisible(): boolean;
  56112. /**
  56113. * @hidden
  56114. */
  56115. render(): boolean;
  56116. /**
  56117. * Dispose and release the lens flare with its associated resources.
  56118. */
  56119. dispose(): void;
  56120. /**
  56121. * Parse a lens flare system from a JSON repressentation
  56122. * @param parsedLensFlareSystem Define the JSON to parse
  56123. * @param scene Define the scene the parsed system should be instantiated in
  56124. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56125. * @returns the parsed system
  56126. */
  56127. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56128. /**
  56129. * Serialize the current Lens Flare System into a JSON representation.
  56130. * @returns the serialized JSON
  56131. */
  56132. serialize(): any;
  56133. }
  56134. }
  56135. declare module "babylonjs/LensFlares/lensFlare" {
  56136. import { Nullable } from "babylonjs/types";
  56137. import { Color3 } from "babylonjs/Maths/math.color";
  56138. import { Texture } from "babylonjs/Materials/Textures/texture";
  56139. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56140. /**
  56141. * This represents one of the lens effect in a `lensFlareSystem`.
  56142. * It controls one of the indiviual texture used in the effect.
  56143. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56144. */
  56145. export class LensFlare {
  56146. /**
  56147. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56148. */
  56149. size: number;
  56150. /**
  56151. * 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.
  56152. */
  56153. position: number;
  56154. /**
  56155. * Define the lens color.
  56156. */
  56157. color: Color3;
  56158. /**
  56159. * Define the lens texture.
  56160. */
  56161. texture: Nullable<Texture>;
  56162. /**
  56163. * Define the alpha mode to render this particular lens.
  56164. */
  56165. alphaMode: number;
  56166. private _system;
  56167. /**
  56168. * Creates a new Lens Flare.
  56169. * This represents one of the lens effect in a `lensFlareSystem`.
  56170. * It controls one of the indiviual texture used in the effect.
  56171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56172. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56173. * @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.
  56174. * @param color Define the lens color
  56175. * @param imgUrl Define the lens texture url
  56176. * @param system Define the `lensFlareSystem` this flare is part of
  56177. * @returns The newly created Lens Flare
  56178. */
  56179. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56180. /**
  56181. * Instantiates a new Lens Flare.
  56182. * This represents one of the lens effect in a `lensFlareSystem`.
  56183. * It controls one of the indiviual texture used in the effect.
  56184. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56185. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56186. * @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.
  56187. * @param color Define the lens color
  56188. * @param imgUrl Define the lens texture url
  56189. * @param system Define the `lensFlareSystem` this flare is part of
  56190. */
  56191. constructor(
  56192. /**
  56193. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56194. */
  56195. size: number,
  56196. /**
  56197. * 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.
  56198. */
  56199. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56200. /**
  56201. * Dispose and release the lens flare with its associated resources.
  56202. */
  56203. dispose(): void;
  56204. }
  56205. }
  56206. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56207. import { Nullable } from "babylonjs/types";
  56208. import { Scene } from "babylonjs/scene";
  56209. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56210. import { AbstractScene } from "babylonjs/abstractScene";
  56211. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56212. module "babylonjs/abstractScene" {
  56213. interface AbstractScene {
  56214. /**
  56215. * The list of lens flare system added to the scene
  56216. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56217. */
  56218. lensFlareSystems: Array<LensFlareSystem>;
  56219. /**
  56220. * Removes the given lens flare system from this scene.
  56221. * @param toRemove The lens flare system to remove
  56222. * @returns The index of the removed lens flare system
  56223. */
  56224. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56225. /**
  56226. * Adds the given lens flare system to this scene
  56227. * @param newLensFlareSystem The lens flare system to add
  56228. */
  56229. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56230. /**
  56231. * Gets a lens flare system using its name
  56232. * @param name defines the name to look for
  56233. * @returns the lens flare system or null if not found
  56234. */
  56235. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56236. /**
  56237. * Gets a lens flare system using its id
  56238. * @param id defines the id to look for
  56239. * @returns the lens flare system or null if not found
  56240. */
  56241. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56242. }
  56243. }
  56244. /**
  56245. * Defines the lens flare scene component responsible to manage any lens flares
  56246. * in a given scene.
  56247. */
  56248. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56249. /**
  56250. * The component name helpfull to identify the component in the list of scene components.
  56251. */
  56252. readonly name: string;
  56253. /**
  56254. * The scene the component belongs to.
  56255. */
  56256. scene: Scene;
  56257. /**
  56258. * Creates a new instance of the component for the given scene
  56259. * @param scene Defines the scene to register the component in
  56260. */
  56261. constructor(scene: Scene);
  56262. /**
  56263. * Registers the component in a given scene
  56264. */
  56265. register(): void;
  56266. /**
  56267. * Rebuilds the elements related to this component in case of
  56268. * context lost for instance.
  56269. */
  56270. rebuild(): void;
  56271. /**
  56272. * Adds all the elements from the container to the scene
  56273. * @param container the container holding the elements
  56274. */
  56275. addFromContainer(container: AbstractScene): void;
  56276. /**
  56277. * Removes all the elements in the container from the scene
  56278. * @param container contains the elements to remove
  56279. * @param dispose if the removed element should be disposed (default: false)
  56280. */
  56281. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56282. /**
  56283. * Serializes the component data to the specified json object
  56284. * @param serializationObject The object to serialize to
  56285. */
  56286. serialize(serializationObject: any): void;
  56287. /**
  56288. * Disposes the component and the associated ressources.
  56289. */
  56290. dispose(): void;
  56291. private _draw;
  56292. }
  56293. }
  56294. declare module "babylonjs/LensFlares/index" {
  56295. export * from "babylonjs/LensFlares/lensFlare";
  56296. export * from "babylonjs/LensFlares/lensFlareSystem";
  56297. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56298. }
  56299. declare module "babylonjs/Shaders/depth.fragment" {
  56300. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56301. /** @hidden */
  56302. export var depthPixelShader: {
  56303. name: string;
  56304. shader: string;
  56305. };
  56306. }
  56307. declare module "babylonjs/Shaders/depth.vertex" {
  56308. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56310. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56311. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56312. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56313. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56314. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56315. /** @hidden */
  56316. export var depthVertexShader: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module "babylonjs/Rendering/depthRenderer" {
  56322. import { Nullable } from "babylonjs/types";
  56323. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56324. import { Scene } from "babylonjs/scene";
  56325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56326. import { Camera } from "babylonjs/Cameras/camera";
  56327. import "babylonjs/Shaders/depth.fragment";
  56328. import "babylonjs/Shaders/depth.vertex";
  56329. /**
  56330. * This represents a depth renderer in Babylon.
  56331. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56332. */
  56333. export class DepthRenderer {
  56334. private _scene;
  56335. private _depthMap;
  56336. private _effect;
  56337. private readonly _storeNonLinearDepth;
  56338. private readonly _clearColor;
  56339. /** Get if the depth renderer is using packed depth or not */
  56340. readonly isPacked: boolean;
  56341. private _cachedDefines;
  56342. private _camera;
  56343. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56344. enabled: boolean;
  56345. /**
  56346. * Specifiess that the depth renderer will only be used within
  56347. * the camera it is created for.
  56348. * This can help forcing its rendering during the camera processing.
  56349. */
  56350. useOnlyInActiveCamera: boolean;
  56351. /** @hidden */
  56352. static _SceneComponentInitialization: (scene: Scene) => void;
  56353. /**
  56354. * Instantiates a depth renderer
  56355. * @param scene The scene the renderer belongs to
  56356. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56357. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56358. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56359. */
  56360. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56361. /**
  56362. * Creates the depth rendering effect and checks if the effect is ready.
  56363. * @param subMesh The submesh to be used to render the depth map of
  56364. * @param useInstances If multiple world instances should be used
  56365. * @returns if the depth renderer is ready to render the depth map
  56366. */
  56367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56368. /**
  56369. * Gets the texture which the depth map will be written to.
  56370. * @returns The depth map texture
  56371. */
  56372. getDepthMap(): RenderTargetTexture;
  56373. /**
  56374. * Disposes of the depth renderer.
  56375. */
  56376. dispose(): void;
  56377. }
  56378. }
  56379. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56380. /** @hidden */
  56381. export var minmaxReduxPixelShader: {
  56382. name: string;
  56383. shader: string;
  56384. };
  56385. }
  56386. declare module "babylonjs/Misc/minMaxReducer" {
  56387. import { Nullable } from "babylonjs/types";
  56388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56389. import { Camera } from "babylonjs/Cameras/camera";
  56390. import { Observer } from "babylonjs/Misc/observable";
  56391. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56392. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56393. import { Observable } from "babylonjs/Misc/observable";
  56394. import "babylonjs/Shaders/minmaxRedux.fragment";
  56395. /**
  56396. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56397. * and maximum values from all values of the texture.
  56398. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56399. * The source values are read from the red channel of the texture.
  56400. */
  56401. export class MinMaxReducer {
  56402. /**
  56403. * Observable triggered when the computation has been performed
  56404. */
  56405. onAfterReductionPerformed: Observable<{
  56406. min: number;
  56407. max: number;
  56408. }>;
  56409. protected _camera: Camera;
  56410. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56411. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56412. protected _postProcessManager: PostProcessManager;
  56413. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56414. protected _forceFullscreenViewport: boolean;
  56415. /**
  56416. * Creates a min/max reducer
  56417. * @param camera The camera to use for the post processes
  56418. */
  56419. constructor(camera: Camera);
  56420. /**
  56421. * Gets the texture used to read the values from.
  56422. */
  56423. get sourceTexture(): Nullable<RenderTargetTexture>;
  56424. /**
  56425. * Sets the source texture to read the values from.
  56426. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56427. * because in such textures '1' value must not be taken into account to compute the maximum
  56428. * as this value is used to clear the texture.
  56429. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56430. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56431. * @param depthRedux Indicates if the texture is a depth texture or not
  56432. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56433. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56434. */
  56435. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56436. /**
  56437. * Defines the refresh rate of the computation.
  56438. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56439. */
  56440. get refreshRate(): number;
  56441. set refreshRate(value: number);
  56442. protected _activated: boolean;
  56443. /**
  56444. * Gets the activation status of the reducer
  56445. */
  56446. get activated(): boolean;
  56447. /**
  56448. * Activates the reduction computation.
  56449. * When activated, the observers registered in onAfterReductionPerformed are
  56450. * called after the compuation is performed
  56451. */
  56452. activate(): void;
  56453. /**
  56454. * Deactivates the reduction computation.
  56455. */
  56456. deactivate(): void;
  56457. /**
  56458. * Disposes the min/max reducer
  56459. * @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.
  56460. */
  56461. dispose(disposeAll?: boolean): void;
  56462. }
  56463. }
  56464. declare module "babylonjs/Misc/depthReducer" {
  56465. import { Nullable } from "babylonjs/types";
  56466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56467. import { Camera } from "babylonjs/Cameras/camera";
  56468. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56469. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56470. /**
  56471. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56472. */
  56473. export class DepthReducer extends MinMaxReducer {
  56474. private _depthRenderer;
  56475. private _depthRendererId;
  56476. /**
  56477. * Gets the depth renderer used for the computation.
  56478. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56479. */
  56480. get depthRenderer(): Nullable<DepthRenderer>;
  56481. /**
  56482. * Creates a depth reducer
  56483. * @param camera The camera used to render the depth texture
  56484. */
  56485. constructor(camera: Camera);
  56486. /**
  56487. * Sets the depth renderer to use to generate the depth map
  56488. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56489. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56490. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56491. */
  56492. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56493. /** @hidden */
  56494. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56495. /**
  56496. * Activates the reduction computation.
  56497. * When activated, the observers registered in onAfterReductionPerformed are
  56498. * called after the compuation is performed
  56499. */
  56500. activate(): void;
  56501. /**
  56502. * Deactivates the reduction computation.
  56503. */
  56504. deactivate(): void;
  56505. /**
  56506. * Disposes the depth reducer
  56507. * @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.
  56508. */
  56509. dispose(disposeAll?: boolean): void;
  56510. }
  56511. }
  56512. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56513. import { Nullable } from "babylonjs/types";
  56514. import { Scene } from "babylonjs/scene";
  56515. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56517. import { Effect } from "babylonjs/Materials/effect";
  56518. import "babylonjs/Shaders/shadowMap.fragment";
  56519. import "babylonjs/Shaders/shadowMap.vertex";
  56520. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56521. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56522. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56523. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56524. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56525. /**
  56526. * A CSM implementation allowing casting shadows on large scenes.
  56527. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56528. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56529. */
  56530. export class CascadedShadowGenerator extends ShadowGenerator {
  56531. private static readonly frustumCornersNDCSpace;
  56532. /**
  56533. * Name of the CSM class
  56534. */
  56535. static CLASSNAME: string;
  56536. /**
  56537. * Defines the default number of cascades used by the CSM.
  56538. */
  56539. static readonly DEFAULT_CASCADES_COUNT: number;
  56540. /**
  56541. * Defines the minimum number of cascades used by the CSM.
  56542. */
  56543. static readonly MIN_CASCADES_COUNT: number;
  56544. /**
  56545. * Defines the maximum number of cascades used by the CSM.
  56546. */
  56547. static readonly MAX_CASCADES_COUNT: number;
  56548. protected _validateFilter(filter: number): number;
  56549. /**
  56550. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56551. */
  56552. penumbraDarkness: number;
  56553. private _numCascades;
  56554. /**
  56555. * Gets or set the number of cascades used by the CSM.
  56556. */
  56557. get numCascades(): number;
  56558. set numCascades(value: number);
  56559. /**
  56560. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56561. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56562. */
  56563. stabilizeCascades: boolean;
  56564. private _freezeShadowCastersBoundingInfo;
  56565. private _freezeShadowCastersBoundingInfoObservable;
  56566. /**
  56567. * Enables or disables the shadow casters bounding info computation.
  56568. * If your shadow casters don't move, you can disable this feature.
  56569. * If it is enabled, the bounding box computation is done every frame.
  56570. */
  56571. get freezeShadowCastersBoundingInfo(): boolean;
  56572. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56573. private _scbiMin;
  56574. private _scbiMax;
  56575. protected _computeShadowCastersBoundingInfo(): void;
  56576. protected _shadowCastersBoundingInfo: BoundingInfo;
  56577. /**
  56578. * Gets or sets the shadow casters bounding info.
  56579. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56580. * so that the system won't overwrite the bounds you provide
  56581. */
  56582. get shadowCastersBoundingInfo(): BoundingInfo;
  56583. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56584. protected _breaksAreDirty: boolean;
  56585. protected _minDistance: number;
  56586. protected _maxDistance: number;
  56587. /**
  56588. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56589. *
  56590. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56591. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56592. * @param min minimal distance for the breaks (default to 0.)
  56593. * @param max maximal distance for the breaks (default to 1.)
  56594. */
  56595. setMinMaxDistance(min: number, max: number): void;
  56596. /** Gets the minimal distance used in the cascade break computation */
  56597. get minDistance(): number;
  56598. /** Gets the maximal distance used in the cascade break computation */
  56599. get maxDistance(): number;
  56600. /**
  56601. * Gets the class name of that object
  56602. * @returns "CascadedShadowGenerator"
  56603. */
  56604. getClassName(): string;
  56605. private _cascadeMinExtents;
  56606. private _cascadeMaxExtents;
  56607. /**
  56608. * Gets a cascade minimum extents
  56609. * @param cascadeIndex index of the cascade
  56610. * @returns the minimum cascade extents
  56611. */
  56612. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56613. /**
  56614. * Gets a cascade maximum extents
  56615. * @param cascadeIndex index of the cascade
  56616. * @returns the maximum cascade extents
  56617. */
  56618. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56619. private _cascades;
  56620. private _currentLayer;
  56621. private _viewSpaceFrustumsZ;
  56622. private _viewMatrices;
  56623. private _projectionMatrices;
  56624. private _transformMatrices;
  56625. private _transformMatricesAsArray;
  56626. private _frustumLengths;
  56627. private _lightSizeUVCorrection;
  56628. private _depthCorrection;
  56629. private _frustumCornersWorldSpace;
  56630. private _frustumCenter;
  56631. private _shadowCameraPos;
  56632. private _shadowMaxZ;
  56633. /**
  56634. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56635. * It defaults to camera.maxZ
  56636. */
  56637. get shadowMaxZ(): number;
  56638. /**
  56639. * Sets the shadow max z distance.
  56640. */
  56641. set shadowMaxZ(value: number);
  56642. protected _debug: boolean;
  56643. /**
  56644. * Gets or sets the debug flag.
  56645. * When enabled, the cascades are materialized by different colors on the screen.
  56646. */
  56647. get debug(): boolean;
  56648. set debug(dbg: boolean);
  56649. private _depthClamp;
  56650. /**
  56651. * Gets or sets the depth clamping value.
  56652. *
  56653. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56654. * to account for the shadow casters far away.
  56655. *
  56656. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56657. */
  56658. get depthClamp(): boolean;
  56659. set depthClamp(value: boolean);
  56660. private _cascadeBlendPercentage;
  56661. /**
  56662. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56663. * It defaults to 0.1 (10% blending).
  56664. */
  56665. get cascadeBlendPercentage(): number;
  56666. set cascadeBlendPercentage(value: number);
  56667. private _lambda;
  56668. /**
  56669. * Gets or set the lambda parameter.
  56670. * This parameter is used to split the camera frustum and create the cascades.
  56671. * 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.
  56672. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56673. */
  56674. get lambda(): number;
  56675. set lambda(value: number);
  56676. /**
  56677. * Gets the view matrix corresponding to a given cascade
  56678. * @param cascadeNum cascade to retrieve the view matrix from
  56679. * @returns the cascade view matrix
  56680. */
  56681. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56682. /**
  56683. * Gets the projection matrix corresponding to a given cascade
  56684. * @param cascadeNum cascade to retrieve the projection matrix from
  56685. * @returns the cascade projection matrix
  56686. */
  56687. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56688. /**
  56689. * Gets the transformation matrix corresponding to a given cascade
  56690. * @param cascadeNum cascade to retrieve the transformation matrix from
  56691. * @returns the cascade transformation matrix
  56692. */
  56693. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56694. private _depthRenderer;
  56695. /**
  56696. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56697. *
  56698. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56699. *
  56700. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56701. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56702. * @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
  56703. */
  56704. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56705. private _depthReducer;
  56706. private _autoCalcDepthBounds;
  56707. /**
  56708. * Gets or sets the autoCalcDepthBounds property.
  56709. *
  56710. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56711. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56712. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56713. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56714. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56715. */
  56716. get autoCalcDepthBounds(): boolean;
  56717. set autoCalcDepthBounds(value: boolean);
  56718. /**
  56719. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56720. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56721. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56722. * for setting the refresh rate on the renderer yourself!
  56723. */
  56724. get autoCalcDepthBoundsRefreshRate(): number;
  56725. set autoCalcDepthBoundsRefreshRate(value: number);
  56726. /**
  56727. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56728. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56729. * you change the camera near/far planes!
  56730. */
  56731. splitFrustum(): void;
  56732. private _splitFrustum;
  56733. private _computeMatrices;
  56734. private _computeFrustumInWorldSpace;
  56735. private _computeCascadeFrustum;
  56736. /** @hidden */
  56737. static _SceneComponentInitialization: (scene: Scene) => void;
  56738. /**
  56739. * Creates a Cascaded Shadow Generator object.
  56740. * A ShadowGenerator is the required tool to use the shadows.
  56741. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56742. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56743. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56744. * @param light The directional light object generating the shadows.
  56745. * @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.
  56746. */
  56747. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56748. protected _initializeGenerator(): void;
  56749. protected _createTargetRenderTexture(): void;
  56750. protected _initializeShadowMap(): void;
  56751. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56752. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56753. /**
  56754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56755. * @param defines Defines of the material we want to update
  56756. * @param lightIndex Index of the light in the enabled light list of the material
  56757. */
  56758. prepareDefines(defines: any, lightIndex: number): void;
  56759. /**
  56760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56761. * defined in the generator but impacting the effect).
  56762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56763. * @param effect The effect we are binfing the information for
  56764. */
  56765. bindShadowLight(lightIndex: string, effect: Effect): void;
  56766. /**
  56767. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56768. * (eq to view projection * shadow projection matrices)
  56769. * @returns The transform matrix used to create the shadow map
  56770. */
  56771. getTransformMatrix(): Matrix;
  56772. /**
  56773. * Disposes the ShadowGenerator.
  56774. * Returns nothing.
  56775. */
  56776. dispose(): void;
  56777. /**
  56778. * Serializes the shadow generator setup to a json object.
  56779. * @returns The serialized JSON object
  56780. */
  56781. serialize(): any;
  56782. /**
  56783. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56784. * @param parsedShadowGenerator The JSON object to parse
  56785. * @param scene The scene to create the shadow map for
  56786. * @returns The parsed shadow generator
  56787. */
  56788. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56789. }
  56790. }
  56791. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56792. import { Scene } from "babylonjs/scene";
  56793. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56794. import { AbstractScene } from "babylonjs/abstractScene";
  56795. /**
  56796. * Defines the shadow generator component responsible to manage any shadow generators
  56797. * in a given scene.
  56798. */
  56799. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56800. /**
  56801. * The component name helpfull to identify the component in the list of scene components.
  56802. */
  56803. readonly name: string;
  56804. /**
  56805. * The scene the component belongs to.
  56806. */
  56807. scene: Scene;
  56808. /**
  56809. * Creates a new instance of the component for the given scene
  56810. * @param scene Defines the scene to register the component in
  56811. */
  56812. constructor(scene: Scene);
  56813. /**
  56814. * Registers the component in a given scene
  56815. */
  56816. register(): void;
  56817. /**
  56818. * Rebuilds the elements related to this component in case of
  56819. * context lost for instance.
  56820. */
  56821. rebuild(): void;
  56822. /**
  56823. * Serializes the component data to the specified json object
  56824. * @param serializationObject The object to serialize to
  56825. */
  56826. serialize(serializationObject: any): void;
  56827. /**
  56828. * Adds all the elements from the container to the scene
  56829. * @param container the container holding the elements
  56830. */
  56831. addFromContainer(container: AbstractScene): void;
  56832. /**
  56833. * Removes all the elements in the container from the scene
  56834. * @param container contains the elements to remove
  56835. * @param dispose if the removed element should be disposed (default: false)
  56836. */
  56837. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56838. /**
  56839. * Rebuilds the elements related to this component in case of
  56840. * context lost for instance.
  56841. */
  56842. dispose(): void;
  56843. private _gatherRenderTargets;
  56844. }
  56845. }
  56846. declare module "babylonjs/Lights/Shadows/index" {
  56847. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56848. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56849. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56850. }
  56851. declare module "babylonjs/Lights/pointLight" {
  56852. import { Scene } from "babylonjs/scene";
  56853. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56855. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56856. import { Effect } from "babylonjs/Materials/effect";
  56857. /**
  56858. * A point light is a light defined by an unique point in world space.
  56859. * The light is emitted in every direction from this point.
  56860. * A good example of a point light is a standard light bulb.
  56861. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56862. */
  56863. export class PointLight extends ShadowLight {
  56864. private _shadowAngle;
  56865. /**
  56866. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56867. * This specifies what angle the shadow will use to be created.
  56868. *
  56869. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56870. */
  56871. get shadowAngle(): number;
  56872. /**
  56873. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56874. * This specifies what angle the shadow will use to be created.
  56875. *
  56876. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56877. */
  56878. set shadowAngle(value: number);
  56879. /**
  56880. * Gets the direction if it has been set.
  56881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56882. */
  56883. get direction(): Vector3;
  56884. /**
  56885. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56886. */
  56887. set direction(value: Vector3);
  56888. /**
  56889. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56890. * A PointLight emits the light in every direction.
  56891. * It can cast shadows.
  56892. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56893. * ```javascript
  56894. * var pointLight = new PointLight("pl", camera.position, scene);
  56895. * ```
  56896. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56897. * @param name The light friendly name
  56898. * @param position The position of the point light in the scene
  56899. * @param scene The scene the lights belongs to
  56900. */
  56901. constructor(name: string, position: Vector3, scene: Scene);
  56902. /**
  56903. * Returns the string "PointLight"
  56904. * @returns the class name
  56905. */
  56906. getClassName(): string;
  56907. /**
  56908. * Returns the integer 0.
  56909. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56910. */
  56911. getTypeID(): number;
  56912. /**
  56913. * Specifies wether or not the shadowmap should be a cube texture.
  56914. * @returns true if the shadowmap needs to be a cube texture.
  56915. */
  56916. needCube(): boolean;
  56917. /**
  56918. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56919. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56920. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56921. */
  56922. getShadowDirection(faceIndex?: number): Vector3;
  56923. /**
  56924. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56925. * - fov = PI / 2
  56926. * - aspect ratio : 1.0
  56927. * - z-near and far equal to the active camera minZ and maxZ.
  56928. * Returns the PointLight.
  56929. */
  56930. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56931. protected _buildUniformLayout(): void;
  56932. /**
  56933. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56934. * @param effect The effect to update
  56935. * @param lightIndex The index of the light in the effect to update
  56936. * @returns The point light
  56937. */
  56938. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56939. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56940. /**
  56941. * Prepares the list of defines specific to the light type.
  56942. * @param defines the list of defines
  56943. * @param lightIndex defines the index of the light for the effect
  56944. */
  56945. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56946. }
  56947. }
  56948. declare module "babylonjs/Lights/index" {
  56949. export * from "babylonjs/Lights/light";
  56950. export * from "babylonjs/Lights/shadowLight";
  56951. export * from "babylonjs/Lights/Shadows/index";
  56952. export * from "babylonjs/Lights/directionalLight";
  56953. export * from "babylonjs/Lights/hemisphericLight";
  56954. export * from "babylonjs/Lights/pointLight";
  56955. export * from "babylonjs/Lights/spotLight";
  56956. }
  56957. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56958. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56959. /**
  56960. * Header information of HDR texture files.
  56961. */
  56962. export interface HDRInfo {
  56963. /**
  56964. * The height of the texture in pixels.
  56965. */
  56966. height: number;
  56967. /**
  56968. * The width of the texture in pixels.
  56969. */
  56970. width: number;
  56971. /**
  56972. * The index of the beginning of the data in the binary file.
  56973. */
  56974. dataPosition: number;
  56975. }
  56976. /**
  56977. * This groups tools to convert HDR texture to native colors array.
  56978. */
  56979. export class HDRTools {
  56980. private static Ldexp;
  56981. private static Rgbe2float;
  56982. private static readStringLine;
  56983. /**
  56984. * Reads header information from an RGBE texture stored in a native array.
  56985. * More information on this format are available here:
  56986. * https://en.wikipedia.org/wiki/RGBE_image_format
  56987. *
  56988. * @param uint8array The binary file stored in native array.
  56989. * @return The header information.
  56990. */
  56991. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56992. /**
  56993. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56994. * This RGBE texture needs to store the information as a panorama.
  56995. *
  56996. * More information on this format are available here:
  56997. * https://en.wikipedia.org/wiki/RGBE_image_format
  56998. *
  56999. * @param buffer The binary file stored in an array buffer.
  57000. * @param size The expected size of the extracted cubemap.
  57001. * @return The Cube Map information.
  57002. */
  57003. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57004. /**
  57005. * Returns the pixels data extracted from an RGBE texture.
  57006. * This pixels will be stored left to right up to down in the R G B order in one array.
  57007. *
  57008. * More information on this format are available here:
  57009. * https://en.wikipedia.org/wiki/RGBE_image_format
  57010. *
  57011. * @param uint8array The binary file stored in an array buffer.
  57012. * @param hdrInfo The header information of the file.
  57013. * @return The pixels data in RGB right to left up to down order.
  57014. */
  57015. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57016. private static RGBE_ReadPixels_RLE;
  57017. }
  57018. }
  57019. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57020. import { Nullable } from "babylonjs/types";
  57021. import { Scene } from "babylonjs/scene";
  57022. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57024. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57025. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57026. /**
  57027. * This represents a texture coming from an HDR input.
  57028. *
  57029. * The only supported format is currently panorama picture stored in RGBE format.
  57030. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57031. */
  57032. export class HDRCubeTexture extends BaseTexture {
  57033. private static _facesMapping;
  57034. private _generateHarmonics;
  57035. private _noMipmap;
  57036. private _textureMatrix;
  57037. private _size;
  57038. private _onLoad;
  57039. private _onError;
  57040. /**
  57041. * The texture URL.
  57042. */
  57043. url: string;
  57044. /**
  57045. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57046. */
  57047. coordinatesMode: number;
  57048. protected _isBlocking: boolean;
  57049. /**
  57050. * Sets wether or not the texture is blocking during loading.
  57051. */
  57052. set isBlocking(value: boolean);
  57053. /**
  57054. * Gets wether or not the texture is blocking during loading.
  57055. */
  57056. get isBlocking(): boolean;
  57057. protected _rotationY: number;
  57058. /**
  57059. * Sets texture matrix rotation angle around Y axis in radians.
  57060. */
  57061. set rotationY(value: number);
  57062. /**
  57063. * Gets texture matrix rotation angle around Y axis radians.
  57064. */
  57065. get rotationY(): number;
  57066. /**
  57067. * Gets or sets the center of the bounding box associated with the cube texture
  57068. * It must define where the camera used to render the texture was set
  57069. */
  57070. boundingBoxPosition: Vector3;
  57071. private _boundingBoxSize;
  57072. /**
  57073. * Gets or sets the size of the bounding box associated with the cube texture
  57074. * When defined, the cubemap will switch to local mode
  57075. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57076. * @example https://www.babylonjs-playground.com/#RNASML
  57077. */
  57078. set boundingBoxSize(value: Vector3);
  57079. get boundingBoxSize(): Vector3;
  57080. /**
  57081. * Instantiates an HDRTexture from the following parameters.
  57082. *
  57083. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57084. * @param scene The scene the texture will be used in
  57085. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57086. * @param noMipmap Forces to not generate the mipmap if true
  57087. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57088. * @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)
  57089. * @param reserved Reserved flag for internal use.
  57090. */
  57091. 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>);
  57092. /**
  57093. * Get the current class name of the texture useful for serialization or dynamic coding.
  57094. * @returns "HDRCubeTexture"
  57095. */
  57096. getClassName(): string;
  57097. /**
  57098. * Occurs when the file is raw .hdr file.
  57099. */
  57100. private loadTexture;
  57101. clone(): HDRCubeTexture;
  57102. delayLoad(): void;
  57103. /**
  57104. * Get the texture reflection matrix used to rotate/transform the reflection.
  57105. * @returns the reflection matrix
  57106. */
  57107. getReflectionTextureMatrix(): Matrix;
  57108. /**
  57109. * Set the texture reflection matrix used to rotate/transform the reflection.
  57110. * @param value Define the reflection matrix to set
  57111. */
  57112. setReflectionTextureMatrix(value: Matrix): void;
  57113. /**
  57114. * Parses a JSON representation of an HDR Texture in order to create the texture
  57115. * @param parsedTexture Define the JSON representation
  57116. * @param scene Define the scene the texture should be created in
  57117. * @param rootUrl Define the root url in case we need to load relative dependencies
  57118. * @returns the newly created texture after parsing
  57119. */
  57120. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57121. serialize(): any;
  57122. }
  57123. }
  57124. declare module "babylonjs/Physics/physicsEngine" {
  57125. import { Nullable } from "babylonjs/types";
  57126. import { Vector3 } from "babylonjs/Maths/math.vector";
  57127. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57128. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57129. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57130. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57131. /**
  57132. * Class used to control physics engine
  57133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57134. */
  57135. export class PhysicsEngine implements IPhysicsEngine {
  57136. private _physicsPlugin;
  57137. /**
  57138. * Global value used to control the smallest number supported by the simulation
  57139. */
  57140. static Epsilon: number;
  57141. private _impostors;
  57142. private _joints;
  57143. private _subTimeStep;
  57144. /**
  57145. * Gets the gravity vector used by the simulation
  57146. */
  57147. gravity: Vector3;
  57148. /**
  57149. * Factory used to create the default physics plugin.
  57150. * @returns The default physics plugin
  57151. */
  57152. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57153. /**
  57154. * Creates a new Physics Engine
  57155. * @param gravity defines the gravity vector used by the simulation
  57156. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57157. */
  57158. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57159. /**
  57160. * Sets the gravity vector used by the simulation
  57161. * @param gravity defines the gravity vector to use
  57162. */
  57163. setGravity(gravity: Vector3): void;
  57164. /**
  57165. * Set the time step of the physics engine.
  57166. * Default is 1/60.
  57167. * To slow it down, enter 1/600 for example.
  57168. * To speed it up, 1/30
  57169. * @param newTimeStep defines the new timestep to apply to this world.
  57170. */
  57171. setTimeStep(newTimeStep?: number): void;
  57172. /**
  57173. * Get the time step of the physics engine.
  57174. * @returns the current time step
  57175. */
  57176. getTimeStep(): number;
  57177. /**
  57178. * Set the sub time step of the physics engine.
  57179. * Default is 0 meaning there is no sub steps
  57180. * To increase physics resolution precision, set a small value (like 1 ms)
  57181. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57182. */
  57183. setSubTimeStep(subTimeStep?: number): void;
  57184. /**
  57185. * Get the sub time step of the physics engine.
  57186. * @returns the current sub time step
  57187. */
  57188. getSubTimeStep(): number;
  57189. /**
  57190. * Release all resources
  57191. */
  57192. dispose(): void;
  57193. /**
  57194. * Gets the name of the current physics plugin
  57195. * @returns the name of the plugin
  57196. */
  57197. getPhysicsPluginName(): string;
  57198. /**
  57199. * Adding a new impostor for the impostor tracking.
  57200. * This will be done by the impostor itself.
  57201. * @param impostor the impostor to add
  57202. */
  57203. addImpostor(impostor: PhysicsImpostor): void;
  57204. /**
  57205. * Remove an impostor from the engine.
  57206. * This impostor and its mesh will not longer be updated by the physics engine.
  57207. * @param impostor the impostor to remove
  57208. */
  57209. removeImpostor(impostor: PhysicsImpostor): void;
  57210. /**
  57211. * Add a joint to the physics engine
  57212. * @param mainImpostor defines the main impostor to which the joint is added.
  57213. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57214. * @param joint defines the joint that will connect both impostors.
  57215. */
  57216. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57217. /**
  57218. * Removes a joint from the simulation
  57219. * @param mainImpostor defines the impostor used with the joint
  57220. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57221. * @param joint defines the joint to remove
  57222. */
  57223. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57224. /**
  57225. * Called by the scene. No need to call it.
  57226. * @param delta defines the timespam between frames
  57227. */
  57228. _step(delta: number): void;
  57229. /**
  57230. * Gets the current plugin used to run the simulation
  57231. * @returns current plugin
  57232. */
  57233. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57234. /**
  57235. * Gets the list of physic impostors
  57236. * @returns an array of PhysicsImpostor
  57237. */
  57238. getImpostors(): Array<PhysicsImpostor>;
  57239. /**
  57240. * Gets the impostor for a physics enabled object
  57241. * @param object defines the object impersonated by the impostor
  57242. * @returns the PhysicsImpostor or null if not found
  57243. */
  57244. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57245. /**
  57246. * Gets the impostor for a physics body object
  57247. * @param body defines physics body used by the impostor
  57248. * @returns the PhysicsImpostor or null if not found
  57249. */
  57250. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57251. /**
  57252. * Does a raycast in the physics world
  57253. * @param from when should the ray start?
  57254. * @param to when should the ray end?
  57255. * @returns PhysicsRaycastResult
  57256. */
  57257. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57258. }
  57259. }
  57260. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57261. import { Nullable } from "babylonjs/types";
  57262. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57264. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57265. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57266. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57267. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57268. /** @hidden */
  57269. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57270. private _useDeltaForWorldStep;
  57271. world: any;
  57272. name: string;
  57273. private _physicsMaterials;
  57274. private _fixedTimeStep;
  57275. private _cannonRaycastResult;
  57276. private _raycastResult;
  57277. private _physicsBodysToRemoveAfterStep;
  57278. BJSCANNON: any;
  57279. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57280. setGravity(gravity: Vector3): void;
  57281. setTimeStep(timeStep: number): void;
  57282. getTimeStep(): number;
  57283. executeStep(delta: number): void;
  57284. private _removeMarkedPhysicsBodiesFromWorld;
  57285. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57286. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57287. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57288. private _processChildMeshes;
  57289. removePhysicsBody(impostor: PhysicsImpostor): void;
  57290. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57291. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57292. private _addMaterial;
  57293. private _checkWithEpsilon;
  57294. private _createShape;
  57295. private _createHeightmap;
  57296. private _minus90X;
  57297. private _plus90X;
  57298. private _tmpPosition;
  57299. private _tmpDeltaPosition;
  57300. private _tmpUnityRotation;
  57301. private _updatePhysicsBodyTransformation;
  57302. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57303. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57304. isSupported(): boolean;
  57305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57306. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57307. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57308. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57309. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57310. getBodyMass(impostor: PhysicsImpostor): number;
  57311. getBodyFriction(impostor: PhysicsImpostor): number;
  57312. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57313. getBodyRestitution(impostor: PhysicsImpostor): number;
  57314. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57315. sleepBody(impostor: PhysicsImpostor): void;
  57316. wakeUpBody(impostor: PhysicsImpostor): void;
  57317. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57318. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57319. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57320. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57321. getRadius(impostor: PhysicsImpostor): number;
  57322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57323. dispose(): void;
  57324. private _extendNamespace;
  57325. /**
  57326. * Does a raycast in the physics world
  57327. * @param from when should the ray start?
  57328. * @param to when should the ray end?
  57329. * @returns PhysicsRaycastResult
  57330. */
  57331. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57332. }
  57333. }
  57334. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57335. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57336. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57337. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57339. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57340. import { Nullable } from "babylonjs/types";
  57341. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57342. /** @hidden */
  57343. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57344. world: any;
  57345. name: string;
  57346. BJSOIMO: any;
  57347. private _raycastResult;
  57348. constructor(iterations?: number, oimoInjection?: any);
  57349. setGravity(gravity: Vector3): void;
  57350. setTimeStep(timeStep: number): void;
  57351. getTimeStep(): number;
  57352. private _tmpImpostorsArray;
  57353. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57354. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57355. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57356. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57357. private _tmpPositionVector;
  57358. removePhysicsBody(impostor: PhysicsImpostor): void;
  57359. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57360. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57361. isSupported(): boolean;
  57362. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57363. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57364. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57365. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57366. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57367. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57368. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57369. getBodyMass(impostor: PhysicsImpostor): number;
  57370. getBodyFriction(impostor: PhysicsImpostor): number;
  57371. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57372. getBodyRestitution(impostor: PhysicsImpostor): number;
  57373. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57374. sleepBody(impostor: PhysicsImpostor): void;
  57375. wakeUpBody(impostor: PhysicsImpostor): void;
  57376. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57377. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57378. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57379. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57380. getRadius(impostor: PhysicsImpostor): number;
  57381. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57382. dispose(): void;
  57383. /**
  57384. * Does a raycast in the physics world
  57385. * @param from when should the ray start?
  57386. * @param to when should the ray end?
  57387. * @returns PhysicsRaycastResult
  57388. */
  57389. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57390. }
  57391. }
  57392. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57393. import { Nullable } from "babylonjs/types";
  57394. import { Scene } from "babylonjs/scene";
  57395. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57396. import { Color4 } from "babylonjs/Maths/math.color";
  57397. import { Mesh } from "babylonjs/Meshes/mesh";
  57398. /**
  57399. * Class containing static functions to help procedurally build meshes
  57400. */
  57401. export class RibbonBuilder {
  57402. /**
  57403. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57404. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57405. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57406. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57407. * * 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
  57408. * * 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
  57409. * * 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
  57410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57413. * * 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
  57414. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57415. * * 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
  57416. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57418. * @param name defines the name of the mesh
  57419. * @param options defines the options used to create the mesh
  57420. * @param scene defines the hosting scene
  57421. * @returns the ribbon mesh
  57422. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57424. */
  57425. static CreateRibbon(name: string, options: {
  57426. pathArray: Vector3[][];
  57427. closeArray?: boolean;
  57428. closePath?: boolean;
  57429. offset?: number;
  57430. updatable?: boolean;
  57431. sideOrientation?: number;
  57432. frontUVs?: Vector4;
  57433. backUVs?: Vector4;
  57434. instance?: Mesh;
  57435. invertUV?: boolean;
  57436. uvs?: Vector2[];
  57437. colors?: Color4[];
  57438. }, scene?: Nullable<Scene>): Mesh;
  57439. }
  57440. }
  57441. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57442. import { Nullable } from "babylonjs/types";
  57443. import { Scene } from "babylonjs/scene";
  57444. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57445. import { Mesh } from "babylonjs/Meshes/mesh";
  57446. /**
  57447. * Class containing static functions to help procedurally build meshes
  57448. */
  57449. export class ShapeBuilder {
  57450. /**
  57451. * 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.
  57452. * * 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.
  57453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57454. * * 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.
  57455. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57456. * * 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
  57457. * * 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
  57458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57463. * @param name defines the name of the mesh
  57464. * @param options defines the options used to create the mesh
  57465. * @param scene defines the hosting scene
  57466. * @returns the extruded shape mesh
  57467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57469. */
  57470. static ExtrudeShape(name: string, options: {
  57471. shape: Vector3[];
  57472. path: Vector3[];
  57473. scale?: number;
  57474. rotation?: number;
  57475. cap?: number;
  57476. updatable?: boolean;
  57477. sideOrientation?: number;
  57478. frontUVs?: Vector4;
  57479. backUVs?: Vector4;
  57480. instance?: Mesh;
  57481. invertUV?: boolean;
  57482. }, scene?: Nullable<Scene>): Mesh;
  57483. /**
  57484. * Creates an custom extruded shape mesh.
  57485. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57486. * * 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.
  57487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57488. * * 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
  57489. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57490. * * 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
  57491. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57492. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57493. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57494. * * 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
  57495. * * 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
  57496. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57501. * @param name defines the name of the mesh
  57502. * @param options defines the options used to create the mesh
  57503. * @param scene defines the hosting scene
  57504. * @returns the custom extruded shape mesh
  57505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57508. */
  57509. static ExtrudeShapeCustom(name: string, options: {
  57510. shape: Vector3[];
  57511. path: Vector3[];
  57512. scaleFunction?: any;
  57513. rotationFunction?: any;
  57514. ribbonCloseArray?: boolean;
  57515. ribbonClosePath?: boolean;
  57516. cap?: number;
  57517. updatable?: boolean;
  57518. sideOrientation?: number;
  57519. frontUVs?: Vector4;
  57520. backUVs?: Vector4;
  57521. instance?: Mesh;
  57522. invertUV?: boolean;
  57523. }, scene?: Nullable<Scene>): Mesh;
  57524. private static _ExtrudeShapeGeneric;
  57525. }
  57526. }
  57527. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57528. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57529. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57530. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57531. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57532. import { Nullable } from "babylonjs/types";
  57533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57534. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57535. /**
  57536. * AmmoJS Physics plugin
  57537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57538. * @see https://github.com/kripken/ammo.js/
  57539. */
  57540. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57541. private _useDeltaForWorldStep;
  57542. /**
  57543. * Reference to the Ammo library
  57544. */
  57545. bjsAMMO: any;
  57546. /**
  57547. * Created ammoJS world which physics bodies are added to
  57548. */
  57549. world: any;
  57550. /**
  57551. * Name of the plugin
  57552. */
  57553. name: string;
  57554. private _timeStep;
  57555. private _fixedTimeStep;
  57556. private _maxSteps;
  57557. private _tmpQuaternion;
  57558. private _tmpAmmoTransform;
  57559. private _tmpAmmoQuaternion;
  57560. private _tmpAmmoConcreteContactResultCallback;
  57561. private _collisionConfiguration;
  57562. private _dispatcher;
  57563. private _overlappingPairCache;
  57564. private _solver;
  57565. private _softBodySolver;
  57566. private _tmpAmmoVectorA;
  57567. private _tmpAmmoVectorB;
  57568. private _tmpAmmoVectorC;
  57569. private _tmpAmmoVectorD;
  57570. private _tmpContactCallbackResult;
  57571. private _tmpAmmoVectorRCA;
  57572. private _tmpAmmoVectorRCB;
  57573. private _raycastResult;
  57574. private static readonly DISABLE_COLLISION_FLAG;
  57575. private static readonly KINEMATIC_FLAG;
  57576. private static readonly DISABLE_DEACTIVATION_FLAG;
  57577. /**
  57578. * Initializes the ammoJS plugin
  57579. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57580. * @param ammoInjection can be used to inject your own ammo reference
  57581. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57582. */
  57583. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57584. /**
  57585. * Sets the gravity of the physics world (m/(s^2))
  57586. * @param gravity Gravity to set
  57587. */
  57588. setGravity(gravity: Vector3): void;
  57589. /**
  57590. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57591. * @param timeStep timestep to use in seconds
  57592. */
  57593. setTimeStep(timeStep: number): void;
  57594. /**
  57595. * 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)
  57596. * @param fixedTimeStep fixedTimeStep to use in seconds
  57597. */
  57598. setFixedTimeStep(fixedTimeStep: number): void;
  57599. /**
  57600. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57601. * @param maxSteps the maximum number of steps by the physics engine per frame
  57602. */
  57603. setMaxSteps(maxSteps: number): void;
  57604. /**
  57605. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57606. * @returns the current timestep in seconds
  57607. */
  57608. getTimeStep(): number;
  57609. /**
  57610. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57611. */
  57612. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57613. private _isImpostorInContact;
  57614. private _isImpostorPairInContact;
  57615. private _stepSimulation;
  57616. /**
  57617. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57618. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57619. * After the step the babylon meshes are set to the position of the physics imposters
  57620. * @param delta amount of time to step forward
  57621. * @param impostors array of imposters to update before/after the step
  57622. */
  57623. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57624. /**
  57625. * Update babylon mesh to match physics world object
  57626. * @param impostor imposter to match
  57627. */
  57628. private _afterSoftStep;
  57629. /**
  57630. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57631. * @param impostor imposter to match
  57632. */
  57633. private _ropeStep;
  57634. /**
  57635. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57636. * @param impostor imposter to match
  57637. */
  57638. private _softbodyOrClothStep;
  57639. private _tmpVector;
  57640. private _tmpMatrix;
  57641. /**
  57642. * Applies an impulse on the imposter
  57643. * @param impostor imposter to apply impulse to
  57644. * @param force amount of force to be applied to the imposter
  57645. * @param contactPoint the location to apply the impulse on the imposter
  57646. */
  57647. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57648. /**
  57649. * Applies a force on the imposter
  57650. * @param impostor imposter to apply force
  57651. * @param force amount of force to be applied to the imposter
  57652. * @param contactPoint the location to apply the force on the imposter
  57653. */
  57654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57655. /**
  57656. * Creates a physics body using the plugin
  57657. * @param impostor the imposter to create the physics body on
  57658. */
  57659. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57660. /**
  57661. * Removes the physics body from the imposter and disposes of the body's memory
  57662. * @param impostor imposter to remove the physics body from
  57663. */
  57664. removePhysicsBody(impostor: PhysicsImpostor): void;
  57665. /**
  57666. * Generates a joint
  57667. * @param impostorJoint the imposter joint to create the joint with
  57668. */
  57669. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57670. /**
  57671. * Removes a joint
  57672. * @param impostorJoint the imposter joint to remove the joint from
  57673. */
  57674. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57675. private _addMeshVerts;
  57676. /**
  57677. * Initialise the soft body vertices to match its object's (mesh) vertices
  57678. * Softbody vertices (nodes) are in world space and to match this
  57679. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57680. * @param impostor to create the softbody for
  57681. */
  57682. private _softVertexData;
  57683. /**
  57684. * Create an impostor's soft body
  57685. * @param impostor to create the softbody for
  57686. */
  57687. private _createSoftbody;
  57688. /**
  57689. * Create cloth for an impostor
  57690. * @param impostor to create the softbody for
  57691. */
  57692. private _createCloth;
  57693. /**
  57694. * Create rope for an impostor
  57695. * @param impostor to create the softbody for
  57696. */
  57697. private _createRope;
  57698. /**
  57699. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57700. * @param impostor to create the custom physics shape for
  57701. */
  57702. private _createCustom;
  57703. private _addHullVerts;
  57704. private _createShape;
  57705. /**
  57706. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57707. * @param impostor imposter containing the physics body and babylon object
  57708. */
  57709. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57710. /**
  57711. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57712. * @param impostor imposter containing the physics body and babylon object
  57713. * @param newPosition new position
  57714. * @param newRotation new rotation
  57715. */
  57716. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57717. /**
  57718. * If this plugin is supported
  57719. * @returns true if its supported
  57720. */
  57721. isSupported(): boolean;
  57722. /**
  57723. * Sets the linear velocity of the physics body
  57724. * @param impostor imposter to set the velocity on
  57725. * @param velocity velocity to set
  57726. */
  57727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57728. /**
  57729. * Sets the angular velocity of the physics body
  57730. * @param impostor imposter to set the velocity on
  57731. * @param velocity velocity to set
  57732. */
  57733. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57734. /**
  57735. * gets the linear velocity
  57736. * @param impostor imposter to get linear velocity from
  57737. * @returns linear velocity
  57738. */
  57739. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57740. /**
  57741. * gets the angular velocity
  57742. * @param impostor imposter to get angular velocity from
  57743. * @returns angular velocity
  57744. */
  57745. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57746. /**
  57747. * Sets the mass of physics body
  57748. * @param impostor imposter to set the mass on
  57749. * @param mass mass to set
  57750. */
  57751. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57752. /**
  57753. * Gets the mass of the physics body
  57754. * @param impostor imposter to get the mass from
  57755. * @returns mass
  57756. */
  57757. getBodyMass(impostor: PhysicsImpostor): number;
  57758. /**
  57759. * Gets friction of the impostor
  57760. * @param impostor impostor to get friction from
  57761. * @returns friction value
  57762. */
  57763. getBodyFriction(impostor: PhysicsImpostor): number;
  57764. /**
  57765. * Sets friction of the impostor
  57766. * @param impostor impostor to set friction on
  57767. * @param friction friction value
  57768. */
  57769. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57770. /**
  57771. * Gets restitution of the impostor
  57772. * @param impostor impostor to get restitution from
  57773. * @returns restitution value
  57774. */
  57775. getBodyRestitution(impostor: PhysicsImpostor): number;
  57776. /**
  57777. * Sets resitution of the impostor
  57778. * @param impostor impostor to set resitution on
  57779. * @param restitution resitution value
  57780. */
  57781. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57782. /**
  57783. * Gets pressure inside the impostor
  57784. * @param impostor impostor to get pressure from
  57785. * @returns pressure value
  57786. */
  57787. getBodyPressure(impostor: PhysicsImpostor): number;
  57788. /**
  57789. * Sets pressure inside a soft body impostor
  57790. * Cloth and rope must remain 0 pressure
  57791. * @param impostor impostor to set pressure on
  57792. * @param pressure pressure value
  57793. */
  57794. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57795. /**
  57796. * Gets stiffness of the impostor
  57797. * @param impostor impostor to get stiffness from
  57798. * @returns pressure value
  57799. */
  57800. getBodyStiffness(impostor: PhysicsImpostor): number;
  57801. /**
  57802. * Sets stiffness of the impostor
  57803. * @param impostor impostor to set stiffness on
  57804. * @param stiffness stiffness value from 0 to 1
  57805. */
  57806. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57807. /**
  57808. * Gets velocityIterations of the impostor
  57809. * @param impostor impostor to get velocity iterations from
  57810. * @returns velocityIterations value
  57811. */
  57812. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57813. /**
  57814. * Sets velocityIterations of the impostor
  57815. * @param impostor impostor to set velocity iterations on
  57816. * @param velocityIterations velocityIterations value
  57817. */
  57818. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57819. /**
  57820. * Gets positionIterations of the impostor
  57821. * @param impostor impostor to get position iterations from
  57822. * @returns positionIterations value
  57823. */
  57824. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57825. /**
  57826. * Sets positionIterations of the impostor
  57827. * @param impostor impostor to set position on
  57828. * @param positionIterations positionIterations value
  57829. */
  57830. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57831. /**
  57832. * Append an anchor to a cloth object
  57833. * @param impostor is the cloth impostor to add anchor to
  57834. * @param otherImpostor is the rigid impostor to anchor to
  57835. * @param width ratio across width from 0 to 1
  57836. * @param height ratio up height from 0 to 1
  57837. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57838. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57839. */
  57840. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57841. /**
  57842. * Append an hook to a rope object
  57843. * @param impostor is the rope impostor to add hook to
  57844. * @param otherImpostor is the rigid impostor to hook to
  57845. * @param length ratio along the rope from 0 to 1
  57846. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57847. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57848. */
  57849. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57850. /**
  57851. * Sleeps the physics body and stops it from being active
  57852. * @param impostor impostor to sleep
  57853. */
  57854. sleepBody(impostor: PhysicsImpostor): void;
  57855. /**
  57856. * Activates the physics body
  57857. * @param impostor impostor to activate
  57858. */
  57859. wakeUpBody(impostor: PhysicsImpostor): void;
  57860. /**
  57861. * Updates the distance parameters of the joint
  57862. * @param joint joint to update
  57863. * @param maxDistance maximum distance of the joint
  57864. * @param minDistance minimum distance of the joint
  57865. */
  57866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57867. /**
  57868. * Sets a motor on the joint
  57869. * @param joint joint to set motor on
  57870. * @param speed speed of the motor
  57871. * @param maxForce maximum force of the motor
  57872. * @param motorIndex index of the motor
  57873. */
  57874. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57875. /**
  57876. * Sets the motors limit
  57877. * @param joint joint to set limit on
  57878. * @param upperLimit upper limit
  57879. * @param lowerLimit lower limit
  57880. */
  57881. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57882. /**
  57883. * Syncs the position and rotation of a mesh with the impostor
  57884. * @param mesh mesh to sync
  57885. * @param impostor impostor to update the mesh with
  57886. */
  57887. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57888. /**
  57889. * Gets the radius of the impostor
  57890. * @param impostor impostor to get radius from
  57891. * @returns the radius
  57892. */
  57893. getRadius(impostor: PhysicsImpostor): number;
  57894. /**
  57895. * Gets the box size of the impostor
  57896. * @param impostor impostor to get box size from
  57897. * @param result the resulting box size
  57898. */
  57899. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57900. /**
  57901. * Disposes of the impostor
  57902. */
  57903. dispose(): void;
  57904. /**
  57905. * Does a raycast in the physics world
  57906. * @param from when should the ray start?
  57907. * @param to when should the ray end?
  57908. * @returns PhysicsRaycastResult
  57909. */
  57910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57911. }
  57912. }
  57913. declare module "babylonjs/Probes/reflectionProbe" {
  57914. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57915. import { Vector3 } from "babylonjs/Maths/math.vector";
  57916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57917. import { Nullable } from "babylonjs/types";
  57918. import { Scene } from "babylonjs/scene";
  57919. module "babylonjs/abstractScene" {
  57920. interface AbstractScene {
  57921. /**
  57922. * The list of reflection probes added to the scene
  57923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57924. */
  57925. reflectionProbes: Array<ReflectionProbe>;
  57926. /**
  57927. * Removes the given reflection probe from this scene.
  57928. * @param toRemove The reflection probe to remove
  57929. * @returns The index of the removed reflection probe
  57930. */
  57931. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57932. /**
  57933. * Adds the given reflection probe to this scene.
  57934. * @param newReflectionProbe The reflection probe to add
  57935. */
  57936. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57937. }
  57938. }
  57939. /**
  57940. * Class used to generate realtime reflection / refraction cube textures
  57941. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57942. */
  57943. export class ReflectionProbe {
  57944. /** defines the name of the probe */
  57945. name: string;
  57946. private _scene;
  57947. private _renderTargetTexture;
  57948. private _projectionMatrix;
  57949. private _viewMatrix;
  57950. private _target;
  57951. private _add;
  57952. private _attachedMesh;
  57953. private _invertYAxis;
  57954. /** Gets or sets probe position (center of the cube map) */
  57955. position: Vector3;
  57956. /**
  57957. * Creates a new reflection probe
  57958. * @param name defines the name of the probe
  57959. * @param size defines the texture resolution (for each face)
  57960. * @param scene defines the hosting scene
  57961. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57962. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57963. */
  57964. constructor(
  57965. /** defines the name of the probe */
  57966. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57967. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57968. get samples(): number;
  57969. set samples(value: number);
  57970. /** Gets or sets the refresh rate to use (on every frame by default) */
  57971. get refreshRate(): number;
  57972. set refreshRate(value: number);
  57973. /**
  57974. * Gets the hosting scene
  57975. * @returns a Scene
  57976. */
  57977. getScene(): Scene;
  57978. /** Gets the internal CubeTexture used to render to */
  57979. get cubeTexture(): RenderTargetTexture;
  57980. /** Gets the list of meshes to render */
  57981. get renderList(): Nullable<AbstractMesh[]>;
  57982. /**
  57983. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57984. * @param mesh defines the mesh to attach to
  57985. */
  57986. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57987. /**
  57988. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57989. * @param renderingGroupId The rendering group id corresponding to its index
  57990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57991. */
  57992. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57993. /**
  57994. * Clean all associated resources
  57995. */
  57996. dispose(): void;
  57997. /**
  57998. * Converts the reflection probe information to a readable string for debug purpose.
  57999. * @param fullDetails Supports for multiple levels of logging within scene loading
  58000. * @returns the human readable reflection probe info
  58001. */
  58002. toString(fullDetails?: boolean): string;
  58003. /**
  58004. * Get the class name of the relfection probe.
  58005. * @returns "ReflectionProbe"
  58006. */
  58007. getClassName(): string;
  58008. /**
  58009. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58010. * @returns The JSON representation of the texture
  58011. */
  58012. serialize(): any;
  58013. /**
  58014. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58015. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58016. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58017. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58018. * @returns The parsed reflection probe if successful
  58019. */
  58020. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58021. }
  58022. }
  58023. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58024. /** @hidden */
  58025. export var _BabylonLoaderRegistered: boolean;
  58026. /**
  58027. * Helps setting up some configuration for the babylon file loader.
  58028. */
  58029. export class BabylonFileLoaderConfiguration {
  58030. /**
  58031. * The loader does not allow injecting custom physix engine into the plugins.
  58032. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58033. * So you could set this variable to your engine import to make it work.
  58034. */
  58035. static LoaderInjectedPhysicsEngine: any;
  58036. }
  58037. }
  58038. declare module "babylonjs/Loading/Plugins/index" {
  58039. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58040. }
  58041. declare module "babylonjs/Loading/index" {
  58042. export * from "babylonjs/Loading/loadingScreen";
  58043. export * from "babylonjs/Loading/Plugins/index";
  58044. export * from "babylonjs/Loading/sceneLoader";
  58045. export * from "babylonjs/Loading/sceneLoaderFlags";
  58046. }
  58047. declare module "babylonjs/Materials/Background/index" {
  58048. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58049. }
  58050. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58051. import { Scene } from "babylonjs/scene";
  58052. import { Color3 } from "babylonjs/Maths/math.color";
  58053. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58055. /**
  58056. * The Physically based simple base material of BJS.
  58057. *
  58058. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58059. * It is used as the base class for both the specGloss and metalRough conventions.
  58060. */
  58061. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58062. /**
  58063. * Number of Simultaneous lights allowed on the material.
  58064. */
  58065. maxSimultaneousLights: number;
  58066. /**
  58067. * If sets to true, disables all the lights affecting the material.
  58068. */
  58069. disableLighting: boolean;
  58070. /**
  58071. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58072. */
  58073. environmentTexture: BaseTexture;
  58074. /**
  58075. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58076. */
  58077. invertNormalMapX: boolean;
  58078. /**
  58079. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58080. */
  58081. invertNormalMapY: boolean;
  58082. /**
  58083. * Normal map used in the model.
  58084. */
  58085. normalTexture: BaseTexture;
  58086. /**
  58087. * Emissivie color used to self-illuminate the model.
  58088. */
  58089. emissiveColor: Color3;
  58090. /**
  58091. * Emissivie texture used to self-illuminate the model.
  58092. */
  58093. emissiveTexture: BaseTexture;
  58094. /**
  58095. * Occlusion Channel Strenght.
  58096. */
  58097. occlusionStrength: number;
  58098. /**
  58099. * Occlusion Texture of the material (adding extra occlusion effects).
  58100. */
  58101. occlusionTexture: BaseTexture;
  58102. /**
  58103. * Defines the alpha limits in alpha test mode.
  58104. */
  58105. alphaCutOff: number;
  58106. /**
  58107. * Gets the current double sided mode.
  58108. */
  58109. get doubleSided(): boolean;
  58110. /**
  58111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58112. */
  58113. set doubleSided(value: boolean);
  58114. /**
  58115. * Stores the pre-calculated light information of a mesh in a texture.
  58116. */
  58117. lightmapTexture: BaseTexture;
  58118. /**
  58119. * If true, the light map contains occlusion information instead of lighting info.
  58120. */
  58121. useLightmapAsShadowmap: boolean;
  58122. /**
  58123. * Instantiates a new PBRMaterial instance.
  58124. *
  58125. * @param name The material name
  58126. * @param scene The scene the material will be use in.
  58127. */
  58128. constructor(name: string, scene: Scene);
  58129. getClassName(): string;
  58130. }
  58131. }
  58132. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58133. import { Scene } from "babylonjs/scene";
  58134. import { Color3 } from "babylonjs/Maths/math.color";
  58135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58136. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58137. /**
  58138. * The PBR material of BJS following the metal roughness convention.
  58139. *
  58140. * This fits to the PBR convention in the GLTF definition:
  58141. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58142. */
  58143. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58144. /**
  58145. * The base color has two different interpretations depending on the value of metalness.
  58146. * When the material is a metal, the base color is the specific measured reflectance value
  58147. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58148. * of the material.
  58149. */
  58150. baseColor: Color3;
  58151. /**
  58152. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58153. * well as opacity information in the alpha channel.
  58154. */
  58155. baseTexture: BaseTexture;
  58156. /**
  58157. * Specifies the metallic scalar value of the material.
  58158. * Can also be used to scale the metalness values of the metallic texture.
  58159. */
  58160. metallic: number;
  58161. /**
  58162. * Specifies the roughness scalar value of the material.
  58163. * Can also be used to scale the roughness values of the metallic texture.
  58164. */
  58165. roughness: number;
  58166. /**
  58167. * Texture containing both the metallic value in the B channel and the
  58168. * roughness value in the G channel to keep better precision.
  58169. */
  58170. metallicRoughnessTexture: BaseTexture;
  58171. /**
  58172. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58173. *
  58174. * @param name The material name
  58175. * @param scene The scene the material will be use in.
  58176. */
  58177. constructor(name: string, scene: Scene);
  58178. /**
  58179. * Return the currrent class name of the material.
  58180. */
  58181. getClassName(): string;
  58182. /**
  58183. * Makes a duplicate of the current material.
  58184. * @param name - name to use for the new material.
  58185. */
  58186. clone(name: string): PBRMetallicRoughnessMaterial;
  58187. /**
  58188. * Serialize the material to a parsable JSON object.
  58189. */
  58190. serialize(): any;
  58191. /**
  58192. * Parses a JSON object correponding to the serialize function.
  58193. */
  58194. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58195. }
  58196. }
  58197. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58198. import { Scene } from "babylonjs/scene";
  58199. import { Color3 } from "babylonjs/Maths/math.color";
  58200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58201. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58202. /**
  58203. * The PBR material of BJS following the specular glossiness convention.
  58204. *
  58205. * This fits to the PBR convention in the GLTF definition:
  58206. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58207. */
  58208. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58209. /**
  58210. * Specifies the diffuse color of the material.
  58211. */
  58212. diffuseColor: Color3;
  58213. /**
  58214. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58215. * channel.
  58216. */
  58217. diffuseTexture: BaseTexture;
  58218. /**
  58219. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58220. */
  58221. specularColor: Color3;
  58222. /**
  58223. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58224. */
  58225. glossiness: number;
  58226. /**
  58227. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58228. */
  58229. specularGlossinessTexture: BaseTexture;
  58230. /**
  58231. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58232. *
  58233. * @param name The material name
  58234. * @param scene The scene the material will be use in.
  58235. */
  58236. constructor(name: string, scene: Scene);
  58237. /**
  58238. * Return the currrent class name of the material.
  58239. */
  58240. getClassName(): string;
  58241. /**
  58242. * Makes a duplicate of the current material.
  58243. * @param name - name to use for the new material.
  58244. */
  58245. clone(name: string): PBRSpecularGlossinessMaterial;
  58246. /**
  58247. * Serialize the material to a parsable JSON object.
  58248. */
  58249. serialize(): any;
  58250. /**
  58251. * Parses a JSON object correponding to the serialize function.
  58252. */
  58253. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58254. }
  58255. }
  58256. declare module "babylonjs/Materials/PBR/index" {
  58257. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58258. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58259. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58260. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58261. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58262. }
  58263. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58264. import { Nullable } from "babylonjs/types";
  58265. import { Scene } from "babylonjs/scene";
  58266. import { Matrix } from "babylonjs/Maths/math.vector";
  58267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58268. /**
  58269. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58270. * It can help converting any input color in a desired output one. This can then be used to create effects
  58271. * from sepia, black and white to sixties or futuristic rendering...
  58272. *
  58273. * The only supported format is currently 3dl.
  58274. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58275. */
  58276. export class ColorGradingTexture extends BaseTexture {
  58277. /**
  58278. * The current texture matrix. (will always be identity in color grading texture)
  58279. */
  58280. private _textureMatrix;
  58281. /**
  58282. * The texture URL.
  58283. */
  58284. url: string;
  58285. /**
  58286. * Empty line regex stored for GC.
  58287. */
  58288. private static _noneEmptyLineRegex;
  58289. private _engine;
  58290. /**
  58291. * Instantiates a ColorGradingTexture from the following parameters.
  58292. *
  58293. * @param url The location of the color gradind data (currently only supporting 3dl)
  58294. * @param scene The scene the texture will be used in
  58295. */
  58296. constructor(url: string, scene: Scene);
  58297. /**
  58298. * Returns the texture matrix used in most of the material.
  58299. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58300. */
  58301. getTextureMatrix(): Matrix;
  58302. /**
  58303. * Occurs when the file being loaded is a .3dl LUT file.
  58304. */
  58305. private load3dlTexture;
  58306. /**
  58307. * Starts the loading process of the texture.
  58308. */
  58309. private loadTexture;
  58310. /**
  58311. * Clones the color gradind texture.
  58312. */
  58313. clone(): ColorGradingTexture;
  58314. /**
  58315. * Called during delayed load for textures.
  58316. */
  58317. delayLoad(): void;
  58318. /**
  58319. * Parses a color grading texture serialized by Babylon.
  58320. * @param parsedTexture The texture information being parsedTexture
  58321. * @param scene The scene to load the texture in
  58322. * @param rootUrl The root url of the data assets to load
  58323. * @return A color gradind texture
  58324. */
  58325. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58326. /**
  58327. * Serializes the LUT texture to json format.
  58328. */
  58329. serialize(): any;
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58334. import { Scene } from "babylonjs/scene";
  58335. import { Nullable } from "babylonjs/types";
  58336. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58337. /**
  58338. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58339. */
  58340. export class EquiRectangularCubeTexture extends BaseTexture {
  58341. /** The six faces of the cube. */
  58342. private static _FacesMapping;
  58343. private _noMipmap;
  58344. private _onLoad;
  58345. private _onError;
  58346. /** The size of the cubemap. */
  58347. private _size;
  58348. /** The buffer of the image. */
  58349. private _buffer;
  58350. /** The width of the input image. */
  58351. private _width;
  58352. /** The height of the input image. */
  58353. private _height;
  58354. /** The URL to the image. */
  58355. url: string;
  58356. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58357. coordinatesMode: number;
  58358. /**
  58359. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58360. * @param url The location of the image
  58361. * @param scene The scene the texture will be used in
  58362. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58363. * @param noMipmap Forces to not generate the mipmap if true
  58364. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58365. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58366. * @param onLoad — defines a callback called when texture is loaded
  58367. * @param onError — defines a callback called if there is an error
  58368. */
  58369. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58370. /**
  58371. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58372. */
  58373. private loadImage;
  58374. /**
  58375. * Convert the image buffer into a cubemap and create a CubeTexture.
  58376. */
  58377. private loadTexture;
  58378. /**
  58379. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58380. * @param buffer The ArrayBuffer that should be converted.
  58381. * @returns The buffer as Float32Array.
  58382. */
  58383. private getFloat32ArrayFromArrayBuffer;
  58384. /**
  58385. * Get the current class name of the texture useful for serialization or dynamic coding.
  58386. * @returns "EquiRectangularCubeTexture"
  58387. */
  58388. getClassName(): string;
  58389. /**
  58390. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58391. * @returns A clone of the current EquiRectangularCubeTexture.
  58392. */
  58393. clone(): EquiRectangularCubeTexture;
  58394. }
  58395. }
  58396. declare module "babylonjs/Misc/tga" {
  58397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58398. /**
  58399. * Based on jsTGALoader - Javascript loader for TGA file
  58400. * By Vincent Thibault
  58401. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58402. */
  58403. export class TGATools {
  58404. private static _TYPE_INDEXED;
  58405. private static _TYPE_RGB;
  58406. private static _TYPE_GREY;
  58407. private static _TYPE_RLE_INDEXED;
  58408. private static _TYPE_RLE_RGB;
  58409. private static _TYPE_RLE_GREY;
  58410. private static _ORIGIN_MASK;
  58411. private static _ORIGIN_SHIFT;
  58412. private static _ORIGIN_BL;
  58413. private static _ORIGIN_BR;
  58414. private static _ORIGIN_UL;
  58415. private static _ORIGIN_UR;
  58416. /**
  58417. * Gets the header of a TGA file
  58418. * @param data defines the TGA data
  58419. * @returns the header
  58420. */
  58421. static GetTGAHeader(data: Uint8Array): any;
  58422. /**
  58423. * Uploads TGA content to a Babylon Texture
  58424. * @hidden
  58425. */
  58426. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58427. /** @hidden */
  58428. 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;
  58429. /** @hidden */
  58430. 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;
  58431. /** @hidden */
  58432. 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;
  58433. /** @hidden */
  58434. 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;
  58435. /** @hidden */
  58436. 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;
  58437. /** @hidden */
  58438. 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;
  58439. }
  58440. }
  58441. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58442. import { Nullable } from "babylonjs/types";
  58443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58444. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58445. /**
  58446. * Implementation of the TGA Texture Loader.
  58447. * @hidden
  58448. */
  58449. export class _TGATextureLoader implements IInternalTextureLoader {
  58450. /**
  58451. * Defines wether the loader supports cascade loading the different faces.
  58452. */
  58453. readonly supportCascades: boolean;
  58454. /**
  58455. * This returns if the loader support the current file information.
  58456. * @param extension defines the file extension of the file being loaded
  58457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58458. * @param fallback defines the fallback internal texture if any
  58459. * @param isBase64 defines whether the texture is encoded as a base64
  58460. * @param isBuffer defines whether the texture data are stored as a buffer
  58461. * @returns true if the loader can load the specified file
  58462. */
  58463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58464. /**
  58465. * Transform the url before loading if required.
  58466. * @param rootUrl the url of the texture
  58467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58468. * @returns the transformed texture
  58469. */
  58470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58471. /**
  58472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58473. * @param rootUrl the url of the texture
  58474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58475. * @returns the fallback texture
  58476. */
  58477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58478. /**
  58479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58480. * @param data contains the texture data
  58481. * @param texture defines the BabylonJS internal texture
  58482. * @param createPolynomials will be true if polynomials have been requested
  58483. * @param onLoad defines the callback to trigger once the texture is ready
  58484. * @param onError defines the callback to trigger in case of error
  58485. */
  58486. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58487. /**
  58488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58489. * @param data contains the texture data
  58490. * @param texture defines the BabylonJS internal texture
  58491. * @param callback defines the method to call once ready to upload
  58492. */
  58493. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58494. }
  58495. }
  58496. declare module "babylonjs/Misc/basis" {
  58497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58498. /**
  58499. * Info about the .basis files
  58500. */
  58501. class BasisFileInfo {
  58502. /**
  58503. * If the file has alpha
  58504. */
  58505. hasAlpha: boolean;
  58506. /**
  58507. * Info about each image of the basis file
  58508. */
  58509. images: Array<{
  58510. levels: Array<{
  58511. width: number;
  58512. height: number;
  58513. transcodedPixels: ArrayBufferView;
  58514. }>;
  58515. }>;
  58516. }
  58517. /**
  58518. * Result of transcoding a basis file
  58519. */
  58520. class TranscodeResult {
  58521. /**
  58522. * Info about the .basis file
  58523. */
  58524. fileInfo: BasisFileInfo;
  58525. /**
  58526. * Format to use when loading the file
  58527. */
  58528. format: number;
  58529. }
  58530. /**
  58531. * Configuration options for the Basis transcoder
  58532. */
  58533. export class BasisTranscodeConfiguration {
  58534. /**
  58535. * Supported compression formats used to determine the supported output format of the transcoder
  58536. */
  58537. supportedCompressionFormats?: {
  58538. /**
  58539. * etc1 compression format
  58540. */
  58541. etc1?: boolean;
  58542. /**
  58543. * s3tc compression format
  58544. */
  58545. s3tc?: boolean;
  58546. /**
  58547. * pvrtc compression format
  58548. */
  58549. pvrtc?: boolean;
  58550. /**
  58551. * etc2 compression format
  58552. */
  58553. etc2?: boolean;
  58554. };
  58555. /**
  58556. * If mipmap levels should be loaded for transcoded images (Default: true)
  58557. */
  58558. loadMipmapLevels?: boolean;
  58559. /**
  58560. * Index of a single image to load (Default: all images)
  58561. */
  58562. loadSingleImage?: number;
  58563. }
  58564. /**
  58565. * Used to load .Basis files
  58566. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58567. */
  58568. export class BasisTools {
  58569. private static _IgnoreSupportedFormats;
  58570. /**
  58571. * URL to use when loading the basis transcoder
  58572. */
  58573. static JSModuleURL: string;
  58574. /**
  58575. * URL to use when loading the wasm module for the transcoder
  58576. */
  58577. static WasmModuleURL: string;
  58578. /**
  58579. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58580. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58581. * @returns internal format corresponding to the Basis format
  58582. */
  58583. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58584. private static _WorkerPromise;
  58585. private static _Worker;
  58586. private static _actionId;
  58587. private static _CreateWorkerAsync;
  58588. /**
  58589. * Transcodes a loaded image file to compressed pixel data
  58590. * @param data image data to transcode
  58591. * @param config configuration options for the transcoding
  58592. * @returns a promise resulting in the transcoded image
  58593. */
  58594. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58595. /**
  58596. * Loads a texture from the transcode result
  58597. * @param texture texture load to
  58598. * @param transcodeResult the result of transcoding the basis file to load from
  58599. */
  58600. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58601. }
  58602. }
  58603. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58604. import { Nullable } from "babylonjs/types";
  58605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58606. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58607. /**
  58608. * Loader for .basis file format
  58609. */
  58610. export class _BasisTextureLoader implements IInternalTextureLoader {
  58611. /**
  58612. * Defines whether the loader supports cascade loading the different faces.
  58613. */
  58614. readonly supportCascades: boolean;
  58615. /**
  58616. * This returns if the loader support the current file information.
  58617. * @param extension defines the file extension of the file being loaded
  58618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58619. * @param fallback defines the fallback internal texture if any
  58620. * @param isBase64 defines whether the texture is encoded as a base64
  58621. * @param isBuffer defines whether the texture data are stored as a buffer
  58622. * @returns true if the loader can load the specified file
  58623. */
  58624. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58625. /**
  58626. * Transform the url before loading if required.
  58627. * @param rootUrl the url of the texture
  58628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58629. * @returns the transformed texture
  58630. */
  58631. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58632. /**
  58633. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58634. * @param rootUrl the url of the texture
  58635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58636. * @returns the fallback texture
  58637. */
  58638. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58639. /**
  58640. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58641. * @param data contains the texture data
  58642. * @param texture defines the BabylonJS internal texture
  58643. * @param createPolynomials will be true if polynomials have been requested
  58644. * @param onLoad defines the callback to trigger once the texture is ready
  58645. * @param onError defines the callback to trigger in case of error
  58646. */
  58647. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58648. /**
  58649. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58650. * @param data contains the texture data
  58651. * @param texture defines the BabylonJS internal texture
  58652. * @param callback defines the method to call once ready to upload
  58653. */
  58654. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58655. }
  58656. }
  58657. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58658. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58659. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58660. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58661. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58662. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58663. }
  58664. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58665. import { Scene } from "babylonjs/scene";
  58666. import { Texture } from "babylonjs/Materials/Textures/texture";
  58667. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58668. /**
  58669. * 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.
  58670. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58672. */
  58673. export class CustomProceduralTexture extends ProceduralTexture {
  58674. private _animate;
  58675. private _time;
  58676. private _config;
  58677. private _texturePath;
  58678. /**
  58679. * Instantiates a new Custom Procedural Texture.
  58680. * 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.
  58681. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58682. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58683. * @param name Define the name of the texture
  58684. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58685. * @param size Define the size of the texture to create
  58686. * @param scene Define the scene the texture belongs to
  58687. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58688. * @param generateMipMaps Define if the texture should creates mip maps or not
  58689. */
  58690. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58691. private _loadJson;
  58692. /**
  58693. * Is the texture ready to be used ? (rendered at least once)
  58694. * @returns true if ready, otherwise, false.
  58695. */
  58696. isReady(): boolean;
  58697. /**
  58698. * Render the texture to its associated render target.
  58699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58700. */
  58701. render(useCameraPostProcess?: boolean): void;
  58702. /**
  58703. * Update the list of dependant textures samplers in the shader.
  58704. */
  58705. updateTextures(): void;
  58706. /**
  58707. * Update the uniform values of the procedural texture in the shader.
  58708. */
  58709. updateShaderUniforms(): void;
  58710. /**
  58711. * Define if the texture animates or not.
  58712. */
  58713. get animate(): boolean;
  58714. set animate(value: boolean);
  58715. }
  58716. }
  58717. declare module "babylonjs/Shaders/noise.fragment" {
  58718. /** @hidden */
  58719. export var noisePixelShader: {
  58720. name: string;
  58721. shader: string;
  58722. };
  58723. }
  58724. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58725. import { Nullable } from "babylonjs/types";
  58726. import { Scene } from "babylonjs/scene";
  58727. import { Texture } from "babylonjs/Materials/Textures/texture";
  58728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58729. import "babylonjs/Shaders/noise.fragment";
  58730. /**
  58731. * Class used to generate noise procedural textures
  58732. */
  58733. export class NoiseProceduralTexture extends ProceduralTexture {
  58734. private _time;
  58735. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58736. brightness: number;
  58737. /** Defines the number of octaves to process */
  58738. octaves: number;
  58739. /** Defines the level of persistence (0.8 by default) */
  58740. persistence: number;
  58741. /** Gets or sets animation speed factor (default is 1) */
  58742. animationSpeedFactor: number;
  58743. /**
  58744. * Creates a new NoiseProceduralTexture
  58745. * @param name defines the name fo the texture
  58746. * @param size defines the size of the texture (default is 256)
  58747. * @param scene defines the hosting scene
  58748. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58749. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58750. */
  58751. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58752. private _updateShaderUniforms;
  58753. protected _getDefines(): string;
  58754. /** Generate the current state of the procedural texture */
  58755. render(useCameraPostProcess?: boolean): void;
  58756. /**
  58757. * Serializes this noise procedural texture
  58758. * @returns a serialized noise procedural texture object
  58759. */
  58760. serialize(): any;
  58761. /**
  58762. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58763. * @param parsedTexture defines parsed texture data
  58764. * @param scene defines the current scene
  58765. * @param rootUrl defines the root URL containing noise procedural texture information
  58766. * @returns a parsed NoiseProceduralTexture
  58767. */
  58768. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58769. }
  58770. }
  58771. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58772. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58773. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58774. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58775. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58776. }
  58777. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58778. import { Nullable } from "babylonjs/types";
  58779. import { Scene } from "babylonjs/scene";
  58780. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58781. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58782. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58783. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58784. /**
  58785. * Raw cube texture where the raw buffers are passed in
  58786. */
  58787. export class RawCubeTexture extends CubeTexture {
  58788. /**
  58789. * Creates a cube texture where the raw buffers are passed in.
  58790. * @param scene defines the scene the texture is attached to
  58791. * @param data defines the array of data to use to create each face
  58792. * @param size defines the size of the textures
  58793. * @param format defines the format of the data
  58794. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58795. * @param generateMipMaps defines if the engine should generate the mip levels
  58796. * @param invertY defines if data must be stored with Y axis inverted
  58797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58798. * @param compression defines the compression used (null by default)
  58799. */
  58800. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58801. /**
  58802. * Updates the raw cube texture.
  58803. * @param data defines the data to store
  58804. * @param format defines the data format
  58805. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58806. * @param invertY defines if data must be stored with Y axis inverted
  58807. * @param compression defines the compression used (null by default)
  58808. * @param level defines which level of the texture to update
  58809. */
  58810. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58811. /**
  58812. * Updates a raw cube texture with RGBD encoded data.
  58813. * @param data defines the array of data [mipmap][face] to use to create each face
  58814. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58817. * @returns a promsie that resolves when the operation is complete
  58818. */
  58819. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58820. /**
  58821. * Clones the raw cube texture.
  58822. * @return a new cube texture
  58823. */
  58824. clone(): CubeTexture;
  58825. /** @hidden */
  58826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58827. }
  58828. }
  58829. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58830. import { Scene } from "babylonjs/scene";
  58831. import { Texture } from "babylonjs/Materials/Textures/texture";
  58832. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58833. /**
  58834. * Class used to store 3D textures containing user data
  58835. */
  58836. export class RawTexture3D extends Texture {
  58837. /** Gets or sets the texture format to use */
  58838. format: number;
  58839. private _engine;
  58840. /**
  58841. * Create a new RawTexture3D
  58842. * @param data defines the data of the texture
  58843. * @param width defines the width of the texture
  58844. * @param height defines the height of the texture
  58845. * @param depth defines the depth of the texture
  58846. * @param format defines the texture format to use
  58847. * @param scene defines the hosting scene
  58848. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58849. * @param invertY defines if texture must be stored with Y axis inverted
  58850. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58851. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58852. */
  58853. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58854. /** Gets or sets the texture format to use */
  58855. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58856. /**
  58857. * Update the texture with new data
  58858. * @param data defines the data to store in the texture
  58859. */
  58860. update(data: ArrayBufferView): void;
  58861. }
  58862. }
  58863. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58864. import { Scene } from "babylonjs/scene";
  58865. import { Texture } from "babylonjs/Materials/Textures/texture";
  58866. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58867. /**
  58868. * Class used to store 2D array textures containing user data
  58869. */
  58870. export class RawTexture2DArray extends Texture {
  58871. /** Gets or sets the texture format to use */
  58872. format: number;
  58873. private _engine;
  58874. /**
  58875. * Create a new RawTexture2DArray
  58876. * @param data defines the data of the texture
  58877. * @param width defines the width of the texture
  58878. * @param height defines the height of the texture
  58879. * @param depth defines the number of layers of the texture
  58880. * @param format defines the texture format to use
  58881. * @param scene defines the hosting scene
  58882. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58883. * @param invertY defines if texture must be stored with Y axis inverted
  58884. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58885. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58886. */
  58887. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58888. /** Gets or sets the texture format to use */
  58889. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58890. /**
  58891. * Update the texture with new data
  58892. * @param data defines the data to store in the texture
  58893. */
  58894. update(data: ArrayBufferView): void;
  58895. }
  58896. }
  58897. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58898. import { Scene } from "babylonjs/scene";
  58899. import { Plane } from "babylonjs/Maths/math.plane";
  58900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58901. /**
  58902. * Creates a refraction texture used by refraction channel of the standard material.
  58903. * It is like a mirror but to see through a material.
  58904. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58905. */
  58906. export class RefractionTexture extends RenderTargetTexture {
  58907. /**
  58908. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58909. * 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.
  58910. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58911. */
  58912. refractionPlane: Plane;
  58913. /**
  58914. * Define how deep under the surface we should see.
  58915. */
  58916. depth: number;
  58917. /**
  58918. * Creates a refraction texture used by refraction channel of the standard material.
  58919. * It is like a mirror but to see through a material.
  58920. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58921. * @param name Define the texture name
  58922. * @param size Define the size of the underlying texture
  58923. * @param scene Define the scene the refraction belongs to
  58924. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58925. */
  58926. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58927. /**
  58928. * Clone the refraction texture.
  58929. * @returns the cloned texture
  58930. */
  58931. clone(): RefractionTexture;
  58932. /**
  58933. * Serialize the texture to a JSON representation you could use in Parse later on
  58934. * @returns the serialized JSON representation
  58935. */
  58936. serialize(): any;
  58937. }
  58938. }
  58939. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58940. import { Nullable } from "babylonjs/types";
  58941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58942. import { Matrix } from "babylonjs/Maths/math.vector";
  58943. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58944. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58945. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58946. import { Scene } from "babylonjs/scene";
  58947. /**
  58948. * Defines the options related to the creation of an HtmlElementTexture
  58949. */
  58950. export interface IHtmlElementTextureOptions {
  58951. /**
  58952. * Defines wether mip maps should be created or not.
  58953. */
  58954. generateMipMaps?: boolean;
  58955. /**
  58956. * Defines the sampling mode of the texture.
  58957. */
  58958. samplingMode?: number;
  58959. /**
  58960. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58961. */
  58962. engine: Nullable<ThinEngine>;
  58963. /**
  58964. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58965. */
  58966. scene: Nullable<Scene>;
  58967. }
  58968. /**
  58969. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58970. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58971. * is automatically managed.
  58972. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58973. * in your application.
  58974. *
  58975. * As the update is not automatic, you need to call them manually.
  58976. */
  58977. export class HtmlElementTexture extends BaseTexture {
  58978. /**
  58979. * The texture URL.
  58980. */
  58981. element: HTMLVideoElement | HTMLCanvasElement;
  58982. private static readonly DefaultOptions;
  58983. private _textureMatrix;
  58984. private _engine;
  58985. private _isVideo;
  58986. private _generateMipMaps;
  58987. private _samplingMode;
  58988. /**
  58989. * Instantiates a HtmlElementTexture from the following parameters.
  58990. *
  58991. * @param name Defines the name of the texture
  58992. * @param element Defines the video or canvas the texture is filled with
  58993. * @param options Defines the other none mandatory texture creation options
  58994. */
  58995. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58996. private _createInternalTexture;
  58997. /**
  58998. * Returns the texture matrix used in most of the material.
  58999. */
  59000. getTextureMatrix(): Matrix;
  59001. /**
  59002. * Updates the content of the texture.
  59003. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59004. */
  59005. update(invertY?: Nullable<boolean>): void;
  59006. }
  59007. }
  59008. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59009. import { Vector2 } from "babylonjs/Maths/math.vector";
  59010. /**
  59011. * Defines the basic options interface of a TexturePacker Frame
  59012. */
  59013. export interface ITexturePackerFrame {
  59014. /**
  59015. * The frame ID
  59016. */
  59017. id: number;
  59018. /**
  59019. * The frames Scale
  59020. */
  59021. scale: Vector2;
  59022. /**
  59023. * The Frames offset
  59024. */
  59025. offset: Vector2;
  59026. }
  59027. /**
  59028. * This is a support class for frame Data on texture packer sets.
  59029. */
  59030. export class TexturePackerFrame implements ITexturePackerFrame {
  59031. /**
  59032. * The frame ID
  59033. */
  59034. id: number;
  59035. /**
  59036. * The frames Scale
  59037. */
  59038. scale: Vector2;
  59039. /**
  59040. * The Frames offset
  59041. */
  59042. offset: Vector2;
  59043. /**
  59044. * Initializes a texture package frame.
  59045. * @param id The numerical frame identifier
  59046. * @param scale Scalar Vector2 for UV frame
  59047. * @param offset Vector2 for the frame position in UV units.
  59048. * @returns TexturePackerFrame
  59049. */
  59050. constructor(id: number, scale: Vector2, offset: Vector2);
  59051. }
  59052. }
  59053. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59055. import { Scene } from "babylonjs/scene";
  59056. import { Nullable } from "babylonjs/types";
  59057. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59058. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59059. /**
  59060. * Defines the basic options interface of a TexturePacker
  59061. */
  59062. export interface ITexturePackerOptions {
  59063. /**
  59064. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59065. */
  59066. map?: string[];
  59067. /**
  59068. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59069. */
  59070. uvsIn?: string;
  59071. /**
  59072. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59073. */
  59074. uvsOut?: string;
  59075. /**
  59076. * number representing the layout style. Defaults to LAYOUT_STRIP
  59077. */
  59078. layout?: number;
  59079. /**
  59080. * number of columns if using custom column count layout(2). This defaults to 4.
  59081. */
  59082. colnum?: number;
  59083. /**
  59084. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59085. */
  59086. updateInputMeshes?: boolean;
  59087. /**
  59088. * boolean flag to dispose all the source textures. Defaults to true.
  59089. */
  59090. disposeSources?: boolean;
  59091. /**
  59092. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59093. */
  59094. fillBlanks?: boolean;
  59095. /**
  59096. * string value representing the context fill style color. Defaults to 'black'.
  59097. */
  59098. customFillColor?: string;
  59099. /**
  59100. * Width and Height Value of each Frame in the TexturePacker Sets
  59101. */
  59102. frameSize?: number;
  59103. /**
  59104. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59105. */
  59106. paddingRatio?: number;
  59107. /**
  59108. * Number that declares the fill method for the padding gutter.
  59109. */
  59110. paddingMode?: number;
  59111. /**
  59112. * If in SUBUV_COLOR padding mode what color to use.
  59113. */
  59114. paddingColor?: Color3 | Color4;
  59115. }
  59116. /**
  59117. * Defines the basic interface of a TexturePacker JSON File
  59118. */
  59119. export interface ITexturePackerJSON {
  59120. /**
  59121. * The frame ID
  59122. */
  59123. name: string;
  59124. /**
  59125. * The base64 channel data
  59126. */
  59127. sets: any;
  59128. /**
  59129. * The options of the Packer
  59130. */
  59131. options: ITexturePackerOptions;
  59132. /**
  59133. * The frame data of the Packer
  59134. */
  59135. frames: Array<number>;
  59136. }
  59137. /**
  59138. * This is a support class that generates a series of packed texture sets.
  59139. * @see https://doc.babylonjs.com/babylon101/materials
  59140. */
  59141. export class TexturePacker {
  59142. /** Packer Layout Constant 0 */
  59143. static readonly LAYOUT_STRIP: number;
  59144. /** Packer Layout Constant 1 */
  59145. static readonly LAYOUT_POWER2: number;
  59146. /** Packer Layout Constant 2 */
  59147. static readonly LAYOUT_COLNUM: number;
  59148. /** Packer Layout Constant 0 */
  59149. static readonly SUBUV_WRAP: number;
  59150. /** Packer Layout Constant 1 */
  59151. static readonly SUBUV_EXTEND: number;
  59152. /** Packer Layout Constant 2 */
  59153. static readonly SUBUV_COLOR: number;
  59154. /** The Name of the Texture Package */
  59155. name: string;
  59156. /** The scene scope of the TexturePacker */
  59157. scene: Scene;
  59158. /** The Meshes to target */
  59159. meshes: AbstractMesh[];
  59160. /** Arguments passed with the Constructor */
  59161. options: ITexturePackerOptions;
  59162. /** The promise that is started upon initialization */
  59163. promise: Nullable<Promise<TexturePacker | string>>;
  59164. /** The Container object for the channel sets that are generated */
  59165. sets: object;
  59166. /** The Container array for the frames that are generated */
  59167. frames: TexturePackerFrame[];
  59168. /** The expected number of textures the system is parsing. */
  59169. private _expecting;
  59170. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59171. private _paddingValue;
  59172. /**
  59173. * Initializes a texture package series from an array of meshes or a single mesh.
  59174. * @param name The name of the package
  59175. * @param meshes The target meshes to compose the package from
  59176. * @param options The arguments that texture packer should follow while building.
  59177. * @param scene The scene which the textures are scoped to.
  59178. * @returns TexturePacker
  59179. */
  59180. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59181. /**
  59182. * Starts the package process
  59183. * @param resolve The promises resolution function
  59184. * @returns TexturePacker
  59185. */
  59186. private _createFrames;
  59187. /**
  59188. * Calculates the Size of the Channel Sets
  59189. * @returns Vector2
  59190. */
  59191. private _calculateSize;
  59192. /**
  59193. * Calculates the UV data for the frames.
  59194. * @param baseSize the base frameSize
  59195. * @param padding the base frame padding
  59196. * @param dtSize size of the Dynamic Texture for that channel
  59197. * @param dtUnits is 1/dtSize
  59198. * @param update flag to update the input meshes
  59199. */
  59200. private _calculateMeshUVFrames;
  59201. /**
  59202. * Calculates the frames Offset.
  59203. * @param index of the frame
  59204. * @returns Vector2
  59205. */
  59206. private _getFrameOffset;
  59207. /**
  59208. * Updates a Mesh to the frame data
  59209. * @param mesh that is the target
  59210. * @param frameID or the frame index
  59211. */
  59212. private _updateMeshUV;
  59213. /**
  59214. * Updates a Meshes materials to use the texture packer channels
  59215. * @param m is the mesh to target
  59216. * @param force all channels on the packer to be set.
  59217. */
  59218. private _updateTextureReferences;
  59219. /**
  59220. * Public method to set a Mesh to a frame
  59221. * @param m that is the target
  59222. * @param frameID or the frame index
  59223. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59224. */
  59225. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59226. /**
  59227. * Starts the async promise to compile the texture packer.
  59228. * @returns Promise<void>
  59229. */
  59230. processAsync(): Promise<void>;
  59231. /**
  59232. * Disposes all textures associated with this packer
  59233. */
  59234. dispose(): void;
  59235. /**
  59236. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59237. * @param imageType is the image type to use.
  59238. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59239. */
  59240. download(imageType?: string, quality?: number): void;
  59241. /**
  59242. * Public method to load a texturePacker JSON file.
  59243. * @param data of the JSON file in string format.
  59244. */
  59245. updateFromJSON(data: string): void;
  59246. }
  59247. }
  59248. declare module "babylonjs/Materials/Textures/Packer/index" {
  59249. export * from "babylonjs/Materials/Textures/Packer/packer";
  59250. export * from "babylonjs/Materials/Textures/Packer/frame";
  59251. }
  59252. declare module "babylonjs/Materials/Textures/index" {
  59253. export * from "babylonjs/Materials/Textures/baseTexture";
  59254. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59255. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59256. export * from "babylonjs/Materials/Textures/cubeTexture";
  59257. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59258. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59259. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59260. export * from "babylonjs/Materials/Textures/internalTexture";
  59261. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59262. export * from "babylonjs/Materials/Textures/Loaders/index";
  59263. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59264. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59265. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59266. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59267. export * from "babylonjs/Materials/Textures/rawTexture";
  59268. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59269. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59270. export * from "babylonjs/Materials/Textures/refractionTexture";
  59271. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59272. export * from "babylonjs/Materials/Textures/texture";
  59273. export * from "babylonjs/Materials/Textures/videoTexture";
  59274. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59275. export * from "babylonjs/Materials/Textures/Packer/index";
  59276. }
  59277. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59278. /**
  59279. * Enum used to define the target of a block
  59280. */
  59281. export enum NodeMaterialBlockTargets {
  59282. /** Vertex shader */
  59283. Vertex = 1,
  59284. /** Fragment shader */
  59285. Fragment = 2,
  59286. /** Neutral */
  59287. Neutral = 4,
  59288. /** Vertex and Fragment */
  59289. VertexAndFragment = 3
  59290. }
  59291. }
  59292. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59293. /**
  59294. * Defines the kind of connection point for node based material
  59295. */
  59296. export enum NodeMaterialBlockConnectionPointTypes {
  59297. /** Float */
  59298. Float = 1,
  59299. /** Int */
  59300. Int = 2,
  59301. /** Vector2 */
  59302. Vector2 = 4,
  59303. /** Vector3 */
  59304. Vector3 = 8,
  59305. /** Vector4 */
  59306. Vector4 = 16,
  59307. /** Color3 */
  59308. Color3 = 32,
  59309. /** Color4 */
  59310. Color4 = 64,
  59311. /** Matrix */
  59312. Matrix = 128,
  59313. /** Detect type based on connection */
  59314. AutoDetect = 1024,
  59315. /** Output type that will be defined by input type */
  59316. BasedOnInput = 2048
  59317. }
  59318. }
  59319. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59320. /**
  59321. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59322. */
  59323. export enum NodeMaterialBlockConnectionPointMode {
  59324. /** Value is an uniform */
  59325. Uniform = 0,
  59326. /** Value is a mesh attribute */
  59327. Attribute = 1,
  59328. /** Value is a varying between vertex and fragment shaders */
  59329. Varying = 2,
  59330. /** Mode is undefined */
  59331. Undefined = 3
  59332. }
  59333. }
  59334. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59335. /**
  59336. * Enum used to define system values e.g. values automatically provided by the system
  59337. */
  59338. export enum NodeMaterialSystemValues {
  59339. /** World */
  59340. World = 1,
  59341. /** View */
  59342. View = 2,
  59343. /** Projection */
  59344. Projection = 3,
  59345. /** ViewProjection */
  59346. ViewProjection = 4,
  59347. /** WorldView */
  59348. WorldView = 5,
  59349. /** WorldViewProjection */
  59350. WorldViewProjection = 6,
  59351. /** CameraPosition */
  59352. CameraPosition = 7,
  59353. /** Fog Color */
  59354. FogColor = 8,
  59355. /** Delta time */
  59356. DeltaTime = 9
  59357. }
  59358. }
  59359. declare module "babylonjs/Materials/Node/Enums/index" {
  59360. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59361. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59362. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59363. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59364. }
  59365. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59367. /**
  59368. * Root class for all node material optimizers
  59369. */
  59370. export class NodeMaterialOptimizer {
  59371. /**
  59372. * Function used to optimize a NodeMaterial graph
  59373. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59374. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59375. */
  59376. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59377. }
  59378. }
  59379. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59383. import { Scene } from "babylonjs/scene";
  59384. /**
  59385. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59386. */
  59387. export class TransformBlock extends NodeMaterialBlock {
  59388. /**
  59389. * Defines the value to use to complement W value to transform it to a Vector4
  59390. */
  59391. complementW: number;
  59392. /**
  59393. * Defines the value to use to complement z value to transform it to a Vector4
  59394. */
  59395. complementZ: number;
  59396. /**
  59397. * Creates a new TransformBlock
  59398. * @param name defines the block name
  59399. */
  59400. constructor(name: string);
  59401. /**
  59402. * Gets the current class name
  59403. * @returns the class name
  59404. */
  59405. getClassName(): string;
  59406. /**
  59407. * Gets the vector input
  59408. */
  59409. get vector(): NodeMaterialConnectionPoint;
  59410. /**
  59411. * Gets the output component
  59412. */
  59413. get output(): NodeMaterialConnectionPoint;
  59414. /**
  59415. * Gets the matrix transform input
  59416. */
  59417. get transform(): NodeMaterialConnectionPoint;
  59418. protected _buildBlock(state: NodeMaterialBuildState): this;
  59419. serialize(): any;
  59420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59421. protected _dumpPropertiesCode(): string;
  59422. }
  59423. }
  59424. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59428. /**
  59429. * Block used to output the vertex position
  59430. */
  59431. export class VertexOutputBlock extends NodeMaterialBlock {
  59432. /**
  59433. * Creates a new VertexOutputBlock
  59434. * @param name defines the block name
  59435. */
  59436. constructor(name: string);
  59437. /**
  59438. * Gets the current class name
  59439. * @returns the class name
  59440. */
  59441. getClassName(): string;
  59442. /**
  59443. * Gets the vector input component
  59444. */
  59445. get vector(): NodeMaterialConnectionPoint;
  59446. protected _buildBlock(state: NodeMaterialBuildState): this;
  59447. }
  59448. }
  59449. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59453. /**
  59454. * Block used to output the final color
  59455. */
  59456. export class FragmentOutputBlock extends NodeMaterialBlock {
  59457. /**
  59458. * Create a new FragmentOutputBlock
  59459. * @param name defines the block name
  59460. */
  59461. constructor(name: string);
  59462. /**
  59463. * Gets the current class name
  59464. * @returns the class name
  59465. */
  59466. getClassName(): string;
  59467. /**
  59468. * Gets the rgba input component
  59469. */
  59470. get rgba(): NodeMaterialConnectionPoint;
  59471. /**
  59472. * Gets the rgb input component
  59473. */
  59474. get rgb(): NodeMaterialConnectionPoint;
  59475. /**
  59476. * Gets the a input component
  59477. */
  59478. get a(): NodeMaterialConnectionPoint;
  59479. protected _buildBlock(state: NodeMaterialBuildState): this;
  59480. }
  59481. }
  59482. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59488. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59489. import { Effect } from "babylonjs/Materials/effect";
  59490. import { Mesh } from "babylonjs/Meshes/mesh";
  59491. import { Nullable } from "babylonjs/types";
  59492. import { Scene } from "babylonjs/scene";
  59493. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59494. /**
  59495. * Block used to read a reflection texture from a sampler
  59496. */
  59497. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59498. private _define3DName;
  59499. private _defineCubicName;
  59500. private _defineExplicitName;
  59501. private _defineProjectionName;
  59502. private _defineLocalCubicName;
  59503. private _defineSphericalName;
  59504. private _definePlanarName;
  59505. private _defineEquirectangularName;
  59506. private _defineMirroredEquirectangularFixedName;
  59507. private _defineEquirectangularFixedName;
  59508. private _defineSkyboxName;
  59509. private _cubeSamplerName;
  59510. private _2DSamplerName;
  59511. private _positionUVWName;
  59512. private _directionWName;
  59513. private _reflectionCoordsName;
  59514. private _reflection2DCoordsName;
  59515. private _reflectionColorName;
  59516. private _reflectionMatrixName;
  59517. /**
  59518. * Gets or sets the texture associated with the node
  59519. */
  59520. texture: Nullable<BaseTexture>;
  59521. /**
  59522. * Create a new TextureBlock
  59523. * @param name defines the block name
  59524. */
  59525. constructor(name: string);
  59526. /**
  59527. * Gets the current class name
  59528. * @returns the class name
  59529. */
  59530. getClassName(): string;
  59531. /**
  59532. * Gets the world position input component
  59533. */
  59534. get position(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the world position input component
  59537. */
  59538. get worldPosition(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the world normal input component
  59541. */
  59542. get worldNormal(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the world input component
  59545. */
  59546. get world(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the camera (or eye) position component
  59549. */
  59550. get cameraPosition(): NodeMaterialConnectionPoint;
  59551. /**
  59552. * Gets the view input component
  59553. */
  59554. get view(): NodeMaterialConnectionPoint;
  59555. /**
  59556. * Gets the rgb output component
  59557. */
  59558. get rgb(): NodeMaterialConnectionPoint;
  59559. /**
  59560. * Gets the r output component
  59561. */
  59562. get r(): NodeMaterialConnectionPoint;
  59563. /**
  59564. * Gets the g output component
  59565. */
  59566. get g(): NodeMaterialConnectionPoint;
  59567. /**
  59568. * Gets the b output component
  59569. */
  59570. get b(): NodeMaterialConnectionPoint;
  59571. autoConfigure(material: NodeMaterial): void;
  59572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59573. isReady(): boolean;
  59574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59575. private _injectVertexCode;
  59576. private _writeOutput;
  59577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59578. protected _dumpPropertiesCode(): string;
  59579. serialize(): any;
  59580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59581. }
  59582. }
  59583. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59585. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59586. import { Scene } from "babylonjs/scene";
  59587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59588. import { Matrix } from "babylonjs/Maths/math.vector";
  59589. import { Mesh } from "babylonjs/Meshes/mesh";
  59590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59591. import { Observable } from "babylonjs/Misc/observable";
  59592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59593. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59594. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59595. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59596. import { Nullable } from "babylonjs/types";
  59597. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59598. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59599. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59600. /**
  59601. * Interface used to configure the node material editor
  59602. */
  59603. export interface INodeMaterialEditorOptions {
  59604. /** Define the URl to load node editor script */
  59605. editorURL?: string;
  59606. }
  59607. /** @hidden */
  59608. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59609. NORMAL: boolean;
  59610. TANGENT: boolean;
  59611. UV1: boolean;
  59612. /** BONES */
  59613. NUM_BONE_INFLUENCERS: number;
  59614. BonesPerMesh: number;
  59615. BONETEXTURE: boolean;
  59616. /** MORPH TARGETS */
  59617. MORPHTARGETS: boolean;
  59618. MORPHTARGETS_NORMAL: boolean;
  59619. MORPHTARGETS_TANGENT: boolean;
  59620. MORPHTARGETS_UV: boolean;
  59621. NUM_MORPH_INFLUENCERS: number;
  59622. /** IMAGE PROCESSING */
  59623. IMAGEPROCESSING: boolean;
  59624. VIGNETTE: boolean;
  59625. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59626. VIGNETTEBLENDMODEOPAQUE: boolean;
  59627. TONEMAPPING: boolean;
  59628. TONEMAPPING_ACES: boolean;
  59629. CONTRAST: boolean;
  59630. EXPOSURE: boolean;
  59631. COLORCURVES: boolean;
  59632. COLORGRADING: boolean;
  59633. COLORGRADING3D: boolean;
  59634. SAMPLER3DGREENDEPTH: boolean;
  59635. SAMPLER3DBGRMAP: boolean;
  59636. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59637. /** MISC. */
  59638. BUMPDIRECTUV: number;
  59639. constructor();
  59640. setValue(name: string, value: boolean): void;
  59641. }
  59642. /**
  59643. * Class used to configure NodeMaterial
  59644. */
  59645. export interface INodeMaterialOptions {
  59646. /**
  59647. * Defines if blocks should emit comments
  59648. */
  59649. emitComments: boolean;
  59650. }
  59651. /**
  59652. * Class used to create a node based material built by assembling shader blocks
  59653. */
  59654. export class NodeMaterial extends PushMaterial {
  59655. private static _BuildIdGenerator;
  59656. private _options;
  59657. private _vertexCompilationState;
  59658. private _fragmentCompilationState;
  59659. private _sharedData;
  59660. private _buildId;
  59661. private _buildWasSuccessful;
  59662. private _cachedWorldViewMatrix;
  59663. private _cachedWorldViewProjectionMatrix;
  59664. private _optimizers;
  59665. private _animationFrame;
  59666. /** Define the Url to load node editor script */
  59667. static EditorURL: string;
  59668. /** Define the Url to load snippets */
  59669. static SnippetUrl: string;
  59670. private BJSNODEMATERIALEDITOR;
  59671. /** Get the inspector from bundle or global */
  59672. private _getGlobalNodeMaterialEditor;
  59673. /**
  59674. * Gets or sets data used by visual editor
  59675. * @see https://nme.babylonjs.com
  59676. */
  59677. editorData: any;
  59678. /**
  59679. * 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)
  59680. */
  59681. ignoreAlpha: boolean;
  59682. /**
  59683. * Defines the maximum number of lights that can be used in the material
  59684. */
  59685. maxSimultaneousLights: number;
  59686. /**
  59687. * Observable raised when the material is built
  59688. */
  59689. onBuildObservable: Observable<NodeMaterial>;
  59690. /**
  59691. * Gets or sets the root nodes of the material vertex shader
  59692. */
  59693. _vertexOutputNodes: NodeMaterialBlock[];
  59694. /**
  59695. * Gets or sets the root nodes of the material fragment (pixel) shader
  59696. */
  59697. _fragmentOutputNodes: NodeMaterialBlock[];
  59698. /** Gets or sets options to control the node material overall behavior */
  59699. get options(): INodeMaterialOptions;
  59700. set options(options: INodeMaterialOptions);
  59701. /**
  59702. * Default configuration related to image processing available in the standard Material.
  59703. */
  59704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59705. /**
  59706. * Gets the image processing configuration used either in this material.
  59707. */
  59708. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59709. /**
  59710. * Sets the Default image processing configuration used either in the this material.
  59711. *
  59712. * If sets to null, the scene one is in use.
  59713. */
  59714. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59715. /**
  59716. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59717. */
  59718. attachedBlocks: NodeMaterialBlock[];
  59719. /**
  59720. * Create a new node based material
  59721. * @param name defines the material name
  59722. * @param scene defines the hosting scene
  59723. * @param options defines creation option
  59724. */
  59725. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59726. /**
  59727. * Gets the current class name of the material e.g. "NodeMaterial"
  59728. * @returns the class name
  59729. */
  59730. getClassName(): string;
  59731. /**
  59732. * Keep track of the image processing observer to allow dispose and replace.
  59733. */
  59734. private _imageProcessingObserver;
  59735. /**
  59736. * Attaches a new image processing configuration to the Standard Material.
  59737. * @param configuration
  59738. */
  59739. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59740. /**
  59741. * Get a block by its name
  59742. * @param name defines the name of the block to retrieve
  59743. * @returns the required block or null if not found
  59744. */
  59745. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59746. /**
  59747. * Get a block by its name
  59748. * @param predicate defines the predicate used to find the good candidate
  59749. * @returns the required block or null if not found
  59750. */
  59751. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59752. /**
  59753. * Get an input block by its name
  59754. * @param predicate defines the predicate used to find the good candidate
  59755. * @returns the required input block or null if not found
  59756. */
  59757. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59758. /**
  59759. * Gets the list of input blocks attached to this material
  59760. * @returns an array of InputBlocks
  59761. */
  59762. getInputBlocks(): InputBlock[];
  59763. /**
  59764. * Adds a new optimizer to the list of optimizers
  59765. * @param optimizer defines the optimizers to add
  59766. * @returns the current material
  59767. */
  59768. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59769. /**
  59770. * Remove an optimizer from the list of optimizers
  59771. * @param optimizer defines the optimizers to remove
  59772. * @returns the current material
  59773. */
  59774. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59775. /**
  59776. * Add a new block to the list of output nodes
  59777. * @param node defines the node to add
  59778. * @returns the current material
  59779. */
  59780. addOutputNode(node: NodeMaterialBlock): this;
  59781. /**
  59782. * Remove a block from the list of root nodes
  59783. * @param node defines the node to remove
  59784. * @returns the current material
  59785. */
  59786. removeOutputNode(node: NodeMaterialBlock): this;
  59787. private _addVertexOutputNode;
  59788. private _removeVertexOutputNode;
  59789. private _addFragmentOutputNode;
  59790. private _removeFragmentOutputNode;
  59791. /**
  59792. * Specifies if the material will require alpha blending
  59793. * @returns a boolean specifying if alpha blending is needed
  59794. */
  59795. needAlphaBlending(): boolean;
  59796. /**
  59797. * Specifies if this material should be rendered in alpha test mode
  59798. * @returns a boolean specifying if an alpha test is needed.
  59799. */
  59800. needAlphaTesting(): boolean;
  59801. private _initializeBlock;
  59802. private _resetDualBlocks;
  59803. /**
  59804. * Remove a block from the current node material
  59805. * @param block defines the block to remove
  59806. */
  59807. removeBlock(block: NodeMaterialBlock): void;
  59808. /**
  59809. * Build the material and generates the inner effect
  59810. * @param verbose defines if the build should log activity
  59811. */
  59812. build(verbose?: boolean): void;
  59813. /**
  59814. * Runs an otpimization phase to try to improve the shader code
  59815. */
  59816. optimize(): void;
  59817. private _prepareDefinesForAttributes;
  59818. /**
  59819. * Get if the submesh is ready to be used and all its information available.
  59820. * Child classes can use it to update shaders
  59821. * @param mesh defines the mesh to check
  59822. * @param subMesh defines which submesh to check
  59823. * @param useInstances specifies that instances should be used
  59824. * @returns a boolean indicating that the submesh is ready or not
  59825. */
  59826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59827. /**
  59828. * Get a string representing the shaders built by the current node graph
  59829. */
  59830. get compiledShaders(): string;
  59831. /**
  59832. * Binds the world matrix to the material
  59833. * @param world defines the world transformation matrix
  59834. */
  59835. bindOnlyWorldMatrix(world: Matrix): void;
  59836. /**
  59837. * Binds the submesh to this material by preparing the effect and shader to draw
  59838. * @param world defines the world transformation matrix
  59839. * @param mesh defines the mesh containing the submesh
  59840. * @param subMesh defines the submesh to bind the material to
  59841. */
  59842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59843. /**
  59844. * Gets the active textures from the material
  59845. * @returns an array of textures
  59846. */
  59847. getActiveTextures(): BaseTexture[];
  59848. /**
  59849. * Gets the list of texture blocks
  59850. * @returns an array of texture blocks
  59851. */
  59852. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59853. /**
  59854. * Specifies if the material uses a texture
  59855. * @param texture defines the texture to check against the material
  59856. * @returns a boolean specifying if the material uses the texture
  59857. */
  59858. hasTexture(texture: BaseTexture): boolean;
  59859. /**
  59860. * Disposes the material
  59861. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59862. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59863. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59864. */
  59865. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59866. /** Creates the node editor window. */
  59867. private _createNodeEditor;
  59868. /**
  59869. * Launch the node material editor
  59870. * @param config Define the configuration of the editor
  59871. * @return a promise fulfilled when the node editor is visible
  59872. */
  59873. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59874. /**
  59875. * Clear the current material
  59876. */
  59877. clear(): void;
  59878. /**
  59879. * Clear the current material and set it to a default state
  59880. */
  59881. setToDefault(): void;
  59882. /**
  59883. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59884. * @param url defines the url to load from
  59885. * @returns a promise that will fullfil when the material is fully loaded
  59886. */
  59887. loadAsync(url: string): Promise<void>;
  59888. private _gatherBlocks;
  59889. /**
  59890. * Generate a string containing the code declaration required to create an equivalent of this material
  59891. * @returns a string
  59892. */
  59893. generateCode(): string;
  59894. /**
  59895. * Serializes this material in a JSON representation
  59896. * @returns the serialized material object
  59897. */
  59898. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59899. private _restoreConnections;
  59900. /**
  59901. * Clear the current graph and load a new one from a serialization object
  59902. * @param source defines the JSON representation of the material
  59903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59904. */
  59905. loadFromSerialization(source: any, rootUrl?: string): void;
  59906. /**
  59907. * Creates a node material from parsed material data
  59908. * @param source defines the JSON representation of the material
  59909. * @param scene defines the hosting scene
  59910. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59911. * @returns a new node material
  59912. */
  59913. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59914. /**
  59915. * Creates a node material from a snippet saved in a remote file
  59916. * @param name defines the name of the material to create
  59917. * @param url defines the url to load from
  59918. * @param scene defines the hosting scene
  59919. * @returns a promise that will resolve to the new node material
  59920. */
  59921. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59922. /**
  59923. * Creates a node material from a snippet saved by the node material editor
  59924. * @param snippetId defines the snippet to load
  59925. * @param scene defines the hosting scene
  59926. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59927. * @returns a promise that will resolve to the new node material
  59928. */
  59929. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59930. /**
  59931. * Creates a new node material set to default basic configuration
  59932. * @param name defines the name of the material
  59933. * @param scene defines the hosting scene
  59934. * @returns a new NodeMaterial
  59935. */
  59936. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59937. }
  59938. }
  59939. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59942. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59945. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59946. import { Effect } from "babylonjs/Materials/effect";
  59947. import { Mesh } from "babylonjs/Meshes/mesh";
  59948. import { Nullable } from "babylonjs/types";
  59949. import { Texture } from "babylonjs/Materials/Textures/texture";
  59950. import { Scene } from "babylonjs/scene";
  59951. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59952. /**
  59953. * Block used to read a texture from a sampler
  59954. */
  59955. export class TextureBlock extends NodeMaterialBlock {
  59956. private _defineName;
  59957. private _linearDefineName;
  59958. private _tempTextureRead;
  59959. private _samplerName;
  59960. private _transformedUVName;
  59961. private _textureTransformName;
  59962. private _textureInfoName;
  59963. private _mainUVName;
  59964. private _mainUVDefineName;
  59965. /**
  59966. * Gets or sets the texture associated with the node
  59967. */
  59968. texture: Nullable<Texture>;
  59969. /**
  59970. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59971. */
  59972. convertToGammaSpace: boolean;
  59973. /**
  59974. * Create a new TextureBlock
  59975. * @param name defines the block name
  59976. */
  59977. constructor(name: string);
  59978. /**
  59979. * Gets the current class name
  59980. * @returns the class name
  59981. */
  59982. getClassName(): string;
  59983. /**
  59984. * Gets the uv input component
  59985. */
  59986. get uv(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the rgba output component
  59989. */
  59990. get rgba(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the rgb output component
  59993. */
  59994. get rgb(): NodeMaterialConnectionPoint;
  59995. /**
  59996. * Gets the r output component
  59997. */
  59998. get r(): NodeMaterialConnectionPoint;
  59999. /**
  60000. * Gets the g output component
  60001. */
  60002. get g(): NodeMaterialConnectionPoint;
  60003. /**
  60004. * Gets the b output component
  60005. */
  60006. get b(): NodeMaterialConnectionPoint;
  60007. /**
  60008. * Gets the a output component
  60009. */
  60010. get a(): NodeMaterialConnectionPoint;
  60011. get target(): NodeMaterialBlockTargets;
  60012. autoConfigure(material: NodeMaterial): void;
  60013. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60015. isReady(): boolean;
  60016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60017. private get _isMixed();
  60018. private _injectVertexCode;
  60019. private _writeTextureRead;
  60020. private _writeOutput;
  60021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60022. protected _dumpPropertiesCode(): string;
  60023. serialize(): any;
  60024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60025. }
  60026. }
  60027. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60030. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60031. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60032. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60033. import { Scene } from "babylonjs/scene";
  60034. /**
  60035. * Class used to store shared data between 2 NodeMaterialBuildState
  60036. */
  60037. export class NodeMaterialBuildStateSharedData {
  60038. /**
  60039. * Gets the list of emitted varyings
  60040. */
  60041. temps: string[];
  60042. /**
  60043. * Gets the list of emitted varyings
  60044. */
  60045. varyings: string[];
  60046. /**
  60047. * Gets the varying declaration string
  60048. */
  60049. varyingDeclaration: string;
  60050. /**
  60051. * Input blocks
  60052. */
  60053. inputBlocks: InputBlock[];
  60054. /**
  60055. * Input blocks
  60056. */
  60057. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60058. /**
  60059. * Bindable blocks (Blocks that need to set data to the effect)
  60060. */
  60061. bindableBlocks: NodeMaterialBlock[];
  60062. /**
  60063. * List of blocks that can provide a compilation fallback
  60064. */
  60065. blocksWithFallbacks: NodeMaterialBlock[];
  60066. /**
  60067. * List of blocks that can provide a define update
  60068. */
  60069. blocksWithDefines: NodeMaterialBlock[];
  60070. /**
  60071. * List of blocks that can provide a repeatable content
  60072. */
  60073. repeatableContentBlocks: NodeMaterialBlock[];
  60074. /**
  60075. * List of blocks that can provide a dynamic list of uniforms
  60076. */
  60077. dynamicUniformBlocks: NodeMaterialBlock[];
  60078. /**
  60079. * List of blocks that can block the isReady function for the material
  60080. */
  60081. blockingBlocks: NodeMaterialBlock[];
  60082. /**
  60083. * Gets the list of animated inputs
  60084. */
  60085. animatedInputs: InputBlock[];
  60086. /**
  60087. * Build Id used to avoid multiple recompilations
  60088. */
  60089. buildId: number;
  60090. /** List of emitted variables */
  60091. variableNames: {
  60092. [key: string]: number;
  60093. };
  60094. /** List of emitted defines */
  60095. defineNames: {
  60096. [key: string]: number;
  60097. };
  60098. /** Should emit comments? */
  60099. emitComments: boolean;
  60100. /** Emit build activity */
  60101. verbose: boolean;
  60102. /** Gets or sets the hosting scene */
  60103. scene: Scene;
  60104. /**
  60105. * Gets the compilation hints emitted at compilation time
  60106. */
  60107. hints: {
  60108. needWorldViewMatrix: boolean;
  60109. needWorldViewProjectionMatrix: boolean;
  60110. needAlphaBlending: boolean;
  60111. needAlphaTesting: boolean;
  60112. };
  60113. /**
  60114. * List of compilation checks
  60115. */
  60116. checks: {
  60117. emitVertex: boolean;
  60118. emitFragment: boolean;
  60119. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60120. };
  60121. /** Creates a new shared data */
  60122. constructor();
  60123. /**
  60124. * Emits console errors and exceptions if there is a failing check
  60125. */
  60126. emitErrors(): void;
  60127. }
  60128. }
  60129. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60130. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60131. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60132. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60133. /**
  60134. * Class used to store node based material build state
  60135. */
  60136. export class NodeMaterialBuildState {
  60137. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60138. supportUniformBuffers: boolean;
  60139. /**
  60140. * Gets the list of emitted attributes
  60141. */
  60142. attributes: string[];
  60143. /**
  60144. * Gets the list of emitted uniforms
  60145. */
  60146. uniforms: string[];
  60147. /**
  60148. * Gets the list of emitted constants
  60149. */
  60150. constants: string[];
  60151. /**
  60152. * Gets the list of emitted samplers
  60153. */
  60154. samplers: string[];
  60155. /**
  60156. * Gets the list of emitted functions
  60157. */
  60158. functions: {
  60159. [key: string]: string;
  60160. };
  60161. /**
  60162. * Gets the list of emitted extensions
  60163. */
  60164. extensions: {
  60165. [key: string]: string;
  60166. };
  60167. /**
  60168. * Gets the target of the compilation state
  60169. */
  60170. target: NodeMaterialBlockTargets;
  60171. /**
  60172. * Gets the list of emitted counters
  60173. */
  60174. counters: {
  60175. [key: string]: number;
  60176. };
  60177. /**
  60178. * Shared data between multiple NodeMaterialBuildState instances
  60179. */
  60180. sharedData: NodeMaterialBuildStateSharedData;
  60181. /** @hidden */
  60182. _vertexState: NodeMaterialBuildState;
  60183. /** @hidden */
  60184. _attributeDeclaration: string;
  60185. /** @hidden */
  60186. _uniformDeclaration: string;
  60187. /** @hidden */
  60188. _constantDeclaration: string;
  60189. /** @hidden */
  60190. _samplerDeclaration: string;
  60191. /** @hidden */
  60192. _varyingTransfer: string;
  60193. private _repeatableContentAnchorIndex;
  60194. /** @hidden */
  60195. _builtCompilationString: string;
  60196. /**
  60197. * Gets the emitted compilation strings
  60198. */
  60199. compilationString: string;
  60200. /**
  60201. * Finalize the compilation strings
  60202. * @param state defines the current compilation state
  60203. */
  60204. finalize(state: NodeMaterialBuildState): void;
  60205. /** @hidden */
  60206. get _repeatableContentAnchor(): string;
  60207. /** @hidden */
  60208. _getFreeVariableName(prefix: string): string;
  60209. /** @hidden */
  60210. _getFreeDefineName(prefix: string): string;
  60211. /** @hidden */
  60212. _excludeVariableName(name: string): void;
  60213. /** @hidden */
  60214. _emit2DSampler(name: string): void;
  60215. /** @hidden */
  60216. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60217. /** @hidden */
  60218. _emitExtension(name: string, extension: string): void;
  60219. /** @hidden */
  60220. _emitFunction(name: string, code: string, comments: string): void;
  60221. /** @hidden */
  60222. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60223. replaceStrings?: {
  60224. search: RegExp;
  60225. replace: string;
  60226. }[];
  60227. repeatKey?: string;
  60228. }): string;
  60229. /** @hidden */
  60230. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60231. repeatKey?: string;
  60232. removeAttributes?: boolean;
  60233. removeUniforms?: boolean;
  60234. removeVaryings?: boolean;
  60235. removeIfDef?: boolean;
  60236. replaceStrings?: {
  60237. search: RegExp;
  60238. replace: string;
  60239. }[];
  60240. }, storeKey?: string): void;
  60241. /** @hidden */
  60242. _registerTempVariable(name: string): boolean;
  60243. /** @hidden */
  60244. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60245. /** @hidden */
  60246. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60247. /** @hidden */
  60248. _emitFloat(value: number): string;
  60249. }
  60250. }
  60251. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60252. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60254. import { Nullable } from "babylonjs/types";
  60255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60256. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60257. import { Effect } from "babylonjs/Materials/effect";
  60258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60259. import { Mesh } from "babylonjs/Meshes/mesh";
  60260. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60261. import { Scene } from "babylonjs/scene";
  60262. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60263. /**
  60264. * Defines a block that can be used inside a node based material
  60265. */
  60266. export class NodeMaterialBlock {
  60267. private _buildId;
  60268. private _buildTarget;
  60269. private _target;
  60270. private _isFinalMerger;
  60271. private _isInput;
  60272. protected _isUnique: boolean;
  60273. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60274. inputsAreExclusive: boolean;
  60275. /** @hidden */
  60276. _codeVariableName: string;
  60277. /** @hidden */
  60278. _inputs: NodeMaterialConnectionPoint[];
  60279. /** @hidden */
  60280. _outputs: NodeMaterialConnectionPoint[];
  60281. /** @hidden */
  60282. _preparationId: number;
  60283. /**
  60284. * Gets or sets the name of the block
  60285. */
  60286. name: string;
  60287. /**
  60288. * Gets or sets the unique id of the node
  60289. */
  60290. uniqueId: number;
  60291. /**
  60292. * Gets or sets the comments associated with this block
  60293. */
  60294. comments: string;
  60295. /**
  60296. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60297. */
  60298. get isUnique(): boolean;
  60299. /**
  60300. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60301. */
  60302. get isFinalMerger(): boolean;
  60303. /**
  60304. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60305. */
  60306. get isInput(): boolean;
  60307. /**
  60308. * Gets or sets the build Id
  60309. */
  60310. get buildId(): number;
  60311. set buildId(value: number);
  60312. /**
  60313. * Gets or sets the target of the block
  60314. */
  60315. get target(): NodeMaterialBlockTargets;
  60316. set target(value: NodeMaterialBlockTargets);
  60317. /**
  60318. * Gets the list of input points
  60319. */
  60320. get inputs(): NodeMaterialConnectionPoint[];
  60321. /** Gets the list of output points */
  60322. get outputs(): NodeMaterialConnectionPoint[];
  60323. /**
  60324. * Find an input by its name
  60325. * @param name defines the name of the input to look for
  60326. * @returns the input or null if not found
  60327. */
  60328. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60329. /**
  60330. * Find an output by its name
  60331. * @param name defines the name of the outputto look for
  60332. * @returns the output or null if not found
  60333. */
  60334. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60335. /**
  60336. * Creates a new NodeMaterialBlock
  60337. * @param name defines the block name
  60338. * @param target defines the target of that block (Vertex by default)
  60339. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60340. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60341. */
  60342. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60343. /**
  60344. * Initialize the block and prepare the context for build
  60345. * @param state defines the state that will be used for the build
  60346. */
  60347. initialize(state: NodeMaterialBuildState): void;
  60348. /**
  60349. * Bind data to effect. Will only be called for blocks with isBindable === true
  60350. * @param effect defines the effect to bind data to
  60351. * @param nodeMaterial defines the hosting NodeMaterial
  60352. * @param mesh defines the mesh that will be rendered
  60353. */
  60354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60355. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60356. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60357. protected _writeFloat(value: number): string;
  60358. /**
  60359. * Gets the current class name e.g. "NodeMaterialBlock"
  60360. * @returns the class name
  60361. */
  60362. getClassName(): string;
  60363. /**
  60364. * Register a new input. Must be called inside a block constructor
  60365. * @param name defines the connection point name
  60366. * @param type defines the connection point type
  60367. * @param isOptional defines a boolean indicating that this input can be omitted
  60368. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60369. * @returns the current block
  60370. */
  60371. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60372. /**
  60373. * Register a new output. Must be called inside a block constructor
  60374. * @param name defines the connection point name
  60375. * @param type defines the connection point type
  60376. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60377. * @returns the current block
  60378. */
  60379. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60380. /**
  60381. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60382. * @param forOutput defines an optional connection point to check compatibility with
  60383. * @returns the first available input or null
  60384. */
  60385. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60386. /**
  60387. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60388. * @param forBlock defines an optional block to check compatibility with
  60389. * @returns the first available input or null
  60390. */
  60391. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60392. /**
  60393. * Gets the sibling of the given output
  60394. * @param current defines the current output
  60395. * @returns the next output in the list or null
  60396. */
  60397. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60398. /**
  60399. * Connect current block with another block
  60400. * @param other defines the block to connect with
  60401. * @param options define the various options to help pick the right connections
  60402. * @returns the current block
  60403. */
  60404. connectTo(other: NodeMaterialBlock, options?: {
  60405. input?: string;
  60406. output?: string;
  60407. outputSwizzle?: string;
  60408. }): this | undefined;
  60409. protected _buildBlock(state: NodeMaterialBuildState): void;
  60410. /**
  60411. * Add uniforms, samplers and uniform buffers at compilation time
  60412. * @param state defines the state to update
  60413. * @param nodeMaterial defines the node material requesting the update
  60414. * @param defines defines the material defines to update
  60415. * @param uniformBuffers defines the list of uniform buffer names
  60416. */
  60417. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60418. /**
  60419. * Add potential fallbacks if shader compilation fails
  60420. * @param mesh defines the mesh to be rendered
  60421. * @param fallbacks defines the current prioritized list of fallbacks
  60422. */
  60423. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60424. /**
  60425. * Initialize defines for shader compilation
  60426. * @param mesh defines the mesh to be rendered
  60427. * @param nodeMaterial defines the node material requesting the update
  60428. * @param defines defines the material defines to update
  60429. * @param useInstances specifies that instances should be used
  60430. */
  60431. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60432. /**
  60433. * Update defines for shader compilation
  60434. * @param mesh defines the mesh to be rendered
  60435. * @param nodeMaterial defines the node material requesting the update
  60436. * @param defines defines the material defines to update
  60437. * @param useInstances specifies that instances should be used
  60438. */
  60439. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60440. /**
  60441. * Lets the block try to connect some inputs automatically
  60442. * @param material defines the hosting NodeMaterial
  60443. */
  60444. autoConfigure(material: NodeMaterial): void;
  60445. /**
  60446. * Function called when a block is declared as repeatable content generator
  60447. * @param vertexShaderState defines the current compilation state for the vertex shader
  60448. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60449. * @param mesh defines the mesh to be rendered
  60450. * @param defines defines the material defines to update
  60451. */
  60452. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60453. /**
  60454. * Checks if the block is ready
  60455. * @param mesh defines the mesh to be rendered
  60456. * @param nodeMaterial defines the node material requesting the update
  60457. * @param defines defines the material defines to update
  60458. * @param useInstances specifies that instances should be used
  60459. * @returns true if the block is ready
  60460. */
  60461. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60462. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60463. private _processBuild;
  60464. /**
  60465. * Compile the current node and generate the shader code
  60466. * @param state defines the current compilation state (uniforms, samplers, current string)
  60467. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60468. * @returns true if already built
  60469. */
  60470. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60471. protected _inputRename(name: string): string;
  60472. protected _outputRename(name: string): string;
  60473. protected _dumpPropertiesCode(): string;
  60474. /** @hidden */
  60475. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60476. /** @hidden */
  60477. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60478. /**
  60479. * Clone the current block to a new identical block
  60480. * @param scene defines the hosting scene
  60481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60482. * @returns a copy of the current block
  60483. */
  60484. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60485. /**
  60486. * Serializes this block in a JSON representation
  60487. * @returns the serialized block object
  60488. */
  60489. serialize(): any;
  60490. /** @hidden */
  60491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60492. /**
  60493. * Release resources
  60494. */
  60495. dispose(): void;
  60496. }
  60497. }
  60498. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60499. /**
  60500. * Enum defining the type of animations supported by InputBlock
  60501. */
  60502. export enum AnimatedInputBlockTypes {
  60503. /** No animation */
  60504. None = 0,
  60505. /** Time based animation. Will only work for floats */
  60506. Time = 1
  60507. }
  60508. }
  60509. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60511. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60512. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60513. import { Nullable } from "babylonjs/types";
  60514. import { Effect } from "babylonjs/Materials/effect";
  60515. import { Matrix } from "babylonjs/Maths/math.vector";
  60516. import { Scene } from "babylonjs/scene";
  60517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60519. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60520. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60521. /**
  60522. * Block used to expose an input value
  60523. */
  60524. export class InputBlock extends NodeMaterialBlock {
  60525. private _mode;
  60526. private _associatedVariableName;
  60527. private _storedValue;
  60528. private _valueCallback;
  60529. private _type;
  60530. private _animationType;
  60531. /** Gets or set a value used to limit the range of float values */
  60532. min: number;
  60533. /** Gets or set a value used to limit the range of float values */
  60534. max: number;
  60535. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60536. isBoolean: boolean;
  60537. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60538. matrixMode: number;
  60539. /** @hidden */
  60540. _systemValue: Nullable<NodeMaterialSystemValues>;
  60541. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60542. visibleInInspector: boolean;
  60543. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60544. isConstant: boolean;
  60545. /** Gets or sets the group to use to display this block in the Inspector */
  60546. groupInInspector: string;
  60547. /**
  60548. * Gets or sets the connection point type (default is float)
  60549. */
  60550. get type(): NodeMaterialBlockConnectionPointTypes;
  60551. /**
  60552. * Creates a new InputBlock
  60553. * @param name defines the block name
  60554. * @param target defines the target of that block (Vertex by default)
  60555. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60556. */
  60557. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60558. /**
  60559. * Gets the output component
  60560. */
  60561. get output(): NodeMaterialConnectionPoint;
  60562. /**
  60563. * Set the source of this connection point to a vertex attribute
  60564. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60565. * @returns the current connection point
  60566. */
  60567. setAsAttribute(attributeName?: string): InputBlock;
  60568. /**
  60569. * Set the source of this connection point to a system value
  60570. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60571. * @returns the current connection point
  60572. */
  60573. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60574. /**
  60575. * Gets or sets the value of that point.
  60576. * Please note that this value will be ignored if valueCallback is defined
  60577. */
  60578. get value(): any;
  60579. set value(value: any);
  60580. /**
  60581. * Gets or sets a callback used to get the value of that point.
  60582. * Please note that setting this value will force the connection point to ignore the value property
  60583. */
  60584. get valueCallback(): () => any;
  60585. set valueCallback(value: () => any);
  60586. /**
  60587. * Gets or sets the associated variable name in the shader
  60588. */
  60589. get associatedVariableName(): string;
  60590. set associatedVariableName(value: string);
  60591. /** Gets or sets the type of animation applied to the input */
  60592. get animationType(): AnimatedInputBlockTypes;
  60593. set animationType(value: AnimatedInputBlockTypes);
  60594. /**
  60595. * Gets a boolean indicating that this connection point not defined yet
  60596. */
  60597. get isUndefined(): boolean;
  60598. /**
  60599. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60600. * In this case the connection point name must be the name of the uniform to use.
  60601. * Can only be set on inputs
  60602. */
  60603. get isUniform(): boolean;
  60604. set isUniform(value: boolean);
  60605. /**
  60606. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60607. * In this case the connection point name must be the name of the attribute to use
  60608. * Can only be set on inputs
  60609. */
  60610. get isAttribute(): boolean;
  60611. set isAttribute(value: boolean);
  60612. /**
  60613. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60614. * Can only be set on exit points
  60615. */
  60616. get isVarying(): boolean;
  60617. set isVarying(value: boolean);
  60618. /**
  60619. * Gets a boolean indicating that the current connection point is a system value
  60620. */
  60621. get isSystemValue(): boolean;
  60622. /**
  60623. * Gets or sets the current well known value or null if not defined as a system value
  60624. */
  60625. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60626. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60627. /**
  60628. * Gets the current class name
  60629. * @returns the class name
  60630. */
  60631. getClassName(): string;
  60632. /**
  60633. * Animate the input if animationType !== None
  60634. * @param scene defines the rendering scene
  60635. */
  60636. animate(scene: Scene): void;
  60637. private _emitDefine;
  60638. initialize(state: NodeMaterialBuildState): void;
  60639. /**
  60640. * Set the input block to its default value (based on its type)
  60641. */
  60642. setDefaultValue(): void;
  60643. private _emitConstant;
  60644. private _emit;
  60645. /** @hidden */
  60646. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60647. /** @hidden */
  60648. _transmit(effect: Effect, scene: Scene): void;
  60649. protected _buildBlock(state: NodeMaterialBuildState): void;
  60650. protected _dumpPropertiesCode(): string;
  60651. serialize(): any;
  60652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60653. }
  60654. }
  60655. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60656. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60657. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60658. import { Nullable } from "babylonjs/types";
  60659. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60660. import { Observable } from "babylonjs/Misc/observable";
  60661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60662. /**
  60663. * Enum used to define the compatibility state between two connection points
  60664. */
  60665. export enum NodeMaterialConnectionPointCompatibilityStates {
  60666. /** Points are compatibles */
  60667. Compatible = 0,
  60668. /** Points are incompatible because of their types */
  60669. TypeIncompatible = 1,
  60670. /** Points are incompatible because of their targets (vertex vs fragment) */
  60671. TargetIncompatible = 2
  60672. }
  60673. /**
  60674. * Defines the direction of a connection point
  60675. */
  60676. export enum NodeMaterialConnectionPointDirection {
  60677. /** Input */
  60678. Input = 0,
  60679. /** Output */
  60680. Output = 1
  60681. }
  60682. /**
  60683. * Defines a connection point for a block
  60684. */
  60685. export class NodeMaterialConnectionPoint {
  60686. /** @hidden */
  60687. _ownerBlock: NodeMaterialBlock;
  60688. /** @hidden */
  60689. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60690. private _endpoints;
  60691. private _associatedVariableName;
  60692. private _direction;
  60693. /** @hidden */
  60694. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60695. /** @hidden */
  60696. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60697. private _type;
  60698. /** @hidden */
  60699. _enforceAssociatedVariableName: boolean;
  60700. /** Gets the direction of the point */
  60701. get direction(): NodeMaterialConnectionPointDirection;
  60702. /**
  60703. * Gets or sets the additional types supported by this connection point
  60704. */
  60705. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60706. /**
  60707. * Gets or sets the additional types excluded by this connection point
  60708. */
  60709. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60710. /**
  60711. * Observable triggered when this point is connected
  60712. */
  60713. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60714. /**
  60715. * Gets or sets the associated variable name in the shader
  60716. */
  60717. get associatedVariableName(): string;
  60718. set associatedVariableName(value: string);
  60719. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60720. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60721. /**
  60722. * Gets or sets the connection point type (default is float)
  60723. */
  60724. get type(): NodeMaterialBlockConnectionPointTypes;
  60725. set type(value: NodeMaterialBlockConnectionPointTypes);
  60726. /**
  60727. * Gets or sets the connection point name
  60728. */
  60729. name: string;
  60730. /**
  60731. * Gets or sets a boolean indicating that this connection point can be omitted
  60732. */
  60733. isOptional: boolean;
  60734. /**
  60735. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60736. */
  60737. define: string;
  60738. /** @hidden */
  60739. _prioritizeVertex: boolean;
  60740. private _target;
  60741. /** Gets or sets the target of that connection point */
  60742. get target(): NodeMaterialBlockTargets;
  60743. set target(value: NodeMaterialBlockTargets);
  60744. /**
  60745. * Gets a boolean indicating that the current point is connected
  60746. */
  60747. get isConnected(): boolean;
  60748. /**
  60749. * Gets a boolean indicating that the current point is connected to an input block
  60750. */
  60751. get isConnectedToInputBlock(): boolean;
  60752. /**
  60753. * Gets a the connected input block (if any)
  60754. */
  60755. get connectInputBlock(): Nullable<InputBlock>;
  60756. /** Get the other side of the connection (if any) */
  60757. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60758. /** Get the block that owns this connection point */
  60759. get ownerBlock(): NodeMaterialBlock;
  60760. /** Get the block connected on the other side of this connection (if any) */
  60761. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60762. /** Get the block connected on the endpoints of this connection (if any) */
  60763. get connectedBlocks(): Array<NodeMaterialBlock>;
  60764. /** Gets the list of connected endpoints */
  60765. get endpoints(): NodeMaterialConnectionPoint[];
  60766. /** Gets a boolean indicating if that output point is connected to at least one input */
  60767. get hasEndpoints(): boolean;
  60768. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60769. get isConnectedInVertexShader(): boolean;
  60770. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60771. get isConnectedInFragmentShader(): boolean;
  60772. /**
  60773. * Creates a new connection point
  60774. * @param name defines the connection point name
  60775. * @param ownerBlock defines the block hosting this connection point
  60776. * @param direction defines the direction of the connection point
  60777. */
  60778. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60779. /**
  60780. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60781. * @returns the class name
  60782. */
  60783. getClassName(): string;
  60784. /**
  60785. * Gets a boolean indicating if the current point can be connected to another point
  60786. * @param connectionPoint defines the other connection point
  60787. * @returns a boolean
  60788. */
  60789. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60790. /**
  60791. * Gets a number indicating if the current point can be connected to another point
  60792. * @param connectionPoint defines the other connection point
  60793. * @returns a number defining the compatibility state
  60794. */
  60795. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60796. /**
  60797. * Connect this point to another connection point
  60798. * @param connectionPoint defines the other connection point
  60799. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60800. * @returns the current connection point
  60801. */
  60802. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60803. /**
  60804. * Disconnect this point from one of his endpoint
  60805. * @param endpoint defines the other connection point
  60806. * @returns the current connection point
  60807. */
  60808. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Serializes this point in a JSON representation
  60811. * @returns the serialized point object
  60812. */
  60813. serialize(): any;
  60814. /**
  60815. * Release resources
  60816. */
  60817. dispose(): void;
  60818. }
  60819. }
  60820. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60824. import { Mesh } from "babylonjs/Meshes/mesh";
  60825. import { Effect } from "babylonjs/Materials/effect";
  60826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60827. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60828. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60829. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60830. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60831. /**
  60832. * Block used to add support for vertex skinning (bones)
  60833. */
  60834. export class BonesBlock extends NodeMaterialBlock {
  60835. /**
  60836. * Creates a new BonesBlock
  60837. * @param name defines the block name
  60838. */
  60839. constructor(name: string);
  60840. /**
  60841. * Initialize the block and prepare the context for build
  60842. * @param state defines the state that will be used for the build
  60843. */
  60844. initialize(state: NodeMaterialBuildState): void;
  60845. /**
  60846. * Gets the current class name
  60847. * @returns the class name
  60848. */
  60849. getClassName(): string;
  60850. /**
  60851. * Gets the matrix indices input component
  60852. */
  60853. get matricesIndices(): NodeMaterialConnectionPoint;
  60854. /**
  60855. * Gets the matrix weights input component
  60856. */
  60857. get matricesWeights(): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Gets the extra matrix indices input component
  60860. */
  60861. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60862. /**
  60863. * Gets the extra matrix weights input component
  60864. */
  60865. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60866. /**
  60867. * Gets the world input component
  60868. */
  60869. get world(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the output component
  60872. */
  60873. get output(): NodeMaterialConnectionPoint;
  60874. autoConfigure(material: NodeMaterial): void;
  60875. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60878. protected _buildBlock(state: NodeMaterialBuildState): this;
  60879. }
  60880. }
  60881. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60886. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60887. /**
  60888. * Block used to add support for instances
  60889. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60890. */
  60891. export class InstancesBlock extends NodeMaterialBlock {
  60892. /**
  60893. * Creates a new InstancesBlock
  60894. * @param name defines the block name
  60895. */
  60896. constructor(name: string);
  60897. /**
  60898. * Gets the current class name
  60899. * @returns the class name
  60900. */
  60901. getClassName(): string;
  60902. /**
  60903. * Gets the first world row input component
  60904. */
  60905. get world0(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the second world row input component
  60908. */
  60909. get world1(): NodeMaterialConnectionPoint;
  60910. /**
  60911. * Gets the third world row input component
  60912. */
  60913. get world2(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the forth world row input component
  60916. */
  60917. get world3(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the world input component
  60920. */
  60921. get world(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the output component
  60924. */
  60925. get output(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the isntanceID component
  60928. */
  60929. get instanceID(): NodeMaterialConnectionPoint;
  60930. autoConfigure(material: NodeMaterial): void;
  60931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60932. protected _buildBlock(state: NodeMaterialBuildState): this;
  60933. }
  60934. }
  60935. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60941. import { Effect } from "babylonjs/Materials/effect";
  60942. import { Mesh } from "babylonjs/Meshes/mesh";
  60943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60945. /**
  60946. * Block used to add morph targets support to vertex shader
  60947. */
  60948. export class MorphTargetsBlock extends NodeMaterialBlock {
  60949. private _repeatableContentAnchor;
  60950. /**
  60951. * Create a new MorphTargetsBlock
  60952. * @param name defines the block name
  60953. */
  60954. constructor(name: string);
  60955. /**
  60956. * Gets the current class name
  60957. * @returns the class name
  60958. */
  60959. getClassName(): string;
  60960. /**
  60961. * Gets the position input component
  60962. */
  60963. get position(): NodeMaterialConnectionPoint;
  60964. /**
  60965. * Gets the normal input component
  60966. */
  60967. get normal(): NodeMaterialConnectionPoint;
  60968. /**
  60969. * Gets the tangent input component
  60970. */
  60971. get tangent(): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Gets the tangent input component
  60974. */
  60975. get uv(): NodeMaterialConnectionPoint;
  60976. /**
  60977. * Gets the position output component
  60978. */
  60979. get positionOutput(): NodeMaterialConnectionPoint;
  60980. /**
  60981. * Gets the normal output component
  60982. */
  60983. get normalOutput(): NodeMaterialConnectionPoint;
  60984. /**
  60985. * Gets the tangent output component
  60986. */
  60987. get tangentOutput(): NodeMaterialConnectionPoint;
  60988. /**
  60989. * Gets the tangent output component
  60990. */
  60991. get uvOutput(): NodeMaterialConnectionPoint;
  60992. initialize(state: NodeMaterialBuildState): void;
  60993. autoConfigure(material: NodeMaterial): void;
  60994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60996. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60997. protected _buildBlock(state: NodeMaterialBuildState): this;
  60998. }
  60999. }
  61000. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61004. import { Nullable } from "babylonjs/types";
  61005. import { Scene } from "babylonjs/scene";
  61006. import { Effect } from "babylonjs/Materials/effect";
  61007. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61008. import { Mesh } from "babylonjs/Meshes/mesh";
  61009. import { Light } from "babylonjs/Lights/light";
  61010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61011. /**
  61012. * Block used to get data information from a light
  61013. */
  61014. export class LightInformationBlock extends NodeMaterialBlock {
  61015. private _lightDataUniformName;
  61016. private _lightColorUniformName;
  61017. private _lightTypeDefineName;
  61018. /**
  61019. * Gets or sets the light associated with this block
  61020. */
  61021. light: Nullable<Light>;
  61022. /**
  61023. * Creates a new LightInformationBlock
  61024. * @param name defines the block name
  61025. */
  61026. constructor(name: string);
  61027. /**
  61028. * Gets the current class name
  61029. * @returns the class name
  61030. */
  61031. getClassName(): string;
  61032. /**
  61033. * Gets the world position input component
  61034. */
  61035. get worldPosition(): NodeMaterialConnectionPoint;
  61036. /**
  61037. * Gets the direction output component
  61038. */
  61039. get direction(): NodeMaterialConnectionPoint;
  61040. /**
  61041. * Gets the direction output component
  61042. */
  61043. get color(): NodeMaterialConnectionPoint;
  61044. /**
  61045. * Gets the direction output component
  61046. */
  61047. get intensity(): NodeMaterialConnectionPoint;
  61048. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61050. protected _buildBlock(state: NodeMaterialBuildState): this;
  61051. serialize(): any;
  61052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61053. }
  61054. }
  61055. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61056. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61057. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61058. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61059. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61060. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61061. }
  61062. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61067. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61068. import { Effect } from "babylonjs/Materials/effect";
  61069. import { Mesh } from "babylonjs/Meshes/mesh";
  61070. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61071. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61072. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61073. /**
  61074. * Block used to add image processing support to fragment shader
  61075. */
  61076. export class ImageProcessingBlock extends NodeMaterialBlock {
  61077. /**
  61078. * Create a new ImageProcessingBlock
  61079. * @param name defines the block name
  61080. */
  61081. constructor(name: string);
  61082. /**
  61083. * Gets the current class name
  61084. * @returns the class name
  61085. */
  61086. getClassName(): string;
  61087. /**
  61088. * Gets the color input component
  61089. */
  61090. get color(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the output component
  61093. */
  61094. get output(): NodeMaterialConnectionPoint;
  61095. /**
  61096. * Initialize the block and prepare the context for build
  61097. * @param state defines the state that will be used for the build
  61098. */
  61099. initialize(state: NodeMaterialBuildState): void;
  61100. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61102. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61103. protected _buildBlock(state: NodeMaterialBuildState): this;
  61104. }
  61105. }
  61106. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61107. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61108. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61110. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61112. import { Effect } from "babylonjs/Materials/effect";
  61113. import { Mesh } from "babylonjs/Meshes/mesh";
  61114. import { Scene } from "babylonjs/scene";
  61115. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61116. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61117. /**
  61118. * Block used to pertub normals based on a normal map
  61119. */
  61120. export class PerturbNormalBlock extends NodeMaterialBlock {
  61121. private _tangentSpaceParameterName;
  61122. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61123. invertX: boolean;
  61124. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61125. invertY: boolean;
  61126. /**
  61127. * Create a new PerturbNormalBlock
  61128. * @param name defines the block name
  61129. */
  61130. constructor(name: string);
  61131. /**
  61132. * Gets the current class name
  61133. * @returns the class name
  61134. */
  61135. getClassName(): string;
  61136. /**
  61137. * Gets the world position input component
  61138. */
  61139. get worldPosition(): NodeMaterialConnectionPoint;
  61140. /**
  61141. * Gets the world normal input component
  61142. */
  61143. get worldNormal(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Gets the world tangent input component
  61146. */
  61147. get worldTangent(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the uv input component
  61150. */
  61151. get uv(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the normal map color input component
  61154. */
  61155. get normalMapColor(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the strength input component
  61158. */
  61159. get strength(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the output component
  61162. */
  61163. get output(): NodeMaterialConnectionPoint;
  61164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61166. autoConfigure(material: NodeMaterial): void;
  61167. protected _buildBlock(state: NodeMaterialBuildState): this;
  61168. protected _dumpPropertiesCode(): string;
  61169. serialize(): any;
  61170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61171. }
  61172. }
  61173. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61177. /**
  61178. * Block used to discard a pixel if a value is smaller than a cutoff
  61179. */
  61180. export class DiscardBlock extends NodeMaterialBlock {
  61181. /**
  61182. * Create a new DiscardBlock
  61183. * @param name defines the block name
  61184. */
  61185. constructor(name: string);
  61186. /**
  61187. * Gets the current class name
  61188. * @returns the class name
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Gets the color input component
  61193. */
  61194. get value(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the cutoff input component
  61197. */
  61198. get cutoff(): NodeMaterialConnectionPoint;
  61199. protected _buildBlock(state: NodeMaterialBuildState): this;
  61200. }
  61201. }
  61202. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61206. /**
  61207. * Block used to test if the fragment shader is front facing
  61208. */
  61209. export class FrontFacingBlock extends NodeMaterialBlock {
  61210. /**
  61211. * Creates a new FrontFacingBlock
  61212. * @param name defines the block name
  61213. */
  61214. constructor(name: string);
  61215. /**
  61216. * Gets the current class name
  61217. * @returns the class name
  61218. */
  61219. getClassName(): string;
  61220. /**
  61221. * Gets the output component
  61222. */
  61223. get output(): NodeMaterialConnectionPoint;
  61224. protected _buildBlock(state: NodeMaterialBuildState): this;
  61225. }
  61226. }
  61227. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61228. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61229. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61230. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61231. /**
  61232. * Block used to get the derivative value on x and y of a given input
  61233. */
  61234. export class DerivativeBlock extends NodeMaterialBlock {
  61235. /**
  61236. * Create a new DerivativeBlock
  61237. * @param name defines the block name
  61238. */
  61239. constructor(name: string);
  61240. /**
  61241. * Gets the current class name
  61242. * @returns the class name
  61243. */
  61244. getClassName(): string;
  61245. /**
  61246. * Gets the input component
  61247. */
  61248. get input(): NodeMaterialConnectionPoint;
  61249. /**
  61250. * Gets the derivative output on x
  61251. */
  61252. get dx(): NodeMaterialConnectionPoint;
  61253. /**
  61254. * Gets the derivative output on y
  61255. */
  61256. get dy(): NodeMaterialConnectionPoint;
  61257. protected _buildBlock(state: NodeMaterialBuildState): this;
  61258. }
  61259. }
  61260. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61261. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61262. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61263. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61266. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61267. }
  61268. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61271. import { Mesh } from "babylonjs/Meshes/mesh";
  61272. import { Effect } from "babylonjs/Materials/effect";
  61273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61275. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61276. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61277. /**
  61278. * Block used to add support for scene fog
  61279. */
  61280. export class FogBlock extends NodeMaterialBlock {
  61281. private _fogDistanceName;
  61282. private _fogParameters;
  61283. /**
  61284. * Create a new FogBlock
  61285. * @param name defines the block name
  61286. */
  61287. constructor(name: string);
  61288. /**
  61289. * Gets the current class name
  61290. * @returns the class name
  61291. */
  61292. getClassName(): string;
  61293. /**
  61294. * Gets the world position input component
  61295. */
  61296. get worldPosition(): NodeMaterialConnectionPoint;
  61297. /**
  61298. * Gets the view input component
  61299. */
  61300. get view(): NodeMaterialConnectionPoint;
  61301. /**
  61302. * Gets the color input component
  61303. */
  61304. get input(): NodeMaterialConnectionPoint;
  61305. /**
  61306. * Gets the fog color input component
  61307. */
  61308. get fogColor(): NodeMaterialConnectionPoint;
  61309. /**
  61310. * Gets the output component
  61311. */
  61312. get output(): NodeMaterialConnectionPoint;
  61313. autoConfigure(material: NodeMaterial): void;
  61314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61316. protected _buildBlock(state: NodeMaterialBuildState): this;
  61317. }
  61318. }
  61319. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61324. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61325. import { Effect } from "babylonjs/Materials/effect";
  61326. import { Mesh } from "babylonjs/Meshes/mesh";
  61327. import { Light } from "babylonjs/Lights/light";
  61328. import { Nullable } from "babylonjs/types";
  61329. import { Scene } from "babylonjs/scene";
  61330. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61331. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61332. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61334. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61335. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61336. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61337. /**
  61338. * Block used to add light in the fragment shader
  61339. */
  61340. export class LightBlock extends NodeMaterialBlock {
  61341. private _lightId;
  61342. /**
  61343. * Gets or sets the light associated with this block
  61344. */
  61345. light: Nullable<Light>;
  61346. /**
  61347. * Create a new LightBlock
  61348. * @param name defines the block name
  61349. */
  61350. constructor(name: string);
  61351. /**
  61352. * Gets the current class name
  61353. * @returns the class name
  61354. */
  61355. getClassName(): string;
  61356. /**
  61357. * Gets the world position input component
  61358. */
  61359. get worldPosition(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the world normal input component
  61362. */
  61363. get worldNormal(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the camera (or eye) position component
  61366. */
  61367. get cameraPosition(): NodeMaterialConnectionPoint;
  61368. /**
  61369. * Gets the glossiness component
  61370. */
  61371. get glossiness(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the glossinness power component
  61374. */
  61375. get glossPower(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the diffuse color component
  61378. */
  61379. get diffuseColor(): NodeMaterialConnectionPoint;
  61380. /**
  61381. * Gets the specular color component
  61382. */
  61383. get specularColor(): NodeMaterialConnectionPoint;
  61384. /**
  61385. * Gets the diffuse output component
  61386. */
  61387. get diffuseOutput(): NodeMaterialConnectionPoint;
  61388. /**
  61389. * Gets the specular output component
  61390. */
  61391. get specularOutput(): NodeMaterialConnectionPoint;
  61392. /**
  61393. * Gets the shadow output component
  61394. */
  61395. get shadow(): NodeMaterialConnectionPoint;
  61396. autoConfigure(material: NodeMaterial): void;
  61397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61398. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61400. private _injectVertexCode;
  61401. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61402. serialize(): any;
  61403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61404. }
  61405. }
  61406. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61407. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61408. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61409. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61410. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61411. }
  61412. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61413. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61414. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61415. }
  61416. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61420. /**
  61421. * Block used to multiply 2 values
  61422. */
  61423. export class MultiplyBlock extends NodeMaterialBlock {
  61424. /**
  61425. * Creates a new MultiplyBlock
  61426. * @param name defines the block name
  61427. */
  61428. constructor(name: string);
  61429. /**
  61430. * Gets the current class name
  61431. * @returns the class name
  61432. */
  61433. getClassName(): string;
  61434. /**
  61435. * Gets the left operand input component
  61436. */
  61437. get left(): NodeMaterialConnectionPoint;
  61438. /**
  61439. * Gets the right operand input component
  61440. */
  61441. get right(): NodeMaterialConnectionPoint;
  61442. /**
  61443. * Gets the output component
  61444. */
  61445. get output(): NodeMaterialConnectionPoint;
  61446. protected _buildBlock(state: NodeMaterialBuildState): this;
  61447. }
  61448. }
  61449. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61453. /**
  61454. * Block used to add 2 vectors
  61455. */
  61456. export class AddBlock extends NodeMaterialBlock {
  61457. /**
  61458. * Creates a new AddBlock
  61459. * @param name defines the block name
  61460. */
  61461. constructor(name: string);
  61462. /**
  61463. * Gets the current class name
  61464. * @returns the class name
  61465. */
  61466. getClassName(): string;
  61467. /**
  61468. * Gets the left operand input component
  61469. */
  61470. get left(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the right operand input component
  61473. */
  61474. get right(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the output component
  61477. */
  61478. get output(): NodeMaterialConnectionPoint;
  61479. protected _buildBlock(state: NodeMaterialBuildState): this;
  61480. }
  61481. }
  61482. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61486. /**
  61487. * Block used to scale a vector by a float
  61488. */
  61489. export class ScaleBlock extends NodeMaterialBlock {
  61490. /**
  61491. * Creates a new ScaleBlock
  61492. * @param name defines the block name
  61493. */
  61494. constructor(name: string);
  61495. /**
  61496. * Gets the current class name
  61497. * @returns the class name
  61498. */
  61499. getClassName(): string;
  61500. /**
  61501. * Gets the input component
  61502. */
  61503. get input(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the factor input component
  61506. */
  61507. get factor(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the output component
  61510. */
  61511. get output(): NodeMaterialConnectionPoint;
  61512. protected _buildBlock(state: NodeMaterialBuildState): this;
  61513. }
  61514. }
  61515. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61519. import { Scene } from "babylonjs/scene";
  61520. /**
  61521. * Block used to clamp a float
  61522. */
  61523. export class ClampBlock extends NodeMaterialBlock {
  61524. /** Gets or sets the minimum range */
  61525. minimum: number;
  61526. /** Gets or sets the maximum range */
  61527. maximum: number;
  61528. /**
  61529. * Creates a new ClampBlock
  61530. * @param name defines the block name
  61531. */
  61532. constructor(name: string);
  61533. /**
  61534. * Gets the current class name
  61535. * @returns the class name
  61536. */
  61537. getClassName(): string;
  61538. /**
  61539. * Gets the value input component
  61540. */
  61541. get value(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the output component
  61544. */
  61545. get output(): NodeMaterialConnectionPoint;
  61546. protected _buildBlock(state: NodeMaterialBuildState): this;
  61547. protected _dumpPropertiesCode(): string;
  61548. serialize(): any;
  61549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61550. }
  61551. }
  61552. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61556. /**
  61557. * Block used to apply a cross product between 2 vectors
  61558. */
  61559. export class CrossBlock extends NodeMaterialBlock {
  61560. /**
  61561. * Creates a new CrossBlock
  61562. * @param name defines the block name
  61563. */
  61564. constructor(name: string);
  61565. /**
  61566. * Gets the current class name
  61567. * @returns the class name
  61568. */
  61569. getClassName(): string;
  61570. /**
  61571. * Gets the left operand input component
  61572. */
  61573. get left(): NodeMaterialConnectionPoint;
  61574. /**
  61575. * Gets the right operand input component
  61576. */
  61577. get right(): NodeMaterialConnectionPoint;
  61578. /**
  61579. * Gets the output component
  61580. */
  61581. get output(): NodeMaterialConnectionPoint;
  61582. protected _buildBlock(state: NodeMaterialBuildState): this;
  61583. }
  61584. }
  61585. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61589. /**
  61590. * Block used to apply a dot product between 2 vectors
  61591. */
  61592. export class DotBlock extends NodeMaterialBlock {
  61593. /**
  61594. * Creates a new DotBlock
  61595. * @param name defines the block name
  61596. */
  61597. constructor(name: string);
  61598. /**
  61599. * Gets the current class name
  61600. * @returns the class name
  61601. */
  61602. getClassName(): string;
  61603. /**
  61604. * Gets the left operand input component
  61605. */
  61606. get left(): NodeMaterialConnectionPoint;
  61607. /**
  61608. * Gets the right operand input component
  61609. */
  61610. get right(): NodeMaterialConnectionPoint;
  61611. /**
  61612. * Gets the output component
  61613. */
  61614. get output(): NodeMaterialConnectionPoint;
  61615. protected _buildBlock(state: NodeMaterialBuildState): this;
  61616. }
  61617. }
  61618. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61622. import { Vector2 } from "babylonjs/Maths/math.vector";
  61623. import { Scene } from "babylonjs/scene";
  61624. /**
  61625. * Block used to remap a float from a range to a new one
  61626. */
  61627. export class RemapBlock extends NodeMaterialBlock {
  61628. /**
  61629. * Gets or sets the source range
  61630. */
  61631. sourceRange: Vector2;
  61632. /**
  61633. * Gets or sets the target range
  61634. */
  61635. targetRange: Vector2;
  61636. /**
  61637. * Creates a new RemapBlock
  61638. * @param name defines the block name
  61639. */
  61640. constructor(name: string);
  61641. /**
  61642. * Gets the current class name
  61643. * @returns the class name
  61644. */
  61645. getClassName(): string;
  61646. /**
  61647. * Gets the input component
  61648. */
  61649. get input(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the source min input component
  61652. */
  61653. get sourceMin(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the source max input component
  61656. */
  61657. get sourceMax(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the target min input component
  61660. */
  61661. get targetMin(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the target max input component
  61664. */
  61665. get targetMax(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the output component
  61668. */
  61669. get output(): NodeMaterialConnectionPoint;
  61670. protected _buildBlock(state: NodeMaterialBuildState): this;
  61671. protected _dumpPropertiesCode(): string;
  61672. serialize(): any;
  61673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61674. }
  61675. }
  61676. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61680. /**
  61681. * Block used to normalize a vector
  61682. */
  61683. export class NormalizeBlock extends NodeMaterialBlock {
  61684. /**
  61685. * Creates a new NormalizeBlock
  61686. * @param name defines the block name
  61687. */
  61688. constructor(name: string);
  61689. /**
  61690. * Gets the current class name
  61691. * @returns the class name
  61692. */
  61693. getClassName(): string;
  61694. /**
  61695. * Gets the input component
  61696. */
  61697. get input(): NodeMaterialConnectionPoint;
  61698. /**
  61699. * Gets the output component
  61700. */
  61701. get output(): NodeMaterialConnectionPoint;
  61702. protected _buildBlock(state: NodeMaterialBuildState): this;
  61703. }
  61704. }
  61705. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61709. import { Scene } from "babylonjs/scene";
  61710. /**
  61711. * Operations supported by the Trigonometry block
  61712. */
  61713. export enum TrigonometryBlockOperations {
  61714. /** Cos */
  61715. Cos = 0,
  61716. /** Sin */
  61717. Sin = 1,
  61718. /** Abs */
  61719. Abs = 2,
  61720. /** Exp */
  61721. Exp = 3,
  61722. /** Exp2 */
  61723. Exp2 = 4,
  61724. /** Round */
  61725. Round = 5,
  61726. /** Floor */
  61727. Floor = 6,
  61728. /** Ceiling */
  61729. Ceiling = 7,
  61730. /** Square root */
  61731. Sqrt = 8,
  61732. /** Log */
  61733. Log = 9,
  61734. /** Tangent */
  61735. Tan = 10,
  61736. /** Arc tangent */
  61737. ArcTan = 11,
  61738. /** Arc cosinus */
  61739. ArcCos = 12,
  61740. /** Arc sinus */
  61741. ArcSin = 13,
  61742. /** Fraction */
  61743. Fract = 14,
  61744. /** Sign */
  61745. Sign = 15,
  61746. /** To radians (from degrees) */
  61747. Radians = 16,
  61748. /** To degrees (from radians) */
  61749. Degrees = 17
  61750. }
  61751. /**
  61752. * Block used to apply trigonometry operation to floats
  61753. */
  61754. export class TrigonometryBlock extends NodeMaterialBlock {
  61755. /**
  61756. * Gets or sets the operation applied by the block
  61757. */
  61758. operation: TrigonometryBlockOperations;
  61759. /**
  61760. * Creates a new TrigonometryBlock
  61761. * @param name defines the block name
  61762. */
  61763. constructor(name: string);
  61764. /**
  61765. * Gets the current class name
  61766. * @returns the class name
  61767. */
  61768. getClassName(): string;
  61769. /**
  61770. * Gets the input component
  61771. */
  61772. get input(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the output component
  61775. */
  61776. get output(): NodeMaterialConnectionPoint;
  61777. protected _buildBlock(state: NodeMaterialBuildState): this;
  61778. serialize(): any;
  61779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61780. protected _dumpPropertiesCode(): string;
  61781. }
  61782. }
  61783. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61784. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61785. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61787. /**
  61788. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61789. */
  61790. export class ColorMergerBlock extends NodeMaterialBlock {
  61791. /**
  61792. * Create a new ColorMergerBlock
  61793. * @param name defines the block name
  61794. */
  61795. constructor(name: string);
  61796. /**
  61797. * Gets the current class name
  61798. * @returns the class name
  61799. */
  61800. getClassName(): string;
  61801. /**
  61802. * Gets the rgb component (input)
  61803. */
  61804. get rgbIn(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the r component (input)
  61807. */
  61808. get r(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the g component (input)
  61811. */
  61812. get g(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the b component (input)
  61815. */
  61816. get b(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the a component (input)
  61819. */
  61820. get a(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the rgba component (output)
  61823. */
  61824. get rgba(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the rgb component (output)
  61827. */
  61828. get rgbOut(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the rgb component (output)
  61831. * @deprecated Please use rgbOut instead.
  61832. */
  61833. get rgb(): NodeMaterialConnectionPoint;
  61834. protected _buildBlock(state: NodeMaterialBuildState): this;
  61835. }
  61836. }
  61837. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61841. /**
  61842. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61843. */
  61844. export class VectorMergerBlock extends NodeMaterialBlock {
  61845. /**
  61846. * Create a new VectorMergerBlock
  61847. * @param name defines the block name
  61848. */
  61849. constructor(name: string);
  61850. /**
  61851. * Gets the current class name
  61852. * @returns the class name
  61853. */
  61854. getClassName(): string;
  61855. /**
  61856. * Gets the xyz component (input)
  61857. */
  61858. get xyzIn(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the xy component (input)
  61861. */
  61862. get xyIn(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the x component (input)
  61865. */
  61866. get x(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the y component (input)
  61869. */
  61870. get y(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the z component (input)
  61873. */
  61874. get z(): NodeMaterialConnectionPoint;
  61875. /**
  61876. * Gets the w component (input)
  61877. */
  61878. get w(): NodeMaterialConnectionPoint;
  61879. /**
  61880. * Gets the xyzw component (output)
  61881. */
  61882. get xyzw(): NodeMaterialConnectionPoint;
  61883. /**
  61884. * Gets the xyz component (output)
  61885. */
  61886. get xyzOut(): NodeMaterialConnectionPoint;
  61887. /**
  61888. * Gets the xy component (output)
  61889. */
  61890. get xyOut(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the xy component (output)
  61893. * @deprecated Please use xyOut instead.
  61894. */
  61895. get xy(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the xyz component (output)
  61898. * @deprecated Please use xyzOut instead.
  61899. */
  61900. get xyz(): NodeMaterialConnectionPoint;
  61901. protected _buildBlock(state: NodeMaterialBuildState): this;
  61902. }
  61903. }
  61904. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61908. /**
  61909. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61910. */
  61911. export class ColorSplitterBlock extends NodeMaterialBlock {
  61912. /**
  61913. * Create a new ColorSplitterBlock
  61914. * @param name defines the block name
  61915. */
  61916. constructor(name: string);
  61917. /**
  61918. * Gets the current class name
  61919. * @returns the class name
  61920. */
  61921. getClassName(): string;
  61922. /**
  61923. * Gets the rgba component (input)
  61924. */
  61925. get rgba(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the rgb component (input)
  61928. */
  61929. get rgbIn(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the rgb component (output)
  61932. */
  61933. get rgbOut(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the r component (output)
  61936. */
  61937. get r(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the g component (output)
  61940. */
  61941. get g(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the b component (output)
  61944. */
  61945. get b(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the a component (output)
  61948. */
  61949. get a(): NodeMaterialConnectionPoint;
  61950. protected _inputRename(name: string): string;
  61951. protected _outputRename(name: string): string;
  61952. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61953. }
  61954. }
  61955. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61957. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61958. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61959. /**
  61960. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61961. */
  61962. export class VectorSplitterBlock extends NodeMaterialBlock {
  61963. /**
  61964. * Create a new VectorSplitterBlock
  61965. * @param name defines the block name
  61966. */
  61967. constructor(name: string);
  61968. /**
  61969. * Gets the current class name
  61970. * @returns the class name
  61971. */
  61972. getClassName(): string;
  61973. /**
  61974. * Gets the xyzw component (input)
  61975. */
  61976. get xyzw(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the xyz component (input)
  61979. */
  61980. get xyzIn(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the xy component (input)
  61983. */
  61984. get xyIn(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the xyz component (output)
  61987. */
  61988. get xyzOut(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the xy component (output)
  61991. */
  61992. get xyOut(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the x component (output)
  61995. */
  61996. get x(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the y component (output)
  61999. */
  62000. get y(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the z component (output)
  62003. */
  62004. get z(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the w component (output)
  62007. */
  62008. get w(): NodeMaterialConnectionPoint;
  62009. protected _inputRename(name: string): string;
  62010. protected _outputRename(name: string): string;
  62011. protected _buildBlock(state: NodeMaterialBuildState): this;
  62012. }
  62013. }
  62014. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62018. /**
  62019. * Block used to lerp between 2 values
  62020. */
  62021. export class LerpBlock extends NodeMaterialBlock {
  62022. /**
  62023. * Creates a new LerpBlock
  62024. * @param name defines the block name
  62025. */
  62026. constructor(name: string);
  62027. /**
  62028. * Gets the current class name
  62029. * @returns the class name
  62030. */
  62031. getClassName(): string;
  62032. /**
  62033. * Gets the left operand input component
  62034. */
  62035. get left(): NodeMaterialConnectionPoint;
  62036. /**
  62037. * Gets the right operand input component
  62038. */
  62039. get right(): NodeMaterialConnectionPoint;
  62040. /**
  62041. * Gets the gradient operand input component
  62042. */
  62043. get gradient(): NodeMaterialConnectionPoint;
  62044. /**
  62045. * Gets the output component
  62046. */
  62047. get output(): NodeMaterialConnectionPoint;
  62048. protected _buildBlock(state: NodeMaterialBuildState): this;
  62049. }
  62050. }
  62051. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62055. /**
  62056. * Block used to divide 2 vectors
  62057. */
  62058. export class DivideBlock extends NodeMaterialBlock {
  62059. /**
  62060. * Creates a new DivideBlock
  62061. * @param name defines the block name
  62062. */
  62063. constructor(name: string);
  62064. /**
  62065. * Gets the current class name
  62066. * @returns the class name
  62067. */
  62068. getClassName(): string;
  62069. /**
  62070. * Gets the left operand input component
  62071. */
  62072. get left(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the right operand input component
  62075. */
  62076. get right(): NodeMaterialConnectionPoint;
  62077. /**
  62078. * Gets the output component
  62079. */
  62080. get output(): NodeMaterialConnectionPoint;
  62081. protected _buildBlock(state: NodeMaterialBuildState): this;
  62082. }
  62083. }
  62084. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62088. /**
  62089. * Block used to subtract 2 vectors
  62090. */
  62091. export class SubtractBlock extends NodeMaterialBlock {
  62092. /**
  62093. * Creates a new SubtractBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the left operand input component
  62104. */
  62105. get left(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the right operand input component
  62108. */
  62109. get right(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the output component
  62112. */
  62113. get output(): NodeMaterialConnectionPoint;
  62114. protected _buildBlock(state: NodeMaterialBuildState): this;
  62115. }
  62116. }
  62117. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62121. /**
  62122. * Block used to step a value
  62123. */
  62124. export class StepBlock extends NodeMaterialBlock {
  62125. /**
  62126. * Creates a new StepBlock
  62127. * @param name defines the block name
  62128. */
  62129. constructor(name: string);
  62130. /**
  62131. * Gets the current class name
  62132. * @returns the class name
  62133. */
  62134. getClassName(): string;
  62135. /**
  62136. * Gets the value operand input component
  62137. */
  62138. get value(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the edge operand input component
  62141. */
  62142. get edge(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the output component
  62145. */
  62146. get output(): NodeMaterialConnectionPoint;
  62147. protected _buildBlock(state: NodeMaterialBuildState): this;
  62148. }
  62149. }
  62150. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62154. /**
  62155. * Block used to get the opposite (1 - x) of a value
  62156. */
  62157. export class OneMinusBlock extends NodeMaterialBlock {
  62158. /**
  62159. * Creates a new OneMinusBlock
  62160. * @param name defines the block name
  62161. */
  62162. constructor(name: string);
  62163. /**
  62164. * Gets the current class name
  62165. * @returns the class name
  62166. */
  62167. getClassName(): string;
  62168. /**
  62169. * Gets the input component
  62170. */
  62171. get input(): NodeMaterialConnectionPoint;
  62172. /**
  62173. * Gets the output component
  62174. */
  62175. get output(): NodeMaterialConnectionPoint;
  62176. protected _buildBlock(state: NodeMaterialBuildState): this;
  62177. }
  62178. }
  62179. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62183. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62184. /**
  62185. * Block used to get the view direction
  62186. */
  62187. export class ViewDirectionBlock extends NodeMaterialBlock {
  62188. /**
  62189. * Creates a new ViewDirectionBlock
  62190. * @param name defines the block name
  62191. */
  62192. constructor(name: string);
  62193. /**
  62194. * Gets the current class name
  62195. * @returns the class name
  62196. */
  62197. getClassName(): string;
  62198. /**
  62199. * Gets the world position component
  62200. */
  62201. get worldPosition(): NodeMaterialConnectionPoint;
  62202. /**
  62203. * Gets the camera position component
  62204. */
  62205. get cameraPosition(): NodeMaterialConnectionPoint;
  62206. /**
  62207. * Gets the output component
  62208. */
  62209. get output(): NodeMaterialConnectionPoint;
  62210. autoConfigure(material: NodeMaterial): void;
  62211. protected _buildBlock(state: NodeMaterialBuildState): this;
  62212. }
  62213. }
  62214. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62215. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62216. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62218. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62219. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62220. /**
  62221. * Block used to compute fresnel value
  62222. */
  62223. export class FresnelBlock extends NodeMaterialBlock {
  62224. /**
  62225. * Create a new FresnelBlock
  62226. * @param name defines the block name
  62227. */
  62228. constructor(name: string);
  62229. /**
  62230. * Gets the current class name
  62231. * @returns the class name
  62232. */
  62233. getClassName(): string;
  62234. /**
  62235. * Gets the world normal input component
  62236. */
  62237. get worldNormal(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the view direction input component
  62240. */
  62241. get viewDirection(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the bias input component
  62244. */
  62245. get bias(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the camera (or eye) position component
  62248. */
  62249. get power(): NodeMaterialConnectionPoint;
  62250. /**
  62251. * Gets the fresnel output component
  62252. */
  62253. get fresnel(): NodeMaterialConnectionPoint;
  62254. autoConfigure(material: NodeMaterial): void;
  62255. protected _buildBlock(state: NodeMaterialBuildState): this;
  62256. }
  62257. }
  62258. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62262. /**
  62263. * Block used to get the max of 2 values
  62264. */
  62265. export class MaxBlock extends NodeMaterialBlock {
  62266. /**
  62267. * Creates a new MaxBlock
  62268. * @param name defines the block name
  62269. */
  62270. constructor(name: string);
  62271. /**
  62272. * Gets the current class name
  62273. * @returns the class name
  62274. */
  62275. getClassName(): string;
  62276. /**
  62277. * Gets the left operand input component
  62278. */
  62279. get left(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the right operand input component
  62282. */
  62283. get right(): NodeMaterialConnectionPoint;
  62284. /**
  62285. * Gets the output component
  62286. */
  62287. get output(): NodeMaterialConnectionPoint;
  62288. protected _buildBlock(state: NodeMaterialBuildState): this;
  62289. }
  62290. }
  62291. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62295. /**
  62296. * Block used to get the min of 2 values
  62297. */
  62298. export class MinBlock extends NodeMaterialBlock {
  62299. /**
  62300. * Creates a new MinBlock
  62301. * @param name defines the block name
  62302. */
  62303. constructor(name: string);
  62304. /**
  62305. * Gets the current class name
  62306. * @returns the class name
  62307. */
  62308. getClassName(): string;
  62309. /**
  62310. * Gets the left operand input component
  62311. */
  62312. get left(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the right operand input component
  62315. */
  62316. get right(): NodeMaterialConnectionPoint;
  62317. /**
  62318. * Gets the output component
  62319. */
  62320. get output(): NodeMaterialConnectionPoint;
  62321. protected _buildBlock(state: NodeMaterialBuildState): this;
  62322. }
  62323. }
  62324. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62328. /**
  62329. * Block used to get the distance between 2 values
  62330. */
  62331. export class DistanceBlock extends NodeMaterialBlock {
  62332. /**
  62333. * Creates a new DistanceBlock
  62334. * @param name defines the block name
  62335. */
  62336. constructor(name: string);
  62337. /**
  62338. * Gets the current class name
  62339. * @returns the class name
  62340. */
  62341. getClassName(): string;
  62342. /**
  62343. * Gets the left operand input component
  62344. */
  62345. get left(): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Gets the right operand input component
  62348. */
  62349. get right(): NodeMaterialConnectionPoint;
  62350. /**
  62351. * Gets the output component
  62352. */
  62353. get output(): NodeMaterialConnectionPoint;
  62354. protected _buildBlock(state: NodeMaterialBuildState): this;
  62355. }
  62356. }
  62357. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62358. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62359. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62360. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62361. /**
  62362. * Block used to get the length of a vector
  62363. */
  62364. export class LengthBlock extends NodeMaterialBlock {
  62365. /**
  62366. * Creates a new LengthBlock
  62367. * @param name defines the block name
  62368. */
  62369. constructor(name: string);
  62370. /**
  62371. * Gets the current class name
  62372. * @returns the class name
  62373. */
  62374. getClassName(): string;
  62375. /**
  62376. * Gets the value input component
  62377. */
  62378. get value(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the output component
  62381. */
  62382. get output(): NodeMaterialConnectionPoint;
  62383. protected _buildBlock(state: NodeMaterialBuildState): this;
  62384. }
  62385. }
  62386. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62390. /**
  62391. * Block used to get negative version of a value (i.e. x * -1)
  62392. */
  62393. export class NegateBlock extends NodeMaterialBlock {
  62394. /**
  62395. * Creates a new NegateBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the value input component
  62406. */
  62407. get value(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the output component
  62410. */
  62411. get output(): NodeMaterialConnectionPoint;
  62412. protected _buildBlock(state: NodeMaterialBuildState): this;
  62413. }
  62414. }
  62415. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62418. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62419. /**
  62420. * Block used to get the value of the first parameter raised to the power of the second
  62421. */
  62422. export class PowBlock extends NodeMaterialBlock {
  62423. /**
  62424. * Creates a new PowBlock
  62425. * @param name defines the block name
  62426. */
  62427. constructor(name: string);
  62428. /**
  62429. * Gets the current class name
  62430. * @returns the class name
  62431. */
  62432. getClassName(): string;
  62433. /**
  62434. * Gets the value operand input component
  62435. */
  62436. get value(): NodeMaterialConnectionPoint;
  62437. /**
  62438. * Gets the power operand input component
  62439. */
  62440. get power(): NodeMaterialConnectionPoint;
  62441. /**
  62442. * Gets the output component
  62443. */
  62444. get output(): NodeMaterialConnectionPoint;
  62445. protected _buildBlock(state: NodeMaterialBuildState): this;
  62446. }
  62447. }
  62448. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62453. /**
  62454. * Block used to get a random number
  62455. */
  62456. export class RandomNumberBlock extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new RandomNumberBlock
  62459. * @param name defines the block name
  62460. */
  62461. constructor(name: string);
  62462. /**
  62463. * Gets the current class name
  62464. * @returns the class name
  62465. */
  62466. getClassName(): string;
  62467. /**
  62468. * Gets the seed input component
  62469. */
  62470. get seed(): NodeMaterialConnectionPoint;
  62471. /**
  62472. * Gets the output component
  62473. */
  62474. get output(): NodeMaterialConnectionPoint;
  62475. protected _buildBlock(state: NodeMaterialBuildState): this;
  62476. }
  62477. }
  62478. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62482. /**
  62483. * Block used to compute arc tangent of 2 values
  62484. */
  62485. export class ArcTan2Block extends NodeMaterialBlock {
  62486. /**
  62487. * Creates a new ArcTan2Block
  62488. * @param name defines the block name
  62489. */
  62490. constructor(name: string);
  62491. /**
  62492. * Gets the current class name
  62493. * @returns the class name
  62494. */
  62495. getClassName(): string;
  62496. /**
  62497. * Gets the x operand input component
  62498. */
  62499. get x(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the y operand input component
  62502. */
  62503. get y(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the output component
  62506. */
  62507. get output(): NodeMaterialConnectionPoint;
  62508. protected _buildBlock(state: NodeMaterialBuildState): this;
  62509. }
  62510. }
  62511. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62515. /**
  62516. * Block used to smooth step a value
  62517. */
  62518. export class SmoothStepBlock extends NodeMaterialBlock {
  62519. /**
  62520. * Creates a new SmoothStepBlock
  62521. * @param name defines the block name
  62522. */
  62523. constructor(name: string);
  62524. /**
  62525. * Gets the current class name
  62526. * @returns the class name
  62527. */
  62528. getClassName(): string;
  62529. /**
  62530. * Gets the value operand input component
  62531. */
  62532. get value(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the first edge operand input component
  62535. */
  62536. get edge0(): NodeMaterialConnectionPoint;
  62537. /**
  62538. * Gets the second edge operand input component
  62539. */
  62540. get edge1(): NodeMaterialConnectionPoint;
  62541. /**
  62542. * Gets the output component
  62543. */
  62544. get output(): NodeMaterialConnectionPoint;
  62545. protected _buildBlock(state: NodeMaterialBuildState): this;
  62546. }
  62547. }
  62548. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62552. /**
  62553. * Block used to get the reciprocal (1 / x) of a value
  62554. */
  62555. export class ReciprocalBlock extends NodeMaterialBlock {
  62556. /**
  62557. * Creates a new ReciprocalBlock
  62558. * @param name defines the block name
  62559. */
  62560. constructor(name: string);
  62561. /**
  62562. * Gets the current class name
  62563. * @returns the class name
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets the input component
  62568. */
  62569. get input(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the output component
  62572. */
  62573. get output(): NodeMaterialConnectionPoint;
  62574. protected _buildBlock(state: NodeMaterialBuildState): this;
  62575. }
  62576. }
  62577. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62581. /**
  62582. * Block used to replace a color by another one
  62583. */
  62584. export class ReplaceColorBlock extends NodeMaterialBlock {
  62585. /**
  62586. * Creates a new ReplaceColorBlock
  62587. * @param name defines the block name
  62588. */
  62589. constructor(name: string);
  62590. /**
  62591. * Gets the current class name
  62592. * @returns the class name
  62593. */
  62594. getClassName(): string;
  62595. /**
  62596. * Gets the value input component
  62597. */
  62598. get value(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the reference input component
  62601. */
  62602. get reference(): NodeMaterialConnectionPoint;
  62603. /**
  62604. * Gets the distance input component
  62605. */
  62606. get distance(): NodeMaterialConnectionPoint;
  62607. /**
  62608. * Gets the replacement input component
  62609. */
  62610. get replacement(): NodeMaterialConnectionPoint;
  62611. /**
  62612. * Gets the output component
  62613. */
  62614. get output(): NodeMaterialConnectionPoint;
  62615. protected _buildBlock(state: NodeMaterialBuildState): this;
  62616. }
  62617. }
  62618. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62622. /**
  62623. * Block used to posterize a value
  62624. * @see https://en.wikipedia.org/wiki/Posterization
  62625. */
  62626. export class PosterizeBlock extends NodeMaterialBlock {
  62627. /**
  62628. * Creates a new PosterizeBlock
  62629. * @param name defines the block name
  62630. */
  62631. constructor(name: string);
  62632. /**
  62633. * Gets the current class name
  62634. * @returns the class name
  62635. */
  62636. getClassName(): string;
  62637. /**
  62638. * Gets the value input component
  62639. */
  62640. get value(): NodeMaterialConnectionPoint;
  62641. /**
  62642. * Gets the steps input component
  62643. */
  62644. get steps(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62656. import { Scene } from "babylonjs/scene";
  62657. /**
  62658. * Operations supported by the Wave block
  62659. */
  62660. export enum WaveBlockKind {
  62661. /** SawTooth */
  62662. SawTooth = 0,
  62663. /** Square */
  62664. Square = 1,
  62665. /** Triangle */
  62666. Triangle = 2
  62667. }
  62668. /**
  62669. * Block used to apply wave operation to floats
  62670. */
  62671. export class WaveBlock extends NodeMaterialBlock {
  62672. /**
  62673. * Gets or sets the kibnd of wave to be applied by the block
  62674. */
  62675. kind: WaveBlockKind;
  62676. /**
  62677. * Creates a new WaveBlock
  62678. * @param name defines the block name
  62679. */
  62680. constructor(name: string);
  62681. /**
  62682. * Gets the current class name
  62683. * @returns the class name
  62684. */
  62685. getClassName(): string;
  62686. /**
  62687. * Gets the input component
  62688. */
  62689. get input(): NodeMaterialConnectionPoint;
  62690. /**
  62691. * Gets the output component
  62692. */
  62693. get output(): NodeMaterialConnectionPoint;
  62694. protected _buildBlock(state: NodeMaterialBuildState): this;
  62695. serialize(): any;
  62696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62697. }
  62698. }
  62699. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62703. import { Color3 } from "babylonjs/Maths/math.color";
  62704. import { Scene } from "babylonjs/scene";
  62705. /**
  62706. * Class used to store a color step for the GradientBlock
  62707. */
  62708. export class GradientBlockColorStep {
  62709. /**
  62710. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62711. */
  62712. step: number;
  62713. /**
  62714. * Gets or sets the color associated with this step
  62715. */
  62716. color: Color3;
  62717. /**
  62718. * Creates a new GradientBlockColorStep
  62719. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62720. * @param color defines the color associated with this step
  62721. */
  62722. constructor(
  62723. /**
  62724. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62725. */
  62726. step: number,
  62727. /**
  62728. * Gets or sets the color associated with this step
  62729. */
  62730. color: Color3);
  62731. }
  62732. /**
  62733. * Block used to return a color from a gradient based on an input value between 0 and 1
  62734. */
  62735. export class GradientBlock extends NodeMaterialBlock {
  62736. /**
  62737. * Gets or sets the list of color steps
  62738. */
  62739. colorSteps: GradientBlockColorStep[];
  62740. /**
  62741. * Creates a new GradientBlock
  62742. * @param name defines the block name
  62743. */
  62744. constructor(name: string);
  62745. /**
  62746. * Gets the current class name
  62747. * @returns the class name
  62748. */
  62749. getClassName(): string;
  62750. /**
  62751. * Gets the gradient input component
  62752. */
  62753. get gradient(): NodeMaterialConnectionPoint;
  62754. /**
  62755. * Gets the output component
  62756. */
  62757. get output(): NodeMaterialConnectionPoint;
  62758. private _writeColorConstant;
  62759. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62760. serialize(): any;
  62761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62762. protected _dumpPropertiesCode(): string;
  62763. }
  62764. }
  62765. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62769. /**
  62770. * Block used to normalize lerp between 2 values
  62771. */
  62772. export class NLerpBlock extends NodeMaterialBlock {
  62773. /**
  62774. * Creates a new NLerpBlock
  62775. * @param name defines the block name
  62776. */
  62777. constructor(name: string);
  62778. /**
  62779. * Gets the current class name
  62780. * @returns the class name
  62781. */
  62782. getClassName(): string;
  62783. /**
  62784. * Gets the left operand input component
  62785. */
  62786. get left(): NodeMaterialConnectionPoint;
  62787. /**
  62788. * Gets the right operand input component
  62789. */
  62790. get right(): NodeMaterialConnectionPoint;
  62791. /**
  62792. * Gets the gradient operand input component
  62793. */
  62794. get gradient(): NodeMaterialConnectionPoint;
  62795. /**
  62796. * Gets the output component
  62797. */
  62798. get output(): NodeMaterialConnectionPoint;
  62799. protected _buildBlock(state: NodeMaterialBuildState): this;
  62800. }
  62801. }
  62802. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62806. import { Scene } from "babylonjs/scene";
  62807. /**
  62808. * block used to Generate a Worley Noise 3D Noise Pattern
  62809. */
  62810. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62811. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62812. manhattanDistance: boolean;
  62813. /**
  62814. * Creates a new WorleyNoise3DBlock
  62815. * @param name defines the block name
  62816. */
  62817. constructor(name: string);
  62818. /**
  62819. * Gets the current class name
  62820. * @returns the class name
  62821. */
  62822. getClassName(): string;
  62823. /**
  62824. * Gets the seed input component
  62825. */
  62826. get seed(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the jitter input component
  62829. */
  62830. get jitter(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the output component
  62833. */
  62834. get output(): NodeMaterialConnectionPoint;
  62835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62836. /**
  62837. * Exposes the properties to the UI?
  62838. */
  62839. protected _dumpPropertiesCode(): string;
  62840. /**
  62841. * Exposes the properties to the Seralize?
  62842. */
  62843. serialize(): any;
  62844. /**
  62845. * Exposes the properties to the deseralize?
  62846. */
  62847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62848. }
  62849. }
  62850. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62854. /**
  62855. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62856. */
  62857. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62858. /**
  62859. * Creates a new SimplexPerlin3DBlock
  62860. * @param name defines the block name
  62861. */
  62862. constructor(name: string);
  62863. /**
  62864. * Gets the current class name
  62865. * @returns the class name
  62866. */
  62867. getClassName(): string;
  62868. /**
  62869. * Gets the seed operand input component
  62870. */
  62871. get seed(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the output component
  62874. */
  62875. get output(): NodeMaterialConnectionPoint;
  62876. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62877. }
  62878. }
  62879. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62883. /**
  62884. * Block used to blend normals
  62885. */
  62886. export class NormalBlendBlock extends NodeMaterialBlock {
  62887. /**
  62888. * Creates a new NormalBlendBlock
  62889. * @param name defines the block name
  62890. */
  62891. constructor(name: string);
  62892. /**
  62893. * Gets the current class name
  62894. * @returns the class name
  62895. */
  62896. getClassName(): string;
  62897. /**
  62898. * Gets the first input component
  62899. */
  62900. get normalMap0(): NodeMaterialConnectionPoint;
  62901. /**
  62902. * Gets the second input component
  62903. */
  62904. get normalMap1(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the output component
  62907. */
  62908. get output(): NodeMaterialConnectionPoint;
  62909. protected _buildBlock(state: NodeMaterialBuildState): this;
  62910. }
  62911. }
  62912. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62916. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62917. /**
  62918. * Block used to rotate a 2d vector by a given angle
  62919. */
  62920. export class Rotate2dBlock extends NodeMaterialBlock {
  62921. /**
  62922. * Creates a new Rotate2dBlock
  62923. * @param name defines the block name
  62924. */
  62925. constructor(name: string);
  62926. /**
  62927. * Gets the current class name
  62928. * @returns the class name
  62929. */
  62930. getClassName(): string;
  62931. /**
  62932. * Gets the input vector
  62933. */
  62934. get input(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the input angle
  62937. */
  62938. get angle(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the output component
  62941. */
  62942. get output(): NodeMaterialConnectionPoint;
  62943. autoConfigure(material: NodeMaterial): void;
  62944. protected _buildBlock(state: NodeMaterialBuildState): this;
  62945. }
  62946. }
  62947. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62951. /**
  62952. * Block used to get the reflected vector from a direction and a normal
  62953. */
  62954. export class ReflectBlock extends NodeMaterialBlock {
  62955. /**
  62956. * Creates a new ReflectBlock
  62957. * @param name defines the block name
  62958. */
  62959. constructor(name: string);
  62960. /**
  62961. * Gets the current class name
  62962. * @returns the class name
  62963. */
  62964. getClassName(): string;
  62965. /**
  62966. * Gets the incident component
  62967. */
  62968. get incident(): NodeMaterialConnectionPoint;
  62969. /**
  62970. * Gets the normal component
  62971. */
  62972. get normal(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the output component
  62975. */
  62976. get output(): NodeMaterialConnectionPoint;
  62977. protected _buildBlock(state: NodeMaterialBuildState): this;
  62978. }
  62979. }
  62980. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62984. /**
  62985. * Block used to get the refracted vector from a direction and a normal
  62986. */
  62987. export class RefractBlock extends NodeMaterialBlock {
  62988. /**
  62989. * Creates a new RefractBlock
  62990. * @param name defines the block name
  62991. */
  62992. constructor(name: string);
  62993. /**
  62994. * Gets the current class name
  62995. * @returns the class name
  62996. */
  62997. getClassName(): string;
  62998. /**
  62999. * Gets the incident component
  63000. */
  63001. get incident(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the normal component
  63004. */
  63005. get normal(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the index of refraction component
  63008. */
  63009. get ior(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the output component
  63012. */
  63013. get output(): NodeMaterialConnectionPoint;
  63014. protected _buildBlock(state: NodeMaterialBuildState): this;
  63015. }
  63016. }
  63017. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63021. /**
  63022. * Block used to desaturate a color
  63023. */
  63024. export class DesaturateBlock extends NodeMaterialBlock {
  63025. /**
  63026. * Creates a new DesaturateBlock
  63027. * @param name defines the block name
  63028. */
  63029. constructor(name: string);
  63030. /**
  63031. * Gets the current class name
  63032. * @returns the class name
  63033. */
  63034. getClassName(): string;
  63035. /**
  63036. * Gets the color operand input component
  63037. */
  63038. get color(): NodeMaterialConnectionPoint;
  63039. /**
  63040. * Gets the level operand input component
  63041. */
  63042. get level(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the output component
  63045. */
  63046. get output(): NodeMaterialConnectionPoint;
  63047. protected _buildBlock(state: NodeMaterialBuildState): this;
  63048. }
  63049. }
  63050. declare module "babylonjs/Materials/Node/Blocks/index" {
  63051. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63052. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63053. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63054. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63055. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63056. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63084. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63085. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63098. }
  63099. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63100. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63101. }
  63102. declare module "babylonjs/Materials/Node/index" {
  63103. export * from "babylonjs/Materials/Node/Enums/index";
  63104. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63105. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63106. export * from "babylonjs/Materials/Node/nodeMaterial";
  63107. export * from "babylonjs/Materials/Node/Blocks/index";
  63108. export * from "babylonjs/Materials/Node/Optimizers/index";
  63109. }
  63110. declare module "babylonjs/Materials/effectRenderer" {
  63111. import { Nullable } from "babylonjs/types";
  63112. import { Texture } from "babylonjs/Materials/Textures/texture";
  63113. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63114. import { Viewport } from "babylonjs/Maths/math.viewport";
  63115. import { Observable } from "babylonjs/Misc/observable";
  63116. import { Effect } from "babylonjs/Materials/effect";
  63117. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63118. import "babylonjs/Shaders/postprocess.vertex";
  63119. /**
  63120. * Effect Render Options
  63121. */
  63122. export interface IEffectRendererOptions {
  63123. /**
  63124. * Defines the vertices positions.
  63125. */
  63126. positions?: number[];
  63127. /**
  63128. * Defines the indices.
  63129. */
  63130. indices?: number[];
  63131. }
  63132. /**
  63133. * Helper class to render one or more effects
  63134. */
  63135. export class EffectRenderer {
  63136. private engine;
  63137. private static _DefaultOptions;
  63138. private _vertexBuffers;
  63139. private _indexBuffer;
  63140. private _ringBufferIndex;
  63141. private _ringScreenBuffer;
  63142. private _fullscreenViewport;
  63143. private _getNextFrameBuffer;
  63144. /**
  63145. * Creates an effect renderer
  63146. * @param engine the engine to use for rendering
  63147. * @param options defines the options of the effect renderer
  63148. */
  63149. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63150. /**
  63151. * Sets the current viewport in normalized coordinates 0-1
  63152. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63153. */
  63154. setViewport(viewport?: Viewport): void;
  63155. /**
  63156. * Binds the embedded attributes buffer to the effect.
  63157. * @param effect Defines the effect to bind the attributes for
  63158. */
  63159. bindBuffers(effect: Effect): void;
  63160. /**
  63161. * Sets the current effect wrapper to use during draw.
  63162. * The effect needs to be ready before calling this api.
  63163. * This also sets the default full screen position attribute.
  63164. * @param effectWrapper Defines the effect to draw with
  63165. */
  63166. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63167. /**
  63168. * Draws a full screen quad.
  63169. */
  63170. draw(): void;
  63171. /**
  63172. * renders one or more effects to a specified texture
  63173. * @param effectWrappers list of effects to renderer
  63174. * @param outputTexture texture to draw to, if null it will render to the screen
  63175. */
  63176. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63177. /**
  63178. * Disposes of the effect renderer
  63179. */
  63180. dispose(): void;
  63181. }
  63182. /**
  63183. * Options to create an EffectWrapper
  63184. */
  63185. interface EffectWrapperCreationOptions {
  63186. /**
  63187. * Engine to use to create the effect
  63188. */
  63189. engine: ThinEngine;
  63190. /**
  63191. * Fragment shader for the effect
  63192. */
  63193. fragmentShader: string;
  63194. /**
  63195. * Vertex shader for the effect
  63196. */
  63197. vertexShader?: string;
  63198. /**
  63199. * Attributes to use in the shader
  63200. */
  63201. attributeNames?: Array<string>;
  63202. /**
  63203. * Uniforms to use in the shader
  63204. */
  63205. uniformNames?: Array<string>;
  63206. /**
  63207. * Texture sampler names to use in the shader
  63208. */
  63209. samplerNames?: Array<string>;
  63210. /**
  63211. * The friendly name of the effect displayed in Spector.
  63212. */
  63213. name?: string;
  63214. }
  63215. /**
  63216. * Wraps an effect to be used for rendering
  63217. */
  63218. export class EffectWrapper {
  63219. /**
  63220. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63221. */
  63222. onApplyObservable: Observable<{}>;
  63223. /**
  63224. * The underlying effect
  63225. */
  63226. effect: Effect;
  63227. /**
  63228. * Creates an effect to be renderer
  63229. * @param creationOptions options to create the effect
  63230. */
  63231. constructor(creationOptions: EffectWrapperCreationOptions);
  63232. /**
  63233. * Disposes of the effect wrapper
  63234. */
  63235. dispose(): void;
  63236. }
  63237. }
  63238. declare module "babylonjs/Materials/index" {
  63239. export * from "babylonjs/Materials/Background/index";
  63240. export * from "babylonjs/Materials/colorCurves";
  63241. export * from "babylonjs/Materials/iEffectFallbacks";
  63242. export * from "babylonjs/Materials/effectFallbacks";
  63243. export * from "babylonjs/Materials/effect";
  63244. export * from "babylonjs/Materials/fresnelParameters";
  63245. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63246. export * from "babylonjs/Materials/material";
  63247. export * from "babylonjs/Materials/materialDefines";
  63248. export * from "babylonjs/Materials/materialHelper";
  63249. export * from "babylonjs/Materials/multiMaterial";
  63250. export * from "babylonjs/Materials/PBR/index";
  63251. export * from "babylonjs/Materials/pushMaterial";
  63252. export * from "babylonjs/Materials/shaderMaterial";
  63253. export * from "babylonjs/Materials/standardMaterial";
  63254. export * from "babylonjs/Materials/Textures/index";
  63255. export * from "babylonjs/Materials/uniformBuffer";
  63256. export * from "babylonjs/Materials/materialFlags";
  63257. export * from "babylonjs/Materials/Node/index";
  63258. export * from "babylonjs/Materials/effectRenderer";
  63259. }
  63260. declare module "babylonjs/Maths/index" {
  63261. export * from "babylonjs/Maths/math.scalar";
  63262. export * from "babylonjs/Maths/math";
  63263. export * from "babylonjs/Maths/sphericalPolynomial";
  63264. }
  63265. declare module "babylonjs/Misc/workerPool" {
  63266. import { IDisposable } from "babylonjs/scene";
  63267. /**
  63268. * Helper class to push actions to a pool of workers.
  63269. */
  63270. export class WorkerPool implements IDisposable {
  63271. private _workerInfos;
  63272. private _pendingActions;
  63273. /**
  63274. * Constructor
  63275. * @param workers Array of workers to use for actions
  63276. */
  63277. constructor(workers: Array<Worker>);
  63278. /**
  63279. * Terminates all workers and clears any pending actions.
  63280. */
  63281. dispose(): void;
  63282. /**
  63283. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63284. * pended until a worker has completed its action.
  63285. * @param action The action to perform. Call onComplete when the action is complete.
  63286. */
  63287. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63288. private _execute;
  63289. }
  63290. }
  63291. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63292. import { IDisposable } from "babylonjs/scene";
  63293. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63294. /**
  63295. * Configuration for Draco compression
  63296. */
  63297. export interface IDracoCompressionConfiguration {
  63298. /**
  63299. * Configuration for the decoder.
  63300. */
  63301. decoder: {
  63302. /**
  63303. * The url to the WebAssembly module.
  63304. */
  63305. wasmUrl?: string;
  63306. /**
  63307. * The url to the WebAssembly binary.
  63308. */
  63309. wasmBinaryUrl?: string;
  63310. /**
  63311. * The url to the fallback JavaScript module.
  63312. */
  63313. fallbackUrl?: string;
  63314. };
  63315. }
  63316. /**
  63317. * Draco compression (https://google.github.io/draco/)
  63318. *
  63319. * This class wraps the Draco module.
  63320. *
  63321. * **Encoder**
  63322. *
  63323. * The encoder is not currently implemented.
  63324. *
  63325. * **Decoder**
  63326. *
  63327. * 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.
  63328. *
  63329. * To update the configuration, use the following code:
  63330. * ```javascript
  63331. * DracoCompression.Configuration = {
  63332. * decoder: {
  63333. * wasmUrl: "<url to the WebAssembly library>",
  63334. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63335. * fallbackUrl: "<url to the fallback JavaScript library>",
  63336. * }
  63337. * };
  63338. * ```
  63339. *
  63340. * 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.
  63341. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63342. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63343. *
  63344. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63345. * ```javascript
  63346. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63347. * ```
  63348. *
  63349. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63350. */
  63351. export class DracoCompression implements IDisposable {
  63352. private _workerPoolPromise?;
  63353. private _decoderModulePromise?;
  63354. /**
  63355. * The configuration. Defaults to the following urls:
  63356. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63357. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63358. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63359. */
  63360. static Configuration: IDracoCompressionConfiguration;
  63361. /**
  63362. * Returns true if the decoder configuration is available.
  63363. */
  63364. static get DecoderAvailable(): boolean;
  63365. /**
  63366. * Default number of workers to create when creating the draco compression object.
  63367. */
  63368. static DefaultNumWorkers: number;
  63369. private static GetDefaultNumWorkers;
  63370. private static _Default;
  63371. /**
  63372. * Default instance for the draco compression object.
  63373. */
  63374. static get Default(): DracoCompression;
  63375. /**
  63376. * Constructor
  63377. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63378. */
  63379. constructor(numWorkers?: number);
  63380. /**
  63381. * Stop all async operations and release resources.
  63382. */
  63383. dispose(): void;
  63384. /**
  63385. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63386. * @returns a promise that resolves when ready
  63387. */
  63388. whenReadyAsync(): Promise<void>;
  63389. /**
  63390. * Decode Draco compressed mesh data to vertex data.
  63391. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63392. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63393. * @returns A promise that resolves with the decoded vertex data
  63394. */
  63395. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63396. [kind: string]: number;
  63397. }): Promise<VertexData>;
  63398. }
  63399. }
  63400. declare module "babylonjs/Meshes/Compression/index" {
  63401. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63402. }
  63403. declare module "babylonjs/Meshes/csg" {
  63404. import { Nullable } from "babylonjs/types";
  63405. import { Scene } from "babylonjs/scene";
  63406. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63407. import { Mesh } from "babylonjs/Meshes/mesh";
  63408. import { Material } from "babylonjs/Materials/material";
  63409. /**
  63410. * Class for building Constructive Solid Geometry
  63411. */
  63412. export class CSG {
  63413. private polygons;
  63414. /**
  63415. * The world matrix
  63416. */
  63417. matrix: Matrix;
  63418. /**
  63419. * Stores the position
  63420. */
  63421. position: Vector3;
  63422. /**
  63423. * Stores the rotation
  63424. */
  63425. rotation: Vector3;
  63426. /**
  63427. * Stores the rotation quaternion
  63428. */
  63429. rotationQuaternion: Nullable<Quaternion>;
  63430. /**
  63431. * Stores the scaling vector
  63432. */
  63433. scaling: Vector3;
  63434. /**
  63435. * Convert the Mesh to CSG
  63436. * @param mesh The Mesh to convert to CSG
  63437. * @returns A new CSG from the Mesh
  63438. */
  63439. static FromMesh(mesh: Mesh): CSG;
  63440. /**
  63441. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63442. * @param polygons Polygons used to construct a CSG solid
  63443. */
  63444. private static FromPolygons;
  63445. /**
  63446. * Clones, or makes a deep copy, of the CSG
  63447. * @returns A new CSG
  63448. */
  63449. clone(): CSG;
  63450. /**
  63451. * Unions this CSG with another CSG
  63452. * @param csg The CSG to union against this CSG
  63453. * @returns The unioned CSG
  63454. */
  63455. union(csg: CSG): CSG;
  63456. /**
  63457. * Unions this CSG with another CSG in place
  63458. * @param csg The CSG to union against this CSG
  63459. */
  63460. unionInPlace(csg: CSG): void;
  63461. /**
  63462. * Subtracts this CSG with another CSG
  63463. * @param csg The CSG to subtract against this CSG
  63464. * @returns A new CSG
  63465. */
  63466. subtract(csg: CSG): CSG;
  63467. /**
  63468. * Subtracts this CSG with another CSG in place
  63469. * @param csg The CSG to subtact against this CSG
  63470. */
  63471. subtractInPlace(csg: CSG): void;
  63472. /**
  63473. * Intersect this CSG with another CSG
  63474. * @param csg The CSG to intersect against this CSG
  63475. * @returns A new CSG
  63476. */
  63477. intersect(csg: CSG): CSG;
  63478. /**
  63479. * Intersects this CSG with another CSG in place
  63480. * @param csg The CSG to intersect against this CSG
  63481. */
  63482. intersectInPlace(csg: CSG): void;
  63483. /**
  63484. * Return a new CSG solid with solid and empty space switched. This solid is
  63485. * not modified.
  63486. * @returns A new CSG solid with solid and empty space switched
  63487. */
  63488. inverse(): CSG;
  63489. /**
  63490. * Inverses the CSG in place
  63491. */
  63492. inverseInPlace(): void;
  63493. /**
  63494. * This is used to keep meshes transformations so they can be restored
  63495. * when we build back a Babylon Mesh
  63496. * NB : All CSG operations are performed in world coordinates
  63497. * @param csg The CSG to copy the transform attributes from
  63498. * @returns This CSG
  63499. */
  63500. copyTransformAttributes(csg: CSG): CSG;
  63501. /**
  63502. * Build Raw mesh from CSG
  63503. * Coordinates here are in world space
  63504. * @param name The name of the mesh geometry
  63505. * @param scene The Scene
  63506. * @param keepSubMeshes Specifies if the submeshes should be kept
  63507. * @returns A new Mesh
  63508. */
  63509. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63510. /**
  63511. * Build Mesh from CSG taking material and transforms into account
  63512. * @param name The name of the Mesh
  63513. * @param material The material of the Mesh
  63514. * @param scene The Scene
  63515. * @param keepSubMeshes Specifies if submeshes should be kept
  63516. * @returns The new Mesh
  63517. */
  63518. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63519. }
  63520. }
  63521. declare module "babylonjs/Meshes/trailMesh" {
  63522. import { Mesh } from "babylonjs/Meshes/mesh";
  63523. import { Scene } from "babylonjs/scene";
  63524. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63525. /**
  63526. * Class used to create a trail following a mesh
  63527. */
  63528. export class TrailMesh extends Mesh {
  63529. private _generator;
  63530. private _autoStart;
  63531. private _running;
  63532. private _diameter;
  63533. private _length;
  63534. private _sectionPolygonPointsCount;
  63535. private _sectionVectors;
  63536. private _sectionNormalVectors;
  63537. private _beforeRenderObserver;
  63538. /**
  63539. * @constructor
  63540. * @param name The value used by scene.getMeshByName() to do a lookup.
  63541. * @param generator The mesh or transform node to generate a trail.
  63542. * @param scene The scene to add this mesh to.
  63543. * @param diameter Diameter of trailing mesh. Default is 1.
  63544. * @param length Length of trailing mesh. Default is 60.
  63545. * @param autoStart Automatically start trailing mesh. Default true.
  63546. */
  63547. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63548. /**
  63549. * "TrailMesh"
  63550. * @returns "TrailMesh"
  63551. */
  63552. getClassName(): string;
  63553. private _createMesh;
  63554. /**
  63555. * Start trailing mesh.
  63556. */
  63557. start(): void;
  63558. /**
  63559. * Stop trailing mesh.
  63560. */
  63561. stop(): void;
  63562. /**
  63563. * Update trailing mesh geometry.
  63564. */
  63565. update(): void;
  63566. /**
  63567. * Returns a new TrailMesh object.
  63568. * @param name is a string, the name given to the new mesh
  63569. * @param newGenerator use new generator object for cloned trail mesh
  63570. * @returns a new mesh
  63571. */
  63572. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63573. /**
  63574. * Serializes this trail mesh
  63575. * @param serializationObject object to write serialization to
  63576. */
  63577. serialize(serializationObject: any): void;
  63578. /**
  63579. * Parses a serialized trail mesh
  63580. * @param parsedMesh the serialized mesh
  63581. * @param scene the scene to create the trail mesh in
  63582. * @returns the created trail mesh
  63583. */
  63584. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63585. }
  63586. }
  63587. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63588. import { Nullable } from "babylonjs/types";
  63589. import { Scene } from "babylonjs/scene";
  63590. import { Vector4 } from "babylonjs/Maths/math.vector";
  63591. import { Color4 } from "babylonjs/Maths/math.color";
  63592. import { Mesh } from "babylonjs/Meshes/mesh";
  63593. /**
  63594. * Class containing static functions to help procedurally build meshes
  63595. */
  63596. export class TiledBoxBuilder {
  63597. /**
  63598. * Creates a box mesh
  63599. * 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)
  63600. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63604. * @param name defines the name of the mesh
  63605. * @param options defines the options used to create the mesh
  63606. * @param scene defines the hosting scene
  63607. * @returns the box mesh
  63608. */
  63609. static CreateTiledBox(name: string, options: {
  63610. pattern?: number;
  63611. width?: number;
  63612. height?: number;
  63613. depth?: number;
  63614. tileSize?: number;
  63615. tileWidth?: number;
  63616. tileHeight?: number;
  63617. alignHorizontal?: number;
  63618. alignVertical?: number;
  63619. faceUV?: Vector4[];
  63620. faceColors?: Color4[];
  63621. sideOrientation?: number;
  63622. updatable?: boolean;
  63623. }, scene?: Nullable<Scene>): Mesh;
  63624. }
  63625. }
  63626. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63627. import { Vector4 } from "babylonjs/Maths/math.vector";
  63628. import { Mesh } from "babylonjs/Meshes/mesh";
  63629. /**
  63630. * Class containing static functions to help procedurally build meshes
  63631. */
  63632. export class TorusKnotBuilder {
  63633. /**
  63634. * Creates a torus knot mesh
  63635. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63636. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63637. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63638. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63642. * @param name defines the name of the mesh
  63643. * @param options defines the options used to create the mesh
  63644. * @param scene defines the hosting scene
  63645. * @returns the torus knot mesh
  63646. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63647. */
  63648. static CreateTorusKnot(name: string, options: {
  63649. radius?: number;
  63650. tube?: number;
  63651. radialSegments?: number;
  63652. tubularSegments?: number;
  63653. p?: number;
  63654. q?: number;
  63655. updatable?: boolean;
  63656. sideOrientation?: number;
  63657. frontUVs?: Vector4;
  63658. backUVs?: Vector4;
  63659. }, scene: any): Mesh;
  63660. }
  63661. }
  63662. declare module "babylonjs/Meshes/polygonMesh" {
  63663. import { Scene } from "babylonjs/scene";
  63664. import { Vector2 } from "babylonjs/Maths/math.vector";
  63665. import { Mesh } from "babylonjs/Meshes/mesh";
  63666. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63667. import { Path2 } from "babylonjs/Maths/math.path";
  63668. /**
  63669. * Polygon
  63670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63671. */
  63672. export class Polygon {
  63673. /**
  63674. * Creates a rectangle
  63675. * @param xmin bottom X coord
  63676. * @param ymin bottom Y coord
  63677. * @param xmax top X coord
  63678. * @param ymax top Y coord
  63679. * @returns points that make the resulting rectation
  63680. */
  63681. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63682. /**
  63683. * Creates a circle
  63684. * @param radius radius of circle
  63685. * @param cx scale in x
  63686. * @param cy scale in y
  63687. * @param numberOfSides number of sides that make up the circle
  63688. * @returns points that make the resulting circle
  63689. */
  63690. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63691. /**
  63692. * Creates a polygon from input string
  63693. * @param input Input polygon data
  63694. * @returns the parsed points
  63695. */
  63696. static Parse(input: string): Vector2[];
  63697. /**
  63698. * Starts building a polygon from x and y coordinates
  63699. * @param x x coordinate
  63700. * @param y y coordinate
  63701. * @returns the started path2
  63702. */
  63703. static StartingAt(x: number, y: number): Path2;
  63704. }
  63705. /**
  63706. * Builds a polygon
  63707. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63708. */
  63709. export class PolygonMeshBuilder {
  63710. private _points;
  63711. private _outlinepoints;
  63712. private _holes;
  63713. private _name;
  63714. private _scene;
  63715. private _epoints;
  63716. private _eholes;
  63717. private _addToepoint;
  63718. /**
  63719. * Babylon reference to the earcut plugin.
  63720. */
  63721. bjsEarcut: any;
  63722. /**
  63723. * Creates a PolygonMeshBuilder
  63724. * @param name name of the builder
  63725. * @param contours Path of the polygon
  63726. * @param scene scene to add to when creating the mesh
  63727. * @param earcutInjection can be used to inject your own earcut reference
  63728. */
  63729. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63730. /**
  63731. * Adds a whole within the polygon
  63732. * @param hole Array of points defining the hole
  63733. * @returns this
  63734. */
  63735. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63736. /**
  63737. * Creates the polygon
  63738. * @param updatable If the mesh should be updatable
  63739. * @param depth The depth of the mesh created
  63740. * @returns the created mesh
  63741. */
  63742. build(updatable?: boolean, depth?: number): Mesh;
  63743. /**
  63744. * Creates the polygon
  63745. * @param depth The depth of the mesh created
  63746. * @returns the created VertexData
  63747. */
  63748. buildVertexData(depth?: number): VertexData;
  63749. /**
  63750. * Adds a side to the polygon
  63751. * @param positions points that make the polygon
  63752. * @param normals normals of the polygon
  63753. * @param uvs uvs of the polygon
  63754. * @param indices indices of the polygon
  63755. * @param bounds bounds of the polygon
  63756. * @param points points of the polygon
  63757. * @param depth depth of the polygon
  63758. * @param flip flip of the polygon
  63759. */
  63760. private addSide;
  63761. }
  63762. }
  63763. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63764. import { Scene } from "babylonjs/scene";
  63765. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63766. import { Color4 } from "babylonjs/Maths/math.color";
  63767. import { Mesh } from "babylonjs/Meshes/mesh";
  63768. import { Nullable } from "babylonjs/types";
  63769. /**
  63770. * Class containing static functions to help procedurally build meshes
  63771. */
  63772. export class PolygonBuilder {
  63773. /**
  63774. * Creates a polygon mesh
  63775. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63776. * * 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
  63777. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63780. * * Remember you can only change the shape positions, not their number when updating a polygon
  63781. * @param name defines the name of the mesh
  63782. * @param options defines the options used to create the mesh
  63783. * @param scene defines the hosting scene
  63784. * @param earcutInjection can be used to inject your own earcut reference
  63785. * @returns the polygon mesh
  63786. */
  63787. static CreatePolygon(name: string, options: {
  63788. shape: Vector3[];
  63789. holes?: Vector3[][];
  63790. depth?: number;
  63791. faceUV?: Vector4[];
  63792. faceColors?: Color4[];
  63793. updatable?: boolean;
  63794. sideOrientation?: number;
  63795. frontUVs?: Vector4;
  63796. backUVs?: Vector4;
  63797. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63798. /**
  63799. * Creates an extruded polygon mesh, with depth in the Y direction.
  63800. * * 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)
  63801. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63802. * @param name defines the name of the mesh
  63803. * @param options defines the options used to create the mesh
  63804. * @param scene defines the hosting scene
  63805. * @param earcutInjection can be used to inject your own earcut reference
  63806. * @returns the polygon mesh
  63807. */
  63808. static ExtrudePolygon(name: string, options: {
  63809. shape: Vector3[];
  63810. holes?: Vector3[][];
  63811. depth?: number;
  63812. faceUV?: Vector4[];
  63813. faceColors?: Color4[];
  63814. updatable?: boolean;
  63815. sideOrientation?: number;
  63816. frontUVs?: Vector4;
  63817. backUVs?: Vector4;
  63818. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63819. }
  63820. }
  63821. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63822. import { Scene } from "babylonjs/scene";
  63823. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63824. import { Mesh } from "babylonjs/Meshes/mesh";
  63825. import { Nullable } from "babylonjs/types";
  63826. /**
  63827. * Class containing static functions to help procedurally build meshes
  63828. */
  63829. export class LatheBuilder {
  63830. /**
  63831. * Creates lathe mesh.
  63832. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63833. * * 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
  63834. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63835. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63836. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63837. * * 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
  63838. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63839. * * 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
  63840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63844. * @param name defines the name of the mesh
  63845. * @param options defines the options used to create the mesh
  63846. * @param scene defines the hosting scene
  63847. * @returns the lathe mesh
  63848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63849. */
  63850. static CreateLathe(name: string, options: {
  63851. shape: Vector3[];
  63852. radius?: number;
  63853. tessellation?: number;
  63854. clip?: number;
  63855. arc?: number;
  63856. closed?: boolean;
  63857. updatable?: boolean;
  63858. sideOrientation?: number;
  63859. frontUVs?: Vector4;
  63860. backUVs?: Vector4;
  63861. cap?: number;
  63862. invertUV?: boolean;
  63863. }, scene?: Nullable<Scene>): Mesh;
  63864. }
  63865. }
  63866. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63867. import { Nullable } from "babylonjs/types";
  63868. import { Scene } from "babylonjs/scene";
  63869. import { Vector4 } from "babylonjs/Maths/math.vector";
  63870. import { Mesh } from "babylonjs/Meshes/mesh";
  63871. /**
  63872. * Class containing static functions to help procedurally build meshes
  63873. */
  63874. export class TiledPlaneBuilder {
  63875. /**
  63876. * Creates a tiled plane mesh
  63877. * * The parameter `pattern` will, depending on value, do nothing or
  63878. * * * flip (reflect about central vertical) alternate tiles across and up
  63879. * * * flip every tile on alternate rows
  63880. * * * rotate (180 degs) alternate tiles across and up
  63881. * * * rotate every tile on alternate rows
  63882. * * * flip and rotate alternate tiles across and up
  63883. * * * flip and rotate every tile on alternate rows
  63884. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63885. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63888. * * 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)
  63889. * * 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)
  63890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63891. * @param name defines the name of the mesh
  63892. * @param options defines the options used to create the mesh
  63893. * @param scene defines the hosting scene
  63894. * @returns the box mesh
  63895. */
  63896. static CreateTiledPlane(name: string, options: {
  63897. pattern?: number;
  63898. tileSize?: number;
  63899. tileWidth?: number;
  63900. tileHeight?: number;
  63901. size?: number;
  63902. width?: number;
  63903. height?: number;
  63904. alignHorizontal?: number;
  63905. alignVertical?: number;
  63906. sideOrientation?: number;
  63907. frontUVs?: Vector4;
  63908. backUVs?: Vector4;
  63909. updatable?: boolean;
  63910. }, scene?: Nullable<Scene>): Mesh;
  63911. }
  63912. }
  63913. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63914. import { Nullable } from "babylonjs/types";
  63915. import { Scene } from "babylonjs/scene";
  63916. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63917. import { Mesh } from "babylonjs/Meshes/mesh";
  63918. /**
  63919. * Class containing static functions to help procedurally build meshes
  63920. */
  63921. export class TubeBuilder {
  63922. /**
  63923. * Creates a tube mesh.
  63924. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63925. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63926. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63927. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63928. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63929. * * 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)
  63930. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63931. * * 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
  63932. * * 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
  63933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63937. * @param name defines the name of the mesh
  63938. * @param options defines the options used to create the mesh
  63939. * @param scene defines the hosting scene
  63940. * @returns the tube mesh
  63941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63942. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63943. */
  63944. static CreateTube(name: string, options: {
  63945. path: Vector3[];
  63946. radius?: number;
  63947. tessellation?: number;
  63948. radiusFunction?: {
  63949. (i: number, distance: number): number;
  63950. };
  63951. cap?: number;
  63952. arc?: number;
  63953. updatable?: boolean;
  63954. sideOrientation?: number;
  63955. frontUVs?: Vector4;
  63956. backUVs?: Vector4;
  63957. instance?: Mesh;
  63958. invertUV?: boolean;
  63959. }, scene?: Nullable<Scene>): Mesh;
  63960. }
  63961. }
  63962. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63963. import { Scene } from "babylonjs/scene";
  63964. import { Vector4 } from "babylonjs/Maths/math.vector";
  63965. import { Mesh } from "babylonjs/Meshes/mesh";
  63966. import { Nullable } from "babylonjs/types";
  63967. /**
  63968. * Class containing static functions to help procedurally build meshes
  63969. */
  63970. export class IcoSphereBuilder {
  63971. /**
  63972. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63973. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63974. * * 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`)
  63975. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63976. * * 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
  63977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63980. * @param name defines the name of the mesh
  63981. * @param options defines the options used to create the mesh
  63982. * @param scene defines the hosting scene
  63983. * @returns the icosahedron mesh
  63984. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63985. */
  63986. static CreateIcoSphere(name: string, options: {
  63987. radius?: number;
  63988. radiusX?: number;
  63989. radiusY?: number;
  63990. radiusZ?: number;
  63991. flat?: boolean;
  63992. subdivisions?: number;
  63993. sideOrientation?: number;
  63994. frontUVs?: Vector4;
  63995. backUVs?: Vector4;
  63996. updatable?: boolean;
  63997. }, scene?: Nullable<Scene>): Mesh;
  63998. }
  63999. }
  64000. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64001. import { Vector3 } from "babylonjs/Maths/math.vector";
  64002. import { Mesh } from "babylonjs/Meshes/mesh";
  64003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64004. /**
  64005. * Class containing static functions to help procedurally build meshes
  64006. */
  64007. export class DecalBuilder {
  64008. /**
  64009. * Creates a decal mesh.
  64010. * 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
  64011. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64012. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64013. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64014. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64015. * @param name defines the name of the mesh
  64016. * @param sourceMesh defines the mesh where the decal must be applied
  64017. * @param options defines the options used to create the mesh
  64018. * @param scene defines the hosting scene
  64019. * @returns the decal mesh
  64020. * @see https://doc.babylonjs.com/how_to/decals
  64021. */
  64022. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64023. position?: Vector3;
  64024. normal?: Vector3;
  64025. size?: Vector3;
  64026. angle?: number;
  64027. }): Mesh;
  64028. }
  64029. }
  64030. declare module "babylonjs/Meshes/meshBuilder" {
  64031. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64032. import { Nullable } from "babylonjs/types";
  64033. import { Scene } from "babylonjs/scene";
  64034. import { Mesh } from "babylonjs/Meshes/mesh";
  64035. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64036. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64038. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64039. import { Plane } from "babylonjs/Maths/math.plane";
  64040. /**
  64041. * Class containing static functions to help procedurally build meshes
  64042. */
  64043. export class MeshBuilder {
  64044. /**
  64045. * Creates a box mesh
  64046. * * The parameter `size` sets the size (float) of each box side (default 1)
  64047. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64048. * * 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)
  64049. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64053. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64054. * @param name defines the name of the mesh
  64055. * @param options defines the options used to create the mesh
  64056. * @param scene defines the hosting scene
  64057. * @returns the box mesh
  64058. */
  64059. static CreateBox(name: string, options: {
  64060. size?: number;
  64061. width?: number;
  64062. height?: number;
  64063. depth?: number;
  64064. faceUV?: Vector4[];
  64065. faceColors?: Color4[];
  64066. sideOrientation?: number;
  64067. frontUVs?: Vector4;
  64068. backUVs?: Vector4;
  64069. updatable?: boolean;
  64070. }, scene?: Nullable<Scene>): Mesh;
  64071. /**
  64072. * Creates a tiled box mesh
  64073. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64075. * @param name defines the name of the mesh
  64076. * @param options defines the options used to create the mesh
  64077. * @param scene defines the hosting scene
  64078. * @returns the tiled box mesh
  64079. */
  64080. static CreateTiledBox(name: string, options: {
  64081. pattern?: number;
  64082. size?: number;
  64083. width?: number;
  64084. height?: number;
  64085. depth: number;
  64086. tileSize?: number;
  64087. tileWidth?: number;
  64088. tileHeight?: number;
  64089. faceUV?: Vector4[];
  64090. faceColors?: Color4[];
  64091. alignHorizontal?: number;
  64092. alignVertical?: number;
  64093. sideOrientation?: number;
  64094. updatable?: boolean;
  64095. }, scene?: Nullable<Scene>): Mesh;
  64096. /**
  64097. * Creates a sphere mesh
  64098. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64099. * * 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`)
  64100. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64101. * * 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
  64102. * * 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)
  64103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64106. * @param name defines the name of the mesh
  64107. * @param options defines the options used to create the mesh
  64108. * @param scene defines the hosting scene
  64109. * @returns the sphere mesh
  64110. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64111. */
  64112. static CreateSphere(name: string, options: {
  64113. segments?: number;
  64114. diameter?: number;
  64115. diameterX?: number;
  64116. diameterY?: number;
  64117. diameterZ?: number;
  64118. arc?: number;
  64119. slice?: number;
  64120. sideOrientation?: number;
  64121. frontUVs?: Vector4;
  64122. backUVs?: Vector4;
  64123. updatable?: boolean;
  64124. }, scene?: Nullable<Scene>): Mesh;
  64125. /**
  64126. * Creates a plane polygonal mesh. By default, this is a disc
  64127. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64128. * * 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
  64129. * * 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
  64130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64133. * @param name defines the name of the mesh
  64134. * @param options defines the options used to create the mesh
  64135. * @param scene defines the hosting scene
  64136. * @returns the plane polygonal mesh
  64137. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64138. */
  64139. static CreateDisc(name: string, options: {
  64140. radius?: number;
  64141. tessellation?: number;
  64142. arc?: number;
  64143. updatable?: boolean;
  64144. sideOrientation?: number;
  64145. frontUVs?: Vector4;
  64146. backUVs?: Vector4;
  64147. }, scene?: Nullable<Scene>): Mesh;
  64148. /**
  64149. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64150. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64151. * * 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`)
  64152. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64153. * * 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
  64154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64157. * @param name defines the name of the mesh
  64158. * @param options defines the options used to create the mesh
  64159. * @param scene defines the hosting scene
  64160. * @returns the icosahedron mesh
  64161. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64162. */
  64163. static CreateIcoSphere(name: string, options: {
  64164. radius?: number;
  64165. radiusX?: number;
  64166. radiusY?: number;
  64167. radiusZ?: number;
  64168. flat?: boolean;
  64169. subdivisions?: number;
  64170. sideOrientation?: number;
  64171. frontUVs?: Vector4;
  64172. backUVs?: Vector4;
  64173. updatable?: boolean;
  64174. }, scene?: Nullable<Scene>): Mesh;
  64175. /**
  64176. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64177. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64178. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64179. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64180. * * 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
  64181. * * 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
  64182. * * 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
  64183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64185. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64186. * * 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
  64187. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64188. * * 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
  64189. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64191. * @param name defines the name of the mesh
  64192. * @param options defines the options used to create the mesh
  64193. * @param scene defines the hosting scene
  64194. * @returns the ribbon mesh
  64195. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64196. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64197. */
  64198. static CreateRibbon(name: string, options: {
  64199. pathArray: Vector3[][];
  64200. closeArray?: boolean;
  64201. closePath?: boolean;
  64202. offset?: number;
  64203. updatable?: boolean;
  64204. sideOrientation?: number;
  64205. frontUVs?: Vector4;
  64206. backUVs?: Vector4;
  64207. instance?: Mesh;
  64208. invertUV?: boolean;
  64209. uvs?: Vector2[];
  64210. colors?: Color4[];
  64211. }, scene?: Nullable<Scene>): Mesh;
  64212. /**
  64213. * Creates a cylinder or a cone mesh
  64214. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64215. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64216. * * 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.
  64217. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64218. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64219. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64220. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64221. * * 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).
  64222. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64223. * * 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).
  64224. * * 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
  64225. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64226. * * 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
  64227. * * 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.
  64228. * * If `enclose` is false, a ring surface is one element.
  64229. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64230. * * 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
  64231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64234. * @param name defines the name of the mesh
  64235. * @param options defines the options used to create the mesh
  64236. * @param scene defines the hosting scene
  64237. * @returns the cylinder mesh
  64238. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64239. */
  64240. static CreateCylinder(name: string, options: {
  64241. height?: number;
  64242. diameterTop?: number;
  64243. diameterBottom?: number;
  64244. diameter?: number;
  64245. tessellation?: number;
  64246. subdivisions?: number;
  64247. arc?: number;
  64248. faceColors?: Color4[];
  64249. faceUV?: Vector4[];
  64250. updatable?: boolean;
  64251. hasRings?: boolean;
  64252. enclose?: boolean;
  64253. cap?: number;
  64254. sideOrientation?: number;
  64255. frontUVs?: Vector4;
  64256. backUVs?: Vector4;
  64257. }, scene?: Nullable<Scene>): Mesh;
  64258. /**
  64259. * Creates a torus mesh
  64260. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64261. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64262. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @returns the torus mesh
  64270. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64271. */
  64272. static CreateTorus(name: string, options: {
  64273. diameter?: number;
  64274. thickness?: number;
  64275. tessellation?: number;
  64276. updatable?: boolean;
  64277. sideOrientation?: number;
  64278. frontUVs?: Vector4;
  64279. backUVs?: Vector4;
  64280. }, scene?: Nullable<Scene>): Mesh;
  64281. /**
  64282. * Creates a torus knot mesh
  64283. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64284. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64285. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64286. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64290. * @param name defines the name of the mesh
  64291. * @param options defines the options used to create the mesh
  64292. * @param scene defines the hosting scene
  64293. * @returns the torus knot mesh
  64294. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64295. */
  64296. static CreateTorusKnot(name: string, options: {
  64297. radius?: number;
  64298. tube?: number;
  64299. radialSegments?: number;
  64300. tubularSegments?: number;
  64301. p?: number;
  64302. q?: number;
  64303. updatable?: boolean;
  64304. sideOrientation?: number;
  64305. frontUVs?: Vector4;
  64306. backUVs?: Vector4;
  64307. }, scene?: Nullable<Scene>): Mesh;
  64308. /**
  64309. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64310. * * 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
  64311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64312. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64313. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64314. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64315. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64316. * * 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
  64317. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64320. * @param name defines the name of the new line system
  64321. * @param options defines the options used to create the line system
  64322. * @param scene defines the hosting scene
  64323. * @returns a new line system mesh
  64324. */
  64325. static CreateLineSystem(name: string, options: {
  64326. lines: Vector3[][];
  64327. updatable?: boolean;
  64328. instance?: Nullable<LinesMesh>;
  64329. colors?: Nullable<Color4[][]>;
  64330. useVertexAlpha?: boolean;
  64331. }, scene: Nullable<Scene>): LinesMesh;
  64332. /**
  64333. * Creates a line mesh
  64334. * 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
  64335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64336. * * The parameter `points` is an array successive Vector3
  64337. * * 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
  64338. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64339. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64340. * * When updating an instance, remember that only point positions can change, not the number of points
  64341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64343. * @param name defines the name of the new line system
  64344. * @param options defines the options used to create the line system
  64345. * @param scene defines the hosting scene
  64346. * @returns a new line mesh
  64347. */
  64348. static CreateLines(name: string, options: {
  64349. points: Vector3[];
  64350. updatable?: boolean;
  64351. instance?: Nullable<LinesMesh>;
  64352. colors?: Color4[];
  64353. useVertexAlpha?: boolean;
  64354. }, scene?: Nullable<Scene>): LinesMesh;
  64355. /**
  64356. * Creates a dashed line mesh
  64357. * * 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
  64358. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64359. * * The parameter `points` is an array successive Vector3
  64360. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64361. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64362. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64363. * * 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
  64364. * * When updating an instance, remember that only point positions can change, not the number of points
  64365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64366. * @param name defines the name of the mesh
  64367. * @param options defines the options used to create the mesh
  64368. * @param scene defines the hosting scene
  64369. * @returns the dashed line mesh
  64370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64371. */
  64372. static CreateDashedLines(name: string, options: {
  64373. points: Vector3[];
  64374. dashSize?: number;
  64375. gapSize?: number;
  64376. dashNb?: number;
  64377. updatable?: boolean;
  64378. instance?: LinesMesh;
  64379. }, scene?: Nullable<Scene>): LinesMesh;
  64380. /**
  64381. * 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.
  64382. * * 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.
  64383. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64384. * * 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.
  64385. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64386. * * 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
  64387. * * 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
  64388. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64393. * @param name defines the name of the mesh
  64394. * @param options defines the options used to create the mesh
  64395. * @param scene defines the hosting scene
  64396. * @returns the extruded shape mesh
  64397. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64399. */
  64400. static ExtrudeShape(name: string, options: {
  64401. shape: Vector3[];
  64402. path: Vector3[];
  64403. scale?: number;
  64404. rotation?: number;
  64405. cap?: number;
  64406. updatable?: boolean;
  64407. sideOrientation?: number;
  64408. frontUVs?: Vector4;
  64409. backUVs?: Vector4;
  64410. instance?: Mesh;
  64411. invertUV?: boolean;
  64412. }, scene?: Nullable<Scene>): Mesh;
  64413. /**
  64414. * Creates an custom extruded shape mesh.
  64415. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64416. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  64417. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64418. * * The parameter `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
  64419. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64420. * * 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
  64421. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64422. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64423. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64424. * * 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
  64425. * * 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
  64426. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64431. * @param name defines the name of the mesh
  64432. * @param options defines the options used to create the mesh
  64433. * @param scene defines the hosting scene
  64434. * @returns the custom extruded shape mesh
  64435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64438. */
  64439. static ExtrudeShapeCustom(name: string, options: {
  64440. shape: Vector3[];
  64441. path: Vector3[];
  64442. scaleFunction?: any;
  64443. rotationFunction?: any;
  64444. ribbonCloseArray?: boolean;
  64445. ribbonClosePath?: boolean;
  64446. cap?: number;
  64447. updatable?: boolean;
  64448. sideOrientation?: number;
  64449. frontUVs?: Vector4;
  64450. backUVs?: Vector4;
  64451. instance?: Mesh;
  64452. invertUV?: boolean;
  64453. }, scene?: Nullable<Scene>): Mesh;
  64454. /**
  64455. * Creates lathe mesh.
  64456. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64457. * * 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
  64458. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64459. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64460. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64461. * * 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
  64462. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64463. * * 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
  64464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64468. * @param name defines the name of the mesh
  64469. * @param options defines the options used to create the mesh
  64470. * @param scene defines the hosting scene
  64471. * @returns the lathe mesh
  64472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64473. */
  64474. static CreateLathe(name: string, options: {
  64475. shape: Vector3[];
  64476. radius?: number;
  64477. tessellation?: number;
  64478. clip?: number;
  64479. arc?: number;
  64480. closed?: boolean;
  64481. updatable?: boolean;
  64482. sideOrientation?: number;
  64483. frontUVs?: Vector4;
  64484. backUVs?: Vector4;
  64485. cap?: number;
  64486. invertUV?: boolean;
  64487. }, scene?: Nullable<Scene>): Mesh;
  64488. /**
  64489. * Creates a tiled plane mesh
  64490. * * You can set a limited pattern arrangement with the tiles
  64491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64494. * @param name defines the name of the mesh
  64495. * @param options defines the options used to create the mesh
  64496. * @param scene defines the hosting scene
  64497. * @returns the plane mesh
  64498. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64499. */
  64500. static CreateTiledPlane(name: string, options: {
  64501. pattern?: number;
  64502. tileSize?: number;
  64503. tileWidth?: number;
  64504. tileHeight?: number;
  64505. size?: number;
  64506. width?: number;
  64507. height?: number;
  64508. alignHorizontal?: number;
  64509. alignVertical?: number;
  64510. sideOrientation?: number;
  64511. frontUVs?: Vector4;
  64512. backUVs?: Vector4;
  64513. updatable?: boolean;
  64514. }, scene?: Nullable<Scene>): Mesh;
  64515. /**
  64516. * Creates a plane mesh
  64517. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64518. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64519. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64523. * @param name defines the name of the mesh
  64524. * @param options defines the options used to create the mesh
  64525. * @param scene defines the hosting scene
  64526. * @returns the plane mesh
  64527. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64528. */
  64529. static CreatePlane(name: string, options: {
  64530. size?: number;
  64531. width?: number;
  64532. height?: number;
  64533. sideOrientation?: number;
  64534. frontUVs?: Vector4;
  64535. backUVs?: Vector4;
  64536. updatable?: boolean;
  64537. sourcePlane?: Plane;
  64538. }, scene?: Nullable<Scene>): Mesh;
  64539. /**
  64540. * Creates a ground mesh
  64541. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64542. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64544. * @param name defines the name of the mesh
  64545. * @param options defines the options used to create the mesh
  64546. * @param scene defines the hosting scene
  64547. * @returns the ground mesh
  64548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64549. */
  64550. static CreateGround(name: string, options: {
  64551. width?: number;
  64552. height?: number;
  64553. subdivisions?: number;
  64554. subdivisionsX?: number;
  64555. subdivisionsY?: number;
  64556. updatable?: boolean;
  64557. }, scene?: Nullable<Scene>): Mesh;
  64558. /**
  64559. * Creates a tiled ground mesh
  64560. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64561. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64562. * * 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
  64563. * * 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
  64564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64565. * @param name defines the name of the mesh
  64566. * @param options defines the options used to create the mesh
  64567. * @param scene defines the hosting scene
  64568. * @returns the tiled ground mesh
  64569. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64570. */
  64571. static CreateTiledGround(name: string, options: {
  64572. xmin: number;
  64573. zmin: number;
  64574. xmax: number;
  64575. zmax: number;
  64576. subdivisions?: {
  64577. w: number;
  64578. h: number;
  64579. };
  64580. precision?: {
  64581. w: number;
  64582. h: number;
  64583. };
  64584. updatable?: boolean;
  64585. }, scene?: Nullable<Scene>): Mesh;
  64586. /**
  64587. * Creates a ground mesh from a height map
  64588. * * The parameter `url` sets the URL of the height map image resource.
  64589. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64590. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64591. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64592. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64593. * * 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.
  64594. * * 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).
  64595. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64597. * @param name defines the name of the mesh
  64598. * @param url defines the url to the height map
  64599. * @param options defines the options used to create the mesh
  64600. * @param scene defines the hosting scene
  64601. * @returns the ground mesh
  64602. * @see https://doc.babylonjs.com/babylon101/height_map
  64603. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64604. */
  64605. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64606. width?: number;
  64607. height?: number;
  64608. subdivisions?: number;
  64609. minHeight?: number;
  64610. maxHeight?: number;
  64611. colorFilter?: Color3;
  64612. alphaFilter?: number;
  64613. updatable?: boolean;
  64614. onReady?: (mesh: GroundMesh) => void;
  64615. }, scene?: Nullable<Scene>): GroundMesh;
  64616. /**
  64617. * Creates a polygon mesh
  64618. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64619. * * 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
  64620. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64623. * * Remember you can only change the shape positions, not their number when updating a polygon
  64624. * @param name defines the name of the mesh
  64625. * @param options defines the options used to create the mesh
  64626. * @param scene defines the hosting scene
  64627. * @param earcutInjection can be used to inject your own earcut reference
  64628. * @returns the polygon mesh
  64629. */
  64630. static CreatePolygon(name: string, options: {
  64631. shape: Vector3[];
  64632. holes?: Vector3[][];
  64633. depth?: number;
  64634. faceUV?: Vector4[];
  64635. faceColors?: Color4[];
  64636. updatable?: boolean;
  64637. sideOrientation?: number;
  64638. frontUVs?: Vector4;
  64639. backUVs?: Vector4;
  64640. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64641. /**
  64642. * Creates an extruded polygon mesh, with depth in the Y direction.
  64643. * * 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)
  64644. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64645. * @param name defines the name of the mesh
  64646. * @param options defines the options used to create the mesh
  64647. * @param scene defines the hosting scene
  64648. * @param earcutInjection can be used to inject your own earcut reference
  64649. * @returns the polygon mesh
  64650. */
  64651. static ExtrudePolygon(name: string, options: {
  64652. shape: Vector3[];
  64653. holes?: Vector3[][];
  64654. depth?: number;
  64655. faceUV?: Vector4[];
  64656. faceColors?: Color4[];
  64657. updatable?: boolean;
  64658. sideOrientation?: number;
  64659. frontUVs?: Vector4;
  64660. backUVs?: Vector4;
  64661. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64662. /**
  64663. * Creates a tube mesh.
  64664. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64665. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64666. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64667. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64668. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64669. * * 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)
  64670. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64671. * * 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
  64672. * * 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
  64673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64677. * @param name defines the name of the mesh
  64678. * @param options defines the options used to create the mesh
  64679. * @param scene defines the hosting scene
  64680. * @returns the tube mesh
  64681. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64682. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64683. */
  64684. static CreateTube(name: string, options: {
  64685. path: Vector3[];
  64686. radius?: number;
  64687. tessellation?: number;
  64688. radiusFunction?: {
  64689. (i: number, distance: number): number;
  64690. };
  64691. cap?: number;
  64692. arc?: number;
  64693. updatable?: boolean;
  64694. sideOrientation?: number;
  64695. frontUVs?: Vector4;
  64696. backUVs?: Vector4;
  64697. instance?: Mesh;
  64698. invertUV?: boolean;
  64699. }, scene?: Nullable<Scene>): Mesh;
  64700. /**
  64701. * Creates a polyhedron mesh
  64702. * * 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
  64703. * * The parameter `size` (positive float, default 1) sets the polygon size
  64704. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64705. * * 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`
  64706. * * 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
  64707. * * 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)`)
  64708. * * 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
  64709. * * 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
  64710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64713. * @param name defines the name of the mesh
  64714. * @param options defines the options used to create the mesh
  64715. * @param scene defines the hosting scene
  64716. * @returns the polyhedron mesh
  64717. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64718. */
  64719. static CreatePolyhedron(name: string, options: {
  64720. type?: number;
  64721. size?: number;
  64722. sizeX?: number;
  64723. sizeY?: number;
  64724. sizeZ?: number;
  64725. custom?: any;
  64726. faceUV?: Vector4[];
  64727. faceColors?: Color4[];
  64728. flat?: boolean;
  64729. updatable?: boolean;
  64730. sideOrientation?: number;
  64731. frontUVs?: Vector4;
  64732. backUVs?: Vector4;
  64733. }, scene?: Nullable<Scene>): Mesh;
  64734. /**
  64735. * Creates a decal mesh.
  64736. * 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
  64737. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64738. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64739. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64740. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64741. * @param name defines the name of the mesh
  64742. * @param sourceMesh defines the mesh where the decal must be applied
  64743. * @param options defines the options used to create the mesh
  64744. * @param scene defines the hosting scene
  64745. * @returns the decal mesh
  64746. * @see https://doc.babylonjs.com/how_to/decals
  64747. */
  64748. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64749. position?: Vector3;
  64750. normal?: Vector3;
  64751. size?: Vector3;
  64752. angle?: number;
  64753. }): Mesh;
  64754. }
  64755. }
  64756. declare module "babylonjs/Meshes/meshSimplification" {
  64757. import { Mesh } from "babylonjs/Meshes/mesh";
  64758. /**
  64759. * A simplifier interface for future simplification implementations
  64760. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64761. */
  64762. export interface ISimplifier {
  64763. /**
  64764. * Simplification of a given mesh according to the given settings.
  64765. * Since this requires computation, it is assumed that the function runs async.
  64766. * @param settings The settings of the simplification, including quality and distance
  64767. * @param successCallback A callback that will be called after the mesh was simplified.
  64768. * @param errorCallback in case of an error, this callback will be called. optional.
  64769. */
  64770. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64771. }
  64772. /**
  64773. * Expected simplification settings.
  64774. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64776. */
  64777. export interface ISimplificationSettings {
  64778. /**
  64779. * Gets or sets the expected quality
  64780. */
  64781. quality: number;
  64782. /**
  64783. * Gets or sets the distance when this optimized version should be used
  64784. */
  64785. distance: number;
  64786. /**
  64787. * Gets an already optimized mesh
  64788. */
  64789. optimizeMesh?: boolean;
  64790. }
  64791. /**
  64792. * Class used to specify simplification options
  64793. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64794. */
  64795. export class SimplificationSettings implements ISimplificationSettings {
  64796. /** expected quality */
  64797. quality: number;
  64798. /** distance when this optimized version should be used */
  64799. distance: number;
  64800. /** already optimized mesh */
  64801. optimizeMesh?: boolean | undefined;
  64802. /**
  64803. * Creates a SimplificationSettings
  64804. * @param quality expected quality
  64805. * @param distance distance when this optimized version should be used
  64806. * @param optimizeMesh already optimized mesh
  64807. */
  64808. constructor(
  64809. /** expected quality */
  64810. quality: number,
  64811. /** distance when this optimized version should be used */
  64812. distance: number,
  64813. /** already optimized mesh */
  64814. optimizeMesh?: boolean | undefined);
  64815. }
  64816. /**
  64817. * Interface used to define a simplification task
  64818. */
  64819. export interface ISimplificationTask {
  64820. /**
  64821. * Array of settings
  64822. */
  64823. settings: Array<ISimplificationSettings>;
  64824. /**
  64825. * Simplification type
  64826. */
  64827. simplificationType: SimplificationType;
  64828. /**
  64829. * Mesh to simplify
  64830. */
  64831. mesh: Mesh;
  64832. /**
  64833. * Callback called on success
  64834. */
  64835. successCallback?: () => void;
  64836. /**
  64837. * Defines if parallel processing can be used
  64838. */
  64839. parallelProcessing: boolean;
  64840. }
  64841. /**
  64842. * Queue used to order the simplification tasks
  64843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64844. */
  64845. export class SimplificationQueue {
  64846. private _simplificationArray;
  64847. /**
  64848. * Gets a boolean indicating that the process is still running
  64849. */
  64850. running: boolean;
  64851. /**
  64852. * Creates a new queue
  64853. */
  64854. constructor();
  64855. /**
  64856. * Adds a new simplification task
  64857. * @param task defines a task to add
  64858. */
  64859. addTask(task: ISimplificationTask): void;
  64860. /**
  64861. * Execute next task
  64862. */
  64863. executeNext(): void;
  64864. /**
  64865. * Execute a simplification task
  64866. * @param task defines the task to run
  64867. */
  64868. runSimplification(task: ISimplificationTask): void;
  64869. private getSimplifier;
  64870. }
  64871. /**
  64872. * The implemented types of simplification
  64873. * At the moment only Quadratic Error Decimation is implemented
  64874. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64875. */
  64876. export enum SimplificationType {
  64877. /** Quadratic error decimation */
  64878. QUADRATIC = 0
  64879. }
  64880. }
  64881. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64882. import { Scene } from "babylonjs/scene";
  64883. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64884. import { ISceneComponent } from "babylonjs/sceneComponent";
  64885. module "babylonjs/scene" {
  64886. interface Scene {
  64887. /** @hidden (Backing field) */
  64888. _simplificationQueue: SimplificationQueue;
  64889. /**
  64890. * Gets or sets the simplification queue attached to the scene
  64891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64892. */
  64893. simplificationQueue: SimplificationQueue;
  64894. }
  64895. }
  64896. module "babylonjs/Meshes/mesh" {
  64897. interface Mesh {
  64898. /**
  64899. * Simplify the mesh according to the given array of settings.
  64900. * Function will return immediately and will simplify async
  64901. * @param settings a collection of simplification settings
  64902. * @param parallelProcessing should all levels calculate parallel or one after the other
  64903. * @param simplificationType the type of simplification to run
  64904. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64905. * @returns the current mesh
  64906. */
  64907. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64908. }
  64909. }
  64910. /**
  64911. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64912. * created in a scene
  64913. */
  64914. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64915. /**
  64916. * The component name helpfull to identify the component in the list of scene components.
  64917. */
  64918. readonly name: string;
  64919. /**
  64920. * The scene the component belongs to.
  64921. */
  64922. scene: Scene;
  64923. /**
  64924. * Creates a new instance of the component for the given scene
  64925. * @param scene Defines the scene to register the component in
  64926. */
  64927. constructor(scene: Scene);
  64928. /**
  64929. * Registers the component in a given scene
  64930. */
  64931. register(): void;
  64932. /**
  64933. * Rebuilds the elements related to this component in case of
  64934. * context lost for instance.
  64935. */
  64936. rebuild(): void;
  64937. /**
  64938. * Disposes the component and the associated ressources
  64939. */
  64940. dispose(): void;
  64941. private _beforeCameraUpdate;
  64942. }
  64943. }
  64944. declare module "babylonjs/Meshes/Builders/index" {
  64945. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64946. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64947. export * from "babylonjs/Meshes/Builders/discBuilder";
  64948. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64949. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64950. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64951. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64952. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64953. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64954. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64955. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64956. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64957. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64958. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64959. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64960. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64961. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64962. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64963. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64964. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64965. }
  64966. declare module "babylonjs/Meshes/index" {
  64967. export * from "babylonjs/Meshes/abstractMesh";
  64968. export * from "babylonjs/Meshes/buffer";
  64969. export * from "babylonjs/Meshes/Compression/index";
  64970. export * from "babylonjs/Meshes/csg";
  64971. export * from "babylonjs/Meshes/geometry";
  64972. export * from "babylonjs/Meshes/groundMesh";
  64973. export * from "babylonjs/Meshes/trailMesh";
  64974. export * from "babylonjs/Meshes/instancedMesh";
  64975. export * from "babylonjs/Meshes/linesMesh";
  64976. export * from "babylonjs/Meshes/mesh";
  64977. export * from "babylonjs/Meshes/mesh.vertexData";
  64978. export * from "babylonjs/Meshes/meshBuilder";
  64979. export * from "babylonjs/Meshes/meshSimplification";
  64980. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64981. export * from "babylonjs/Meshes/polygonMesh";
  64982. export * from "babylonjs/Meshes/subMesh";
  64983. export * from "babylonjs/Meshes/meshLODLevel";
  64984. export * from "babylonjs/Meshes/transformNode";
  64985. export * from "babylonjs/Meshes/Builders/index";
  64986. export * from "babylonjs/Meshes/dataBuffer";
  64987. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64988. }
  64989. declare module "babylonjs/Morph/index" {
  64990. export * from "babylonjs/Morph/morphTarget";
  64991. export * from "babylonjs/Morph/morphTargetManager";
  64992. }
  64993. declare module "babylonjs/Navigation/INavigationEngine" {
  64994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64995. import { Vector3 } from "babylonjs/Maths/math";
  64996. import { Mesh } from "babylonjs/Meshes/mesh";
  64997. import { Scene } from "babylonjs/scene";
  64998. /**
  64999. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65000. */
  65001. export interface INavigationEnginePlugin {
  65002. /**
  65003. * plugin name
  65004. */
  65005. name: string;
  65006. /**
  65007. * Creates a navigation mesh
  65008. * @param meshes array of all the geometry used to compute the navigatio mesh
  65009. * @param parameters bunch of parameters used to filter geometry
  65010. */
  65011. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65012. /**
  65013. * Create a navigation mesh debug mesh
  65014. * @param scene is where the mesh will be added
  65015. * @returns debug display mesh
  65016. */
  65017. createDebugNavMesh(scene: Scene): Mesh;
  65018. /**
  65019. * Get a navigation mesh constrained position, closest to the parameter position
  65020. * @param position world position
  65021. * @returns the closest point to position constrained by the navigation mesh
  65022. */
  65023. getClosestPoint(position: Vector3): Vector3;
  65024. /**
  65025. * Get a navigation mesh constrained position, within a particular radius
  65026. * @param position world position
  65027. * @param maxRadius the maximum distance to the constrained world position
  65028. * @returns the closest point to position constrained by the navigation mesh
  65029. */
  65030. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65031. /**
  65032. * Compute the final position from a segment made of destination-position
  65033. * @param position world position
  65034. * @param destination world position
  65035. * @returns the resulting point along the navmesh
  65036. */
  65037. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65038. /**
  65039. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65040. * @param start world position
  65041. * @param end world position
  65042. * @returns array containing world position composing the path
  65043. */
  65044. computePath(start: Vector3, end: Vector3): Vector3[];
  65045. /**
  65046. * If this plugin is supported
  65047. * @returns true if plugin is supported
  65048. */
  65049. isSupported(): boolean;
  65050. /**
  65051. * Create a new Crowd so you can add agents
  65052. * @param maxAgents the maximum agent count in the crowd
  65053. * @param maxAgentRadius the maximum radius an agent can have
  65054. * @param scene to attach the crowd to
  65055. * @returns the crowd you can add agents to
  65056. */
  65057. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65058. /**
  65059. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65060. * The queries will try to find a solution within those bounds
  65061. * default is (1,1,1)
  65062. * @param extent x,y,z value that define the extent around the queries point of reference
  65063. */
  65064. setDefaultQueryExtent(extent: Vector3): void;
  65065. /**
  65066. * Get the Bounding box extent specified by setDefaultQueryExtent
  65067. * @returns the box extent values
  65068. */
  65069. getDefaultQueryExtent(): Vector3;
  65070. /**
  65071. * Release all resources
  65072. */
  65073. dispose(): void;
  65074. }
  65075. /**
  65076. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65077. */
  65078. export interface ICrowd {
  65079. /**
  65080. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65081. * You can attach anything to that node. The node position is updated in the scene update tick.
  65082. * @param pos world position that will be constrained by the navigation mesh
  65083. * @param parameters agent parameters
  65084. * @param transform hooked to the agent that will be update by the scene
  65085. * @returns agent index
  65086. */
  65087. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65088. /**
  65089. * Returns the agent position in world space
  65090. * @param index agent index returned by addAgent
  65091. * @returns world space position
  65092. */
  65093. getAgentPosition(index: number): Vector3;
  65094. /**
  65095. * Gets the agent velocity in world space
  65096. * @param index agent index returned by addAgent
  65097. * @returns world space velocity
  65098. */
  65099. getAgentVelocity(index: number): Vector3;
  65100. /**
  65101. * remove a particular agent previously created
  65102. * @param index agent index returned by addAgent
  65103. */
  65104. removeAgent(index: number): void;
  65105. /**
  65106. * get the list of all agents attached to this crowd
  65107. * @returns list of agent indices
  65108. */
  65109. getAgents(): number[];
  65110. /**
  65111. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65112. * @param deltaTime in seconds
  65113. */
  65114. update(deltaTime: number): void;
  65115. /**
  65116. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65117. * @param index agent index returned by addAgent
  65118. * @param destination targeted world position
  65119. */
  65120. agentGoto(index: number, destination: Vector3): void;
  65121. /**
  65122. * Teleport the agent to a new position
  65123. * @param index agent index returned by addAgent
  65124. * @param destination targeted world position
  65125. */
  65126. agentTeleport(index: number, destination: Vector3): void;
  65127. /**
  65128. * Update agent parameters
  65129. * @param index agent index returned by addAgent
  65130. * @param parameters agent parameters
  65131. */
  65132. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65133. /**
  65134. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65135. * The queries will try to find a solution within those bounds
  65136. * default is (1,1,1)
  65137. * @param extent x,y,z value that define the extent around the queries point of reference
  65138. */
  65139. setDefaultQueryExtent(extent: Vector3): void;
  65140. /**
  65141. * Get the Bounding box extent specified by setDefaultQueryExtent
  65142. * @returns the box extent values
  65143. */
  65144. getDefaultQueryExtent(): Vector3;
  65145. /**
  65146. * Release all resources
  65147. */
  65148. dispose(): void;
  65149. }
  65150. /**
  65151. * Configures an agent
  65152. */
  65153. export interface IAgentParameters {
  65154. /**
  65155. * Agent radius. [Limit: >= 0]
  65156. */
  65157. radius: number;
  65158. /**
  65159. * Agent height. [Limit: > 0]
  65160. */
  65161. height: number;
  65162. /**
  65163. * Maximum allowed acceleration. [Limit: >= 0]
  65164. */
  65165. maxAcceleration: number;
  65166. /**
  65167. * Maximum allowed speed. [Limit: >= 0]
  65168. */
  65169. maxSpeed: number;
  65170. /**
  65171. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65172. */
  65173. collisionQueryRange: number;
  65174. /**
  65175. * The path visibility optimization range. [Limit: > 0]
  65176. */
  65177. pathOptimizationRange: number;
  65178. /**
  65179. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65180. */
  65181. separationWeight: number;
  65182. }
  65183. /**
  65184. * Configures the navigation mesh creation
  65185. */
  65186. export interface INavMeshParameters {
  65187. /**
  65188. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65189. */
  65190. cs: number;
  65191. /**
  65192. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65193. */
  65194. ch: number;
  65195. /**
  65196. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65197. */
  65198. walkableSlopeAngle: number;
  65199. /**
  65200. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65201. * be considered walkable. [Limit: >= 3] [Units: vx]
  65202. */
  65203. walkableHeight: number;
  65204. /**
  65205. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65206. */
  65207. walkableClimb: number;
  65208. /**
  65209. * The distance to erode/shrink the walkable area of the heightfield away from
  65210. * obstructions. [Limit: >=0] [Units: vx]
  65211. */
  65212. walkableRadius: number;
  65213. /**
  65214. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65215. */
  65216. maxEdgeLen: number;
  65217. /**
  65218. * The maximum distance a simplfied contour's border edges should deviate
  65219. * the original raw contour. [Limit: >=0] [Units: vx]
  65220. */
  65221. maxSimplificationError: number;
  65222. /**
  65223. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65224. */
  65225. minRegionArea: number;
  65226. /**
  65227. * Any regions with a span count smaller than this value will, if possible,
  65228. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65229. */
  65230. mergeRegionArea: number;
  65231. /**
  65232. * The maximum number of vertices allowed for polygons generated during the
  65233. * contour to polygon conversion process. [Limit: >= 3]
  65234. */
  65235. maxVertsPerPoly: number;
  65236. /**
  65237. * Sets the sampling distance to use when generating the detail mesh.
  65238. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65239. */
  65240. detailSampleDist: number;
  65241. /**
  65242. * The maximum distance the detail mesh surface should deviate from heightfield
  65243. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65244. */
  65245. detailSampleMaxError: number;
  65246. }
  65247. }
  65248. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65249. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65250. import { Mesh } from "babylonjs/Meshes/mesh";
  65251. import { Scene } from "babylonjs/scene";
  65252. import { Vector3 } from "babylonjs/Maths/math";
  65253. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65254. /**
  65255. * RecastJS navigation plugin
  65256. */
  65257. export class RecastJSPlugin implements INavigationEnginePlugin {
  65258. /**
  65259. * Reference to the Recast library
  65260. */
  65261. bjsRECAST: any;
  65262. /**
  65263. * plugin name
  65264. */
  65265. name: string;
  65266. /**
  65267. * the first navmesh created. We might extend this to support multiple navmeshes
  65268. */
  65269. navMesh: any;
  65270. /**
  65271. * Initializes the recastJS plugin
  65272. * @param recastInjection can be used to inject your own recast reference
  65273. */
  65274. constructor(recastInjection?: any);
  65275. /**
  65276. * Creates a navigation mesh
  65277. * @param meshes array of all the geometry used to compute the navigatio mesh
  65278. * @param parameters bunch of parameters used to filter geometry
  65279. */
  65280. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65281. /**
  65282. * Create a navigation mesh debug mesh
  65283. * @param scene is where the mesh will be added
  65284. * @returns debug display mesh
  65285. */
  65286. createDebugNavMesh(scene: Scene): Mesh;
  65287. /**
  65288. * Get a navigation mesh constrained position, closest to the parameter position
  65289. * @param position world position
  65290. * @returns the closest point to position constrained by the navigation mesh
  65291. */
  65292. getClosestPoint(position: Vector3): Vector3;
  65293. /**
  65294. * Get a navigation mesh constrained position, within a particular radius
  65295. * @param position world position
  65296. * @param maxRadius the maximum distance to the constrained world position
  65297. * @returns the closest point to position constrained by the navigation mesh
  65298. */
  65299. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65300. /**
  65301. * Compute the final position from a segment made of destination-position
  65302. * @param position world position
  65303. * @param destination world position
  65304. * @returns the resulting point along the navmesh
  65305. */
  65306. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65307. /**
  65308. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65309. * @param start world position
  65310. * @param end world position
  65311. * @returns array containing world position composing the path
  65312. */
  65313. computePath(start: Vector3, end: Vector3): Vector3[];
  65314. /**
  65315. * Create a new Crowd so you can add agents
  65316. * @param maxAgents the maximum agent count in the crowd
  65317. * @param maxAgentRadius the maximum radius an agent can have
  65318. * @param scene to attach the crowd to
  65319. * @returns the crowd you can add agents to
  65320. */
  65321. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65322. /**
  65323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65324. * The queries will try to find a solution within those bounds
  65325. * default is (1,1,1)
  65326. * @param extent x,y,z value that define the extent around the queries point of reference
  65327. */
  65328. setDefaultQueryExtent(extent: Vector3): void;
  65329. /**
  65330. * Get the Bounding box extent specified by setDefaultQueryExtent
  65331. * @returns the box extent values
  65332. */
  65333. getDefaultQueryExtent(): Vector3;
  65334. /**
  65335. * Disposes
  65336. */
  65337. dispose(): void;
  65338. /**
  65339. * If this plugin is supported
  65340. * @returns true if plugin is supported
  65341. */
  65342. isSupported(): boolean;
  65343. }
  65344. /**
  65345. * Recast detour crowd implementation
  65346. */
  65347. export class RecastJSCrowd implements ICrowd {
  65348. /**
  65349. * Recast/detour plugin
  65350. */
  65351. bjsRECASTPlugin: RecastJSPlugin;
  65352. /**
  65353. * Link to the detour crowd
  65354. */
  65355. recastCrowd: any;
  65356. /**
  65357. * One transform per agent
  65358. */
  65359. transforms: TransformNode[];
  65360. /**
  65361. * All agents created
  65362. */
  65363. agents: number[];
  65364. /**
  65365. * Link to the scene is kept to unregister the crowd from the scene
  65366. */
  65367. private _scene;
  65368. /**
  65369. * Observer for crowd updates
  65370. */
  65371. private _onBeforeAnimationsObserver;
  65372. /**
  65373. * Constructor
  65374. * @param plugin recastJS plugin
  65375. * @param maxAgents the maximum agent count in the crowd
  65376. * @param maxAgentRadius the maximum radius an agent can have
  65377. * @param scene to attach the crowd to
  65378. * @returns the crowd you can add agents to
  65379. */
  65380. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65381. /**
  65382. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65383. * You can attach anything to that node. The node position is updated in the scene update tick.
  65384. * @param pos world position that will be constrained by the navigation mesh
  65385. * @param parameters agent parameters
  65386. * @param transform hooked to the agent that will be update by the scene
  65387. * @returns agent index
  65388. */
  65389. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65390. /**
  65391. * Returns the agent position in world space
  65392. * @param index agent index returned by addAgent
  65393. * @returns world space position
  65394. */
  65395. getAgentPosition(index: number): Vector3;
  65396. /**
  65397. * Returns the agent velocity in world space
  65398. * @param index agent index returned by addAgent
  65399. * @returns world space velocity
  65400. */
  65401. getAgentVelocity(index: number): Vector3;
  65402. /**
  65403. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65404. * @param index agent index returned by addAgent
  65405. * @param destination targeted world position
  65406. */
  65407. agentGoto(index: number, destination: Vector3): void;
  65408. /**
  65409. * Teleport the agent to a new position
  65410. * @param index agent index returned by addAgent
  65411. * @param destination targeted world position
  65412. */
  65413. agentTeleport(index: number, destination: Vector3): void;
  65414. /**
  65415. * Update agent parameters
  65416. * @param index agent index returned by addAgent
  65417. * @param parameters agent parameters
  65418. */
  65419. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65420. /**
  65421. * remove a particular agent previously created
  65422. * @param index agent index returned by addAgent
  65423. */
  65424. removeAgent(index: number): void;
  65425. /**
  65426. * get the list of all agents attached to this crowd
  65427. * @returns list of agent indices
  65428. */
  65429. getAgents(): number[];
  65430. /**
  65431. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65432. * @param deltaTime in seconds
  65433. */
  65434. update(deltaTime: number): void;
  65435. /**
  65436. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65437. * The queries will try to find a solution within those bounds
  65438. * default is (1,1,1)
  65439. * @param extent x,y,z value that define the extent around the queries point of reference
  65440. */
  65441. setDefaultQueryExtent(extent: Vector3): void;
  65442. /**
  65443. * Get the Bounding box extent specified by setDefaultQueryExtent
  65444. * @returns the box extent values
  65445. */
  65446. getDefaultQueryExtent(): Vector3;
  65447. /**
  65448. * Release all resources
  65449. */
  65450. dispose(): void;
  65451. }
  65452. }
  65453. declare module "babylonjs/Navigation/Plugins/index" {
  65454. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65455. }
  65456. declare module "babylonjs/Navigation/index" {
  65457. export * from "babylonjs/Navigation/INavigationEngine";
  65458. export * from "babylonjs/Navigation/Plugins/index";
  65459. }
  65460. declare module "babylonjs/Offline/database" {
  65461. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65462. /**
  65463. * Class used to enable access to IndexedDB
  65464. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65465. */
  65466. export class Database implements IOfflineProvider {
  65467. private _callbackManifestChecked;
  65468. private _currentSceneUrl;
  65469. private _db;
  65470. private _enableSceneOffline;
  65471. private _enableTexturesOffline;
  65472. private _manifestVersionFound;
  65473. private _mustUpdateRessources;
  65474. private _hasReachedQuota;
  65475. private _isSupported;
  65476. private _idbFactory;
  65477. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65478. private static IsUASupportingBlobStorage;
  65479. /**
  65480. * Gets a boolean indicating if Database storate is enabled (off by default)
  65481. */
  65482. static IDBStorageEnabled: boolean;
  65483. /**
  65484. * Gets a boolean indicating if scene must be saved in the database
  65485. */
  65486. get enableSceneOffline(): boolean;
  65487. /**
  65488. * Gets a boolean indicating if textures must be saved in the database
  65489. */
  65490. get enableTexturesOffline(): boolean;
  65491. /**
  65492. * Creates a new Database
  65493. * @param urlToScene defines the url to load the scene
  65494. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65495. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65496. */
  65497. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65498. private static _ParseURL;
  65499. private static _ReturnFullUrlLocation;
  65500. private _checkManifestFile;
  65501. /**
  65502. * Open the database and make it available
  65503. * @param successCallback defines the callback to call on success
  65504. * @param errorCallback defines the callback to call on error
  65505. */
  65506. open(successCallback: () => void, errorCallback: () => void): void;
  65507. /**
  65508. * Loads an image from the database
  65509. * @param url defines the url to load from
  65510. * @param image defines the target DOM image
  65511. */
  65512. loadImage(url: string, image: HTMLImageElement): void;
  65513. private _loadImageFromDBAsync;
  65514. private _saveImageIntoDBAsync;
  65515. private _checkVersionFromDB;
  65516. private _loadVersionFromDBAsync;
  65517. private _saveVersionIntoDBAsync;
  65518. /**
  65519. * Loads a file from database
  65520. * @param url defines the URL to load from
  65521. * @param sceneLoaded defines a callback to call on success
  65522. * @param progressCallBack defines a callback to call when progress changed
  65523. * @param errorCallback defines a callback to call on error
  65524. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65525. */
  65526. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65527. private _loadFileAsync;
  65528. private _saveFileAsync;
  65529. /**
  65530. * Validates if xhr data is correct
  65531. * @param xhr defines the request to validate
  65532. * @param dataType defines the expected data type
  65533. * @returns true if data is correct
  65534. */
  65535. private static _ValidateXHRData;
  65536. }
  65537. }
  65538. declare module "babylonjs/Offline/index" {
  65539. export * from "babylonjs/Offline/database";
  65540. export * from "babylonjs/Offline/IOfflineProvider";
  65541. }
  65542. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65543. /** @hidden */
  65544. export var gpuUpdateParticlesPixelShader: {
  65545. name: string;
  65546. shader: string;
  65547. };
  65548. }
  65549. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65550. /** @hidden */
  65551. export var gpuUpdateParticlesVertexShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65557. /** @hidden */
  65558. export var clipPlaneFragmentDeclaration2: {
  65559. name: string;
  65560. shader: string;
  65561. };
  65562. }
  65563. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65564. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65565. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65567. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65568. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65569. /** @hidden */
  65570. export var gpuRenderParticlesPixelShader: {
  65571. name: string;
  65572. shader: string;
  65573. };
  65574. }
  65575. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65576. /** @hidden */
  65577. export var clipPlaneVertexDeclaration2: {
  65578. name: string;
  65579. shader: string;
  65580. };
  65581. }
  65582. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65585. /** @hidden */
  65586. export var gpuRenderParticlesVertexShader: {
  65587. name: string;
  65588. shader: string;
  65589. };
  65590. }
  65591. declare module "babylonjs/Particles/gpuParticleSystem" {
  65592. import { Nullable } from "babylonjs/types";
  65593. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65594. import { Observable } from "babylonjs/Misc/observable";
  65595. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65597. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65598. import { Scene, IDisposable } from "babylonjs/scene";
  65599. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65600. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65601. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65602. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65603. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65604. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65605. /**
  65606. * This represents a GPU particle system in Babylon
  65607. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65608. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65609. */
  65610. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65611. /**
  65612. * The layer mask we are rendering the particles through.
  65613. */
  65614. layerMask: number;
  65615. private _capacity;
  65616. private _activeCount;
  65617. private _currentActiveCount;
  65618. private _accumulatedCount;
  65619. private _renderEffect;
  65620. private _updateEffect;
  65621. private _buffer0;
  65622. private _buffer1;
  65623. private _spriteBuffer;
  65624. private _updateVAO;
  65625. private _renderVAO;
  65626. private _targetIndex;
  65627. private _sourceBuffer;
  65628. private _targetBuffer;
  65629. private _engine;
  65630. private _currentRenderId;
  65631. private _started;
  65632. private _stopped;
  65633. private _timeDelta;
  65634. private _randomTexture;
  65635. private _randomTexture2;
  65636. private _attributesStrideSize;
  65637. private _updateEffectOptions;
  65638. private _randomTextureSize;
  65639. private _actualFrame;
  65640. private readonly _rawTextureWidth;
  65641. /**
  65642. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65643. */
  65644. static get IsSupported(): boolean;
  65645. /**
  65646. * An event triggered when the system is disposed.
  65647. */
  65648. onDisposeObservable: Observable<GPUParticleSystem>;
  65649. /**
  65650. * Gets the maximum number of particles active at the same time.
  65651. * @returns The max number of active particles.
  65652. */
  65653. getCapacity(): number;
  65654. /**
  65655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65656. * to override the particles.
  65657. */
  65658. forceDepthWrite: boolean;
  65659. /**
  65660. * Gets or set the number of active particles
  65661. */
  65662. get activeParticleCount(): number;
  65663. set activeParticleCount(value: number);
  65664. private _preWarmDone;
  65665. /**
  65666. * Is this system ready to be used/rendered
  65667. * @return true if the system is ready
  65668. */
  65669. isReady(): boolean;
  65670. /**
  65671. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65672. * @returns True if it has been started, otherwise false.
  65673. */
  65674. isStarted(): boolean;
  65675. /**
  65676. * Starts the particle system and begins to emit
  65677. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65678. */
  65679. start(delay?: number): void;
  65680. /**
  65681. * Stops the particle system.
  65682. */
  65683. stop(): void;
  65684. /**
  65685. * Remove all active particles
  65686. */
  65687. reset(): void;
  65688. /**
  65689. * Returns the string "GPUParticleSystem"
  65690. * @returns a string containing the class name
  65691. */
  65692. getClassName(): string;
  65693. private _colorGradientsTexture;
  65694. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65695. /**
  65696. * Adds a new color gradient
  65697. * @param gradient defines the gradient to use (between 0 and 1)
  65698. * @param color1 defines the color to affect to the specified gradient
  65699. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65700. * @returns the current particle system
  65701. */
  65702. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65703. /**
  65704. * Remove a specific color gradient
  65705. * @param gradient defines the gradient to remove
  65706. * @returns the current particle system
  65707. */
  65708. removeColorGradient(gradient: number): GPUParticleSystem;
  65709. private _angularSpeedGradientsTexture;
  65710. private _sizeGradientsTexture;
  65711. private _velocityGradientsTexture;
  65712. private _limitVelocityGradientsTexture;
  65713. private _dragGradientsTexture;
  65714. private _addFactorGradient;
  65715. /**
  65716. * Adds a new size gradient
  65717. * @param gradient defines the gradient to use (between 0 and 1)
  65718. * @param factor defines the size factor to affect to the specified gradient
  65719. * @returns the current particle system
  65720. */
  65721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65722. /**
  65723. * Remove a specific size gradient
  65724. * @param gradient defines the gradient to remove
  65725. * @returns the current particle system
  65726. */
  65727. removeSizeGradient(gradient: number): GPUParticleSystem;
  65728. /**
  65729. * Adds a new angular speed gradient
  65730. * @param gradient defines the gradient to use (between 0 and 1)
  65731. * @param factor defines the angular speed to affect to the specified gradient
  65732. * @returns the current particle system
  65733. */
  65734. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65735. /**
  65736. * Remove a specific angular speed gradient
  65737. * @param gradient defines the gradient to remove
  65738. * @returns the current particle system
  65739. */
  65740. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65741. /**
  65742. * Adds a new velocity gradient
  65743. * @param gradient defines the gradient to use (between 0 and 1)
  65744. * @param factor defines the velocity to affect to the specified gradient
  65745. * @returns the current particle system
  65746. */
  65747. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65748. /**
  65749. * Remove a specific velocity gradient
  65750. * @param gradient defines the gradient to remove
  65751. * @returns the current particle system
  65752. */
  65753. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65754. /**
  65755. * Adds a new limit velocity gradient
  65756. * @param gradient defines the gradient to use (between 0 and 1)
  65757. * @param factor defines the limit velocity value to affect to the specified gradient
  65758. * @returns the current particle system
  65759. */
  65760. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65761. /**
  65762. * Remove a specific limit velocity gradient
  65763. * @param gradient defines the gradient to remove
  65764. * @returns the current particle system
  65765. */
  65766. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65767. /**
  65768. * Adds a new drag gradient
  65769. * @param gradient defines the gradient to use (between 0 and 1)
  65770. * @param factor defines the drag value to affect to the specified gradient
  65771. * @returns the current particle system
  65772. */
  65773. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65774. /**
  65775. * Remove a specific drag gradient
  65776. * @param gradient defines the gradient to remove
  65777. * @returns the current particle system
  65778. */
  65779. removeDragGradient(gradient: number): GPUParticleSystem;
  65780. /**
  65781. * Not supported by GPUParticleSystem
  65782. * @param gradient defines the gradient to use (between 0 and 1)
  65783. * @param factor defines the emit rate value to affect to the specified gradient
  65784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65785. * @returns the current particle system
  65786. */
  65787. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65788. /**
  65789. * Not supported by GPUParticleSystem
  65790. * @param gradient defines the gradient to remove
  65791. * @returns the current particle system
  65792. */
  65793. removeEmitRateGradient(gradient: number): IParticleSystem;
  65794. /**
  65795. * Not supported by GPUParticleSystem
  65796. * @param gradient defines the gradient to use (between 0 and 1)
  65797. * @param factor defines the start size value to affect to the specified gradient
  65798. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65799. * @returns the current particle system
  65800. */
  65801. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65802. /**
  65803. * Not supported by GPUParticleSystem
  65804. * @param gradient defines the gradient to remove
  65805. * @returns the current particle system
  65806. */
  65807. removeStartSizeGradient(gradient: number): IParticleSystem;
  65808. /**
  65809. * Not supported by GPUParticleSystem
  65810. * @param gradient defines the gradient to use (between 0 and 1)
  65811. * @param min defines the color remap minimal range
  65812. * @param max defines the color remap maximal range
  65813. * @returns the current particle system
  65814. */
  65815. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65816. /**
  65817. * Not supported by GPUParticleSystem
  65818. * @param gradient defines the gradient to remove
  65819. * @returns the current particle system
  65820. */
  65821. removeColorRemapGradient(): IParticleSystem;
  65822. /**
  65823. * Not supported by GPUParticleSystem
  65824. * @param gradient defines the gradient to use (between 0 and 1)
  65825. * @param min defines the alpha remap minimal range
  65826. * @param max defines the alpha remap maximal range
  65827. * @returns the current particle system
  65828. */
  65829. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65830. /**
  65831. * Not supported by GPUParticleSystem
  65832. * @param gradient defines the gradient to remove
  65833. * @returns the current particle system
  65834. */
  65835. removeAlphaRemapGradient(): IParticleSystem;
  65836. /**
  65837. * Not supported by GPUParticleSystem
  65838. * @param gradient defines the gradient to use (between 0 and 1)
  65839. * @param color defines the color to affect to the specified gradient
  65840. * @returns the current particle system
  65841. */
  65842. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65843. /**
  65844. * Not supported by GPUParticleSystem
  65845. * @param gradient defines the gradient to remove
  65846. * @returns the current particle system
  65847. */
  65848. removeRampGradient(): IParticleSystem;
  65849. /**
  65850. * Not supported by GPUParticleSystem
  65851. * @returns the list of ramp gradients
  65852. */
  65853. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65854. /**
  65855. * Not supported by GPUParticleSystem
  65856. * Gets or sets a boolean indicating that ramp gradients must be used
  65857. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65858. */
  65859. get useRampGradients(): boolean;
  65860. set useRampGradients(value: boolean);
  65861. /**
  65862. * Not supported by GPUParticleSystem
  65863. * @param gradient defines the gradient to use (between 0 and 1)
  65864. * @param factor defines the life time factor to affect to the specified gradient
  65865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65866. * @returns the current particle system
  65867. */
  65868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65869. /**
  65870. * Not supported by GPUParticleSystem
  65871. * @param gradient defines the gradient to remove
  65872. * @returns the current particle system
  65873. */
  65874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65875. /**
  65876. * Instantiates a GPU particle system.
  65877. * 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.
  65878. * @param name The name of the particle system
  65879. * @param options The options used to create the system
  65880. * @param scene The scene the particle system belongs to
  65881. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65882. */
  65883. constructor(name: string, options: Partial<{
  65884. capacity: number;
  65885. randomTextureSize: number;
  65886. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65887. protected _reset(): void;
  65888. private _createUpdateVAO;
  65889. private _createRenderVAO;
  65890. private _initialize;
  65891. /** @hidden */
  65892. _recreateUpdateEffect(): void;
  65893. /** @hidden */
  65894. _recreateRenderEffect(): void;
  65895. /**
  65896. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65897. * @param preWarm defines if we are in the pre-warmimg phase
  65898. */
  65899. animate(preWarm?: boolean): void;
  65900. private _createFactorGradientTexture;
  65901. private _createSizeGradientTexture;
  65902. private _createAngularSpeedGradientTexture;
  65903. private _createVelocityGradientTexture;
  65904. private _createLimitVelocityGradientTexture;
  65905. private _createDragGradientTexture;
  65906. private _createColorGradientTexture;
  65907. /**
  65908. * Renders the particle system in its current state
  65909. * @param preWarm defines if the system should only update the particles but not render them
  65910. * @returns the current number of particles
  65911. */
  65912. render(preWarm?: boolean): number;
  65913. /**
  65914. * Rebuilds the particle system
  65915. */
  65916. rebuild(): void;
  65917. private _releaseBuffers;
  65918. private _releaseVAOs;
  65919. /**
  65920. * Disposes the particle system and free the associated resources
  65921. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65922. */
  65923. dispose(disposeTexture?: boolean): void;
  65924. /**
  65925. * Clones the particle system.
  65926. * @param name The name of the cloned object
  65927. * @param newEmitter The new emitter to use
  65928. * @returns the cloned particle system
  65929. */
  65930. clone(name: string, newEmitter: any): GPUParticleSystem;
  65931. /**
  65932. * Serializes the particle system to a JSON object.
  65933. * @returns the JSON object
  65934. */
  65935. serialize(): any;
  65936. /**
  65937. * Parses a JSON object to create a GPU particle system.
  65938. * @param parsedParticleSystem The JSON object to parse
  65939. * @param scene The scene to create the particle system in
  65940. * @param rootUrl The root url to use to load external dependencies like texture
  65941. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65942. * @returns the parsed GPU particle system
  65943. */
  65944. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65945. }
  65946. }
  65947. declare module "babylonjs/Particles/particleSystemSet" {
  65948. import { Nullable } from "babylonjs/types";
  65949. import { Color3 } from "babylonjs/Maths/math.color";
  65950. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65952. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65953. import { Scene, IDisposable } from "babylonjs/scene";
  65954. /**
  65955. * Represents a set of particle systems working together to create a specific effect
  65956. */
  65957. export class ParticleSystemSet implements IDisposable {
  65958. /**
  65959. * Gets or sets base Assets URL
  65960. */
  65961. static BaseAssetsUrl: string;
  65962. private _emitterCreationOptions;
  65963. private _emitterNode;
  65964. /**
  65965. * Gets the particle system list
  65966. */
  65967. systems: IParticleSystem[];
  65968. /**
  65969. * Gets the emitter node used with this set
  65970. */
  65971. get emitterNode(): Nullable<TransformNode>;
  65972. /**
  65973. * Creates a new emitter mesh as a sphere
  65974. * @param options defines the options used to create the sphere
  65975. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65976. * @param scene defines the hosting scene
  65977. */
  65978. setEmitterAsSphere(options: {
  65979. diameter: number;
  65980. segments: number;
  65981. color: Color3;
  65982. }, renderingGroupId: number, scene: Scene): void;
  65983. /**
  65984. * Starts all particle systems of the set
  65985. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65986. */
  65987. start(emitter?: AbstractMesh): void;
  65988. /**
  65989. * Release all associated resources
  65990. */
  65991. dispose(): void;
  65992. /**
  65993. * Serialize the set into a JSON compatible object
  65994. * @returns a JSON compatible representation of the set
  65995. */
  65996. serialize(): any;
  65997. /**
  65998. * Parse a new ParticleSystemSet from a serialized source
  65999. * @param data defines a JSON compatible representation of the set
  66000. * @param scene defines the hosting scene
  66001. * @param gpu defines if we want GPU particles or CPU particles
  66002. * @returns a new ParticleSystemSet
  66003. */
  66004. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66005. }
  66006. }
  66007. declare module "babylonjs/Particles/particleHelper" {
  66008. import { Nullable } from "babylonjs/types";
  66009. import { Scene } from "babylonjs/scene";
  66010. import { Vector3 } from "babylonjs/Maths/math.vector";
  66011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66013. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66014. /**
  66015. * This class is made for on one-liner static method to help creating particle system set.
  66016. */
  66017. export class ParticleHelper {
  66018. /**
  66019. * Gets or sets base Assets URL
  66020. */
  66021. static BaseAssetsUrl: string;
  66022. /**
  66023. * Create a default particle system that you can tweak
  66024. * @param emitter defines the emitter to use
  66025. * @param capacity defines the system capacity (default is 500 particles)
  66026. * @param scene defines the hosting scene
  66027. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66028. * @returns the new Particle system
  66029. */
  66030. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66031. /**
  66032. * This is the main static method (one-liner) of this helper to create different particle systems
  66033. * @param type This string represents the type to the particle system to create
  66034. * @param scene The scene where the particle system should live
  66035. * @param gpu If the system will use gpu
  66036. * @returns the ParticleSystemSet created
  66037. */
  66038. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66039. /**
  66040. * Static function used to export a particle system to a ParticleSystemSet variable.
  66041. * Please note that the emitter shape is not exported
  66042. * @param systems defines the particle systems to export
  66043. * @returns the created particle system set
  66044. */
  66045. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66046. }
  66047. }
  66048. declare module "babylonjs/Particles/particleSystemComponent" {
  66049. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66050. import { Effect } from "babylonjs/Materials/effect";
  66051. import "babylonjs/Shaders/particles.vertex";
  66052. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66053. module "babylonjs/Engines/engine" {
  66054. interface Engine {
  66055. /**
  66056. * Create an effect to use with particle systems.
  66057. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66058. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66059. * @param uniformsNames defines a list of attribute names
  66060. * @param samplers defines an array of string used to represent textures
  66061. * @param defines defines the string containing the defines to use to compile the shaders
  66062. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66063. * @param onCompiled defines a function to call when the effect creation is successful
  66064. * @param onError defines a function to call when the effect creation has failed
  66065. * @returns the new Effect
  66066. */
  66067. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66068. }
  66069. }
  66070. module "babylonjs/Meshes/mesh" {
  66071. interface Mesh {
  66072. /**
  66073. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66074. * @returns an array of IParticleSystem
  66075. */
  66076. getEmittedParticleSystems(): IParticleSystem[];
  66077. /**
  66078. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66079. * @returns an array of IParticleSystem
  66080. */
  66081. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66082. }
  66083. }
  66084. /**
  66085. * @hidden
  66086. */
  66087. export var _IDoNeedToBeInTheBuild: number;
  66088. }
  66089. declare module "babylonjs/Particles/pointsCloudSystem" {
  66090. import { Color4 } from "babylonjs/Maths/math";
  66091. import { Mesh } from "babylonjs/Meshes/mesh";
  66092. import { Scene, IDisposable } from "babylonjs/scene";
  66093. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66094. /** Defines the 4 color options */
  66095. export enum PointColor {
  66096. /** color value */
  66097. Color = 2,
  66098. /** uv value */
  66099. UV = 1,
  66100. /** random value */
  66101. Random = 0,
  66102. /** stated value */
  66103. Stated = 3
  66104. }
  66105. /**
  66106. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66107. * 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.
  66108. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66109. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66110. *
  66111. * Full documentation here : TO BE ENTERED
  66112. */
  66113. export class PointsCloudSystem implements IDisposable {
  66114. /**
  66115. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66116. * Example : var p = SPS.particles[i];
  66117. */
  66118. particles: CloudPoint[];
  66119. /**
  66120. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66121. */
  66122. nbParticles: number;
  66123. /**
  66124. * This a counter for your own usage. It's not set by any SPS functions.
  66125. */
  66126. counter: number;
  66127. /**
  66128. * The PCS name. This name is also given to the underlying mesh.
  66129. */
  66130. name: string;
  66131. /**
  66132. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66133. */
  66134. mesh: Mesh;
  66135. /**
  66136. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66137. * Please read :
  66138. */
  66139. vars: any;
  66140. /**
  66141. * @hidden
  66142. */
  66143. _size: number;
  66144. private _scene;
  66145. private _promises;
  66146. private _positions;
  66147. private _indices;
  66148. private _normals;
  66149. private _colors;
  66150. private _uvs;
  66151. private _indices32;
  66152. private _positions32;
  66153. private _colors32;
  66154. private _uvs32;
  66155. private _updatable;
  66156. private _isVisibilityBoxLocked;
  66157. private _alwaysVisible;
  66158. private _groups;
  66159. private _groupCounter;
  66160. private _computeParticleColor;
  66161. private _computeParticleTexture;
  66162. private _computeParticleRotation;
  66163. private _computeBoundingBox;
  66164. private _isReady;
  66165. /**
  66166. * Creates a PCS (Points Cloud System) object
  66167. * @param name (String) is the PCS name, this will be the underlying mesh name
  66168. * @param pointSize (number) is the size for each point
  66169. * @param scene (Scene) is the scene in which the PCS is added
  66170. * @param options defines the options of the PCS e.g.
  66171. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66172. */
  66173. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66174. updatable?: boolean;
  66175. });
  66176. /**
  66177. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66178. * If no points were added to the PCS, the returned mesh is just a single point.
  66179. * @returns a promise for the created mesh
  66180. */
  66181. buildMeshAsync(): Promise<Mesh>;
  66182. /**
  66183. * @hidden
  66184. */
  66185. private _buildMesh;
  66186. private _addParticle;
  66187. private _randomUnitVector;
  66188. private _getColorIndicesForCoord;
  66189. private _setPointsColorOrUV;
  66190. private _colorFromTexture;
  66191. private _calculateDensity;
  66192. /**
  66193. * Adds points to the PCS in random positions within a unit sphere
  66194. * @param nb (positive integer) the number of particles to be created from this model
  66195. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66196. * @returns the number of groups in the system
  66197. */
  66198. addPoints(nb: number, pointFunction?: any): number;
  66199. /**
  66200. * Adds points to the PCS from the surface of the model shape
  66201. * @param mesh is any Mesh object that will be used as a surface model for the points
  66202. * @param nb (positive integer) the number of particles to be created from this model
  66203. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66204. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66205. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66206. * @returns the number of groups in the system
  66207. */
  66208. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66209. /**
  66210. * Adds points to the PCS inside the model shape
  66211. * @param mesh is any Mesh object that will be used as a surface model for the points
  66212. * @param nb (positive integer) the number of particles to be created from this model
  66213. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66214. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66215. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66216. * @returns the number of groups in the system
  66217. */
  66218. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66219. /**
  66220. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66221. * This method calls `updateParticle()` for each particle of the SPS.
  66222. * For an animated SPS, it is usually called within the render loop.
  66223. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66224. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66225. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66226. * @returns the PCS.
  66227. */
  66228. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66229. /**
  66230. * Disposes the PCS.
  66231. */
  66232. dispose(): void;
  66233. /**
  66234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66235. * doc :
  66236. * @returns the PCS.
  66237. */
  66238. refreshVisibleSize(): PointsCloudSystem;
  66239. /**
  66240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66241. * @param size the size (float) of the visibility box
  66242. * note : this doesn't lock the PCS mesh bounding box.
  66243. * doc :
  66244. */
  66245. setVisibilityBox(size: number): void;
  66246. /**
  66247. * Gets whether the PCS is always visible or not
  66248. * doc :
  66249. */
  66250. get isAlwaysVisible(): boolean;
  66251. /**
  66252. * Sets the PCS as always visible or not
  66253. * doc :
  66254. */
  66255. set isAlwaysVisible(val: boolean);
  66256. /**
  66257. * Tells to `setParticles()` to compute the particle rotations or not
  66258. * Default value : false. The PCS is faster when it's set to false
  66259. * Note : particle rotations are only applied to parent particles
  66260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66261. */
  66262. set computeParticleRotation(val: boolean);
  66263. /**
  66264. * Tells to `setParticles()` to compute the particle colors or not.
  66265. * Default value : true. The PCS is faster when it's set to false.
  66266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66267. */
  66268. set computeParticleColor(val: boolean);
  66269. set computeParticleTexture(val: boolean);
  66270. /**
  66271. * Gets if `setParticles()` computes the particle colors or not.
  66272. * Default value : false. The PCS is faster when it's set to false.
  66273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66274. */
  66275. get computeParticleColor(): boolean;
  66276. /**
  66277. * Gets if `setParticles()` computes the particle textures or not.
  66278. * Default value : false. The PCS is faster when it's set to false.
  66279. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66280. */
  66281. get computeParticleTexture(): boolean;
  66282. /**
  66283. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66284. */
  66285. set computeBoundingBox(val: boolean);
  66286. /**
  66287. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66288. */
  66289. get computeBoundingBox(): boolean;
  66290. /**
  66291. * This function does nothing. It may be overwritten to set all the particle first values.
  66292. * The PCS doesn't call this function, you may have to call it by your own.
  66293. * doc :
  66294. */
  66295. initParticles(): void;
  66296. /**
  66297. * This function does nothing. It may be overwritten to recycle a particle
  66298. * The PCS doesn't call this function, you can to call it
  66299. * doc :
  66300. * @param particle The particle to recycle
  66301. * @returns the recycled particle
  66302. */
  66303. recycleParticle(particle: CloudPoint): CloudPoint;
  66304. /**
  66305. * Updates a particle : this function should be overwritten by the user.
  66306. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66307. * doc :
  66308. * @example : just set a particle position or velocity and recycle conditions
  66309. * @param particle The particle to update
  66310. * @returns the updated particle
  66311. */
  66312. updateParticle(particle: CloudPoint): CloudPoint;
  66313. /**
  66314. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66315. * This does nothing and may be overwritten by the user.
  66316. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66317. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66318. * @param update the boolean update value actually passed to setParticles()
  66319. */
  66320. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66321. /**
  66322. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66323. * This will be passed three parameters.
  66324. * This does nothing and may be overwritten by the user.
  66325. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66326. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66327. * @param update the boolean update value actually passed to setParticles()
  66328. */
  66329. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66330. }
  66331. }
  66332. declare module "babylonjs/Particles/cloudPoint" {
  66333. import { Nullable } from "babylonjs/types";
  66334. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66335. import { Mesh } from "babylonjs/Meshes/mesh";
  66336. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66337. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66338. /**
  66339. * Represents one particle of a points cloud system.
  66340. */
  66341. export class CloudPoint {
  66342. /**
  66343. * particle global index
  66344. */
  66345. idx: number;
  66346. /**
  66347. * The color of the particle
  66348. */
  66349. color: Nullable<Color4>;
  66350. /**
  66351. * The world space position of the particle.
  66352. */
  66353. position: Vector3;
  66354. /**
  66355. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66356. */
  66357. rotation: Vector3;
  66358. /**
  66359. * The world space rotation quaternion of the particle.
  66360. */
  66361. rotationQuaternion: Nullable<Quaternion>;
  66362. /**
  66363. * The uv of the particle.
  66364. */
  66365. uv: Nullable<Vector2>;
  66366. /**
  66367. * The current speed of the particle.
  66368. */
  66369. velocity: Vector3;
  66370. /**
  66371. * The pivot point in the particle local space.
  66372. */
  66373. pivot: Vector3;
  66374. /**
  66375. * Must the particle be translated from its pivot point in its local space ?
  66376. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66377. * Default : false
  66378. */
  66379. translateFromPivot: boolean;
  66380. /**
  66381. * Index of this particle in the global "positions" array (Internal use)
  66382. * @hidden
  66383. */
  66384. _pos: number;
  66385. /**
  66386. * @hidden Index of this particle in the global "indices" array (Internal use)
  66387. */
  66388. _ind: number;
  66389. /**
  66390. * Group this particle belongs to
  66391. */
  66392. _group: PointsGroup;
  66393. /**
  66394. * Group id of this particle
  66395. */
  66396. groupId: number;
  66397. /**
  66398. * Index of the particle in its group id (Internal use)
  66399. */
  66400. idxInGroup: number;
  66401. /**
  66402. * @hidden Particle BoundingInfo object (Internal use)
  66403. */
  66404. _boundingInfo: BoundingInfo;
  66405. /**
  66406. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66407. */
  66408. _pcs: PointsCloudSystem;
  66409. /**
  66410. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66411. */
  66412. _stillInvisible: boolean;
  66413. /**
  66414. * @hidden Last computed particle rotation matrix
  66415. */
  66416. _rotationMatrix: number[];
  66417. /**
  66418. * Parent particle Id, if any.
  66419. * Default null.
  66420. */
  66421. parentId: Nullable<number>;
  66422. /**
  66423. * @hidden Internal global position in the PCS.
  66424. */
  66425. _globalPosition: Vector3;
  66426. /**
  66427. * Creates a Point Cloud object.
  66428. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66429. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66430. * @param group (PointsGroup) is the group the particle belongs to
  66431. * @param groupId (integer) is the group identifier in the PCS.
  66432. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66433. * @param pcs defines the PCS it is associated to
  66434. */
  66435. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66436. /**
  66437. * get point size
  66438. */
  66439. get size(): Vector3;
  66440. /**
  66441. * Set point size
  66442. */
  66443. set size(scale: Vector3);
  66444. /**
  66445. * Legacy support, changed quaternion to rotationQuaternion
  66446. */
  66447. get quaternion(): Nullable<Quaternion>;
  66448. /**
  66449. * Legacy support, changed quaternion to rotationQuaternion
  66450. */
  66451. set quaternion(q: Nullable<Quaternion>);
  66452. /**
  66453. * Returns a boolean. True if the particle intersects a mesh, else false
  66454. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66455. * @param target is the object (point or mesh) what the intersection is computed against
  66456. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66457. * @returns true if it intersects
  66458. */
  66459. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66460. /**
  66461. * get the rotation matrix of the particle
  66462. * @hidden
  66463. */
  66464. getRotationMatrix(m: Matrix): void;
  66465. }
  66466. /**
  66467. * Represents a group of points in a points cloud system
  66468. * * PCS internal tool, don't use it manually.
  66469. */
  66470. export class PointsGroup {
  66471. /**
  66472. * The group id
  66473. * @hidden
  66474. */
  66475. groupID: number;
  66476. /**
  66477. * image data for group (internal use)
  66478. * @hidden
  66479. */
  66480. _groupImageData: Nullable<ArrayBufferView>;
  66481. /**
  66482. * Image Width (internal use)
  66483. * @hidden
  66484. */
  66485. _groupImgWidth: number;
  66486. /**
  66487. * Image Height (internal use)
  66488. * @hidden
  66489. */
  66490. _groupImgHeight: number;
  66491. /**
  66492. * Custom position function (internal use)
  66493. * @hidden
  66494. */
  66495. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66496. /**
  66497. * density per facet for surface points
  66498. * @hidden
  66499. */
  66500. _groupDensity: number[];
  66501. /**
  66502. * Only when points are colored by texture carries pointer to texture list array
  66503. * @hidden
  66504. */
  66505. _textureNb: number;
  66506. /**
  66507. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66508. * PCS internal tool, don't use it manually.
  66509. * @hidden
  66510. */
  66511. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66512. }
  66513. }
  66514. declare module "babylonjs/Particles/index" {
  66515. export * from "babylonjs/Particles/baseParticleSystem";
  66516. export * from "babylonjs/Particles/EmitterTypes/index";
  66517. export * from "babylonjs/Particles/gpuParticleSystem";
  66518. export * from "babylonjs/Particles/IParticleSystem";
  66519. export * from "babylonjs/Particles/particle";
  66520. export * from "babylonjs/Particles/particleHelper";
  66521. export * from "babylonjs/Particles/particleSystem";
  66522. export * from "babylonjs/Particles/particleSystemComponent";
  66523. export * from "babylonjs/Particles/particleSystemSet";
  66524. export * from "babylonjs/Particles/solidParticle";
  66525. export * from "babylonjs/Particles/solidParticleSystem";
  66526. export * from "babylonjs/Particles/cloudPoint";
  66527. export * from "babylonjs/Particles/pointsCloudSystem";
  66528. export * from "babylonjs/Particles/subEmitter";
  66529. }
  66530. declare module "babylonjs/Physics/physicsEngineComponent" {
  66531. import { Nullable } from "babylonjs/types";
  66532. import { Observable, Observer } from "babylonjs/Misc/observable";
  66533. import { Vector3 } from "babylonjs/Maths/math.vector";
  66534. import { Mesh } from "babylonjs/Meshes/mesh";
  66535. import { ISceneComponent } from "babylonjs/sceneComponent";
  66536. import { Scene } from "babylonjs/scene";
  66537. import { Node } from "babylonjs/node";
  66538. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66539. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66540. module "babylonjs/scene" {
  66541. interface Scene {
  66542. /** @hidden (Backing field) */
  66543. _physicsEngine: Nullable<IPhysicsEngine>;
  66544. /** @hidden */
  66545. _physicsTimeAccumulator: number;
  66546. /**
  66547. * Gets the current physics engine
  66548. * @returns a IPhysicsEngine or null if none attached
  66549. */
  66550. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66551. /**
  66552. * Enables physics to the current scene
  66553. * @param gravity defines the scene's gravity for the physics engine
  66554. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66555. * @return a boolean indicating if the physics engine was initialized
  66556. */
  66557. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66558. /**
  66559. * Disables and disposes the physics engine associated with the scene
  66560. */
  66561. disablePhysicsEngine(): void;
  66562. /**
  66563. * Gets a boolean indicating if there is an active physics engine
  66564. * @returns a boolean indicating if there is an active physics engine
  66565. */
  66566. isPhysicsEnabled(): boolean;
  66567. /**
  66568. * Deletes a physics compound impostor
  66569. * @param compound defines the compound to delete
  66570. */
  66571. deleteCompoundImpostor(compound: any): void;
  66572. /**
  66573. * An event triggered when physic simulation is about to be run
  66574. */
  66575. onBeforePhysicsObservable: Observable<Scene>;
  66576. /**
  66577. * An event triggered when physic simulation has been done
  66578. */
  66579. onAfterPhysicsObservable: Observable<Scene>;
  66580. }
  66581. }
  66582. module "babylonjs/Meshes/abstractMesh" {
  66583. interface AbstractMesh {
  66584. /** @hidden */
  66585. _physicsImpostor: Nullable<PhysicsImpostor>;
  66586. /**
  66587. * Gets or sets impostor used for physic simulation
  66588. * @see http://doc.babylonjs.com/features/physics_engine
  66589. */
  66590. physicsImpostor: Nullable<PhysicsImpostor>;
  66591. /**
  66592. * Gets the current physics impostor
  66593. * @see http://doc.babylonjs.com/features/physics_engine
  66594. * @returns a physics impostor or null
  66595. */
  66596. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66597. /** Apply a physic impulse to the mesh
  66598. * @param force defines the force to apply
  66599. * @param contactPoint defines where to apply the force
  66600. * @returns the current mesh
  66601. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66602. */
  66603. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66604. /**
  66605. * Creates a physic joint between two meshes
  66606. * @param otherMesh defines the other mesh to use
  66607. * @param pivot1 defines the pivot to use on this mesh
  66608. * @param pivot2 defines the pivot to use on the other mesh
  66609. * @param options defines additional options (can be plugin dependent)
  66610. * @returns the current mesh
  66611. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66612. */
  66613. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66614. /** @hidden */
  66615. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66616. }
  66617. }
  66618. /**
  66619. * Defines the physics engine scene component responsible to manage a physics engine
  66620. */
  66621. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66622. /**
  66623. * The component name helpful to identify the component in the list of scene components.
  66624. */
  66625. readonly name: string;
  66626. /**
  66627. * The scene the component belongs to.
  66628. */
  66629. scene: Scene;
  66630. /**
  66631. * Creates a new instance of the component for the given scene
  66632. * @param scene Defines the scene to register the component in
  66633. */
  66634. constructor(scene: Scene);
  66635. /**
  66636. * Registers the component in a given scene
  66637. */
  66638. register(): void;
  66639. /**
  66640. * Rebuilds the elements related to this component in case of
  66641. * context lost for instance.
  66642. */
  66643. rebuild(): void;
  66644. /**
  66645. * Disposes the component and the associated ressources
  66646. */
  66647. dispose(): void;
  66648. }
  66649. }
  66650. declare module "babylonjs/Physics/physicsHelper" {
  66651. import { Nullable } from "babylonjs/types";
  66652. import { Vector3 } from "babylonjs/Maths/math.vector";
  66653. import { Mesh } from "babylonjs/Meshes/mesh";
  66654. import { Scene } from "babylonjs/scene";
  66655. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66656. /**
  66657. * A helper for physics simulations
  66658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66659. */
  66660. export class PhysicsHelper {
  66661. private _scene;
  66662. private _physicsEngine;
  66663. /**
  66664. * Initializes the Physics helper
  66665. * @param scene Babylon.js scene
  66666. */
  66667. constructor(scene: Scene);
  66668. /**
  66669. * Applies a radial explosion impulse
  66670. * @param origin the origin of the explosion
  66671. * @param radiusOrEventOptions the radius or the options of radial explosion
  66672. * @param strength the explosion strength
  66673. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66674. * @returns A physics radial explosion event, or null
  66675. */
  66676. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66677. /**
  66678. * Applies a radial explosion force
  66679. * @param origin the origin of the explosion
  66680. * @param radiusOrEventOptions the radius or the options of radial explosion
  66681. * @param strength the explosion strength
  66682. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66683. * @returns A physics radial explosion event, or null
  66684. */
  66685. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66686. /**
  66687. * Creates a gravitational field
  66688. * @param origin the origin of the explosion
  66689. * @param radiusOrEventOptions the radius or the options of radial explosion
  66690. * @param strength the explosion strength
  66691. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66692. * @returns A physics gravitational field event, or null
  66693. */
  66694. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66695. /**
  66696. * Creates a physics updraft event
  66697. * @param origin the origin of the updraft
  66698. * @param radiusOrEventOptions the radius or the options of the updraft
  66699. * @param strength the strength of the updraft
  66700. * @param height the height of the updraft
  66701. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66702. * @returns A physics updraft event, or null
  66703. */
  66704. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66705. /**
  66706. * Creates a physics vortex event
  66707. * @param origin the of the vortex
  66708. * @param radiusOrEventOptions the radius or the options of the vortex
  66709. * @param strength the strength of the vortex
  66710. * @param height the height of the vortex
  66711. * @returns a Physics vortex event, or null
  66712. * A physics vortex event or null
  66713. */
  66714. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66715. }
  66716. /**
  66717. * Represents a physics radial explosion event
  66718. */
  66719. class PhysicsRadialExplosionEvent {
  66720. private _scene;
  66721. private _options;
  66722. private _sphere;
  66723. private _dataFetched;
  66724. /**
  66725. * Initializes a radial explosioin event
  66726. * @param _scene BabylonJS scene
  66727. * @param _options The options for the vortex event
  66728. */
  66729. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66730. /**
  66731. * Returns the data related to the radial explosion event (sphere).
  66732. * @returns The radial explosion event data
  66733. */
  66734. getData(): PhysicsRadialExplosionEventData;
  66735. /**
  66736. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66737. * @param impostor A physics imposter
  66738. * @param origin the origin of the explosion
  66739. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66740. */
  66741. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66742. /**
  66743. * Triggers affecterd impostors callbacks
  66744. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66745. */
  66746. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66747. /**
  66748. * Disposes the sphere.
  66749. * @param force Specifies if the sphere should be disposed by force
  66750. */
  66751. dispose(force?: boolean): void;
  66752. /*** Helpers ***/
  66753. private _prepareSphere;
  66754. private _intersectsWithSphere;
  66755. }
  66756. /**
  66757. * Represents a gravitational field event
  66758. */
  66759. class PhysicsGravitationalFieldEvent {
  66760. private _physicsHelper;
  66761. private _scene;
  66762. private _origin;
  66763. private _options;
  66764. private _tickCallback;
  66765. private _sphere;
  66766. private _dataFetched;
  66767. /**
  66768. * Initializes the physics gravitational field event
  66769. * @param _physicsHelper A physics helper
  66770. * @param _scene BabylonJS scene
  66771. * @param _origin The origin position of the gravitational field event
  66772. * @param _options The options for the vortex event
  66773. */
  66774. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66775. /**
  66776. * Returns the data related to the gravitational field event (sphere).
  66777. * @returns A gravitational field event
  66778. */
  66779. getData(): PhysicsGravitationalFieldEventData;
  66780. /**
  66781. * Enables the gravitational field.
  66782. */
  66783. enable(): void;
  66784. /**
  66785. * Disables the gravitational field.
  66786. */
  66787. disable(): void;
  66788. /**
  66789. * Disposes the sphere.
  66790. * @param force The force to dispose from the gravitational field event
  66791. */
  66792. dispose(force?: boolean): void;
  66793. private _tick;
  66794. }
  66795. /**
  66796. * Represents a physics updraft event
  66797. */
  66798. class PhysicsUpdraftEvent {
  66799. private _scene;
  66800. private _origin;
  66801. private _options;
  66802. private _physicsEngine;
  66803. private _originTop;
  66804. private _originDirection;
  66805. private _tickCallback;
  66806. private _cylinder;
  66807. private _cylinderPosition;
  66808. private _dataFetched;
  66809. /**
  66810. * Initializes the physics updraft event
  66811. * @param _scene BabylonJS scene
  66812. * @param _origin The origin position of the updraft
  66813. * @param _options The options for the updraft event
  66814. */
  66815. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66816. /**
  66817. * Returns the data related to the updraft event (cylinder).
  66818. * @returns A physics updraft event
  66819. */
  66820. getData(): PhysicsUpdraftEventData;
  66821. /**
  66822. * Enables the updraft.
  66823. */
  66824. enable(): void;
  66825. /**
  66826. * Disables the updraft.
  66827. */
  66828. disable(): void;
  66829. /**
  66830. * Disposes the cylinder.
  66831. * @param force Specifies if the updraft should be disposed by force
  66832. */
  66833. dispose(force?: boolean): void;
  66834. private getImpostorHitData;
  66835. private _tick;
  66836. /*** Helpers ***/
  66837. private _prepareCylinder;
  66838. private _intersectsWithCylinder;
  66839. }
  66840. /**
  66841. * Represents a physics vortex event
  66842. */
  66843. class PhysicsVortexEvent {
  66844. private _scene;
  66845. private _origin;
  66846. private _options;
  66847. private _physicsEngine;
  66848. private _originTop;
  66849. private _tickCallback;
  66850. private _cylinder;
  66851. private _cylinderPosition;
  66852. private _dataFetched;
  66853. /**
  66854. * Initializes the physics vortex event
  66855. * @param _scene The BabylonJS scene
  66856. * @param _origin The origin position of the vortex
  66857. * @param _options The options for the vortex event
  66858. */
  66859. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66860. /**
  66861. * Returns the data related to the vortex event (cylinder).
  66862. * @returns The physics vortex event data
  66863. */
  66864. getData(): PhysicsVortexEventData;
  66865. /**
  66866. * Enables the vortex.
  66867. */
  66868. enable(): void;
  66869. /**
  66870. * Disables the cortex.
  66871. */
  66872. disable(): void;
  66873. /**
  66874. * Disposes the sphere.
  66875. * @param force
  66876. */
  66877. dispose(force?: boolean): void;
  66878. private getImpostorHitData;
  66879. private _tick;
  66880. /*** Helpers ***/
  66881. private _prepareCylinder;
  66882. private _intersectsWithCylinder;
  66883. }
  66884. /**
  66885. * Options fot the radial explosion event
  66886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66887. */
  66888. export class PhysicsRadialExplosionEventOptions {
  66889. /**
  66890. * The radius of the sphere for the radial explosion.
  66891. */
  66892. radius: number;
  66893. /**
  66894. * The strenth of the explosion.
  66895. */
  66896. strength: number;
  66897. /**
  66898. * The strenght of the force in correspondence to the distance of the affected object
  66899. */
  66900. falloff: PhysicsRadialImpulseFalloff;
  66901. /**
  66902. * Sphere options for the radial explosion.
  66903. */
  66904. sphere: {
  66905. segments: number;
  66906. diameter: number;
  66907. };
  66908. /**
  66909. * Sphere options for the radial explosion.
  66910. */
  66911. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66912. }
  66913. /**
  66914. * Options fot the updraft event
  66915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66916. */
  66917. export class PhysicsUpdraftEventOptions {
  66918. /**
  66919. * The radius of the cylinder for the vortex
  66920. */
  66921. radius: number;
  66922. /**
  66923. * The strenth of the updraft.
  66924. */
  66925. strength: number;
  66926. /**
  66927. * The height of the cylinder for the updraft.
  66928. */
  66929. height: number;
  66930. /**
  66931. * The mode for the the updraft.
  66932. */
  66933. updraftMode: PhysicsUpdraftMode;
  66934. }
  66935. /**
  66936. * Options fot the vortex event
  66937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66938. */
  66939. export class PhysicsVortexEventOptions {
  66940. /**
  66941. * The radius of the cylinder for the vortex
  66942. */
  66943. radius: number;
  66944. /**
  66945. * The strenth of the vortex.
  66946. */
  66947. strength: number;
  66948. /**
  66949. * The height of the cylinder for the vortex.
  66950. */
  66951. height: number;
  66952. /**
  66953. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66954. */
  66955. centripetalForceThreshold: number;
  66956. /**
  66957. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66958. */
  66959. centripetalForceMultiplier: number;
  66960. /**
  66961. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66962. */
  66963. centrifugalForceMultiplier: number;
  66964. /**
  66965. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66966. */
  66967. updraftForceMultiplier: number;
  66968. }
  66969. /**
  66970. * The strenght of the force in correspondence to the distance of the affected object
  66971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66972. */
  66973. export enum PhysicsRadialImpulseFalloff {
  66974. /** Defines that impulse is constant in strength across it's whole radius */
  66975. Constant = 0,
  66976. /** Defines that impulse gets weaker if it's further from the origin */
  66977. Linear = 1
  66978. }
  66979. /**
  66980. * The strength of the force in correspondence to the distance of the affected object
  66981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66982. */
  66983. export enum PhysicsUpdraftMode {
  66984. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66985. Center = 0,
  66986. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66987. Perpendicular = 1
  66988. }
  66989. /**
  66990. * Interface for a physics hit data
  66991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66992. */
  66993. export interface PhysicsHitData {
  66994. /**
  66995. * The force applied at the contact point
  66996. */
  66997. force: Vector3;
  66998. /**
  66999. * The contact point
  67000. */
  67001. contactPoint: Vector3;
  67002. /**
  67003. * The distance from the origin to the contact point
  67004. */
  67005. distanceFromOrigin: number;
  67006. }
  67007. /**
  67008. * Interface for radial explosion event data
  67009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67010. */
  67011. export interface PhysicsRadialExplosionEventData {
  67012. /**
  67013. * A sphere used for the radial explosion event
  67014. */
  67015. sphere: Mesh;
  67016. }
  67017. /**
  67018. * Interface for gravitational field event data
  67019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67020. */
  67021. export interface PhysicsGravitationalFieldEventData {
  67022. /**
  67023. * A sphere mesh used for the gravitational field event
  67024. */
  67025. sphere: Mesh;
  67026. }
  67027. /**
  67028. * Interface for updraft event data
  67029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67030. */
  67031. export interface PhysicsUpdraftEventData {
  67032. /**
  67033. * A cylinder used for the updraft event
  67034. */
  67035. cylinder: Mesh;
  67036. }
  67037. /**
  67038. * Interface for vortex event data
  67039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67040. */
  67041. export interface PhysicsVortexEventData {
  67042. /**
  67043. * A cylinder used for the vortex event
  67044. */
  67045. cylinder: Mesh;
  67046. }
  67047. /**
  67048. * Interface for an affected physics impostor
  67049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67050. */
  67051. export interface PhysicsAffectedImpostorWithData {
  67052. /**
  67053. * The impostor affected by the effect
  67054. */
  67055. impostor: PhysicsImpostor;
  67056. /**
  67057. * The data about the hit/horce from the explosion
  67058. */
  67059. hitData: PhysicsHitData;
  67060. }
  67061. }
  67062. declare module "babylonjs/Physics/Plugins/index" {
  67063. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67064. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67065. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67066. }
  67067. declare module "babylonjs/Physics/index" {
  67068. export * from "babylonjs/Physics/IPhysicsEngine";
  67069. export * from "babylonjs/Physics/physicsEngine";
  67070. export * from "babylonjs/Physics/physicsEngineComponent";
  67071. export * from "babylonjs/Physics/physicsHelper";
  67072. export * from "babylonjs/Physics/physicsImpostor";
  67073. export * from "babylonjs/Physics/physicsJoint";
  67074. export * from "babylonjs/Physics/Plugins/index";
  67075. }
  67076. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67077. /** @hidden */
  67078. export var blackAndWhitePixelShader: {
  67079. name: string;
  67080. shader: string;
  67081. };
  67082. }
  67083. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67084. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67085. import { Camera } from "babylonjs/Cameras/camera";
  67086. import { Engine } from "babylonjs/Engines/engine";
  67087. import "babylonjs/Shaders/blackAndWhite.fragment";
  67088. /**
  67089. * Post process used to render in black and white
  67090. */
  67091. export class BlackAndWhitePostProcess extends PostProcess {
  67092. /**
  67093. * Linear about to convert he result to black and white (default: 1)
  67094. */
  67095. degree: number;
  67096. /**
  67097. * Creates a black and white post process
  67098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67099. * @param name The name of the effect.
  67100. * @param options The required width/height ratio to downsize to before computing the render pass.
  67101. * @param camera The camera to apply the render pass to.
  67102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67103. * @param engine The engine which the post process will be applied. (default: current engine)
  67104. * @param reusable If the post process can be reused on the same frame. (default: false)
  67105. */
  67106. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67107. }
  67108. }
  67109. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67110. import { Nullable } from "babylonjs/types";
  67111. import { Camera } from "babylonjs/Cameras/camera";
  67112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67113. import { Engine } from "babylonjs/Engines/engine";
  67114. /**
  67115. * This represents a set of one or more post processes in Babylon.
  67116. * A post process can be used to apply a shader to a texture after it is rendered.
  67117. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67118. */
  67119. export class PostProcessRenderEffect {
  67120. private _postProcesses;
  67121. private _getPostProcesses;
  67122. private _singleInstance;
  67123. private _cameras;
  67124. private _indicesForCamera;
  67125. /**
  67126. * Name of the effect
  67127. * @hidden
  67128. */
  67129. _name: string;
  67130. /**
  67131. * Instantiates a post process render effect.
  67132. * A post process can be used to apply a shader to a texture after it is rendered.
  67133. * @param engine The engine the effect is tied to
  67134. * @param name The name of the effect
  67135. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67136. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67137. */
  67138. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67139. /**
  67140. * Checks if all the post processes in the effect are supported.
  67141. */
  67142. get isSupported(): boolean;
  67143. /**
  67144. * Updates the current state of the effect
  67145. * @hidden
  67146. */
  67147. _update(): void;
  67148. /**
  67149. * Attaches the effect on cameras
  67150. * @param cameras The camera to attach to.
  67151. * @hidden
  67152. */
  67153. _attachCameras(cameras: Camera): void;
  67154. /**
  67155. * Attaches the effect on cameras
  67156. * @param cameras The camera to attach to.
  67157. * @hidden
  67158. */
  67159. _attachCameras(cameras: Camera[]): void;
  67160. /**
  67161. * Detaches the effect on cameras
  67162. * @param cameras The camera to detatch from.
  67163. * @hidden
  67164. */
  67165. _detachCameras(cameras: Camera): void;
  67166. /**
  67167. * Detatches the effect on cameras
  67168. * @param cameras The camera to detatch from.
  67169. * @hidden
  67170. */
  67171. _detachCameras(cameras: Camera[]): void;
  67172. /**
  67173. * Enables the effect on given cameras
  67174. * @param cameras The camera to enable.
  67175. * @hidden
  67176. */
  67177. _enable(cameras: Camera): void;
  67178. /**
  67179. * Enables the effect on given cameras
  67180. * @param cameras The camera to enable.
  67181. * @hidden
  67182. */
  67183. _enable(cameras: Nullable<Camera[]>): void;
  67184. /**
  67185. * Disables the effect on the given cameras
  67186. * @param cameras The camera to disable.
  67187. * @hidden
  67188. */
  67189. _disable(cameras: Camera): void;
  67190. /**
  67191. * Disables the effect on the given cameras
  67192. * @param cameras The camera to disable.
  67193. * @hidden
  67194. */
  67195. _disable(cameras: Nullable<Camera[]>): void;
  67196. /**
  67197. * Gets a list of the post processes contained in the effect.
  67198. * @param camera The camera to get the post processes on.
  67199. * @returns The list of the post processes in the effect.
  67200. */
  67201. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67202. }
  67203. }
  67204. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67205. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67206. /** @hidden */
  67207. export var extractHighlightsPixelShader: {
  67208. name: string;
  67209. shader: string;
  67210. };
  67211. }
  67212. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67213. import { Nullable } from "babylonjs/types";
  67214. import { Camera } from "babylonjs/Cameras/camera";
  67215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67216. import { Engine } from "babylonjs/Engines/engine";
  67217. import "babylonjs/Shaders/extractHighlights.fragment";
  67218. /**
  67219. * 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.
  67220. */
  67221. export class ExtractHighlightsPostProcess extends PostProcess {
  67222. /**
  67223. * The luminance threshold, pixels below this value will be set to black.
  67224. */
  67225. threshold: number;
  67226. /** @hidden */
  67227. _exposure: number;
  67228. /**
  67229. * Post process which has the input texture to be used when performing highlight extraction
  67230. * @hidden
  67231. */
  67232. _inputPostProcess: Nullable<PostProcess>;
  67233. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67234. }
  67235. }
  67236. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67237. /** @hidden */
  67238. export var bloomMergePixelShader: {
  67239. name: string;
  67240. shader: string;
  67241. };
  67242. }
  67243. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67245. import { Nullable } from "babylonjs/types";
  67246. import { Engine } from "babylonjs/Engines/engine";
  67247. import { Camera } from "babylonjs/Cameras/camera";
  67248. import "babylonjs/Shaders/bloomMerge.fragment";
  67249. /**
  67250. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67251. */
  67252. export class BloomMergePostProcess extends PostProcess {
  67253. /** Weight of the bloom to be added to the original input. */
  67254. weight: number;
  67255. /**
  67256. * Creates a new instance of @see BloomMergePostProcess
  67257. * @param name The name of the effect.
  67258. * @param originalFromInput Post process which's input will be used for the merge.
  67259. * @param blurred Blurred highlights post process which's output will be used.
  67260. * @param weight Weight of the bloom to be added to the original input.
  67261. * @param options The required width/height ratio to downsize to before computing the render pass.
  67262. * @param camera The camera to apply the render pass to.
  67263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67264. * @param engine The engine which the post process will be applied. (default: current engine)
  67265. * @param reusable If the post process can be reused on the same frame. (default: false)
  67266. * @param textureType Type of textures used when performing the post process. (default: 0)
  67267. * @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)
  67268. */
  67269. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67270. /** Weight of the bloom to be added to the original input. */
  67271. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67272. }
  67273. }
  67274. declare module "babylonjs/PostProcesses/bloomEffect" {
  67275. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67276. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67277. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67278. import { Camera } from "babylonjs/Cameras/camera";
  67279. import { Scene } from "babylonjs/scene";
  67280. /**
  67281. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67282. */
  67283. export class BloomEffect extends PostProcessRenderEffect {
  67284. private bloomScale;
  67285. /**
  67286. * @hidden Internal
  67287. */
  67288. _effects: Array<PostProcess>;
  67289. /**
  67290. * @hidden Internal
  67291. */
  67292. _downscale: ExtractHighlightsPostProcess;
  67293. private _blurX;
  67294. private _blurY;
  67295. private _merge;
  67296. /**
  67297. * The luminance threshold to find bright areas of the image to bloom.
  67298. */
  67299. get threshold(): number;
  67300. set threshold(value: number);
  67301. /**
  67302. * The strength of the bloom.
  67303. */
  67304. get weight(): number;
  67305. set weight(value: number);
  67306. /**
  67307. * Specifies the size of the bloom blur kernel, relative to the final output size
  67308. */
  67309. get kernel(): number;
  67310. set kernel(value: number);
  67311. /**
  67312. * Creates a new instance of @see BloomEffect
  67313. * @param scene The scene the effect belongs to.
  67314. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67315. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67316. * @param bloomWeight The the strength of bloom.
  67317. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67318. * @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)
  67319. */
  67320. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67321. /**
  67322. * Disposes each of the internal effects for a given camera.
  67323. * @param camera The camera to dispose the effect on.
  67324. */
  67325. disposeEffects(camera: Camera): void;
  67326. /**
  67327. * @hidden Internal
  67328. */
  67329. _updateEffects(): void;
  67330. /**
  67331. * Internal
  67332. * @returns if all the contained post processes are ready.
  67333. * @hidden
  67334. */
  67335. _isReady(): boolean;
  67336. }
  67337. }
  67338. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67339. /** @hidden */
  67340. export var chromaticAberrationPixelShader: {
  67341. name: string;
  67342. shader: string;
  67343. };
  67344. }
  67345. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67346. import { Vector2 } from "babylonjs/Maths/math.vector";
  67347. import { Nullable } from "babylonjs/types";
  67348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67349. import { Camera } from "babylonjs/Cameras/camera";
  67350. import { Engine } from "babylonjs/Engines/engine";
  67351. import "babylonjs/Shaders/chromaticAberration.fragment";
  67352. /**
  67353. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67354. */
  67355. export class ChromaticAberrationPostProcess extends PostProcess {
  67356. /**
  67357. * The amount of seperation of rgb channels (default: 30)
  67358. */
  67359. aberrationAmount: number;
  67360. /**
  67361. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67362. */
  67363. radialIntensity: number;
  67364. /**
  67365. * 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))
  67366. */
  67367. direction: Vector2;
  67368. /**
  67369. * 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))
  67370. */
  67371. centerPosition: Vector2;
  67372. /**
  67373. * Creates a new instance ChromaticAberrationPostProcess
  67374. * @param name The name of the effect.
  67375. * @param screenWidth The width of the screen to apply the effect on.
  67376. * @param screenHeight The height of the screen to apply the effect on.
  67377. * @param options The required width/height ratio to downsize to before computing the render pass.
  67378. * @param camera The camera to apply the render pass to.
  67379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67380. * @param engine The engine which the post process will be applied. (default: current engine)
  67381. * @param reusable If the post process can be reused on the same frame. (default: false)
  67382. * @param textureType Type of textures used when performing the post process. (default: 0)
  67383. * @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)
  67384. */
  67385. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67386. }
  67387. }
  67388. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67389. /** @hidden */
  67390. export var circleOfConfusionPixelShader: {
  67391. name: string;
  67392. shader: string;
  67393. };
  67394. }
  67395. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67396. import { Nullable } from "babylonjs/types";
  67397. import { Engine } from "babylonjs/Engines/engine";
  67398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67399. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67400. import { Camera } from "babylonjs/Cameras/camera";
  67401. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67402. /**
  67403. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67404. */
  67405. export class CircleOfConfusionPostProcess extends PostProcess {
  67406. /**
  67407. * 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.
  67408. */
  67409. lensSize: number;
  67410. /**
  67411. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67412. */
  67413. fStop: number;
  67414. /**
  67415. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67416. */
  67417. focusDistance: number;
  67418. /**
  67419. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67420. */
  67421. focalLength: number;
  67422. private _depthTexture;
  67423. /**
  67424. * Creates a new instance CircleOfConfusionPostProcess
  67425. * @param name The name of the effect.
  67426. * @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.
  67427. * @param options The required width/height ratio to downsize to before computing the render pass.
  67428. * @param camera The camera to apply the render pass to.
  67429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67430. * @param engine The engine which the post process will be applied. (default: current engine)
  67431. * @param reusable If the post process can be reused on the same frame. (default: false)
  67432. * @param textureType Type of textures used when performing the post process. (default: 0)
  67433. * @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)
  67434. */
  67435. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67436. /**
  67437. * 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.
  67438. */
  67439. set depthTexture(value: RenderTargetTexture);
  67440. }
  67441. }
  67442. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67443. /** @hidden */
  67444. export var colorCorrectionPixelShader: {
  67445. name: string;
  67446. shader: string;
  67447. };
  67448. }
  67449. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67451. import { Engine } from "babylonjs/Engines/engine";
  67452. import { Camera } from "babylonjs/Cameras/camera";
  67453. import "babylonjs/Shaders/colorCorrection.fragment";
  67454. /**
  67455. *
  67456. * This post-process allows the modification of rendered colors by using
  67457. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67458. *
  67459. * The object needs to be provided an url to a texture containing the color
  67460. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67461. * Use an image editing software to tweak the LUT to match your needs.
  67462. *
  67463. * For an example of a color LUT, see here:
  67464. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67465. * For explanations on color grading, see here:
  67466. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67467. *
  67468. */
  67469. export class ColorCorrectionPostProcess extends PostProcess {
  67470. private _colorTableTexture;
  67471. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67472. }
  67473. }
  67474. declare module "babylonjs/Shaders/convolution.fragment" {
  67475. /** @hidden */
  67476. export var convolutionPixelShader: {
  67477. name: string;
  67478. shader: string;
  67479. };
  67480. }
  67481. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67482. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67483. import { Nullable } from "babylonjs/types";
  67484. import { Camera } from "babylonjs/Cameras/camera";
  67485. import { Engine } from "babylonjs/Engines/engine";
  67486. import "babylonjs/Shaders/convolution.fragment";
  67487. /**
  67488. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67489. * input texture to perform effects such as edge detection or sharpening
  67490. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67491. */
  67492. export class ConvolutionPostProcess extends PostProcess {
  67493. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67494. kernel: number[];
  67495. /**
  67496. * Creates a new instance ConvolutionPostProcess
  67497. * @param name The name of the effect.
  67498. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67499. * @param options The required width/height ratio to downsize to before computing the render pass.
  67500. * @param camera The camera to apply the render pass to.
  67501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67502. * @param engine The engine which the post process will be applied. (default: current engine)
  67503. * @param reusable If the post process can be reused on the same frame. (default: false)
  67504. * @param textureType Type of textures used when performing the post process. (default: 0)
  67505. */
  67506. constructor(name: string,
  67507. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67508. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67509. /**
  67510. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67511. */
  67512. static EdgeDetect0Kernel: number[];
  67513. /**
  67514. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67515. */
  67516. static EdgeDetect1Kernel: number[];
  67517. /**
  67518. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67519. */
  67520. static EdgeDetect2Kernel: number[];
  67521. /**
  67522. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67523. */
  67524. static SharpenKernel: number[];
  67525. /**
  67526. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67527. */
  67528. static EmbossKernel: number[];
  67529. /**
  67530. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67531. */
  67532. static GaussianKernel: number[];
  67533. }
  67534. }
  67535. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67536. import { Nullable } from "babylonjs/types";
  67537. import { Vector2 } from "babylonjs/Maths/math.vector";
  67538. import { Camera } from "babylonjs/Cameras/camera";
  67539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67540. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67541. import { Engine } from "babylonjs/Engines/engine";
  67542. import { Scene } from "babylonjs/scene";
  67543. /**
  67544. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67545. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67546. * based on samples that have a large difference in distance than the center pixel.
  67547. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67548. */
  67549. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67550. direction: Vector2;
  67551. /**
  67552. * Creates a new instance CircleOfConfusionPostProcess
  67553. * @param name The name of the effect.
  67554. * @param scene The scene the effect belongs to.
  67555. * @param direction The direction the blur should be applied.
  67556. * @param kernel The size of the kernel used to blur.
  67557. * @param options The required width/height ratio to downsize to before computing the render pass.
  67558. * @param camera The camera to apply the render pass to.
  67559. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67560. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67562. * @param engine The engine which the post process will be applied. (default: current engine)
  67563. * @param reusable If the post process can be reused on the same frame. (default: false)
  67564. * @param textureType Type of textures used when performing the post process. (default: 0)
  67565. * @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)
  67566. */
  67567. 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);
  67568. }
  67569. }
  67570. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67571. /** @hidden */
  67572. export var depthOfFieldMergePixelShader: {
  67573. name: string;
  67574. shader: string;
  67575. };
  67576. }
  67577. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67578. import { Nullable } from "babylonjs/types";
  67579. import { Camera } from "babylonjs/Cameras/camera";
  67580. import { Effect } from "babylonjs/Materials/effect";
  67581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67582. import { Engine } from "babylonjs/Engines/engine";
  67583. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67584. /**
  67585. * Options to be set when merging outputs from the default pipeline.
  67586. */
  67587. export class DepthOfFieldMergePostProcessOptions {
  67588. /**
  67589. * The original image to merge on top of
  67590. */
  67591. originalFromInput: PostProcess;
  67592. /**
  67593. * Parameters to perform the merge of the depth of field effect
  67594. */
  67595. depthOfField?: {
  67596. circleOfConfusion: PostProcess;
  67597. blurSteps: Array<PostProcess>;
  67598. };
  67599. /**
  67600. * Parameters to perform the merge of bloom effect
  67601. */
  67602. bloom?: {
  67603. blurred: PostProcess;
  67604. weight: number;
  67605. };
  67606. }
  67607. /**
  67608. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67609. */
  67610. export class DepthOfFieldMergePostProcess extends PostProcess {
  67611. private blurSteps;
  67612. /**
  67613. * Creates a new instance of DepthOfFieldMergePostProcess
  67614. * @param name The name of the effect.
  67615. * @param originalFromInput Post process which's input will be used for the merge.
  67616. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67617. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67618. * @param options The required width/height ratio to downsize to before computing the render pass.
  67619. * @param camera The camera to apply the render pass to.
  67620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67621. * @param engine The engine which the post process will be applied. (default: current engine)
  67622. * @param reusable If the post process can be reused on the same frame. (default: false)
  67623. * @param textureType Type of textures used when performing the post process. (default: 0)
  67624. * @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)
  67625. */
  67626. 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);
  67627. /**
  67628. * Updates the effect with the current post process compile time values and recompiles the shader.
  67629. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67630. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67631. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67632. * @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
  67633. * @param onCompiled Called when the shader has been compiled.
  67634. * @param onError Called if there is an error when compiling a shader.
  67635. */
  67636. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67637. }
  67638. }
  67639. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67640. import { Nullable } from "babylonjs/types";
  67641. import { Camera } from "babylonjs/Cameras/camera";
  67642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67643. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67644. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67645. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67646. import { Scene } from "babylonjs/scene";
  67647. /**
  67648. * Specifies the level of max blur that should be applied when using the depth of field effect
  67649. */
  67650. export enum DepthOfFieldEffectBlurLevel {
  67651. /**
  67652. * Subtle blur
  67653. */
  67654. Low = 0,
  67655. /**
  67656. * Medium blur
  67657. */
  67658. Medium = 1,
  67659. /**
  67660. * Large blur
  67661. */
  67662. High = 2
  67663. }
  67664. /**
  67665. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67666. */
  67667. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67668. private _circleOfConfusion;
  67669. /**
  67670. * @hidden Internal, blurs from high to low
  67671. */
  67672. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67673. private _depthOfFieldBlurY;
  67674. private _dofMerge;
  67675. /**
  67676. * @hidden Internal post processes in depth of field effect
  67677. */
  67678. _effects: Array<PostProcess>;
  67679. /**
  67680. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67681. */
  67682. set focalLength(value: number);
  67683. get focalLength(): number;
  67684. /**
  67685. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67686. */
  67687. set fStop(value: number);
  67688. get fStop(): number;
  67689. /**
  67690. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67691. */
  67692. set focusDistance(value: number);
  67693. get focusDistance(): number;
  67694. /**
  67695. * 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.
  67696. */
  67697. set lensSize(value: number);
  67698. get lensSize(): number;
  67699. /**
  67700. * Creates a new instance DepthOfFieldEffect
  67701. * @param scene The scene the effect belongs to.
  67702. * @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.
  67703. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67704. * @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)
  67705. */
  67706. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67707. /**
  67708. * Get the current class name of the current effet
  67709. * @returns "DepthOfFieldEffect"
  67710. */
  67711. getClassName(): string;
  67712. /**
  67713. * 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.
  67714. */
  67715. set depthTexture(value: RenderTargetTexture);
  67716. /**
  67717. * Disposes each of the internal effects for a given camera.
  67718. * @param camera The camera to dispose the effect on.
  67719. */
  67720. disposeEffects(camera: Camera): void;
  67721. /**
  67722. * @hidden Internal
  67723. */
  67724. _updateEffects(): void;
  67725. /**
  67726. * Internal
  67727. * @returns if all the contained post processes are ready.
  67728. * @hidden
  67729. */
  67730. _isReady(): boolean;
  67731. }
  67732. }
  67733. declare module "babylonjs/Shaders/displayPass.fragment" {
  67734. /** @hidden */
  67735. export var displayPassPixelShader: {
  67736. name: string;
  67737. shader: string;
  67738. };
  67739. }
  67740. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67741. import { Nullable } from "babylonjs/types";
  67742. import { Camera } from "babylonjs/Cameras/camera";
  67743. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67744. import { Engine } from "babylonjs/Engines/engine";
  67745. import "babylonjs/Shaders/displayPass.fragment";
  67746. /**
  67747. * DisplayPassPostProcess which produces an output the same as it's input
  67748. */
  67749. export class DisplayPassPostProcess extends PostProcess {
  67750. /**
  67751. * Creates the DisplayPassPostProcess
  67752. * @param name The name of the effect.
  67753. * @param options The required width/height ratio to downsize to before computing the render pass.
  67754. * @param camera The camera to apply the render pass to.
  67755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67756. * @param engine The engine which the post process will be applied. (default: current engine)
  67757. * @param reusable If the post process can be reused on the same frame. (default: false)
  67758. */
  67759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67760. }
  67761. }
  67762. declare module "babylonjs/Shaders/filter.fragment" {
  67763. /** @hidden */
  67764. export var filterPixelShader: {
  67765. name: string;
  67766. shader: string;
  67767. };
  67768. }
  67769. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67770. import { Nullable } from "babylonjs/types";
  67771. import { Matrix } from "babylonjs/Maths/math.vector";
  67772. import { Camera } from "babylonjs/Cameras/camera";
  67773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67774. import { Engine } from "babylonjs/Engines/engine";
  67775. import "babylonjs/Shaders/filter.fragment";
  67776. /**
  67777. * Applies a kernel filter to the image
  67778. */
  67779. export class FilterPostProcess extends PostProcess {
  67780. /** The matrix to be applied to the image */
  67781. kernelMatrix: Matrix;
  67782. /**
  67783. *
  67784. * @param name The name of the effect.
  67785. * @param kernelMatrix The matrix to be applied to the image
  67786. * @param options The required width/height ratio to downsize to before computing the render pass.
  67787. * @param camera The camera to apply the render pass to.
  67788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67789. * @param engine The engine which the post process will be applied. (default: current engine)
  67790. * @param reusable If the post process can be reused on the same frame. (default: false)
  67791. */
  67792. constructor(name: string,
  67793. /** The matrix to be applied to the image */
  67794. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67795. }
  67796. }
  67797. declare module "babylonjs/Shaders/fxaa.fragment" {
  67798. /** @hidden */
  67799. export var fxaaPixelShader: {
  67800. name: string;
  67801. shader: string;
  67802. };
  67803. }
  67804. declare module "babylonjs/Shaders/fxaa.vertex" {
  67805. /** @hidden */
  67806. export var fxaaVertexShader: {
  67807. name: string;
  67808. shader: string;
  67809. };
  67810. }
  67811. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67812. import { Nullable } from "babylonjs/types";
  67813. import { Camera } from "babylonjs/Cameras/camera";
  67814. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67815. import { Engine } from "babylonjs/Engines/engine";
  67816. import "babylonjs/Shaders/fxaa.fragment";
  67817. import "babylonjs/Shaders/fxaa.vertex";
  67818. /**
  67819. * Fxaa post process
  67820. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67821. */
  67822. export class FxaaPostProcess extends PostProcess {
  67823. /** @hidden */
  67824. texelWidth: number;
  67825. /** @hidden */
  67826. texelHeight: number;
  67827. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67828. private _getDefines;
  67829. }
  67830. }
  67831. declare module "babylonjs/Shaders/grain.fragment" {
  67832. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67833. /** @hidden */
  67834. export var grainPixelShader: {
  67835. name: string;
  67836. shader: string;
  67837. };
  67838. }
  67839. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67840. import { Nullable } from "babylonjs/types";
  67841. import { Camera } from "babylonjs/Cameras/camera";
  67842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67843. import { Engine } from "babylonjs/Engines/engine";
  67844. import "babylonjs/Shaders/grain.fragment";
  67845. /**
  67846. * The GrainPostProcess adds noise to the image at mid luminance levels
  67847. */
  67848. export class GrainPostProcess extends PostProcess {
  67849. /**
  67850. * The intensity of the grain added (default: 30)
  67851. */
  67852. intensity: number;
  67853. /**
  67854. * If the grain should be randomized on every frame
  67855. */
  67856. animated: boolean;
  67857. /**
  67858. * Creates a new instance of @see GrainPostProcess
  67859. * @param name The name of the effect.
  67860. * @param options The required width/height ratio to downsize to before computing the render pass.
  67861. * @param camera The camera to apply the render pass to.
  67862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67863. * @param engine The engine which the post process will be applied. (default: current engine)
  67864. * @param reusable If the post process can be reused on the same frame. (default: false)
  67865. * @param textureType Type of textures used when performing the post process. (default: 0)
  67866. * @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)
  67867. */
  67868. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67869. }
  67870. }
  67871. declare module "babylonjs/Shaders/highlights.fragment" {
  67872. /** @hidden */
  67873. export var highlightsPixelShader: {
  67874. name: string;
  67875. shader: string;
  67876. };
  67877. }
  67878. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67879. import { Nullable } from "babylonjs/types";
  67880. import { Camera } from "babylonjs/Cameras/camera";
  67881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67882. import { Engine } from "babylonjs/Engines/engine";
  67883. import "babylonjs/Shaders/highlights.fragment";
  67884. /**
  67885. * Extracts highlights from the image
  67886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67887. */
  67888. export class HighlightsPostProcess extends PostProcess {
  67889. /**
  67890. * Extracts highlights from the image
  67891. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67892. * @param name The name of the effect.
  67893. * @param options The required width/height ratio to downsize to before computing the render pass.
  67894. * @param camera The camera to apply the render pass to.
  67895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67896. * @param engine The engine which the post process will be applied. (default: current engine)
  67897. * @param reusable If the post process can be reused on the same frame. (default: false)
  67898. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67899. */
  67900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67901. }
  67902. }
  67903. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67904. /** @hidden */
  67905. export var mrtFragmentDeclaration: {
  67906. name: string;
  67907. shader: string;
  67908. };
  67909. }
  67910. declare module "babylonjs/Shaders/geometry.fragment" {
  67911. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67912. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67913. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67914. /** @hidden */
  67915. export var geometryPixelShader: {
  67916. name: string;
  67917. shader: string;
  67918. };
  67919. }
  67920. declare module "babylonjs/Shaders/geometry.vertex" {
  67921. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67924. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67926. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67927. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67928. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67929. /** @hidden */
  67930. export var geometryVertexShader: {
  67931. name: string;
  67932. shader: string;
  67933. };
  67934. }
  67935. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67936. import { Matrix } from "babylonjs/Maths/math.vector";
  67937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67938. import { Mesh } from "babylonjs/Meshes/mesh";
  67939. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67940. import { Effect } from "babylonjs/Materials/effect";
  67941. import { Scene } from "babylonjs/scene";
  67942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67943. import "babylonjs/Shaders/geometry.fragment";
  67944. import "babylonjs/Shaders/geometry.vertex";
  67945. /** @hidden */
  67946. interface ISavedTransformationMatrix {
  67947. world: Matrix;
  67948. viewProjection: Matrix;
  67949. }
  67950. /**
  67951. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67952. */
  67953. export class GeometryBufferRenderer {
  67954. /**
  67955. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67956. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67957. */
  67958. static readonly POSITION_TEXTURE_TYPE: number;
  67959. /**
  67960. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67961. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67962. */
  67963. static readonly VELOCITY_TEXTURE_TYPE: number;
  67964. /**
  67965. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67966. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67967. */
  67968. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67969. /**
  67970. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67971. * in order to compute objects velocities when enableVelocity is set to "true"
  67972. * @hidden
  67973. */
  67974. _previousTransformationMatrices: {
  67975. [index: number]: ISavedTransformationMatrix;
  67976. };
  67977. /**
  67978. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67979. * in order to compute objects velocities when enableVelocity is set to "true"
  67980. * @hidden
  67981. */
  67982. _previousBonesTransformationMatrices: {
  67983. [index: number]: Float32Array;
  67984. };
  67985. /**
  67986. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67987. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67988. */
  67989. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67990. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67991. renderTransparentMeshes: boolean;
  67992. private _scene;
  67993. private _multiRenderTarget;
  67994. private _ratio;
  67995. private _enablePosition;
  67996. private _enableVelocity;
  67997. private _enableReflectivity;
  67998. private _positionIndex;
  67999. private _velocityIndex;
  68000. private _reflectivityIndex;
  68001. protected _effect: Effect;
  68002. protected _cachedDefines: string;
  68003. /**
  68004. * Set the render list (meshes to be rendered) used in the G buffer.
  68005. */
  68006. set renderList(meshes: Mesh[]);
  68007. /**
  68008. * Gets wether or not G buffer are supported by the running hardware.
  68009. * This requires draw buffer supports
  68010. */
  68011. get isSupported(): boolean;
  68012. /**
  68013. * Returns the index of the given texture type in the G-Buffer textures array
  68014. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68015. * @returns the index of the given texture type in the G-Buffer textures array
  68016. */
  68017. getTextureIndex(textureType: number): number;
  68018. /**
  68019. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68020. */
  68021. get enablePosition(): boolean;
  68022. /**
  68023. * Sets whether or not objects positions are enabled for the G buffer.
  68024. */
  68025. set enablePosition(enable: boolean);
  68026. /**
  68027. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68028. */
  68029. get enableVelocity(): boolean;
  68030. /**
  68031. * Sets wether or not objects velocities are enabled for the G buffer.
  68032. */
  68033. set enableVelocity(enable: boolean);
  68034. /**
  68035. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68036. */
  68037. get enableReflectivity(): boolean;
  68038. /**
  68039. * Sets wether or not objects roughness are enabled for the G buffer.
  68040. */
  68041. set enableReflectivity(enable: boolean);
  68042. /**
  68043. * Gets the scene associated with the buffer.
  68044. */
  68045. get scene(): Scene;
  68046. /**
  68047. * Gets the ratio used by the buffer during its creation.
  68048. * How big is the buffer related to the main canvas.
  68049. */
  68050. get ratio(): number;
  68051. /** @hidden */
  68052. static _SceneComponentInitialization: (scene: Scene) => void;
  68053. /**
  68054. * Creates a new G Buffer for the scene
  68055. * @param scene The scene the buffer belongs to
  68056. * @param ratio How big is the buffer related to the main canvas.
  68057. */
  68058. constructor(scene: Scene, ratio?: number);
  68059. /**
  68060. * Checks wether everything is ready to render a submesh to the G buffer.
  68061. * @param subMesh the submesh to check readiness for
  68062. * @param useInstances is the mesh drawn using instance or not
  68063. * @returns true if ready otherwise false
  68064. */
  68065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68066. /**
  68067. * Gets the current underlying G Buffer.
  68068. * @returns the buffer
  68069. */
  68070. getGBuffer(): MultiRenderTarget;
  68071. /**
  68072. * Gets the number of samples used to render the buffer (anti aliasing).
  68073. */
  68074. get samples(): number;
  68075. /**
  68076. * Sets the number of samples used to render the buffer (anti aliasing).
  68077. */
  68078. set samples(value: number);
  68079. /**
  68080. * Disposes the renderer and frees up associated resources.
  68081. */
  68082. dispose(): void;
  68083. protected _createRenderTargets(): void;
  68084. private _copyBonesTransformationMatrices;
  68085. }
  68086. }
  68087. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68088. import { Nullable } from "babylonjs/types";
  68089. import { Scene } from "babylonjs/scene";
  68090. import { ISceneComponent } from "babylonjs/sceneComponent";
  68091. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68092. module "babylonjs/scene" {
  68093. interface Scene {
  68094. /** @hidden (Backing field) */
  68095. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68096. /**
  68097. * Gets or Sets the current geometry buffer associated to the scene.
  68098. */
  68099. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68100. /**
  68101. * Enables a GeometryBufferRender and associates it with the scene
  68102. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68103. * @returns the GeometryBufferRenderer
  68104. */
  68105. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68106. /**
  68107. * Disables the GeometryBufferRender associated with the scene
  68108. */
  68109. disableGeometryBufferRenderer(): void;
  68110. }
  68111. }
  68112. /**
  68113. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68114. * in several rendering techniques.
  68115. */
  68116. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68117. /**
  68118. * The component name helpful to identify the component in the list of scene components.
  68119. */
  68120. readonly name: string;
  68121. /**
  68122. * The scene the component belongs to.
  68123. */
  68124. scene: Scene;
  68125. /**
  68126. * Creates a new instance of the component for the given scene
  68127. * @param scene Defines the scene to register the component in
  68128. */
  68129. constructor(scene: Scene);
  68130. /**
  68131. * Registers the component in a given scene
  68132. */
  68133. register(): void;
  68134. /**
  68135. * Rebuilds the elements related to this component in case of
  68136. * context lost for instance.
  68137. */
  68138. rebuild(): void;
  68139. /**
  68140. * Disposes the component and the associated ressources
  68141. */
  68142. dispose(): void;
  68143. private _gatherRenderTargets;
  68144. }
  68145. }
  68146. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68147. /** @hidden */
  68148. export var motionBlurPixelShader: {
  68149. name: string;
  68150. shader: string;
  68151. };
  68152. }
  68153. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68154. import { Nullable } from "babylonjs/types";
  68155. import { Camera } from "babylonjs/Cameras/camera";
  68156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68157. import { Scene } from "babylonjs/scene";
  68158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68159. import "babylonjs/Animations/animatable";
  68160. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68161. import "babylonjs/Shaders/motionBlur.fragment";
  68162. import { Engine } from "babylonjs/Engines/engine";
  68163. /**
  68164. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68165. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68166. * As an example, all you have to do is to create the post-process:
  68167. * var mb = new BABYLON.MotionBlurPostProcess(
  68168. * 'mb', // The name of the effect.
  68169. * scene, // The scene containing the objects to blur according to their velocity.
  68170. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68171. * camera // The camera to apply the render pass to.
  68172. * );
  68173. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68174. */
  68175. export class MotionBlurPostProcess extends PostProcess {
  68176. /**
  68177. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68178. */
  68179. motionStrength: number;
  68180. /**
  68181. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68182. */
  68183. get motionBlurSamples(): number;
  68184. /**
  68185. * Sets the number of iterations to be used for motion blur quality
  68186. */
  68187. set motionBlurSamples(samples: number);
  68188. private _motionBlurSamples;
  68189. private _geometryBufferRenderer;
  68190. /**
  68191. * Creates a new instance MotionBlurPostProcess
  68192. * @param name The name of the effect.
  68193. * @param scene The scene containing the objects to blur according to their velocity.
  68194. * @param options The required width/height ratio to downsize to before computing the render pass.
  68195. * @param camera The camera to apply the render pass to.
  68196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68197. * @param engine The engine which the post process will be applied. (default: current engine)
  68198. * @param reusable If the post process can be reused on the same frame. (default: false)
  68199. * @param textureType Type of textures used when performing the post process. (default: 0)
  68200. * @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)
  68201. */
  68202. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68203. /**
  68204. * Excludes the given skinned mesh from computing bones velocities.
  68205. * 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.
  68206. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68207. */
  68208. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68209. /**
  68210. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68211. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68212. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68213. */
  68214. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68215. /**
  68216. * Disposes the post process.
  68217. * @param camera The camera to dispose the post process on.
  68218. */
  68219. dispose(camera?: Camera): void;
  68220. }
  68221. }
  68222. declare module "babylonjs/Shaders/refraction.fragment" {
  68223. /** @hidden */
  68224. export var refractionPixelShader: {
  68225. name: string;
  68226. shader: string;
  68227. };
  68228. }
  68229. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68230. import { Color3 } from "babylonjs/Maths/math.color";
  68231. import { Camera } from "babylonjs/Cameras/camera";
  68232. import { Texture } from "babylonjs/Materials/Textures/texture";
  68233. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68234. import { Engine } from "babylonjs/Engines/engine";
  68235. import "babylonjs/Shaders/refraction.fragment";
  68236. /**
  68237. * Post process which applies a refractin texture
  68238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68239. */
  68240. export class RefractionPostProcess extends PostProcess {
  68241. /** the base color of the refraction (used to taint the rendering) */
  68242. color: Color3;
  68243. /** simulated refraction depth */
  68244. depth: number;
  68245. /** the coefficient of the base color (0 to remove base color tainting) */
  68246. colorLevel: number;
  68247. private _refTexture;
  68248. private _ownRefractionTexture;
  68249. /**
  68250. * Gets or sets the refraction texture
  68251. * Please note that you are responsible for disposing the texture if you set it manually
  68252. */
  68253. get refractionTexture(): Texture;
  68254. set refractionTexture(value: Texture);
  68255. /**
  68256. * Initializes the RefractionPostProcess
  68257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68258. * @param name The name of the effect.
  68259. * @param refractionTextureUrl Url of the refraction texture to use
  68260. * @param color the base color of the refraction (used to taint the rendering)
  68261. * @param depth simulated refraction depth
  68262. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68263. * @param camera The camera to apply the render pass to.
  68264. * @param options The required width/height ratio to downsize to before computing the render pass.
  68265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68266. * @param engine The engine which the post process will be applied. (default: current engine)
  68267. * @param reusable If the post process can be reused on the same frame. (default: false)
  68268. */
  68269. constructor(name: string, refractionTextureUrl: string,
  68270. /** the base color of the refraction (used to taint the rendering) */
  68271. color: Color3,
  68272. /** simulated refraction depth */
  68273. depth: number,
  68274. /** the coefficient of the base color (0 to remove base color tainting) */
  68275. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68276. /**
  68277. * Disposes of the post process
  68278. * @param camera Camera to dispose post process on
  68279. */
  68280. dispose(camera: Camera): void;
  68281. }
  68282. }
  68283. declare module "babylonjs/Shaders/sharpen.fragment" {
  68284. /** @hidden */
  68285. export var sharpenPixelShader: {
  68286. name: string;
  68287. shader: string;
  68288. };
  68289. }
  68290. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68291. import { Nullable } from "babylonjs/types";
  68292. import { Camera } from "babylonjs/Cameras/camera";
  68293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68294. import "babylonjs/Shaders/sharpen.fragment";
  68295. import { Engine } from "babylonjs/Engines/engine";
  68296. /**
  68297. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68298. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68299. */
  68300. export class SharpenPostProcess extends PostProcess {
  68301. /**
  68302. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68303. */
  68304. colorAmount: number;
  68305. /**
  68306. * How much sharpness should be applied (default: 0.3)
  68307. */
  68308. edgeAmount: number;
  68309. /**
  68310. * Creates a new instance ConvolutionPostProcess
  68311. * @param name The name of the effect.
  68312. * @param options The required width/height ratio to downsize to before computing the render pass.
  68313. * @param camera The camera to apply the render pass to.
  68314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68315. * @param engine The engine which the post process will be applied. (default: current engine)
  68316. * @param reusable If the post process can be reused on the same frame. (default: false)
  68317. * @param textureType Type of textures used when performing the post process. (default: 0)
  68318. * @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)
  68319. */
  68320. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68321. }
  68322. }
  68323. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68324. import { Nullable } from "babylonjs/types";
  68325. import { Camera } from "babylonjs/Cameras/camera";
  68326. import { Engine } from "babylonjs/Engines/engine";
  68327. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68328. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68329. /**
  68330. * PostProcessRenderPipeline
  68331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68332. */
  68333. export class PostProcessRenderPipeline {
  68334. private engine;
  68335. private _renderEffects;
  68336. private _renderEffectsForIsolatedPass;
  68337. /**
  68338. * List of inspectable custom properties (used by the Inspector)
  68339. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68340. */
  68341. inspectableCustomProperties: IInspectable[];
  68342. /**
  68343. * @hidden
  68344. */
  68345. protected _cameras: Camera[];
  68346. /** @hidden */
  68347. _name: string;
  68348. /**
  68349. * Gets pipeline name
  68350. */
  68351. get name(): string;
  68352. /** Gets the list of attached cameras */
  68353. get cameras(): Camera[];
  68354. /**
  68355. * Initializes a PostProcessRenderPipeline
  68356. * @param engine engine to add the pipeline to
  68357. * @param name name of the pipeline
  68358. */
  68359. constructor(engine: Engine, name: string);
  68360. /**
  68361. * Gets the class name
  68362. * @returns "PostProcessRenderPipeline"
  68363. */
  68364. getClassName(): string;
  68365. /**
  68366. * If all the render effects in the pipeline are supported
  68367. */
  68368. get isSupported(): boolean;
  68369. /**
  68370. * Adds an effect to the pipeline
  68371. * @param renderEffect the effect to add
  68372. */
  68373. addEffect(renderEffect: PostProcessRenderEffect): void;
  68374. /** @hidden */
  68375. _rebuild(): void;
  68376. /** @hidden */
  68377. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68378. /** @hidden */
  68379. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68380. /** @hidden */
  68381. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68382. /** @hidden */
  68383. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68384. /** @hidden */
  68385. _attachCameras(cameras: Camera, unique: boolean): void;
  68386. /** @hidden */
  68387. _attachCameras(cameras: Camera[], unique: boolean): void;
  68388. /** @hidden */
  68389. _detachCameras(cameras: Camera): void;
  68390. /** @hidden */
  68391. _detachCameras(cameras: Nullable<Camera[]>): void;
  68392. /** @hidden */
  68393. _update(): void;
  68394. /** @hidden */
  68395. _reset(): void;
  68396. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68397. /**
  68398. * Disposes of the pipeline
  68399. */
  68400. dispose(): void;
  68401. }
  68402. }
  68403. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68404. import { Camera } from "babylonjs/Cameras/camera";
  68405. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68406. /**
  68407. * PostProcessRenderPipelineManager class
  68408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68409. */
  68410. export class PostProcessRenderPipelineManager {
  68411. private _renderPipelines;
  68412. /**
  68413. * Initializes a PostProcessRenderPipelineManager
  68414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68415. */
  68416. constructor();
  68417. /**
  68418. * Gets the list of supported render pipelines
  68419. */
  68420. get supportedPipelines(): PostProcessRenderPipeline[];
  68421. /**
  68422. * Adds a pipeline to the manager
  68423. * @param renderPipeline The pipeline to add
  68424. */
  68425. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68426. /**
  68427. * Attaches a camera to the pipeline
  68428. * @param renderPipelineName The name of the pipeline to attach to
  68429. * @param cameras the camera to attach
  68430. * @param unique if the camera can be attached multiple times to the pipeline
  68431. */
  68432. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68433. /**
  68434. * Detaches a camera from the pipeline
  68435. * @param renderPipelineName The name of the pipeline to detach from
  68436. * @param cameras the camera to detach
  68437. */
  68438. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68439. /**
  68440. * Enables an effect by name on a pipeline
  68441. * @param renderPipelineName the name of the pipeline to enable the effect in
  68442. * @param renderEffectName the name of the effect to enable
  68443. * @param cameras the cameras that the effect should be enabled on
  68444. */
  68445. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68446. /**
  68447. * Disables an effect by name on a pipeline
  68448. * @param renderPipelineName the name of the pipeline to disable the effect in
  68449. * @param renderEffectName the name of the effect to disable
  68450. * @param cameras the cameras that the effect should be disabled on
  68451. */
  68452. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68453. /**
  68454. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68455. */
  68456. update(): void;
  68457. /** @hidden */
  68458. _rebuild(): void;
  68459. /**
  68460. * Disposes of the manager and pipelines
  68461. */
  68462. dispose(): void;
  68463. }
  68464. }
  68465. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68466. import { ISceneComponent } from "babylonjs/sceneComponent";
  68467. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68468. import { Scene } from "babylonjs/scene";
  68469. module "babylonjs/scene" {
  68470. interface Scene {
  68471. /** @hidden (Backing field) */
  68472. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68473. /**
  68474. * Gets the postprocess render pipeline manager
  68475. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68476. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68477. */
  68478. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68479. }
  68480. }
  68481. /**
  68482. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68483. */
  68484. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68485. /**
  68486. * The component name helpfull to identify the component in the list of scene components.
  68487. */
  68488. readonly name: string;
  68489. /**
  68490. * The scene the component belongs to.
  68491. */
  68492. scene: Scene;
  68493. /**
  68494. * Creates a new instance of the component for the given scene
  68495. * @param scene Defines the scene to register the component in
  68496. */
  68497. constructor(scene: Scene);
  68498. /**
  68499. * Registers the component in a given scene
  68500. */
  68501. register(): void;
  68502. /**
  68503. * Rebuilds the elements related to this component in case of
  68504. * context lost for instance.
  68505. */
  68506. rebuild(): void;
  68507. /**
  68508. * Disposes the component and the associated ressources
  68509. */
  68510. dispose(): void;
  68511. private _gatherRenderTargets;
  68512. }
  68513. }
  68514. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68515. import { Nullable } from "babylonjs/types";
  68516. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68517. import { Camera } from "babylonjs/Cameras/camera";
  68518. import { IDisposable } from "babylonjs/scene";
  68519. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68520. import { Scene } from "babylonjs/scene";
  68521. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68522. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68523. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68524. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68525. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68526. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68527. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68528. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68529. import { Animation } from "babylonjs/Animations/animation";
  68530. /**
  68531. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68532. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68533. */
  68534. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68535. private _scene;
  68536. private _camerasToBeAttached;
  68537. /**
  68538. * ID of the sharpen post process,
  68539. */
  68540. private readonly SharpenPostProcessId;
  68541. /**
  68542. * @ignore
  68543. * ID of the image processing post process;
  68544. */
  68545. readonly ImageProcessingPostProcessId: string;
  68546. /**
  68547. * @ignore
  68548. * ID of the Fast Approximate Anti-Aliasing post process;
  68549. */
  68550. readonly FxaaPostProcessId: string;
  68551. /**
  68552. * ID of the chromatic aberration post process,
  68553. */
  68554. private readonly ChromaticAberrationPostProcessId;
  68555. /**
  68556. * ID of the grain post process
  68557. */
  68558. private readonly GrainPostProcessId;
  68559. /**
  68560. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68561. */
  68562. sharpen: SharpenPostProcess;
  68563. private _sharpenEffect;
  68564. private bloom;
  68565. /**
  68566. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68567. */
  68568. depthOfField: DepthOfFieldEffect;
  68569. /**
  68570. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68571. */
  68572. fxaa: FxaaPostProcess;
  68573. /**
  68574. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68575. */
  68576. imageProcessing: ImageProcessingPostProcess;
  68577. /**
  68578. * Chromatic aberration post process which will shift rgb colors in the image
  68579. */
  68580. chromaticAberration: ChromaticAberrationPostProcess;
  68581. private _chromaticAberrationEffect;
  68582. /**
  68583. * Grain post process which add noise to the image
  68584. */
  68585. grain: GrainPostProcess;
  68586. private _grainEffect;
  68587. /**
  68588. * Glow post process which adds a glow to emissive areas of the image
  68589. */
  68590. private _glowLayer;
  68591. /**
  68592. * Animations which can be used to tweak settings over a period of time
  68593. */
  68594. animations: Animation[];
  68595. private _imageProcessingConfigurationObserver;
  68596. private _sharpenEnabled;
  68597. private _bloomEnabled;
  68598. private _depthOfFieldEnabled;
  68599. private _depthOfFieldBlurLevel;
  68600. private _fxaaEnabled;
  68601. private _imageProcessingEnabled;
  68602. private _defaultPipelineTextureType;
  68603. private _bloomScale;
  68604. private _chromaticAberrationEnabled;
  68605. private _grainEnabled;
  68606. private _buildAllowed;
  68607. /**
  68608. * Gets active scene
  68609. */
  68610. get scene(): Scene;
  68611. /**
  68612. * Enable or disable the sharpen process from the pipeline
  68613. */
  68614. set sharpenEnabled(enabled: boolean);
  68615. get sharpenEnabled(): boolean;
  68616. private _resizeObserver;
  68617. private _hardwareScaleLevel;
  68618. private _bloomKernel;
  68619. /**
  68620. * Specifies the size of the bloom blur kernel, relative to the final output size
  68621. */
  68622. get bloomKernel(): number;
  68623. set bloomKernel(value: number);
  68624. /**
  68625. * Specifies the weight of the bloom in the final rendering
  68626. */
  68627. private _bloomWeight;
  68628. /**
  68629. * Specifies the luma threshold for the area that will be blurred by the bloom
  68630. */
  68631. private _bloomThreshold;
  68632. private _hdr;
  68633. /**
  68634. * The strength of the bloom.
  68635. */
  68636. set bloomWeight(value: number);
  68637. get bloomWeight(): number;
  68638. /**
  68639. * The strength of the bloom.
  68640. */
  68641. set bloomThreshold(value: number);
  68642. get bloomThreshold(): number;
  68643. /**
  68644. * The scale of the bloom, lower value will provide better performance.
  68645. */
  68646. set bloomScale(value: number);
  68647. get bloomScale(): number;
  68648. /**
  68649. * Enable or disable the bloom from the pipeline
  68650. */
  68651. set bloomEnabled(enabled: boolean);
  68652. get bloomEnabled(): boolean;
  68653. private _rebuildBloom;
  68654. /**
  68655. * If the depth of field is enabled.
  68656. */
  68657. get depthOfFieldEnabled(): boolean;
  68658. set depthOfFieldEnabled(enabled: boolean);
  68659. /**
  68660. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68661. */
  68662. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68663. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68664. /**
  68665. * If the anti aliasing is enabled.
  68666. */
  68667. set fxaaEnabled(enabled: boolean);
  68668. get fxaaEnabled(): boolean;
  68669. private _samples;
  68670. /**
  68671. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68672. */
  68673. set samples(sampleCount: number);
  68674. get samples(): number;
  68675. /**
  68676. * If image processing is enabled.
  68677. */
  68678. set imageProcessingEnabled(enabled: boolean);
  68679. get imageProcessingEnabled(): boolean;
  68680. /**
  68681. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68682. */
  68683. set glowLayerEnabled(enabled: boolean);
  68684. get glowLayerEnabled(): boolean;
  68685. /**
  68686. * Gets the glow layer (or null if not defined)
  68687. */
  68688. get glowLayer(): Nullable<GlowLayer>;
  68689. /**
  68690. * Enable or disable the chromaticAberration process from the pipeline
  68691. */
  68692. set chromaticAberrationEnabled(enabled: boolean);
  68693. get chromaticAberrationEnabled(): boolean;
  68694. /**
  68695. * Enable or disable the grain process from the pipeline
  68696. */
  68697. set grainEnabled(enabled: boolean);
  68698. get grainEnabled(): boolean;
  68699. /**
  68700. * @constructor
  68701. * @param name - The rendering pipeline name (default: "")
  68702. * @param hdr - If high dynamic range textures should be used (default: true)
  68703. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68704. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68705. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68706. */
  68707. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68708. /**
  68709. * Get the class name
  68710. * @returns "DefaultRenderingPipeline"
  68711. */
  68712. getClassName(): string;
  68713. /**
  68714. * Force the compilation of the entire pipeline.
  68715. */
  68716. prepare(): void;
  68717. private _hasCleared;
  68718. private _prevPostProcess;
  68719. private _prevPrevPostProcess;
  68720. private _setAutoClearAndTextureSharing;
  68721. private _depthOfFieldSceneObserver;
  68722. private _buildPipeline;
  68723. private _disposePostProcesses;
  68724. /**
  68725. * Adds a camera to the pipeline
  68726. * @param camera the camera to be added
  68727. */
  68728. addCamera(camera: Camera): void;
  68729. /**
  68730. * Removes a camera from the pipeline
  68731. * @param camera the camera to remove
  68732. */
  68733. removeCamera(camera: Camera): void;
  68734. /**
  68735. * Dispose of the pipeline and stop all post processes
  68736. */
  68737. dispose(): void;
  68738. /**
  68739. * Serialize the rendering pipeline (Used when exporting)
  68740. * @returns the serialized object
  68741. */
  68742. serialize(): any;
  68743. /**
  68744. * Parse the serialized pipeline
  68745. * @param source Source pipeline.
  68746. * @param scene The scene to load the pipeline to.
  68747. * @param rootUrl The URL of the serialized pipeline.
  68748. * @returns An instantiated pipeline from the serialized object.
  68749. */
  68750. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68751. }
  68752. }
  68753. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68754. /** @hidden */
  68755. export var lensHighlightsPixelShader: {
  68756. name: string;
  68757. shader: string;
  68758. };
  68759. }
  68760. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68761. /** @hidden */
  68762. export var depthOfFieldPixelShader: {
  68763. name: string;
  68764. shader: string;
  68765. };
  68766. }
  68767. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68768. import { Camera } from "babylonjs/Cameras/camera";
  68769. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68770. import { Scene } from "babylonjs/scene";
  68771. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68772. import "babylonjs/Shaders/chromaticAberration.fragment";
  68773. import "babylonjs/Shaders/lensHighlights.fragment";
  68774. import "babylonjs/Shaders/depthOfField.fragment";
  68775. /**
  68776. * BABYLON.JS Chromatic Aberration GLSL Shader
  68777. * Author: Olivier Guyot
  68778. * Separates very slightly R, G and B colors on the edges of the screen
  68779. * Inspired by Francois Tarlier & Martins Upitis
  68780. */
  68781. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68782. /**
  68783. * @ignore
  68784. * The chromatic aberration PostProcess id in the pipeline
  68785. */
  68786. LensChromaticAberrationEffect: string;
  68787. /**
  68788. * @ignore
  68789. * The highlights enhancing PostProcess id in the pipeline
  68790. */
  68791. HighlightsEnhancingEffect: string;
  68792. /**
  68793. * @ignore
  68794. * The depth-of-field PostProcess id in the pipeline
  68795. */
  68796. LensDepthOfFieldEffect: string;
  68797. private _scene;
  68798. private _depthTexture;
  68799. private _grainTexture;
  68800. private _chromaticAberrationPostProcess;
  68801. private _highlightsPostProcess;
  68802. private _depthOfFieldPostProcess;
  68803. private _edgeBlur;
  68804. private _grainAmount;
  68805. private _chromaticAberration;
  68806. private _distortion;
  68807. private _highlightsGain;
  68808. private _highlightsThreshold;
  68809. private _dofDistance;
  68810. private _dofAperture;
  68811. private _dofDarken;
  68812. private _dofPentagon;
  68813. private _blurNoise;
  68814. /**
  68815. * @constructor
  68816. *
  68817. * Effect parameters are as follow:
  68818. * {
  68819. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68820. * edge_blur: number; // from 0 to x (1 for realism)
  68821. * distortion: number; // from 0 to x (1 for realism)
  68822. * grain_amount: number; // from 0 to 1
  68823. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68824. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68825. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68826. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68827. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68828. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68829. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68830. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68831. * }
  68832. * Note: if an effect parameter is unset, effect is disabled
  68833. *
  68834. * @param name The rendering pipeline name
  68835. * @param parameters - An object containing all parameters (see above)
  68836. * @param scene The scene linked to this pipeline
  68837. * @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)
  68838. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68839. */
  68840. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68841. /**
  68842. * Get the class name
  68843. * @returns "LensRenderingPipeline"
  68844. */
  68845. getClassName(): string;
  68846. /**
  68847. * Gets associated scene
  68848. */
  68849. get scene(): Scene;
  68850. /**
  68851. * Gets or sets the edge blur
  68852. */
  68853. get edgeBlur(): number;
  68854. set edgeBlur(value: number);
  68855. /**
  68856. * Gets or sets the grain amount
  68857. */
  68858. get grainAmount(): number;
  68859. set grainAmount(value: number);
  68860. /**
  68861. * Gets or sets the chromatic aberration amount
  68862. */
  68863. get chromaticAberration(): number;
  68864. set chromaticAberration(value: number);
  68865. /**
  68866. * Gets or sets the depth of field aperture
  68867. */
  68868. get dofAperture(): number;
  68869. set dofAperture(value: number);
  68870. /**
  68871. * Gets or sets the edge distortion
  68872. */
  68873. get edgeDistortion(): number;
  68874. set edgeDistortion(value: number);
  68875. /**
  68876. * Gets or sets the depth of field distortion
  68877. */
  68878. get dofDistortion(): number;
  68879. set dofDistortion(value: number);
  68880. /**
  68881. * Gets or sets the darken out of focus amount
  68882. */
  68883. get darkenOutOfFocus(): number;
  68884. set darkenOutOfFocus(value: number);
  68885. /**
  68886. * Gets or sets a boolean indicating if blur noise is enabled
  68887. */
  68888. get blurNoise(): boolean;
  68889. set blurNoise(value: boolean);
  68890. /**
  68891. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68892. */
  68893. get pentagonBokeh(): boolean;
  68894. set pentagonBokeh(value: boolean);
  68895. /**
  68896. * Gets or sets the highlight grain amount
  68897. */
  68898. get highlightsGain(): number;
  68899. set highlightsGain(value: number);
  68900. /**
  68901. * Gets or sets the highlight threshold
  68902. */
  68903. get highlightsThreshold(): number;
  68904. set highlightsThreshold(value: number);
  68905. /**
  68906. * Sets the amount of blur at the edges
  68907. * @param amount blur amount
  68908. */
  68909. setEdgeBlur(amount: number): void;
  68910. /**
  68911. * Sets edge blur to 0
  68912. */
  68913. disableEdgeBlur(): void;
  68914. /**
  68915. * Sets the amout of grain
  68916. * @param amount Amount of grain
  68917. */
  68918. setGrainAmount(amount: number): void;
  68919. /**
  68920. * Set grain amount to 0
  68921. */
  68922. disableGrain(): void;
  68923. /**
  68924. * Sets the chromatic aberration amount
  68925. * @param amount amount of chromatic aberration
  68926. */
  68927. setChromaticAberration(amount: number): void;
  68928. /**
  68929. * Sets chromatic aberration amount to 0
  68930. */
  68931. disableChromaticAberration(): void;
  68932. /**
  68933. * Sets the EdgeDistortion amount
  68934. * @param amount amount of EdgeDistortion
  68935. */
  68936. setEdgeDistortion(amount: number): void;
  68937. /**
  68938. * Sets edge distortion to 0
  68939. */
  68940. disableEdgeDistortion(): void;
  68941. /**
  68942. * Sets the FocusDistance amount
  68943. * @param amount amount of FocusDistance
  68944. */
  68945. setFocusDistance(amount: number): void;
  68946. /**
  68947. * Disables depth of field
  68948. */
  68949. disableDepthOfField(): void;
  68950. /**
  68951. * Sets the Aperture amount
  68952. * @param amount amount of Aperture
  68953. */
  68954. setAperture(amount: number): void;
  68955. /**
  68956. * Sets the DarkenOutOfFocus amount
  68957. * @param amount amount of DarkenOutOfFocus
  68958. */
  68959. setDarkenOutOfFocus(amount: number): void;
  68960. private _pentagonBokehIsEnabled;
  68961. /**
  68962. * Creates a pentagon bokeh effect
  68963. */
  68964. enablePentagonBokeh(): void;
  68965. /**
  68966. * Disables the pentagon bokeh effect
  68967. */
  68968. disablePentagonBokeh(): void;
  68969. /**
  68970. * Enables noise blur
  68971. */
  68972. enableNoiseBlur(): void;
  68973. /**
  68974. * Disables noise blur
  68975. */
  68976. disableNoiseBlur(): void;
  68977. /**
  68978. * Sets the HighlightsGain amount
  68979. * @param amount amount of HighlightsGain
  68980. */
  68981. setHighlightsGain(amount: number): void;
  68982. /**
  68983. * Sets the HighlightsThreshold amount
  68984. * @param amount amount of HighlightsThreshold
  68985. */
  68986. setHighlightsThreshold(amount: number): void;
  68987. /**
  68988. * Disables highlights
  68989. */
  68990. disableHighlights(): void;
  68991. /**
  68992. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68993. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68994. */
  68995. dispose(disableDepthRender?: boolean): void;
  68996. private _createChromaticAberrationPostProcess;
  68997. private _createHighlightsPostProcess;
  68998. private _createDepthOfFieldPostProcess;
  68999. private _createGrainTexture;
  69000. }
  69001. }
  69002. declare module "babylonjs/Shaders/ssao2.fragment" {
  69003. /** @hidden */
  69004. export var ssao2PixelShader: {
  69005. name: string;
  69006. shader: string;
  69007. };
  69008. }
  69009. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69010. /** @hidden */
  69011. export var ssaoCombinePixelShader: {
  69012. name: string;
  69013. shader: string;
  69014. };
  69015. }
  69016. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69017. import { Camera } from "babylonjs/Cameras/camera";
  69018. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69019. import { Scene } from "babylonjs/scene";
  69020. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69021. import "babylonjs/Shaders/ssao2.fragment";
  69022. import "babylonjs/Shaders/ssaoCombine.fragment";
  69023. /**
  69024. * Render pipeline to produce ssao effect
  69025. */
  69026. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69027. /**
  69028. * @ignore
  69029. * The PassPostProcess id in the pipeline that contains the original scene color
  69030. */
  69031. SSAOOriginalSceneColorEffect: string;
  69032. /**
  69033. * @ignore
  69034. * The SSAO PostProcess id in the pipeline
  69035. */
  69036. SSAORenderEffect: string;
  69037. /**
  69038. * @ignore
  69039. * The horizontal blur PostProcess id in the pipeline
  69040. */
  69041. SSAOBlurHRenderEffect: string;
  69042. /**
  69043. * @ignore
  69044. * The vertical blur PostProcess id in the pipeline
  69045. */
  69046. SSAOBlurVRenderEffect: string;
  69047. /**
  69048. * @ignore
  69049. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69050. */
  69051. SSAOCombineRenderEffect: string;
  69052. /**
  69053. * The output strength of the SSAO post-process. Default value is 1.0.
  69054. */
  69055. totalStrength: number;
  69056. /**
  69057. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69058. */
  69059. maxZ: number;
  69060. /**
  69061. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69062. */
  69063. minZAspect: number;
  69064. private _samples;
  69065. /**
  69066. * Number of samples used for the SSAO calculations. Default value is 8
  69067. */
  69068. set samples(n: number);
  69069. get samples(): number;
  69070. private _textureSamples;
  69071. /**
  69072. * Number of samples to use for antialiasing
  69073. */
  69074. set textureSamples(n: number);
  69075. get textureSamples(): number;
  69076. /**
  69077. * Ratio object used for SSAO ratio and blur ratio
  69078. */
  69079. private _ratio;
  69080. /**
  69081. * Dynamically generated sphere sampler.
  69082. */
  69083. private _sampleSphere;
  69084. /**
  69085. * Blur filter offsets
  69086. */
  69087. private _samplerOffsets;
  69088. private _expensiveBlur;
  69089. /**
  69090. * If bilateral blur should be used
  69091. */
  69092. set expensiveBlur(b: boolean);
  69093. get expensiveBlur(): boolean;
  69094. /**
  69095. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69096. */
  69097. radius: number;
  69098. /**
  69099. * The base color of the SSAO post-process
  69100. * The final result is "base + ssao" between [0, 1]
  69101. */
  69102. base: number;
  69103. /**
  69104. * Support test.
  69105. */
  69106. static get IsSupported(): boolean;
  69107. private _scene;
  69108. private _depthTexture;
  69109. private _normalTexture;
  69110. private _randomTexture;
  69111. private _originalColorPostProcess;
  69112. private _ssaoPostProcess;
  69113. private _blurHPostProcess;
  69114. private _blurVPostProcess;
  69115. private _ssaoCombinePostProcess;
  69116. /**
  69117. * Gets active scene
  69118. */
  69119. get scene(): Scene;
  69120. /**
  69121. * @constructor
  69122. * @param name The rendering pipeline name
  69123. * @param scene The scene linked to this pipeline
  69124. * @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 }
  69125. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69126. */
  69127. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69128. /**
  69129. * Get the class name
  69130. * @returns "SSAO2RenderingPipeline"
  69131. */
  69132. getClassName(): string;
  69133. /**
  69134. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69135. */
  69136. dispose(disableGeometryBufferRenderer?: boolean): void;
  69137. private _createBlurPostProcess;
  69138. /** @hidden */
  69139. _rebuild(): void;
  69140. private _bits;
  69141. private _radicalInverse_VdC;
  69142. private _hammersley;
  69143. private _hemisphereSample_uniform;
  69144. private _generateHemisphere;
  69145. private _createSSAOPostProcess;
  69146. private _createSSAOCombinePostProcess;
  69147. private _createRandomTexture;
  69148. /**
  69149. * Serialize the rendering pipeline (Used when exporting)
  69150. * @returns the serialized object
  69151. */
  69152. serialize(): any;
  69153. /**
  69154. * Parse the serialized pipeline
  69155. * @param source Source pipeline.
  69156. * @param scene The scene to load the pipeline to.
  69157. * @param rootUrl The URL of the serialized pipeline.
  69158. * @returns An instantiated pipeline from the serialized object.
  69159. */
  69160. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69161. }
  69162. }
  69163. declare module "babylonjs/Shaders/ssao.fragment" {
  69164. /** @hidden */
  69165. export var ssaoPixelShader: {
  69166. name: string;
  69167. shader: string;
  69168. };
  69169. }
  69170. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69171. import { Camera } from "babylonjs/Cameras/camera";
  69172. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69173. import { Scene } from "babylonjs/scene";
  69174. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69175. import "babylonjs/Shaders/ssao.fragment";
  69176. import "babylonjs/Shaders/ssaoCombine.fragment";
  69177. /**
  69178. * Render pipeline to produce ssao effect
  69179. */
  69180. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69181. /**
  69182. * @ignore
  69183. * The PassPostProcess id in the pipeline that contains the original scene color
  69184. */
  69185. SSAOOriginalSceneColorEffect: string;
  69186. /**
  69187. * @ignore
  69188. * The SSAO PostProcess id in the pipeline
  69189. */
  69190. SSAORenderEffect: string;
  69191. /**
  69192. * @ignore
  69193. * The horizontal blur PostProcess id in the pipeline
  69194. */
  69195. SSAOBlurHRenderEffect: string;
  69196. /**
  69197. * @ignore
  69198. * The vertical blur PostProcess id in the pipeline
  69199. */
  69200. SSAOBlurVRenderEffect: string;
  69201. /**
  69202. * @ignore
  69203. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69204. */
  69205. SSAOCombineRenderEffect: string;
  69206. /**
  69207. * The output strength of the SSAO post-process. Default value is 1.0.
  69208. */
  69209. totalStrength: number;
  69210. /**
  69211. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69212. */
  69213. radius: number;
  69214. /**
  69215. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69216. * Must not be equal to fallOff and superior to fallOff.
  69217. * Default value is 0.0075
  69218. */
  69219. area: number;
  69220. /**
  69221. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69222. * Must not be equal to area and inferior to area.
  69223. * Default value is 0.000001
  69224. */
  69225. fallOff: number;
  69226. /**
  69227. * The base color of the SSAO post-process
  69228. * The final result is "base + ssao" between [0, 1]
  69229. */
  69230. base: number;
  69231. private _scene;
  69232. private _depthTexture;
  69233. private _randomTexture;
  69234. private _originalColorPostProcess;
  69235. private _ssaoPostProcess;
  69236. private _blurHPostProcess;
  69237. private _blurVPostProcess;
  69238. private _ssaoCombinePostProcess;
  69239. private _firstUpdate;
  69240. /**
  69241. * Gets active scene
  69242. */
  69243. get scene(): Scene;
  69244. /**
  69245. * @constructor
  69246. * @param name - The rendering pipeline name
  69247. * @param scene - The scene linked to this pipeline
  69248. * @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 }
  69249. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69250. */
  69251. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69252. /**
  69253. * Get the class name
  69254. * @returns "SSAORenderingPipeline"
  69255. */
  69256. getClassName(): string;
  69257. /**
  69258. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69259. */
  69260. dispose(disableDepthRender?: boolean): void;
  69261. private _createBlurPostProcess;
  69262. /** @hidden */
  69263. _rebuild(): void;
  69264. private _createSSAOPostProcess;
  69265. private _createSSAOCombinePostProcess;
  69266. private _createRandomTexture;
  69267. }
  69268. }
  69269. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69270. /** @hidden */
  69271. export var screenSpaceReflectionPixelShader: {
  69272. name: string;
  69273. shader: string;
  69274. };
  69275. }
  69276. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69277. import { Nullable } from "babylonjs/types";
  69278. import { Camera } from "babylonjs/Cameras/camera";
  69279. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69280. import { Scene } from "babylonjs/scene";
  69281. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69282. import { Engine } from "babylonjs/Engines/engine";
  69283. /**
  69284. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69285. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69286. */
  69287. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69288. /**
  69289. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69290. */
  69291. threshold: number;
  69292. /**
  69293. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69294. */
  69295. strength: number;
  69296. /**
  69297. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69298. */
  69299. reflectionSpecularFalloffExponent: number;
  69300. /**
  69301. * 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]
  69302. */
  69303. step: number;
  69304. /**
  69305. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69306. */
  69307. roughnessFactor: number;
  69308. private _geometryBufferRenderer;
  69309. private _enableSmoothReflections;
  69310. private _reflectionSamples;
  69311. private _smoothSteps;
  69312. /**
  69313. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69314. * @param name The name of the effect.
  69315. * @param scene The scene containing the objects to calculate reflections.
  69316. * @param options The required width/height ratio to downsize to before computing the render pass.
  69317. * @param camera The camera to apply the render pass to.
  69318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69319. * @param engine The engine which the post process will be applied. (default: current engine)
  69320. * @param reusable If the post process can be reused on the same frame. (default: false)
  69321. * @param textureType Type of textures used when performing the post process. (default: 0)
  69322. * @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)
  69323. */
  69324. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69325. /**
  69326. * Gets wether or not smoothing reflections is enabled.
  69327. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69328. */
  69329. get enableSmoothReflections(): boolean;
  69330. /**
  69331. * Sets wether or not smoothing reflections is enabled.
  69332. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69333. */
  69334. set enableSmoothReflections(enabled: boolean);
  69335. /**
  69336. * Gets 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. get reflectionSamples(): number;
  69340. /**
  69341. * Sets the number of samples taken while computing reflections. More samples count is high,
  69342. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69343. */
  69344. set reflectionSamples(samples: number);
  69345. /**
  69346. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69347. * more the post-process will require GPU power and can generate a drop in FPS.
  69348. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69349. */
  69350. get smoothSteps(): number;
  69351. set smoothSteps(steps: number);
  69352. private _updateEffectDefines;
  69353. }
  69354. }
  69355. declare module "babylonjs/Shaders/standard.fragment" {
  69356. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69357. /** @hidden */
  69358. export var standardPixelShader: {
  69359. name: string;
  69360. shader: string;
  69361. };
  69362. }
  69363. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69364. import { Nullable } from "babylonjs/types";
  69365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69366. import { Camera } from "babylonjs/Cameras/camera";
  69367. import { Texture } from "babylonjs/Materials/Textures/texture";
  69368. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69369. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69370. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69371. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69372. import { IDisposable } from "babylonjs/scene";
  69373. import { SpotLight } from "babylonjs/Lights/spotLight";
  69374. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69375. import { Scene } from "babylonjs/scene";
  69376. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69377. import { Animation } from "babylonjs/Animations/animation";
  69378. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69379. import "babylonjs/Shaders/standard.fragment";
  69380. /**
  69381. * Standard rendering pipeline
  69382. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69383. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69384. */
  69385. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69386. /**
  69387. * Public members
  69388. */
  69389. /**
  69390. * Post-process which contains the original scene color before the pipeline applies all the effects
  69391. */
  69392. originalPostProcess: Nullable<PostProcess>;
  69393. /**
  69394. * Post-process used to down scale an image x4
  69395. */
  69396. downSampleX4PostProcess: Nullable<PostProcess>;
  69397. /**
  69398. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69399. */
  69400. brightPassPostProcess: Nullable<PostProcess>;
  69401. /**
  69402. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69403. */
  69404. blurHPostProcesses: PostProcess[];
  69405. /**
  69406. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69407. */
  69408. blurVPostProcesses: PostProcess[];
  69409. /**
  69410. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69411. */
  69412. textureAdderPostProcess: Nullable<PostProcess>;
  69413. /**
  69414. * Post-process used to create volumetric lighting effect
  69415. */
  69416. volumetricLightPostProcess: Nullable<PostProcess>;
  69417. /**
  69418. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69419. */
  69420. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69421. /**
  69422. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69423. */
  69424. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69425. /**
  69426. * Post-process used to merge the volumetric light effect and the real scene color
  69427. */
  69428. volumetricLightMergePostProces: Nullable<PostProcess>;
  69429. /**
  69430. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69431. */
  69432. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69433. /**
  69434. * Base post-process used to calculate the average luminance of the final image for HDR
  69435. */
  69436. luminancePostProcess: Nullable<PostProcess>;
  69437. /**
  69438. * Post-processes used to create down sample post-processes in order to get
  69439. * the average luminance of the final image for HDR
  69440. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69441. */
  69442. luminanceDownSamplePostProcesses: PostProcess[];
  69443. /**
  69444. * Post-process used to create a HDR effect (light adaptation)
  69445. */
  69446. hdrPostProcess: Nullable<PostProcess>;
  69447. /**
  69448. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69449. */
  69450. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69451. /**
  69452. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69453. */
  69454. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69455. /**
  69456. * Post-process used to merge the final HDR post-process and the real scene color
  69457. */
  69458. hdrFinalPostProcess: Nullable<PostProcess>;
  69459. /**
  69460. * Post-process used to create a lens flare effect
  69461. */
  69462. lensFlarePostProcess: Nullable<PostProcess>;
  69463. /**
  69464. * Post-process that merges the result of the lens flare post-process and the real scene color
  69465. */
  69466. lensFlareComposePostProcess: Nullable<PostProcess>;
  69467. /**
  69468. * Post-process used to create a motion blur effect
  69469. */
  69470. motionBlurPostProcess: Nullable<PostProcess>;
  69471. /**
  69472. * Post-process used to create a depth of field effect
  69473. */
  69474. depthOfFieldPostProcess: Nullable<PostProcess>;
  69475. /**
  69476. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69477. */
  69478. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69479. /**
  69480. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69481. */
  69482. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69483. /**
  69484. * Represents the brightness threshold in order to configure the illuminated surfaces
  69485. */
  69486. brightThreshold: number;
  69487. /**
  69488. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69489. */
  69490. blurWidth: number;
  69491. /**
  69492. * Sets if the blur for highlighted surfaces must be only horizontal
  69493. */
  69494. horizontalBlur: boolean;
  69495. /**
  69496. * Gets the overall exposure used by the pipeline
  69497. */
  69498. get exposure(): number;
  69499. /**
  69500. * Sets the overall exposure used by the pipeline
  69501. */
  69502. set exposure(value: number);
  69503. /**
  69504. * Texture used typically to simulate "dirty" on camera lens
  69505. */
  69506. lensTexture: Nullable<Texture>;
  69507. /**
  69508. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69509. */
  69510. volumetricLightCoefficient: number;
  69511. /**
  69512. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69513. */
  69514. volumetricLightPower: number;
  69515. /**
  69516. * Used the set the blur intensity to smooth the volumetric lights
  69517. */
  69518. volumetricLightBlurScale: number;
  69519. /**
  69520. * Light (spot or directional) used to generate the volumetric lights rays
  69521. * The source light must have a shadow generate so the pipeline can get its
  69522. * depth map
  69523. */
  69524. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69525. /**
  69526. * For eye adaptation, represents the minimum luminance the eye can see
  69527. */
  69528. hdrMinimumLuminance: number;
  69529. /**
  69530. * For eye adaptation, represents the decrease luminance speed
  69531. */
  69532. hdrDecreaseRate: number;
  69533. /**
  69534. * For eye adaptation, represents the increase luminance speed
  69535. */
  69536. hdrIncreaseRate: number;
  69537. /**
  69538. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69539. */
  69540. get hdrAutoExposure(): boolean;
  69541. /**
  69542. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69543. */
  69544. set hdrAutoExposure(value: boolean);
  69545. /**
  69546. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69547. */
  69548. lensColorTexture: Nullable<Texture>;
  69549. /**
  69550. * The overall strengh for the lens flare effect
  69551. */
  69552. lensFlareStrength: number;
  69553. /**
  69554. * Dispersion coefficient for lens flare ghosts
  69555. */
  69556. lensFlareGhostDispersal: number;
  69557. /**
  69558. * Main lens flare halo width
  69559. */
  69560. lensFlareHaloWidth: number;
  69561. /**
  69562. * Based on the lens distortion effect, defines how much the lens flare result
  69563. * is distorted
  69564. */
  69565. lensFlareDistortionStrength: number;
  69566. /**
  69567. * Configures the blur intensity used for for lens flare (halo)
  69568. */
  69569. lensFlareBlurWidth: number;
  69570. /**
  69571. * Lens star texture must be used to simulate rays on the flares and is available
  69572. * in the documentation
  69573. */
  69574. lensStarTexture: Nullable<Texture>;
  69575. /**
  69576. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69577. * flare effect by taking account of the dirt texture
  69578. */
  69579. lensFlareDirtTexture: Nullable<Texture>;
  69580. /**
  69581. * Represents the focal length for the depth of field effect
  69582. */
  69583. depthOfFieldDistance: number;
  69584. /**
  69585. * Represents the blur intensity for the blurred part of the depth of field effect
  69586. */
  69587. depthOfFieldBlurWidth: number;
  69588. /**
  69589. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69590. */
  69591. get motionStrength(): number;
  69592. /**
  69593. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69594. */
  69595. set motionStrength(strength: number);
  69596. /**
  69597. * Gets wether or not the motion blur post-process is object based or screen based.
  69598. */
  69599. get objectBasedMotionBlur(): boolean;
  69600. /**
  69601. * Sets wether or not the motion blur post-process should be object based or screen based
  69602. */
  69603. set objectBasedMotionBlur(value: boolean);
  69604. /**
  69605. * List of animations for the pipeline (IAnimatable implementation)
  69606. */
  69607. animations: Animation[];
  69608. /**
  69609. * Private members
  69610. */
  69611. private _scene;
  69612. private _currentDepthOfFieldSource;
  69613. private _basePostProcess;
  69614. private _fixedExposure;
  69615. private _currentExposure;
  69616. private _hdrAutoExposure;
  69617. private _hdrCurrentLuminance;
  69618. private _motionStrength;
  69619. private _isObjectBasedMotionBlur;
  69620. private _floatTextureType;
  69621. private _camerasToBeAttached;
  69622. private _ratio;
  69623. private _bloomEnabled;
  69624. private _depthOfFieldEnabled;
  69625. private _vlsEnabled;
  69626. private _lensFlareEnabled;
  69627. private _hdrEnabled;
  69628. private _motionBlurEnabled;
  69629. private _fxaaEnabled;
  69630. private _screenSpaceReflectionsEnabled;
  69631. private _motionBlurSamples;
  69632. private _volumetricLightStepsCount;
  69633. private _samples;
  69634. /**
  69635. * @ignore
  69636. * Specifies if the bloom pipeline is enabled
  69637. */
  69638. get BloomEnabled(): boolean;
  69639. set BloomEnabled(enabled: boolean);
  69640. /**
  69641. * @ignore
  69642. * Specifies if the depth of field pipeline is enabed
  69643. */
  69644. get DepthOfFieldEnabled(): boolean;
  69645. set DepthOfFieldEnabled(enabled: boolean);
  69646. /**
  69647. * @ignore
  69648. * Specifies if the lens flare pipeline is enabed
  69649. */
  69650. get LensFlareEnabled(): boolean;
  69651. set LensFlareEnabled(enabled: boolean);
  69652. /**
  69653. * @ignore
  69654. * Specifies if the HDR pipeline is enabled
  69655. */
  69656. get HDREnabled(): boolean;
  69657. set HDREnabled(enabled: boolean);
  69658. /**
  69659. * @ignore
  69660. * Specifies if the volumetric lights scattering effect is enabled
  69661. */
  69662. get VLSEnabled(): boolean;
  69663. set VLSEnabled(enabled: boolean);
  69664. /**
  69665. * @ignore
  69666. * Specifies if the motion blur effect is enabled
  69667. */
  69668. get MotionBlurEnabled(): boolean;
  69669. set MotionBlurEnabled(enabled: boolean);
  69670. /**
  69671. * Specifies if anti-aliasing is enabled
  69672. */
  69673. get fxaaEnabled(): boolean;
  69674. set fxaaEnabled(enabled: boolean);
  69675. /**
  69676. * Specifies if screen space reflections are enabled.
  69677. */
  69678. get screenSpaceReflectionsEnabled(): boolean;
  69679. set screenSpaceReflectionsEnabled(enabled: boolean);
  69680. /**
  69681. * Specifies the number of steps used to calculate the volumetric lights
  69682. * Typically in interval [50, 200]
  69683. */
  69684. get volumetricLightStepsCount(): number;
  69685. set volumetricLightStepsCount(count: number);
  69686. /**
  69687. * Specifies the number of samples used for the motion blur effect
  69688. * Typically in interval [16, 64]
  69689. */
  69690. get motionBlurSamples(): number;
  69691. set motionBlurSamples(samples: number);
  69692. /**
  69693. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69694. */
  69695. get samples(): number;
  69696. set samples(sampleCount: number);
  69697. /**
  69698. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69699. * @constructor
  69700. * @param name The rendering pipeline name
  69701. * @param scene The scene linked to this pipeline
  69702. * @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)
  69703. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69704. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69705. */
  69706. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69707. private _buildPipeline;
  69708. private _createDownSampleX4PostProcess;
  69709. private _createBrightPassPostProcess;
  69710. private _createBlurPostProcesses;
  69711. private _createTextureAdderPostProcess;
  69712. private _createVolumetricLightPostProcess;
  69713. private _createLuminancePostProcesses;
  69714. private _createHdrPostProcess;
  69715. private _createLensFlarePostProcess;
  69716. private _createDepthOfFieldPostProcess;
  69717. private _createMotionBlurPostProcess;
  69718. private _getDepthTexture;
  69719. private _disposePostProcesses;
  69720. /**
  69721. * Dispose of the pipeline and stop all post processes
  69722. */
  69723. dispose(): void;
  69724. /**
  69725. * Serialize the rendering pipeline (Used when exporting)
  69726. * @returns the serialized object
  69727. */
  69728. serialize(): any;
  69729. /**
  69730. * Parse the serialized pipeline
  69731. * @param source Source pipeline.
  69732. * @param scene The scene to load the pipeline to.
  69733. * @param rootUrl The URL of the serialized pipeline.
  69734. * @returns An instantiated pipeline from the serialized object.
  69735. */
  69736. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69737. /**
  69738. * Luminance steps
  69739. */
  69740. static LuminanceSteps: number;
  69741. }
  69742. }
  69743. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69744. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69745. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69749. }
  69750. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69751. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69752. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69753. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69754. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69755. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69756. }
  69757. declare module "babylonjs/Shaders/tonemap.fragment" {
  69758. /** @hidden */
  69759. export var tonemapPixelShader: {
  69760. name: string;
  69761. shader: string;
  69762. };
  69763. }
  69764. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69765. import { Camera } from "babylonjs/Cameras/camera";
  69766. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69767. import "babylonjs/Shaders/tonemap.fragment";
  69768. import { Engine } from "babylonjs/Engines/engine";
  69769. /** Defines operator used for tonemapping */
  69770. export enum TonemappingOperator {
  69771. /** Hable */
  69772. Hable = 0,
  69773. /** Reinhard */
  69774. Reinhard = 1,
  69775. /** HejiDawson */
  69776. HejiDawson = 2,
  69777. /** Photographic */
  69778. Photographic = 3
  69779. }
  69780. /**
  69781. * Defines a post process to apply tone mapping
  69782. */
  69783. export class TonemapPostProcess extends PostProcess {
  69784. private _operator;
  69785. /** Defines the required exposure adjustement */
  69786. exposureAdjustment: number;
  69787. /**
  69788. * Creates a new TonemapPostProcess
  69789. * @param name defines the name of the postprocess
  69790. * @param _operator defines the operator to use
  69791. * @param exposureAdjustment defines the required exposure adjustement
  69792. * @param camera defines the camera to use (can be null)
  69793. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69794. * @param engine defines the hosting engine (can be ignore if camera is set)
  69795. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69796. */
  69797. constructor(name: string, _operator: TonemappingOperator,
  69798. /** Defines the required exposure adjustement */
  69799. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69800. }
  69801. }
  69802. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69803. /** @hidden */
  69804. export var volumetricLightScatteringPixelShader: {
  69805. name: string;
  69806. shader: string;
  69807. };
  69808. }
  69809. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69810. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69813. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69815. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69816. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69817. /** @hidden */
  69818. export var volumetricLightScatteringPassVertexShader: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69824. /** @hidden */
  69825. export var volumetricLightScatteringPassPixelShader: {
  69826. name: string;
  69827. shader: string;
  69828. };
  69829. }
  69830. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69831. import { Vector3 } from "babylonjs/Maths/math.vector";
  69832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69833. import { Mesh } from "babylonjs/Meshes/mesh";
  69834. import { Camera } from "babylonjs/Cameras/camera";
  69835. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69836. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69837. import { Scene } from "babylonjs/scene";
  69838. import "babylonjs/Meshes/Builders/planeBuilder";
  69839. import "babylonjs/Shaders/depth.vertex";
  69840. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69841. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69842. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69843. import { Engine } from "babylonjs/Engines/engine";
  69844. /**
  69845. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69846. */
  69847. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69848. private _volumetricLightScatteringPass;
  69849. private _volumetricLightScatteringRTT;
  69850. private _viewPort;
  69851. private _screenCoordinates;
  69852. private _cachedDefines;
  69853. /**
  69854. * If not undefined, the mesh position is computed from the attached node position
  69855. */
  69856. attachedNode: {
  69857. position: Vector3;
  69858. };
  69859. /**
  69860. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69861. */
  69862. customMeshPosition: Vector3;
  69863. /**
  69864. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69865. */
  69866. useCustomMeshPosition: boolean;
  69867. /**
  69868. * If the post-process should inverse the light scattering direction
  69869. */
  69870. invert: boolean;
  69871. /**
  69872. * The internal mesh used by the post-process
  69873. */
  69874. mesh: Mesh;
  69875. /**
  69876. * @hidden
  69877. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69878. */
  69879. get useDiffuseColor(): boolean;
  69880. set useDiffuseColor(useDiffuseColor: boolean);
  69881. /**
  69882. * Array containing the excluded meshes not rendered in the internal pass
  69883. */
  69884. excludedMeshes: AbstractMesh[];
  69885. /**
  69886. * Controls the overall intensity of the post-process
  69887. */
  69888. exposure: number;
  69889. /**
  69890. * Dissipates each sample's contribution in range [0, 1]
  69891. */
  69892. decay: number;
  69893. /**
  69894. * Controls the overall intensity of each sample
  69895. */
  69896. weight: number;
  69897. /**
  69898. * Controls the density of each sample
  69899. */
  69900. density: number;
  69901. /**
  69902. * @constructor
  69903. * @param name The post-process name
  69904. * @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)
  69905. * @param camera The camera that the post-process will be attached to
  69906. * @param mesh The mesh used to create the light scattering
  69907. * @param samples The post-process quality, default 100
  69908. * @param samplingModeThe post-process filtering mode
  69909. * @param engine The babylon engine
  69910. * @param reusable If the post-process is reusable
  69911. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69912. */
  69913. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69914. /**
  69915. * Returns the string "VolumetricLightScatteringPostProcess"
  69916. * @returns "VolumetricLightScatteringPostProcess"
  69917. */
  69918. getClassName(): string;
  69919. private _isReady;
  69920. /**
  69921. * Sets the new light position for light scattering effect
  69922. * @param position The new custom light position
  69923. */
  69924. setCustomMeshPosition(position: Vector3): void;
  69925. /**
  69926. * Returns the light position for light scattering effect
  69927. * @return Vector3 The custom light position
  69928. */
  69929. getCustomMeshPosition(): Vector3;
  69930. /**
  69931. * Disposes the internal assets and detaches the post-process from the camera
  69932. */
  69933. dispose(camera: Camera): void;
  69934. /**
  69935. * Returns the render target texture used by the post-process
  69936. * @return the render target texture used by the post-process
  69937. */
  69938. getPass(): RenderTargetTexture;
  69939. private _meshExcluded;
  69940. private _createPass;
  69941. private _updateMeshScreenCoordinates;
  69942. /**
  69943. * Creates a default mesh for the Volumeric Light Scattering post-process
  69944. * @param name The mesh name
  69945. * @param scene The scene where to create the mesh
  69946. * @return the default mesh
  69947. */
  69948. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69949. }
  69950. }
  69951. declare module "babylonjs/PostProcesses/index" {
  69952. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69953. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69954. export * from "babylonjs/PostProcesses/bloomEffect";
  69955. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69956. export * from "babylonjs/PostProcesses/blurPostProcess";
  69957. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69958. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69959. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69960. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69961. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69962. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69963. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69964. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69965. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69966. export * from "babylonjs/PostProcesses/filterPostProcess";
  69967. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69968. export * from "babylonjs/PostProcesses/grainPostProcess";
  69969. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69970. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69971. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69972. export * from "babylonjs/PostProcesses/passPostProcess";
  69973. export * from "babylonjs/PostProcesses/postProcess";
  69974. export * from "babylonjs/PostProcesses/postProcessManager";
  69975. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69976. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69977. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69978. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69979. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69980. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69981. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69982. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69983. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69984. }
  69985. declare module "babylonjs/Probes/index" {
  69986. export * from "babylonjs/Probes/reflectionProbe";
  69987. }
  69988. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69989. import { Scene } from "babylonjs/scene";
  69990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69991. import { SmartArray } from "babylonjs/Misc/smartArray";
  69992. import { ISceneComponent } from "babylonjs/sceneComponent";
  69993. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69994. import "babylonjs/Meshes/Builders/boxBuilder";
  69995. import "babylonjs/Shaders/color.fragment";
  69996. import "babylonjs/Shaders/color.vertex";
  69997. import { Color3 } from "babylonjs/Maths/math.color";
  69998. module "babylonjs/scene" {
  69999. interface Scene {
  70000. /** @hidden (Backing field) */
  70001. _boundingBoxRenderer: BoundingBoxRenderer;
  70002. /** @hidden (Backing field) */
  70003. _forceShowBoundingBoxes: boolean;
  70004. /**
  70005. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70006. */
  70007. forceShowBoundingBoxes: boolean;
  70008. /**
  70009. * Gets the bounding box renderer associated with the scene
  70010. * @returns a BoundingBoxRenderer
  70011. */
  70012. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70013. }
  70014. }
  70015. module "babylonjs/Meshes/abstractMesh" {
  70016. interface AbstractMesh {
  70017. /** @hidden (Backing field) */
  70018. _showBoundingBox: boolean;
  70019. /**
  70020. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70021. */
  70022. showBoundingBox: boolean;
  70023. }
  70024. }
  70025. /**
  70026. * Component responsible of rendering the bounding box of the meshes in a scene.
  70027. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70028. */
  70029. export class BoundingBoxRenderer implements ISceneComponent {
  70030. /**
  70031. * The component name helpfull to identify the component in the list of scene components.
  70032. */
  70033. readonly name: string;
  70034. /**
  70035. * The scene the component belongs to.
  70036. */
  70037. scene: Scene;
  70038. /**
  70039. * Color of the bounding box lines placed in front of an object
  70040. */
  70041. frontColor: Color3;
  70042. /**
  70043. * Color of the bounding box lines placed behind an object
  70044. */
  70045. backColor: Color3;
  70046. /**
  70047. * Defines if the renderer should show the back lines or not
  70048. */
  70049. showBackLines: boolean;
  70050. /**
  70051. * @hidden
  70052. */
  70053. renderList: SmartArray<BoundingBox>;
  70054. private _colorShader;
  70055. private _vertexBuffers;
  70056. private _indexBuffer;
  70057. private _fillIndexBuffer;
  70058. private _fillIndexData;
  70059. /**
  70060. * Instantiates a new bounding box renderer in a scene.
  70061. * @param scene the scene the renderer renders in
  70062. */
  70063. constructor(scene: Scene);
  70064. /**
  70065. * Registers the component in a given scene
  70066. */
  70067. register(): void;
  70068. private _evaluateSubMesh;
  70069. private _activeMesh;
  70070. private _prepareRessources;
  70071. private _createIndexBuffer;
  70072. /**
  70073. * Rebuilds the elements related to this component in case of
  70074. * context lost for instance.
  70075. */
  70076. rebuild(): void;
  70077. /**
  70078. * @hidden
  70079. */
  70080. reset(): void;
  70081. /**
  70082. * Render the bounding boxes of a specific rendering group
  70083. * @param renderingGroupId defines the rendering group to render
  70084. */
  70085. render(renderingGroupId: number): void;
  70086. /**
  70087. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70088. * @param mesh Define the mesh to render the occlusion bounding box for
  70089. */
  70090. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70091. /**
  70092. * Dispose and release the resources attached to this renderer.
  70093. */
  70094. dispose(): void;
  70095. }
  70096. }
  70097. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70098. import { Nullable } from "babylonjs/types";
  70099. import { Scene } from "babylonjs/scene";
  70100. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70101. import { Camera } from "babylonjs/Cameras/camera";
  70102. import { ISceneComponent } from "babylonjs/sceneComponent";
  70103. module "babylonjs/scene" {
  70104. interface Scene {
  70105. /** @hidden (Backing field) */
  70106. _depthRenderer: {
  70107. [id: string]: DepthRenderer;
  70108. };
  70109. /**
  70110. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70111. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70112. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70113. * @returns the created depth renderer
  70114. */
  70115. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70116. /**
  70117. * Disables a depth renderer for a given camera
  70118. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70119. */
  70120. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70121. }
  70122. }
  70123. /**
  70124. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70125. * in several rendering techniques.
  70126. */
  70127. export class DepthRendererSceneComponent implements ISceneComponent {
  70128. /**
  70129. * The component name helpfull to identify the component in the list of scene components.
  70130. */
  70131. readonly name: string;
  70132. /**
  70133. * The scene the component belongs to.
  70134. */
  70135. scene: Scene;
  70136. /**
  70137. * Creates a new instance of the component for the given scene
  70138. * @param scene Defines the scene to register the component in
  70139. */
  70140. constructor(scene: Scene);
  70141. /**
  70142. * Registers the component in a given scene
  70143. */
  70144. register(): void;
  70145. /**
  70146. * Rebuilds the elements related to this component in case of
  70147. * context lost for instance.
  70148. */
  70149. rebuild(): void;
  70150. /**
  70151. * Disposes the component and the associated ressources
  70152. */
  70153. dispose(): void;
  70154. private _gatherRenderTargets;
  70155. private _gatherActiveCameraRenderTargets;
  70156. }
  70157. }
  70158. declare module "babylonjs/Shaders/outline.fragment" {
  70159. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70160. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70161. /** @hidden */
  70162. export var outlinePixelShader: {
  70163. name: string;
  70164. shader: string;
  70165. };
  70166. }
  70167. declare module "babylonjs/Shaders/outline.vertex" {
  70168. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70169. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70171. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70172. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70174. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70175. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70176. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70177. /** @hidden */
  70178. export var outlineVertexShader: {
  70179. name: string;
  70180. shader: string;
  70181. };
  70182. }
  70183. declare module "babylonjs/Rendering/outlineRenderer" {
  70184. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70185. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70186. import { Scene } from "babylonjs/scene";
  70187. import { ISceneComponent } from "babylonjs/sceneComponent";
  70188. import "babylonjs/Shaders/outline.fragment";
  70189. import "babylonjs/Shaders/outline.vertex";
  70190. module "babylonjs/scene" {
  70191. interface Scene {
  70192. /** @hidden */
  70193. _outlineRenderer: OutlineRenderer;
  70194. /**
  70195. * Gets the outline renderer associated with the scene
  70196. * @returns a OutlineRenderer
  70197. */
  70198. getOutlineRenderer(): OutlineRenderer;
  70199. }
  70200. }
  70201. module "babylonjs/Meshes/abstractMesh" {
  70202. interface AbstractMesh {
  70203. /** @hidden (Backing field) */
  70204. _renderOutline: boolean;
  70205. /**
  70206. * Gets or sets a boolean indicating if the outline must be rendered as well
  70207. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70208. */
  70209. renderOutline: boolean;
  70210. /** @hidden (Backing field) */
  70211. _renderOverlay: boolean;
  70212. /**
  70213. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70214. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70215. */
  70216. renderOverlay: boolean;
  70217. }
  70218. }
  70219. /**
  70220. * This class is responsible to draw bothe outline/overlay of meshes.
  70221. * It should not be used directly but through the available method on mesh.
  70222. */
  70223. export class OutlineRenderer implements ISceneComponent {
  70224. /**
  70225. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70226. */
  70227. private static _StencilReference;
  70228. /**
  70229. * The name of the component. Each component must have a unique name.
  70230. */
  70231. name: string;
  70232. /**
  70233. * The scene the component belongs to.
  70234. */
  70235. scene: Scene;
  70236. /**
  70237. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70238. */
  70239. zOffset: number;
  70240. private _engine;
  70241. private _effect;
  70242. private _cachedDefines;
  70243. private _savedDepthWrite;
  70244. /**
  70245. * Instantiates a new outline renderer. (There could be only one per scene).
  70246. * @param scene Defines the scene it belongs to
  70247. */
  70248. constructor(scene: Scene);
  70249. /**
  70250. * Register the component to one instance of a scene.
  70251. */
  70252. register(): void;
  70253. /**
  70254. * Rebuilds the elements related to this component in case of
  70255. * context lost for instance.
  70256. */
  70257. rebuild(): void;
  70258. /**
  70259. * Disposes the component and the associated ressources.
  70260. */
  70261. dispose(): void;
  70262. /**
  70263. * Renders the outline in the canvas.
  70264. * @param subMesh Defines the sumesh to render
  70265. * @param batch Defines the batch of meshes in case of instances
  70266. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70267. */
  70268. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70269. /**
  70270. * Returns whether or not the outline renderer is ready for a given submesh.
  70271. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70272. * @param subMesh Defines the submesh to check readyness for
  70273. * @param useInstances Defines wheter wee are trying to render instances or not
  70274. * @returns true if ready otherwise false
  70275. */
  70276. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70277. private _beforeRenderingMesh;
  70278. private _afterRenderingMesh;
  70279. }
  70280. }
  70281. declare module "babylonjs/Rendering/index" {
  70282. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70283. export * from "babylonjs/Rendering/depthRenderer";
  70284. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70285. export * from "babylonjs/Rendering/edgesRenderer";
  70286. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70287. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70288. export * from "babylonjs/Rendering/outlineRenderer";
  70289. export * from "babylonjs/Rendering/renderingGroup";
  70290. export * from "babylonjs/Rendering/renderingManager";
  70291. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70292. }
  70293. declare module "babylonjs/Sprites/ISprites" {
  70294. /**
  70295. * Defines the basic options interface of a Sprite Frame Source Size.
  70296. */
  70297. export interface ISpriteJSONSpriteSourceSize {
  70298. /**
  70299. * number of the original width of the Frame
  70300. */
  70301. w: number;
  70302. /**
  70303. * number of the original height of the Frame
  70304. */
  70305. h: number;
  70306. }
  70307. /**
  70308. * Defines the basic options interface of a Sprite Frame Data.
  70309. */
  70310. export interface ISpriteJSONSpriteFrameData {
  70311. /**
  70312. * number of the x offset of the Frame
  70313. */
  70314. x: number;
  70315. /**
  70316. * number of the y offset of the Frame
  70317. */
  70318. y: number;
  70319. /**
  70320. * number of the width of the Frame
  70321. */
  70322. w: number;
  70323. /**
  70324. * number of the height of the Frame
  70325. */
  70326. h: number;
  70327. }
  70328. /**
  70329. * Defines the basic options interface of a JSON Sprite.
  70330. */
  70331. export interface ISpriteJSONSprite {
  70332. /**
  70333. * string name of the Frame
  70334. */
  70335. filename: string;
  70336. /**
  70337. * ISpriteJSONSpriteFrame basic object of the frame data
  70338. */
  70339. frame: ISpriteJSONSpriteFrameData;
  70340. /**
  70341. * boolean to flag is the frame was rotated.
  70342. */
  70343. rotated: boolean;
  70344. /**
  70345. * boolean to flag is the frame was trimmed.
  70346. */
  70347. trimmed: boolean;
  70348. /**
  70349. * ISpriteJSONSpriteFrame basic object of the source data
  70350. */
  70351. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70352. /**
  70353. * ISpriteJSONSpriteFrame basic object of the source data
  70354. */
  70355. sourceSize: ISpriteJSONSpriteSourceSize;
  70356. }
  70357. /**
  70358. * Defines the basic options interface of a JSON atlas.
  70359. */
  70360. export interface ISpriteJSONAtlas {
  70361. /**
  70362. * Array of objects that contain the frame data.
  70363. */
  70364. frames: Array<ISpriteJSONSprite>;
  70365. /**
  70366. * object basic object containing the sprite meta data.
  70367. */
  70368. meta?: object;
  70369. }
  70370. }
  70371. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70372. /** @hidden */
  70373. export var spriteMapPixelShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70379. /** @hidden */
  70380. export var spriteMapVertexShader: {
  70381. name: string;
  70382. shader: string;
  70383. };
  70384. }
  70385. declare module "babylonjs/Sprites/spriteMap" {
  70386. import { IDisposable, Scene } from "babylonjs/scene";
  70387. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70388. import { Texture } from "babylonjs/Materials/Textures/texture";
  70389. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70390. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70391. import "babylonjs/Meshes/Builders/planeBuilder";
  70392. import "babylonjs/Shaders/spriteMap.fragment";
  70393. import "babylonjs/Shaders/spriteMap.vertex";
  70394. /**
  70395. * Defines the basic options interface of a SpriteMap
  70396. */
  70397. export interface ISpriteMapOptions {
  70398. /**
  70399. * Vector2 of the number of cells in the grid.
  70400. */
  70401. stageSize?: Vector2;
  70402. /**
  70403. * Vector2 of the size of the output plane in World Units.
  70404. */
  70405. outputSize?: Vector2;
  70406. /**
  70407. * Vector3 of the position of the output plane in World Units.
  70408. */
  70409. outputPosition?: Vector3;
  70410. /**
  70411. * Vector3 of the rotation of the output plane.
  70412. */
  70413. outputRotation?: Vector3;
  70414. /**
  70415. * number of layers that the system will reserve in resources.
  70416. */
  70417. layerCount?: number;
  70418. /**
  70419. * number of max animation frames a single cell will reserve in resources.
  70420. */
  70421. maxAnimationFrames?: number;
  70422. /**
  70423. * number cell index of the base tile when the system compiles.
  70424. */
  70425. baseTile?: number;
  70426. /**
  70427. * boolean flip the sprite after its been repositioned by the framing data.
  70428. */
  70429. flipU?: boolean;
  70430. /**
  70431. * Vector3 scalar of the global RGB values of the SpriteMap.
  70432. */
  70433. colorMultiply?: Vector3;
  70434. }
  70435. /**
  70436. * Defines the IDisposable interface in order to be cleanable from resources.
  70437. */
  70438. export interface ISpriteMap extends IDisposable {
  70439. /**
  70440. * String name of the SpriteMap.
  70441. */
  70442. name: string;
  70443. /**
  70444. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70445. */
  70446. atlasJSON: ISpriteJSONAtlas;
  70447. /**
  70448. * Texture of the SpriteMap.
  70449. */
  70450. spriteSheet: Texture;
  70451. /**
  70452. * The parameters to initialize the SpriteMap with.
  70453. */
  70454. options: ISpriteMapOptions;
  70455. }
  70456. /**
  70457. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70458. */
  70459. export class SpriteMap implements ISpriteMap {
  70460. /** The Name of the spriteMap */
  70461. name: string;
  70462. /** The JSON file with the frame and meta data */
  70463. atlasJSON: ISpriteJSONAtlas;
  70464. /** The systems Sprite Sheet Texture */
  70465. spriteSheet: Texture;
  70466. /** Arguments passed with the Constructor */
  70467. options: ISpriteMapOptions;
  70468. /** Public Sprite Storage array, parsed from atlasJSON */
  70469. sprites: Array<ISpriteJSONSprite>;
  70470. /** Returns the Number of Sprites in the System */
  70471. get spriteCount(): number;
  70472. /** Returns the Position of Output Plane*/
  70473. get position(): Vector3;
  70474. /** Returns the Position of Output Plane*/
  70475. set position(v: Vector3);
  70476. /** Returns the Rotation of Output Plane*/
  70477. get rotation(): Vector3;
  70478. /** Returns the Rotation of Output Plane*/
  70479. set rotation(v: Vector3);
  70480. /** Sets the AnimationMap*/
  70481. get animationMap(): RawTexture;
  70482. /** Sets the AnimationMap*/
  70483. set animationMap(v: RawTexture);
  70484. /** Scene that the SpriteMap was created in */
  70485. private _scene;
  70486. /** Texture Buffer of Float32 that holds tile frame data*/
  70487. private _frameMap;
  70488. /** Texture Buffers of Float32 that holds tileMap data*/
  70489. private _tileMaps;
  70490. /** Texture Buffer of Float32 that holds Animation Data*/
  70491. private _animationMap;
  70492. /** Custom ShaderMaterial Central to the System*/
  70493. private _material;
  70494. /** Custom ShaderMaterial Central to the System*/
  70495. private _output;
  70496. /** Systems Time Ticker*/
  70497. private _time;
  70498. /**
  70499. * Creates a new SpriteMap
  70500. * @param name defines the SpriteMaps Name
  70501. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70502. * @param spriteSheet is the Texture that the Sprites are on.
  70503. * @param options a basic deployment configuration
  70504. * @param scene The Scene that the map is deployed on
  70505. */
  70506. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70507. /**
  70508. * Returns tileID location
  70509. * @returns Vector2 the cell position ID
  70510. */
  70511. getTileID(): Vector2;
  70512. /**
  70513. * Gets the UV location of the mouse over the SpriteMap.
  70514. * @returns Vector2 the UV position of the mouse interaction
  70515. */
  70516. getMousePosition(): Vector2;
  70517. /**
  70518. * Creates the "frame" texture Buffer
  70519. * -------------------------------------
  70520. * Structure of frames
  70521. * "filename": "Falling-Water-2.png",
  70522. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70523. * "rotated": true,
  70524. * "trimmed": true,
  70525. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70526. * "sourceSize": {"w":32,"h":32}
  70527. * @returns RawTexture of the frameMap
  70528. */
  70529. private _createFrameBuffer;
  70530. /**
  70531. * Creates the tileMap texture Buffer
  70532. * @param buffer normally and array of numbers, or a false to generate from scratch
  70533. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70534. * @returns RawTexture of the tileMap
  70535. */
  70536. private _createTileBuffer;
  70537. /**
  70538. * Modifies the data of the tileMaps
  70539. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70540. * @param pos is the iVector2 Coordinates of the Tile
  70541. * @param tile The SpriteIndex of the new Tile
  70542. */
  70543. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70544. /**
  70545. * Creates the animationMap texture Buffer
  70546. * @param buffer normally and array of numbers, or a false to generate from scratch
  70547. * @returns RawTexture of the animationMap
  70548. */
  70549. private _createTileAnimationBuffer;
  70550. /**
  70551. * Modifies the data of the animationMap
  70552. * @param cellID is the Index of the Sprite
  70553. * @param _frame is the target Animation frame
  70554. * @param toCell is the Target Index of the next frame of the animation
  70555. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70556. * @param speed is a global scalar of the time variable on the map.
  70557. */
  70558. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70559. /**
  70560. * Exports the .tilemaps file
  70561. */
  70562. saveTileMaps(): void;
  70563. /**
  70564. * Imports the .tilemaps file
  70565. * @param url of the .tilemaps file
  70566. */
  70567. loadTileMaps(url: string): void;
  70568. /**
  70569. * Release associated resources
  70570. */
  70571. dispose(): void;
  70572. }
  70573. }
  70574. declare module "babylonjs/Sprites/spritePackedManager" {
  70575. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70576. import { Scene } from "babylonjs/scene";
  70577. /**
  70578. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70579. * @see http://doc.babylonjs.com/babylon101/sprites
  70580. */
  70581. export class SpritePackedManager extends SpriteManager {
  70582. /** defines the packed manager's name */
  70583. name: string;
  70584. /**
  70585. * Creates a new sprite manager from a packed sprite sheet
  70586. * @param name defines the manager's name
  70587. * @param imgUrl defines the sprite sheet url
  70588. * @param capacity defines the maximum allowed number of sprites
  70589. * @param scene defines the hosting scene
  70590. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70591. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70592. * @param samplingMode defines the smapling mode to use with spritesheet
  70593. * @param fromPacked set to true; do not alter
  70594. */
  70595. constructor(
  70596. /** defines the packed manager's name */
  70597. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70598. }
  70599. }
  70600. declare module "babylonjs/Sprites/index" {
  70601. export * from "babylonjs/Sprites/sprite";
  70602. export * from "babylonjs/Sprites/ISprites";
  70603. export * from "babylonjs/Sprites/spriteManager";
  70604. export * from "babylonjs/Sprites/spriteMap";
  70605. export * from "babylonjs/Sprites/spritePackedManager";
  70606. export * from "babylonjs/Sprites/spriteSceneComponent";
  70607. }
  70608. declare module "babylonjs/States/index" {
  70609. export * from "babylonjs/States/alphaCullingState";
  70610. export * from "babylonjs/States/depthCullingState";
  70611. export * from "babylonjs/States/stencilState";
  70612. }
  70613. declare module "babylonjs/Misc/assetsManager" {
  70614. import { Scene } from "babylonjs/scene";
  70615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70616. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70617. import { Skeleton } from "babylonjs/Bones/skeleton";
  70618. import { Observable } from "babylonjs/Misc/observable";
  70619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70620. import { Texture } from "babylonjs/Materials/Textures/texture";
  70621. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70622. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70623. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70624. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70625. /**
  70626. * Defines the list of states available for a task inside a AssetsManager
  70627. */
  70628. export enum AssetTaskState {
  70629. /**
  70630. * Initialization
  70631. */
  70632. INIT = 0,
  70633. /**
  70634. * Running
  70635. */
  70636. RUNNING = 1,
  70637. /**
  70638. * Done
  70639. */
  70640. DONE = 2,
  70641. /**
  70642. * Error
  70643. */
  70644. ERROR = 3
  70645. }
  70646. /**
  70647. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70648. */
  70649. export abstract class AbstractAssetTask {
  70650. /**
  70651. * Task name
  70652. */ name: string;
  70653. /**
  70654. * Callback called when the task is successful
  70655. */
  70656. onSuccess: (task: any) => void;
  70657. /**
  70658. * Callback called when the task is not successful
  70659. */
  70660. onError: (task: any, message?: string, exception?: any) => void;
  70661. /**
  70662. * Creates a new AssetsManager
  70663. * @param name defines the name of the task
  70664. */
  70665. constructor(
  70666. /**
  70667. * Task name
  70668. */ name: string);
  70669. private _isCompleted;
  70670. private _taskState;
  70671. private _errorObject;
  70672. /**
  70673. * Get if the task is completed
  70674. */
  70675. get isCompleted(): boolean;
  70676. /**
  70677. * Gets the current state of the task
  70678. */
  70679. get taskState(): AssetTaskState;
  70680. /**
  70681. * Gets the current error object (if task is in error)
  70682. */
  70683. get errorObject(): {
  70684. message?: string;
  70685. exception?: any;
  70686. };
  70687. /**
  70688. * Internal only
  70689. * @hidden
  70690. */
  70691. _setErrorObject(message?: string, exception?: any): void;
  70692. /**
  70693. * Execute the current task
  70694. * @param scene defines the scene where you want your assets to be loaded
  70695. * @param onSuccess is a callback called when the task is successfully executed
  70696. * @param onError is a callback called if an error occurs
  70697. */
  70698. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70699. /**
  70700. * Execute the current task
  70701. * @param scene defines the scene where you want your assets to be loaded
  70702. * @param onSuccess is a callback called when the task is successfully executed
  70703. * @param onError is a callback called if an error occurs
  70704. */
  70705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70706. /**
  70707. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70708. * This can be used with failed tasks that have the reason for failure fixed.
  70709. */
  70710. reset(): void;
  70711. private onErrorCallback;
  70712. private onDoneCallback;
  70713. }
  70714. /**
  70715. * Define the interface used by progress events raised during assets loading
  70716. */
  70717. export interface IAssetsProgressEvent {
  70718. /**
  70719. * Defines the number of remaining tasks to process
  70720. */
  70721. remainingCount: number;
  70722. /**
  70723. * Defines the total number of tasks
  70724. */
  70725. totalCount: number;
  70726. /**
  70727. * Defines the task that was just processed
  70728. */
  70729. task: AbstractAssetTask;
  70730. }
  70731. /**
  70732. * Class used to share progress information about assets loading
  70733. */
  70734. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70735. /**
  70736. * Defines the number of remaining tasks to process
  70737. */
  70738. remainingCount: number;
  70739. /**
  70740. * Defines the total number of tasks
  70741. */
  70742. totalCount: number;
  70743. /**
  70744. * Defines the task that was just processed
  70745. */
  70746. task: AbstractAssetTask;
  70747. /**
  70748. * Creates a AssetsProgressEvent
  70749. * @param remainingCount defines the number of remaining tasks to process
  70750. * @param totalCount defines the total number of tasks
  70751. * @param task defines the task that was just processed
  70752. */
  70753. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70754. }
  70755. /**
  70756. * Define a task used by AssetsManager to load meshes
  70757. */
  70758. export class MeshAssetTask extends AbstractAssetTask {
  70759. /**
  70760. * Defines the name of the task
  70761. */
  70762. name: string;
  70763. /**
  70764. * Defines the list of mesh's names you want to load
  70765. */
  70766. meshesNames: any;
  70767. /**
  70768. * Defines the root url to use as a base to load your meshes and associated resources
  70769. */
  70770. rootUrl: string;
  70771. /**
  70772. * Defines the filename of the scene to load from
  70773. */
  70774. sceneFilename: string;
  70775. /**
  70776. * Gets the list of loaded meshes
  70777. */
  70778. loadedMeshes: Array<AbstractMesh>;
  70779. /**
  70780. * Gets the list of loaded particle systems
  70781. */
  70782. loadedParticleSystems: Array<IParticleSystem>;
  70783. /**
  70784. * Gets the list of loaded skeletons
  70785. */
  70786. loadedSkeletons: Array<Skeleton>;
  70787. /**
  70788. * Gets the list of loaded animation groups
  70789. */
  70790. loadedAnimationGroups: Array<AnimationGroup>;
  70791. /**
  70792. * Callback called when the task is successful
  70793. */
  70794. onSuccess: (task: MeshAssetTask) => void;
  70795. /**
  70796. * Callback called when the task is successful
  70797. */
  70798. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70799. /**
  70800. * Creates a new MeshAssetTask
  70801. * @param name defines the name of the task
  70802. * @param meshesNames defines the list of mesh's names you want to load
  70803. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70804. * @param sceneFilename defines the filename of the scene to load from
  70805. */
  70806. constructor(
  70807. /**
  70808. * Defines the name of the task
  70809. */
  70810. name: string,
  70811. /**
  70812. * Defines the list of mesh's names you want to load
  70813. */
  70814. meshesNames: any,
  70815. /**
  70816. * Defines the root url to use as a base to load your meshes and associated resources
  70817. */
  70818. rootUrl: string,
  70819. /**
  70820. * Defines the filename of the scene to load from
  70821. */
  70822. sceneFilename: string);
  70823. /**
  70824. * Execute the current task
  70825. * @param scene defines the scene where you want your assets to be loaded
  70826. * @param onSuccess is a callback called when the task is successfully executed
  70827. * @param onError is a callback called if an error occurs
  70828. */
  70829. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70830. }
  70831. /**
  70832. * Define a task used by AssetsManager to load text content
  70833. */
  70834. export class TextFileAssetTask extends AbstractAssetTask {
  70835. /**
  70836. * Defines the name of the task
  70837. */
  70838. name: string;
  70839. /**
  70840. * Defines the location of the file to load
  70841. */
  70842. url: string;
  70843. /**
  70844. * Gets the loaded text string
  70845. */
  70846. text: string;
  70847. /**
  70848. * Callback called when the task is successful
  70849. */
  70850. onSuccess: (task: TextFileAssetTask) => void;
  70851. /**
  70852. * Callback called when the task is successful
  70853. */
  70854. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70855. /**
  70856. * Creates a new TextFileAssetTask object
  70857. * @param name defines the name of the task
  70858. * @param url defines the location of the file to load
  70859. */
  70860. constructor(
  70861. /**
  70862. * Defines the name of the task
  70863. */
  70864. name: string,
  70865. /**
  70866. * Defines the location of the file to load
  70867. */
  70868. url: string);
  70869. /**
  70870. * Execute the current task
  70871. * @param scene defines the scene where you want your assets to be loaded
  70872. * @param onSuccess is a callback called when the task is successfully executed
  70873. * @param onError is a callback called if an error occurs
  70874. */
  70875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70876. }
  70877. /**
  70878. * Define a task used by AssetsManager to load binary data
  70879. */
  70880. export class BinaryFileAssetTask extends AbstractAssetTask {
  70881. /**
  70882. * Defines the name of the task
  70883. */
  70884. name: string;
  70885. /**
  70886. * Defines the location of the file to load
  70887. */
  70888. url: string;
  70889. /**
  70890. * Gets the lodaded data (as an array buffer)
  70891. */
  70892. data: ArrayBuffer;
  70893. /**
  70894. * Callback called when the task is successful
  70895. */
  70896. onSuccess: (task: BinaryFileAssetTask) => void;
  70897. /**
  70898. * Callback called when the task is successful
  70899. */
  70900. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70901. /**
  70902. * Creates a new BinaryFileAssetTask object
  70903. * @param name defines the name of the new task
  70904. * @param url defines the location of the file to load
  70905. */
  70906. constructor(
  70907. /**
  70908. * Defines the name of the task
  70909. */
  70910. name: string,
  70911. /**
  70912. * Defines the location of the file to load
  70913. */
  70914. url: string);
  70915. /**
  70916. * Execute the current task
  70917. * @param scene defines the scene where you want your assets to be loaded
  70918. * @param onSuccess is a callback called when the task is successfully executed
  70919. * @param onError is a callback called if an error occurs
  70920. */
  70921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70922. }
  70923. /**
  70924. * Define a task used by AssetsManager to load images
  70925. */
  70926. export class ImageAssetTask extends AbstractAssetTask {
  70927. /**
  70928. * Defines the name of the task
  70929. */
  70930. name: string;
  70931. /**
  70932. * Defines the location of the image to load
  70933. */
  70934. url: string;
  70935. /**
  70936. * Gets the loaded images
  70937. */
  70938. image: HTMLImageElement;
  70939. /**
  70940. * Callback called when the task is successful
  70941. */
  70942. onSuccess: (task: ImageAssetTask) => void;
  70943. /**
  70944. * Callback called when the task is successful
  70945. */
  70946. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70947. /**
  70948. * Creates a new ImageAssetTask
  70949. * @param name defines the name of the task
  70950. * @param url defines the location of the image to load
  70951. */
  70952. constructor(
  70953. /**
  70954. * Defines the name of the task
  70955. */
  70956. name: string,
  70957. /**
  70958. * Defines the location of the image to load
  70959. */
  70960. url: string);
  70961. /**
  70962. * Execute the current task
  70963. * @param scene defines the scene where you want your assets to be loaded
  70964. * @param onSuccess is a callback called when the task is successfully executed
  70965. * @param onError is a callback called if an error occurs
  70966. */
  70967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70968. }
  70969. /**
  70970. * Defines the interface used by texture loading tasks
  70971. */
  70972. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70973. /**
  70974. * Gets the loaded texture
  70975. */
  70976. texture: TEX;
  70977. }
  70978. /**
  70979. * Define a task used by AssetsManager to load 2D textures
  70980. */
  70981. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70982. /**
  70983. * Defines the name of the task
  70984. */
  70985. name: string;
  70986. /**
  70987. * Defines the location of the file to load
  70988. */
  70989. url: string;
  70990. /**
  70991. * Defines if mipmap should not be generated (default is false)
  70992. */
  70993. noMipmap?: boolean | undefined;
  70994. /**
  70995. * Defines if texture must be inverted on Y axis (default is false)
  70996. */
  70997. invertY?: boolean | undefined;
  70998. /**
  70999. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71000. */
  71001. samplingMode: number;
  71002. /**
  71003. * Gets the loaded texture
  71004. */
  71005. texture: Texture;
  71006. /**
  71007. * Callback called when the task is successful
  71008. */
  71009. onSuccess: (task: TextureAssetTask) => void;
  71010. /**
  71011. * Callback called when the task is successful
  71012. */
  71013. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71014. /**
  71015. * Creates a new TextureAssetTask object
  71016. * @param name defines the name of the task
  71017. * @param url defines the location of the file to load
  71018. * @param noMipmap defines if mipmap should not be generated (default is false)
  71019. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71020. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71021. */
  71022. constructor(
  71023. /**
  71024. * Defines the name of the task
  71025. */
  71026. name: string,
  71027. /**
  71028. * Defines the location of the file to load
  71029. */
  71030. url: string,
  71031. /**
  71032. * Defines if mipmap should not be generated (default is false)
  71033. */
  71034. noMipmap?: boolean | undefined,
  71035. /**
  71036. * Defines if texture must be inverted on Y axis (default is false)
  71037. */
  71038. invertY?: boolean | undefined,
  71039. /**
  71040. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71041. */
  71042. samplingMode?: number);
  71043. /**
  71044. * Execute the current task
  71045. * @param scene defines the scene where you want your assets to be loaded
  71046. * @param onSuccess is a callback called when the task is successfully executed
  71047. * @param onError is a callback called if an error occurs
  71048. */
  71049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71050. }
  71051. /**
  71052. * Define a task used by AssetsManager to load cube textures
  71053. */
  71054. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71055. /**
  71056. * Defines the name of the task
  71057. */
  71058. name: string;
  71059. /**
  71060. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71061. */
  71062. url: string;
  71063. /**
  71064. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71065. */
  71066. extensions?: string[] | undefined;
  71067. /**
  71068. * Defines if mipmaps should not be generated (default is false)
  71069. */
  71070. noMipmap?: boolean | undefined;
  71071. /**
  71072. * Defines the explicit list of files (undefined by default)
  71073. */
  71074. files?: string[] | undefined;
  71075. /**
  71076. * Gets the loaded texture
  71077. */
  71078. texture: CubeTexture;
  71079. /**
  71080. * Callback called when the task is successful
  71081. */
  71082. onSuccess: (task: CubeTextureAssetTask) => void;
  71083. /**
  71084. * Callback called when the task is successful
  71085. */
  71086. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71087. /**
  71088. * Creates a new CubeTextureAssetTask
  71089. * @param name defines the name of the task
  71090. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71091. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71092. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71093. * @param files defines the explicit list of files (undefined by default)
  71094. */
  71095. constructor(
  71096. /**
  71097. * Defines the name of the task
  71098. */
  71099. name: string,
  71100. /**
  71101. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71102. */
  71103. url: string,
  71104. /**
  71105. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71106. */
  71107. extensions?: string[] | undefined,
  71108. /**
  71109. * Defines if mipmaps should not be generated (default is false)
  71110. */
  71111. noMipmap?: boolean | undefined,
  71112. /**
  71113. * Defines the explicit list of files (undefined by default)
  71114. */
  71115. files?: string[] | undefined);
  71116. /**
  71117. * Execute the current task
  71118. * @param scene defines the scene where you want your assets to be loaded
  71119. * @param onSuccess is a callback called when the task is successfully executed
  71120. * @param onError is a callback called if an error occurs
  71121. */
  71122. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71123. }
  71124. /**
  71125. * Define a task used by AssetsManager to load HDR cube textures
  71126. */
  71127. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71128. /**
  71129. * Defines the name of the task
  71130. */
  71131. name: string;
  71132. /**
  71133. * Defines the location of the file to load
  71134. */
  71135. url: string;
  71136. /**
  71137. * Defines the desired size (the more it increases the longer the generation will be)
  71138. */
  71139. size: number;
  71140. /**
  71141. * Defines if mipmaps should not be generated (default is false)
  71142. */
  71143. noMipmap: boolean;
  71144. /**
  71145. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71146. */
  71147. generateHarmonics: boolean;
  71148. /**
  71149. * 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)
  71150. */
  71151. gammaSpace: boolean;
  71152. /**
  71153. * Internal Use Only
  71154. */
  71155. reserved: boolean;
  71156. /**
  71157. * Gets the loaded texture
  71158. */
  71159. texture: HDRCubeTexture;
  71160. /**
  71161. * Callback called when the task is successful
  71162. */
  71163. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71164. /**
  71165. * Callback called when the task is successful
  71166. */
  71167. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71168. /**
  71169. * Creates a new HDRCubeTextureAssetTask object
  71170. * @param name defines the name of the task
  71171. * @param url defines the location of the file to load
  71172. * @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.
  71173. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71174. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71175. * @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)
  71176. * @param reserved Internal use only
  71177. */
  71178. constructor(
  71179. /**
  71180. * Defines the name of the task
  71181. */
  71182. name: string,
  71183. /**
  71184. * Defines the location of the file to load
  71185. */
  71186. url: string,
  71187. /**
  71188. * Defines the desired size (the more it increases the longer the generation will be)
  71189. */
  71190. size: number,
  71191. /**
  71192. * Defines if mipmaps should not be generated (default is false)
  71193. */
  71194. noMipmap?: boolean,
  71195. /**
  71196. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71197. */
  71198. generateHarmonics?: boolean,
  71199. /**
  71200. * 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)
  71201. */
  71202. gammaSpace?: boolean,
  71203. /**
  71204. * Internal Use Only
  71205. */
  71206. reserved?: boolean);
  71207. /**
  71208. * Execute the current task
  71209. * @param scene defines the scene where you want your assets to be loaded
  71210. * @param onSuccess is a callback called when the task is successfully executed
  71211. * @param onError is a callback called if an error occurs
  71212. */
  71213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71214. }
  71215. /**
  71216. * Define a task used by AssetsManager to load Equirectangular cube textures
  71217. */
  71218. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71219. /**
  71220. * Defines the name of the task
  71221. */
  71222. name: string;
  71223. /**
  71224. * Defines the location of the file to load
  71225. */
  71226. url: string;
  71227. /**
  71228. * Defines the desired size (the more it increases the longer the generation will be)
  71229. */
  71230. size: number;
  71231. /**
  71232. * Defines if mipmaps should not be generated (default is false)
  71233. */
  71234. noMipmap: boolean;
  71235. /**
  71236. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71237. * but the standard material would require them in Gamma space) (default is true)
  71238. */
  71239. gammaSpace: boolean;
  71240. /**
  71241. * Gets the loaded texture
  71242. */
  71243. texture: EquiRectangularCubeTexture;
  71244. /**
  71245. * Callback called when the task is successful
  71246. */
  71247. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71248. /**
  71249. * Callback called when the task is successful
  71250. */
  71251. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71252. /**
  71253. * Creates a new EquiRectangularCubeTextureAssetTask object
  71254. * @param name defines the name of the task
  71255. * @param url defines the location of the file to load
  71256. * @param size defines the desired size (the more it increases the longer the generation will be)
  71257. * If the size is omitted this implies you are using a preprocessed cubemap.
  71258. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71259. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71260. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71261. * (default is true)
  71262. */
  71263. constructor(
  71264. /**
  71265. * Defines the name of the task
  71266. */
  71267. name: string,
  71268. /**
  71269. * Defines the location of the file to load
  71270. */
  71271. url: string,
  71272. /**
  71273. * Defines the desired size (the more it increases the longer the generation will be)
  71274. */
  71275. size: number,
  71276. /**
  71277. * Defines if mipmaps should not be generated (default is false)
  71278. */
  71279. noMipmap?: boolean,
  71280. /**
  71281. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71282. * but the standard material would require them in Gamma space) (default is true)
  71283. */
  71284. gammaSpace?: boolean);
  71285. /**
  71286. * Execute the current task
  71287. * @param scene defines the scene where you want your assets to be loaded
  71288. * @param onSuccess is a callback called when the task is successfully executed
  71289. * @param onError is a callback called if an error occurs
  71290. */
  71291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71292. }
  71293. /**
  71294. * This class can be used to easily import assets into a scene
  71295. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71296. */
  71297. export class AssetsManager {
  71298. private _scene;
  71299. private _isLoading;
  71300. protected _tasks: AbstractAssetTask[];
  71301. protected _waitingTasksCount: number;
  71302. protected _totalTasksCount: number;
  71303. /**
  71304. * Callback called when all tasks are processed
  71305. */
  71306. onFinish: (tasks: AbstractAssetTask[]) => void;
  71307. /**
  71308. * Callback called when a task is successful
  71309. */
  71310. onTaskSuccess: (task: AbstractAssetTask) => void;
  71311. /**
  71312. * Callback called when a task had an error
  71313. */
  71314. onTaskError: (task: AbstractAssetTask) => void;
  71315. /**
  71316. * Callback called when a task is done (whatever the result is)
  71317. */
  71318. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71319. /**
  71320. * Observable called when all tasks are processed
  71321. */
  71322. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71323. /**
  71324. * Observable called when a task had an error
  71325. */
  71326. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71327. /**
  71328. * Observable called when all tasks were executed
  71329. */
  71330. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71331. /**
  71332. * Observable called when a task is done (whatever the result is)
  71333. */
  71334. onProgressObservable: Observable<IAssetsProgressEvent>;
  71335. /**
  71336. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71337. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71338. */
  71339. useDefaultLoadingScreen: boolean;
  71340. /**
  71341. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71342. * when all assets have been downloaded.
  71343. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71344. */
  71345. autoHideLoadingUI: boolean;
  71346. /**
  71347. * Creates a new AssetsManager
  71348. * @param scene defines the scene to work on
  71349. */
  71350. constructor(scene: Scene);
  71351. /**
  71352. * Add a MeshAssetTask to the list of active tasks
  71353. * @param taskName defines the name of the new task
  71354. * @param meshesNames defines the name of meshes to load
  71355. * @param rootUrl defines the root url to use to locate files
  71356. * @param sceneFilename defines the filename of the scene file
  71357. * @returns a new MeshAssetTask object
  71358. */
  71359. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71360. /**
  71361. * Add a TextFileAssetTask to the list of active tasks
  71362. * @param taskName defines the name of the new task
  71363. * @param url defines the url of the file to load
  71364. * @returns a new TextFileAssetTask object
  71365. */
  71366. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71367. /**
  71368. * Add a BinaryFileAssetTask to the list of active tasks
  71369. * @param taskName defines the name of the new task
  71370. * @param url defines the url of the file to load
  71371. * @returns a new BinaryFileAssetTask object
  71372. */
  71373. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71374. /**
  71375. * Add a ImageAssetTask to the list of active tasks
  71376. * @param taskName defines the name of the new task
  71377. * @param url defines the url of the file to load
  71378. * @returns a new ImageAssetTask object
  71379. */
  71380. addImageTask(taskName: string, url: string): ImageAssetTask;
  71381. /**
  71382. * Add a TextureAssetTask to the list of active tasks
  71383. * @param taskName defines the name of the new task
  71384. * @param url defines the url of the file to load
  71385. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71386. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71387. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71388. * @returns a new TextureAssetTask object
  71389. */
  71390. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71391. /**
  71392. * Add a CubeTextureAssetTask to the list of active tasks
  71393. * @param taskName defines the name of the new task
  71394. * @param url defines the url of the file to load
  71395. * @param extensions defines the extension to use to load the cube map (can be null)
  71396. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71397. * @param files defines the list of files to load (can be null)
  71398. * @returns a new CubeTextureAssetTask object
  71399. */
  71400. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71401. /**
  71402. *
  71403. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71404. * @param taskName defines the name of the new task
  71405. * @param url defines the url of the file to load
  71406. * @param size defines the size you want for the cubemap (can be null)
  71407. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71408. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71409. * @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)
  71410. * @param reserved Internal use only
  71411. * @returns a new HDRCubeTextureAssetTask object
  71412. */
  71413. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71414. /**
  71415. *
  71416. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71417. * @param taskName defines the name of the new task
  71418. * @param url defines the url of the file to load
  71419. * @param size defines the size you want for the cubemap (can be null)
  71420. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71421. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71422. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71423. * @returns a new EquiRectangularCubeTextureAssetTask object
  71424. */
  71425. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71426. /**
  71427. * Remove a task from the assets manager.
  71428. * @param task the task to remove
  71429. */
  71430. removeTask(task: AbstractAssetTask): void;
  71431. private _decreaseWaitingTasksCount;
  71432. private _runTask;
  71433. /**
  71434. * Reset the AssetsManager and remove all tasks
  71435. * @return the current instance of the AssetsManager
  71436. */
  71437. reset(): AssetsManager;
  71438. /**
  71439. * Start the loading process
  71440. * @return the current instance of the AssetsManager
  71441. */
  71442. load(): AssetsManager;
  71443. /**
  71444. * Start the loading process as an async operation
  71445. * @return a promise returning the list of failed tasks
  71446. */
  71447. loadAsync(): Promise<void>;
  71448. }
  71449. }
  71450. declare module "babylonjs/Misc/deferred" {
  71451. /**
  71452. * Wrapper class for promise with external resolve and reject.
  71453. */
  71454. export class Deferred<T> {
  71455. /**
  71456. * The promise associated with this deferred object.
  71457. */
  71458. readonly promise: Promise<T>;
  71459. private _resolve;
  71460. private _reject;
  71461. /**
  71462. * The resolve method of the promise associated with this deferred object.
  71463. */
  71464. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71465. /**
  71466. * The reject method of the promise associated with this deferred object.
  71467. */
  71468. get reject(): (reason?: any) => void;
  71469. /**
  71470. * Constructor for this deferred object.
  71471. */
  71472. constructor();
  71473. }
  71474. }
  71475. declare module "babylonjs/Misc/meshExploder" {
  71476. import { Mesh } from "babylonjs/Meshes/mesh";
  71477. /**
  71478. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71479. */
  71480. export class MeshExploder {
  71481. private _centerMesh;
  71482. private _meshes;
  71483. private _meshesOrigins;
  71484. private _toCenterVectors;
  71485. private _scaledDirection;
  71486. private _newPosition;
  71487. private _centerPosition;
  71488. /**
  71489. * Explodes meshes from a center mesh.
  71490. * @param meshes The meshes to explode.
  71491. * @param centerMesh The mesh to be center of explosion.
  71492. */
  71493. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71494. private _setCenterMesh;
  71495. /**
  71496. * Get class name
  71497. * @returns "MeshExploder"
  71498. */
  71499. getClassName(): string;
  71500. /**
  71501. * "Exploded meshes"
  71502. * @returns Array of meshes with the centerMesh at index 0.
  71503. */
  71504. getMeshes(): Array<Mesh>;
  71505. /**
  71506. * Explodes meshes giving a specific direction
  71507. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71508. */
  71509. explode(direction?: number): void;
  71510. }
  71511. }
  71512. declare module "babylonjs/Misc/filesInput" {
  71513. import { Engine } from "babylonjs/Engines/engine";
  71514. import { Scene } from "babylonjs/scene";
  71515. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71516. /**
  71517. * Class used to help managing file picking and drag'n'drop
  71518. */
  71519. export class FilesInput {
  71520. /**
  71521. * List of files ready to be loaded
  71522. */
  71523. static get FilesToLoad(): {
  71524. [key: string]: File;
  71525. };
  71526. /**
  71527. * Callback called when a file is processed
  71528. */
  71529. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71530. private _engine;
  71531. private _currentScene;
  71532. private _sceneLoadedCallback;
  71533. private _progressCallback;
  71534. private _additionalRenderLoopLogicCallback;
  71535. private _textureLoadingCallback;
  71536. private _startingProcessingFilesCallback;
  71537. private _onReloadCallback;
  71538. private _errorCallback;
  71539. private _elementToMonitor;
  71540. private _sceneFileToLoad;
  71541. private _filesToLoad;
  71542. /**
  71543. * Creates a new FilesInput
  71544. * @param engine defines the rendering engine
  71545. * @param scene defines the hosting scene
  71546. * @param sceneLoadedCallback callback called when scene is loaded
  71547. * @param progressCallback callback called to track progress
  71548. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71549. * @param textureLoadingCallback callback called when a texture is loading
  71550. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71551. * @param onReloadCallback callback called when a reload is requested
  71552. * @param errorCallback callback call if an error occurs
  71553. */
  71554. 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);
  71555. private _dragEnterHandler;
  71556. private _dragOverHandler;
  71557. private _dropHandler;
  71558. /**
  71559. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71560. * @param elementToMonitor defines the DOM element to track
  71561. */
  71562. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71563. /**
  71564. * Release all associated resources
  71565. */
  71566. dispose(): void;
  71567. private renderFunction;
  71568. private drag;
  71569. private drop;
  71570. private _traverseFolder;
  71571. private _processFiles;
  71572. /**
  71573. * Load files from a drop event
  71574. * @param event defines the drop event to use as source
  71575. */
  71576. loadFiles(event: any): void;
  71577. private _processReload;
  71578. /**
  71579. * Reload the current scene from the loaded files
  71580. */
  71581. reload(): void;
  71582. }
  71583. }
  71584. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71585. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71586. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71587. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71588. }
  71589. declare module "babylonjs/Misc/sceneOptimizer" {
  71590. import { Scene, IDisposable } from "babylonjs/scene";
  71591. import { Observable } from "babylonjs/Misc/observable";
  71592. /**
  71593. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71594. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71595. */
  71596. export class SceneOptimization {
  71597. /**
  71598. * Defines the priority of this optimization (0 by default which means first in the list)
  71599. */
  71600. priority: number;
  71601. /**
  71602. * Gets a string describing the action executed by the current optimization
  71603. * @returns description string
  71604. */
  71605. getDescription(): string;
  71606. /**
  71607. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71608. * @param scene defines the current scene where to apply this optimization
  71609. * @param optimizer defines the current optimizer
  71610. * @returns true if everything that can be done was applied
  71611. */
  71612. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71613. /**
  71614. * Creates the SceneOptimization object
  71615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71616. * @param desc defines the description associated with the optimization
  71617. */
  71618. constructor(
  71619. /**
  71620. * Defines the priority of this optimization (0 by default which means first in the list)
  71621. */
  71622. priority?: number);
  71623. }
  71624. /**
  71625. * Defines an optimization used to reduce the size of render target textures
  71626. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71627. */
  71628. export class TextureOptimization extends SceneOptimization {
  71629. /**
  71630. * Defines the priority of this optimization (0 by default which means first in the list)
  71631. */
  71632. priority: number;
  71633. /**
  71634. * 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
  71635. */
  71636. maximumSize: number;
  71637. /**
  71638. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71639. */
  71640. step: number;
  71641. /**
  71642. * Gets a string describing the action executed by the current optimization
  71643. * @returns description string
  71644. */
  71645. getDescription(): string;
  71646. /**
  71647. * Creates the TextureOptimization object
  71648. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71649. * @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
  71650. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71651. */
  71652. constructor(
  71653. /**
  71654. * Defines the priority of this optimization (0 by default which means first in the list)
  71655. */
  71656. priority?: number,
  71657. /**
  71658. * 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
  71659. */
  71660. maximumSize?: number,
  71661. /**
  71662. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71663. */
  71664. step?: number);
  71665. /**
  71666. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71667. * @param scene defines the current scene where to apply this optimization
  71668. * @param optimizer defines the current optimizer
  71669. * @returns true if everything that can be done was applied
  71670. */
  71671. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71672. }
  71673. /**
  71674. * Defines an optimization used to increase or decrease the rendering resolution
  71675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71676. */
  71677. export class HardwareScalingOptimization extends SceneOptimization {
  71678. /**
  71679. * Defines the priority of this optimization (0 by default which means first in the list)
  71680. */
  71681. priority: number;
  71682. /**
  71683. * Defines the maximum scale to use (2 by default)
  71684. */
  71685. maximumScale: number;
  71686. /**
  71687. * Defines the step to use between two passes (0.5 by default)
  71688. */
  71689. step: number;
  71690. private _currentScale;
  71691. private _directionOffset;
  71692. /**
  71693. * Gets a string describing the action executed by the current optimization
  71694. * @return description string
  71695. */
  71696. getDescription(): string;
  71697. /**
  71698. * Creates the HardwareScalingOptimization object
  71699. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71700. * @param maximumScale defines the maximum scale to use (2 by default)
  71701. * @param step defines the step to use between two passes (0.5 by default)
  71702. */
  71703. constructor(
  71704. /**
  71705. * Defines the priority of this optimization (0 by default which means first in the list)
  71706. */
  71707. priority?: number,
  71708. /**
  71709. * Defines the maximum scale to use (2 by default)
  71710. */
  71711. maximumScale?: number,
  71712. /**
  71713. * Defines the step to use between two passes (0.5 by default)
  71714. */
  71715. step?: number);
  71716. /**
  71717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71718. * @param scene defines the current scene where to apply this optimization
  71719. * @param optimizer defines the current optimizer
  71720. * @returns true if everything that can be done was applied
  71721. */
  71722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71723. }
  71724. /**
  71725. * Defines an optimization used to remove shadows
  71726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71727. */
  71728. export class ShadowsOptimization extends SceneOptimization {
  71729. /**
  71730. * Gets a string describing the action executed by the current optimization
  71731. * @return description string
  71732. */
  71733. getDescription(): string;
  71734. /**
  71735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71736. * @param scene defines the current scene where to apply this optimization
  71737. * @param optimizer defines the current optimizer
  71738. * @returns true if everything that can be done was applied
  71739. */
  71740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71741. }
  71742. /**
  71743. * Defines an optimization used to turn post-processes off
  71744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71745. */
  71746. export class PostProcessesOptimization extends SceneOptimization {
  71747. /**
  71748. * Gets a string describing the action executed by the current optimization
  71749. * @return description string
  71750. */
  71751. getDescription(): string;
  71752. /**
  71753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71754. * @param scene defines the current scene where to apply this optimization
  71755. * @param optimizer defines the current optimizer
  71756. * @returns true if everything that can be done was applied
  71757. */
  71758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71759. }
  71760. /**
  71761. * Defines an optimization used to turn lens flares off
  71762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71763. */
  71764. export class LensFlaresOptimization extends SceneOptimization {
  71765. /**
  71766. * Gets a string describing the action executed by the current optimization
  71767. * @return description string
  71768. */
  71769. getDescription(): string;
  71770. /**
  71771. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71772. * @param scene defines the current scene where to apply this optimization
  71773. * @param optimizer defines the current optimizer
  71774. * @returns true if everything that can be done was applied
  71775. */
  71776. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71777. }
  71778. /**
  71779. * Defines an optimization based on user defined callback.
  71780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71781. */
  71782. export class CustomOptimization extends SceneOptimization {
  71783. /**
  71784. * Callback called to apply the custom optimization.
  71785. */
  71786. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71787. /**
  71788. * Callback called to get custom description
  71789. */
  71790. onGetDescription: () => string;
  71791. /**
  71792. * Gets a string describing the action executed by the current optimization
  71793. * @returns description string
  71794. */
  71795. getDescription(): string;
  71796. /**
  71797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71798. * @param scene defines the current scene where to apply this optimization
  71799. * @param optimizer defines the current optimizer
  71800. * @returns true if everything that can be done was applied
  71801. */
  71802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71803. }
  71804. /**
  71805. * Defines an optimization used to turn particles off
  71806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71807. */
  71808. export class ParticlesOptimization extends SceneOptimization {
  71809. /**
  71810. * Gets a string describing the action executed by the current optimization
  71811. * @return description string
  71812. */
  71813. getDescription(): string;
  71814. /**
  71815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71816. * @param scene defines the current scene where to apply this optimization
  71817. * @param optimizer defines the current optimizer
  71818. * @returns true if everything that can be done was applied
  71819. */
  71820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71821. }
  71822. /**
  71823. * Defines an optimization used to turn render targets off
  71824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71825. */
  71826. export class RenderTargetsOptimization extends SceneOptimization {
  71827. /**
  71828. * Gets a string describing the action executed by the current optimization
  71829. * @return description string
  71830. */
  71831. getDescription(): string;
  71832. /**
  71833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71834. * @param scene defines the current scene where to apply this optimization
  71835. * @param optimizer defines the current optimizer
  71836. * @returns true if everything that can be done was applied
  71837. */
  71838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71839. }
  71840. /**
  71841. * Defines an optimization used to merge meshes with compatible materials
  71842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71843. */
  71844. export class MergeMeshesOptimization extends SceneOptimization {
  71845. private static _UpdateSelectionTree;
  71846. /**
  71847. * Gets or sets a boolean which defines if optimization octree has to be updated
  71848. */
  71849. static get UpdateSelectionTree(): boolean;
  71850. /**
  71851. * Gets or sets a boolean which defines if optimization octree has to be updated
  71852. */
  71853. static set UpdateSelectionTree(value: boolean);
  71854. /**
  71855. * Gets a string describing the action executed by the current optimization
  71856. * @return description string
  71857. */
  71858. getDescription(): string;
  71859. private _canBeMerged;
  71860. /**
  71861. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71862. * @param scene defines the current scene where to apply this optimization
  71863. * @param optimizer defines the current optimizer
  71864. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71865. * @returns true if everything that can be done was applied
  71866. */
  71867. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71868. }
  71869. /**
  71870. * Defines a list of options used by SceneOptimizer
  71871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71872. */
  71873. export class SceneOptimizerOptions {
  71874. /**
  71875. * Defines the target frame rate to reach (60 by default)
  71876. */
  71877. targetFrameRate: number;
  71878. /**
  71879. * Defines the interval between two checkes (2000ms by default)
  71880. */
  71881. trackerDuration: number;
  71882. /**
  71883. * Gets the list of optimizations to apply
  71884. */
  71885. optimizations: SceneOptimization[];
  71886. /**
  71887. * Creates a new list of options used by SceneOptimizer
  71888. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71889. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71890. */
  71891. constructor(
  71892. /**
  71893. * Defines the target frame rate to reach (60 by default)
  71894. */
  71895. targetFrameRate?: number,
  71896. /**
  71897. * Defines the interval between two checkes (2000ms by default)
  71898. */
  71899. trackerDuration?: number);
  71900. /**
  71901. * Add a new optimization
  71902. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71903. * @returns the current SceneOptimizerOptions
  71904. */
  71905. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71906. /**
  71907. * Add a new custom optimization
  71908. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71909. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71910. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71911. * @returns the current SceneOptimizerOptions
  71912. */
  71913. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71914. /**
  71915. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71916. * @param targetFrameRate defines the target frame rate (60 by default)
  71917. * @returns a SceneOptimizerOptions object
  71918. */
  71919. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71920. /**
  71921. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71922. * @param targetFrameRate defines the target frame rate (60 by default)
  71923. * @returns a SceneOptimizerOptions object
  71924. */
  71925. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71926. /**
  71927. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71928. * @param targetFrameRate defines the target frame rate (60 by default)
  71929. * @returns a SceneOptimizerOptions object
  71930. */
  71931. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71932. }
  71933. /**
  71934. * Class used to run optimizations in order to reach a target frame rate
  71935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71936. */
  71937. export class SceneOptimizer implements IDisposable {
  71938. private _isRunning;
  71939. private _options;
  71940. private _scene;
  71941. private _currentPriorityLevel;
  71942. private _targetFrameRate;
  71943. private _trackerDuration;
  71944. private _currentFrameRate;
  71945. private _sceneDisposeObserver;
  71946. private _improvementMode;
  71947. /**
  71948. * Defines an observable called when the optimizer reaches the target frame rate
  71949. */
  71950. onSuccessObservable: Observable<SceneOptimizer>;
  71951. /**
  71952. * Defines an observable called when the optimizer enables an optimization
  71953. */
  71954. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71955. /**
  71956. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71957. */
  71958. onFailureObservable: Observable<SceneOptimizer>;
  71959. /**
  71960. * Gets a boolean indicating if the optimizer is in improvement mode
  71961. */
  71962. get isInImprovementMode(): boolean;
  71963. /**
  71964. * Gets the current priority level (0 at start)
  71965. */
  71966. get currentPriorityLevel(): number;
  71967. /**
  71968. * Gets the current frame rate checked by the SceneOptimizer
  71969. */
  71970. get currentFrameRate(): number;
  71971. /**
  71972. * Gets or sets the current target frame rate (60 by default)
  71973. */
  71974. get targetFrameRate(): number;
  71975. /**
  71976. * Gets or sets the current target frame rate (60 by default)
  71977. */
  71978. set targetFrameRate(value: number);
  71979. /**
  71980. * Gets or sets the current interval between two checks (every 2000ms by default)
  71981. */
  71982. get trackerDuration(): number;
  71983. /**
  71984. * Gets or sets the current interval between two checks (every 2000ms by default)
  71985. */
  71986. set trackerDuration(value: number);
  71987. /**
  71988. * Gets the list of active optimizations
  71989. */
  71990. get optimizations(): SceneOptimization[];
  71991. /**
  71992. * Creates a new SceneOptimizer
  71993. * @param scene defines the scene to work on
  71994. * @param options defines the options to use with the SceneOptimizer
  71995. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71996. * @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)
  71997. */
  71998. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71999. /**
  72000. * Stops the current optimizer
  72001. */
  72002. stop(): void;
  72003. /**
  72004. * Reset the optimizer to initial step (current priority level = 0)
  72005. */
  72006. reset(): void;
  72007. /**
  72008. * Start the optimizer. By default it will try to reach a specific framerate
  72009. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72010. */
  72011. start(): void;
  72012. private _checkCurrentState;
  72013. /**
  72014. * Release all resources
  72015. */
  72016. dispose(): void;
  72017. /**
  72018. * Helper function to create a SceneOptimizer with one single line of code
  72019. * @param scene defines the scene to work on
  72020. * @param options defines the options to use with the SceneOptimizer
  72021. * @param onSuccess defines a callback to call on success
  72022. * @param onFailure defines a callback to call on failure
  72023. * @returns the new SceneOptimizer object
  72024. */
  72025. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72026. }
  72027. }
  72028. declare module "babylonjs/Misc/sceneSerializer" {
  72029. import { Scene } from "babylonjs/scene";
  72030. /**
  72031. * Class used to serialize a scene into a string
  72032. */
  72033. export class SceneSerializer {
  72034. /**
  72035. * Clear cache used by a previous serialization
  72036. */
  72037. static ClearCache(): void;
  72038. /**
  72039. * Serialize a scene into a JSON compatible object
  72040. * @param scene defines the scene to serialize
  72041. * @returns a JSON compatible object
  72042. */
  72043. static Serialize(scene: Scene): any;
  72044. /**
  72045. * Serialize a mesh into a JSON compatible object
  72046. * @param toSerialize defines the mesh to serialize
  72047. * @param withParents defines if parents must be serialized as well
  72048. * @param withChildren defines if children must be serialized as well
  72049. * @returns a JSON compatible object
  72050. */
  72051. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72052. }
  72053. }
  72054. declare module "babylonjs/Misc/textureTools" {
  72055. import { Texture } from "babylonjs/Materials/Textures/texture";
  72056. /**
  72057. * Class used to host texture specific utilities
  72058. */
  72059. export class TextureTools {
  72060. /**
  72061. * Uses the GPU to create a copy texture rescaled at a given size
  72062. * @param texture Texture to copy from
  72063. * @param width defines the desired width
  72064. * @param height defines the desired height
  72065. * @param useBilinearMode defines if bilinear mode has to be used
  72066. * @return the generated texture
  72067. */
  72068. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72069. }
  72070. }
  72071. declare module "babylonjs/Misc/videoRecorder" {
  72072. import { Nullable } from "babylonjs/types";
  72073. import { Engine } from "babylonjs/Engines/engine";
  72074. /**
  72075. * This represents the different options available for the video capture.
  72076. */
  72077. export interface VideoRecorderOptions {
  72078. /** Defines the mime type of the video. */
  72079. mimeType: string;
  72080. /** Defines the FPS the video should be recorded at. */
  72081. fps: number;
  72082. /** Defines the chunk size for the recording data. */
  72083. recordChunckSize: number;
  72084. /** The audio tracks to attach to the recording. */
  72085. audioTracks?: MediaStreamTrack[];
  72086. }
  72087. /**
  72088. * This can help with recording videos from BabylonJS.
  72089. * This is based on the available WebRTC functionalities of the browser.
  72090. *
  72091. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72092. */
  72093. export class VideoRecorder {
  72094. private static readonly _defaultOptions;
  72095. /**
  72096. * Returns whether or not the VideoRecorder is available in your browser.
  72097. * @param engine Defines the Babylon Engine.
  72098. * @returns true if supported otherwise false.
  72099. */
  72100. static IsSupported(engine: Engine): boolean;
  72101. private readonly _options;
  72102. private _canvas;
  72103. private _mediaRecorder;
  72104. private _recordedChunks;
  72105. private _fileName;
  72106. private _resolve;
  72107. private _reject;
  72108. /**
  72109. * True when a recording is already in progress.
  72110. */
  72111. get isRecording(): boolean;
  72112. /**
  72113. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72114. * @param engine Defines the BabylonJS Engine you wish to record.
  72115. * @param options Defines options that can be used to customize the capture.
  72116. */
  72117. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72118. /**
  72119. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72120. */
  72121. stopRecording(): void;
  72122. /**
  72123. * Starts recording the canvas for a max duration specified in parameters.
  72124. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72125. * If null no automatic download will start and you can rely on the promise to get the data back.
  72126. * @param maxDuration Defines the maximum recording time in seconds.
  72127. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72128. * @return A promise callback at the end of the recording with the video data in Blob.
  72129. */
  72130. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72131. /**
  72132. * Releases internal resources used during the recording.
  72133. */
  72134. dispose(): void;
  72135. private _handleDataAvailable;
  72136. private _handleError;
  72137. private _handleStop;
  72138. }
  72139. }
  72140. declare module "babylonjs/Misc/screenshotTools" {
  72141. import { Camera } from "babylonjs/Cameras/camera";
  72142. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72143. import { Engine } from "babylonjs/Engines/engine";
  72144. /**
  72145. * Class containing a set of static utilities functions for screenshots
  72146. */
  72147. export class ScreenshotTools {
  72148. /**
  72149. * Captures a screenshot of the current rendering
  72150. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72151. * @param engine defines the rendering engine
  72152. * @param camera defines the source camera
  72153. * @param size This parameter can be set to a single number or to an object with the
  72154. * following (optional) properties: precision, width, height. If a single number is passed,
  72155. * it will be used for both width and height. If an object is passed, the screenshot size
  72156. * will be derived from the parameters. The precision property is a multiplier allowing
  72157. * rendering at a higher or lower resolution
  72158. * @param successCallback defines the callback receives a single parameter which contains the
  72159. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72160. * src parameter of an <img> to display it
  72161. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72162. * Check your browser for supported MIME types
  72163. */
  72164. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72165. /**
  72166. * Captures a screenshot of the current rendering
  72167. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72168. * @param engine defines the rendering engine
  72169. * @param camera defines the source camera
  72170. * @param size This parameter can be set to a single number or to an object with the
  72171. * following (optional) properties: precision, width, height. If a single number is passed,
  72172. * it will be used for both width and height. If an object is passed, the screenshot size
  72173. * will be derived from the parameters. The precision property is a multiplier allowing
  72174. * rendering at a higher or lower resolution
  72175. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72176. * Check your browser for supported MIME types
  72177. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72178. * to the src parameter of an <img> to display it
  72179. */
  72180. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72181. /**
  72182. * Generates an image screenshot from the specified camera.
  72183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72184. * @param engine The engine to use for rendering
  72185. * @param camera The camera to use for rendering
  72186. * @param size This parameter can be set to a single number or to an object with the
  72187. * following (optional) properties: precision, width, height. If a single number is passed,
  72188. * it will be used for both width and height. If an object is passed, the screenshot size
  72189. * will be derived from the parameters. The precision property is a multiplier allowing
  72190. * rendering at a higher or lower resolution
  72191. * @param successCallback The callback receives a single parameter which contains the
  72192. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72193. * src parameter of an <img> to display it
  72194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72195. * Check your browser for supported MIME types
  72196. * @param samples Texture samples (default: 1)
  72197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72198. * @param fileName A name for for the downloaded file.
  72199. */
  72200. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72201. /**
  72202. * Generates an image screenshot from the specified camera.
  72203. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72204. * @param engine The engine to use for rendering
  72205. * @param camera The camera to use for rendering
  72206. * @param size This parameter can be set to a single number or to an object with the
  72207. * following (optional) properties: precision, width, height. If a single number is passed,
  72208. * it will be used for both width and height. If an object is passed, the screenshot size
  72209. * will be derived from the parameters. The precision property is a multiplier allowing
  72210. * rendering at a higher or lower resolution
  72211. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72212. * Check your browser for supported MIME types
  72213. * @param samples Texture samples (default: 1)
  72214. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72215. * @param fileName A name for for the downloaded file.
  72216. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72217. * to the src parameter of an <img> to display it
  72218. */
  72219. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72220. /**
  72221. * Gets height and width for screenshot size
  72222. * @private
  72223. */
  72224. private static _getScreenshotSize;
  72225. }
  72226. }
  72227. declare module "babylonjs/Misc/dataReader" {
  72228. /**
  72229. * Interface for a data buffer
  72230. */
  72231. export interface IDataBuffer {
  72232. /**
  72233. * Reads bytes from the data buffer.
  72234. * @param byteOffset The byte offset to read
  72235. * @param byteLength The byte length to read
  72236. * @returns A promise that resolves when the bytes are read
  72237. */
  72238. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72239. /**
  72240. * The byte length of the buffer.
  72241. */
  72242. readonly byteLength: number;
  72243. }
  72244. /**
  72245. * Utility class for reading from a data buffer
  72246. */
  72247. export class DataReader {
  72248. /**
  72249. * The data buffer associated with this data reader.
  72250. */
  72251. readonly buffer: IDataBuffer;
  72252. /**
  72253. * The current byte offset from the beginning of the data buffer.
  72254. */
  72255. byteOffset: number;
  72256. private _dataView;
  72257. private _dataByteOffset;
  72258. /**
  72259. * Constructor
  72260. * @param buffer The buffer to read
  72261. */
  72262. constructor(buffer: IDataBuffer);
  72263. /**
  72264. * Loads the given byte length.
  72265. * @param byteLength The byte length to load
  72266. * @returns A promise that resolves when the load is complete
  72267. */
  72268. loadAsync(byteLength: number): Promise<void>;
  72269. /**
  72270. * Read a unsigned 32-bit integer from the currently loaded data range.
  72271. * @returns The 32-bit integer read
  72272. */
  72273. readUint32(): number;
  72274. /**
  72275. * Read a byte array from the currently loaded data range.
  72276. * @param byteLength The byte length to read
  72277. * @returns The byte array read
  72278. */
  72279. readUint8Array(byteLength: number): Uint8Array;
  72280. /**
  72281. * Read a string from the currently loaded data range.
  72282. * @param byteLength The byte length to read
  72283. * @returns The string read
  72284. */
  72285. readString(byteLength: number): string;
  72286. /**
  72287. * Skips the given byte length the currently loaded data range.
  72288. * @param byteLength The byte length to skip
  72289. */
  72290. skipBytes(byteLength: number): void;
  72291. }
  72292. }
  72293. declare module "babylonjs/Misc/index" {
  72294. export * from "babylonjs/Misc/andOrNotEvaluator";
  72295. export * from "babylonjs/Misc/assetsManager";
  72296. export * from "babylonjs/Misc/basis";
  72297. export * from "babylonjs/Misc/dds";
  72298. export * from "babylonjs/Misc/decorators";
  72299. export * from "babylonjs/Misc/deferred";
  72300. export * from "babylonjs/Misc/environmentTextureTools";
  72301. export * from "babylonjs/Misc/meshExploder";
  72302. export * from "babylonjs/Misc/filesInput";
  72303. export * from "babylonjs/Misc/HighDynamicRange/index";
  72304. export * from "babylonjs/Misc/khronosTextureContainer";
  72305. export * from "babylonjs/Misc/observable";
  72306. export * from "babylonjs/Misc/performanceMonitor";
  72307. export * from "babylonjs/Misc/promise";
  72308. export * from "babylonjs/Misc/sceneOptimizer";
  72309. export * from "babylonjs/Misc/sceneSerializer";
  72310. export * from "babylonjs/Misc/smartArray";
  72311. export * from "babylonjs/Misc/stringDictionary";
  72312. export * from "babylonjs/Misc/tags";
  72313. export * from "babylonjs/Misc/textureTools";
  72314. export * from "babylonjs/Misc/tga";
  72315. export * from "babylonjs/Misc/tools";
  72316. export * from "babylonjs/Misc/videoRecorder";
  72317. export * from "babylonjs/Misc/virtualJoystick";
  72318. export * from "babylonjs/Misc/workerPool";
  72319. export * from "babylonjs/Misc/logger";
  72320. export * from "babylonjs/Misc/typeStore";
  72321. export * from "babylonjs/Misc/filesInputStore";
  72322. export * from "babylonjs/Misc/deepCopier";
  72323. export * from "babylonjs/Misc/pivotTools";
  72324. export * from "babylonjs/Misc/precisionDate";
  72325. export * from "babylonjs/Misc/screenshotTools";
  72326. export * from "babylonjs/Misc/typeStore";
  72327. export * from "babylonjs/Misc/webRequest";
  72328. export * from "babylonjs/Misc/iInspectable";
  72329. export * from "babylonjs/Misc/brdfTextureTools";
  72330. export * from "babylonjs/Misc/rgbdTextureTools";
  72331. export * from "babylonjs/Misc/gradients";
  72332. export * from "babylonjs/Misc/perfCounter";
  72333. export * from "babylonjs/Misc/fileRequest";
  72334. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72335. export * from "babylonjs/Misc/retryStrategy";
  72336. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72337. export * from "babylonjs/Misc/canvasGenerator";
  72338. export * from "babylonjs/Misc/fileTools";
  72339. export * from "babylonjs/Misc/stringTools";
  72340. export * from "babylonjs/Misc/dataReader";
  72341. export * from "babylonjs/Misc/minMaxReducer";
  72342. export * from "babylonjs/Misc/depthReducer";
  72343. }
  72344. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72345. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72346. import { Observable } from "babylonjs/Misc/observable";
  72347. import { Matrix } from "babylonjs/Maths/math.vector";
  72348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72349. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72350. /**
  72351. * Options used for hit testing
  72352. */
  72353. export interface IWebXRHitTestOptions {
  72354. /**
  72355. * Only test when user interacted with the scene. Default - hit test every frame
  72356. */
  72357. testOnPointerDownOnly?: boolean;
  72358. /**
  72359. * The node to use to transform the local results to world coordinates
  72360. */
  72361. worldParentNode?: TransformNode;
  72362. }
  72363. /**
  72364. * Interface defining the babylon result of raycasting/hit-test
  72365. */
  72366. export interface IWebXRHitResult {
  72367. /**
  72368. * The native hit test result
  72369. */
  72370. xrHitResult: XRHitResult;
  72371. /**
  72372. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72373. */
  72374. transformationMatrix: Matrix;
  72375. }
  72376. /**
  72377. * The currently-working hit-test module.
  72378. * Hit test (or raycasting) is used to interact with the real world.
  72379. * For further information read here - https://github.com/immersive-web/hit-test
  72380. */
  72381. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72382. /**
  72383. * options to use when constructing this feature
  72384. */
  72385. readonly options: IWebXRHitTestOptions;
  72386. /**
  72387. * The module's name
  72388. */
  72389. static readonly Name: string;
  72390. /**
  72391. * The (Babylon) version of this module.
  72392. * This is an integer representing the implementation version.
  72393. * This number does not correspond to the webxr specs version
  72394. */
  72395. static readonly Version: number;
  72396. /**
  72397. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72398. * @param event the (select) event to use to select with
  72399. * @param referenceSpace the reference space to use for this hit test
  72400. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72401. */
  72402. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72403. /**
  72404. * execute a hit test with an XR Ray
  72405. *
  72406. * @param xrSession a native xrSession that will execute this hit test
  72407. * @param xrRay the ray (position and direction) to use for raycasting
  72408. * @param referenceSpace native XR reference space to use for the hit-test
  72409. * @param filter filter function that will filter the results
  72410. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72411. */
  72412. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72413. /**
  72414. * Triggered when new babylon (transformed) hit test results are available
  72415. */
  72416. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72417. private _onSelectEnabled;
  72418. /**
  72419. * Creates a new instance of the (legacy version) hit test feature
  72420. * @param _xrSessionManager an instance of WebXRSessionManager
  72421. * @param options options to use when constructing this feature
  72422. */
  72423. constructor(_xrSessionManager: WebXRSessionManager,
  72424. /**
  72425. * options to use when constructing this feature
  72426. */
  72427. options?: IWebXRHitTestOptions);
  72428. /**
  72429. * Populated with the last native XR Hit Results
  72430. */
  72431. lastNativeXRHitResults: XRHitResult[];
  72432. /**
  72433. * attach this feature
  72434. * Will usually be called by the features manager
  72435. *
  72436. * @returns true if successful.
  72437. */
  72438. attach(): boolean;
  72439. /**
  72440. * detach this feature.
  72441. * Will usually be called by the features manager
  72442. *
  72443. * @returns true if successful.
  72444. */
  72445. detach(): boolean;
  72446. private _onHitTestResults;
  72447. private _origin;
  72448. private _direction;
  72449. private _mat;
  72450. protected _onXRFrame(frame: XRFrame): void;
  72451. private _onSelect;
  72452. /**
  72453. * Dispose this feature and all of the resources attached
  72454. */
  72455. dispose(): void;
  72456. }
  72457. }
  72458. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72460. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72461. import { Observable } from "babylonjs/Misc/observable";
  72462. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72463. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72464. /**
  72465. * Options used in the plane detector module
  72466. */
  72467. export interface IWebXRPlaneDetectorOptions {
  72468. /**
  72469. * The node to use to transform the local results to world coordinates
  72470. */
  72471. worldParentNode?: TransformNode;
  72472. }
  72473. /**
  72474. * A babylon interface for a webxr plane.
  72475. * A Plane is actually a polygon, built from N points in space
  72476. *
  72477. * Supported in chrome 79, not supported in canary 81 ATM
  72478. */
  72479. export interface IWebXRPlane {
  72480. /**
  72481. * a babylon-assigned ID for this polygon
  72482. */
  72483. id: number;
  72484. /**
  72485. * the native xr-plane object
  72486. */
  72487. xrPlane: XRPlane;
  72488. /**
  72489. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72490. */
  72491. polygonDefinition: Array<Vector3>;
  72492. /**
  72493. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72494. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72495. */
  72496. transformationMatrix: Matrix;
  72497. }
  72498. /**
  72499. * The plane detector is used to detect planes in the real world when in AR
  72500. * For more information see https://github.com/immersive-web/real-world-geometry/
  72501. */
  72502. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72503. private _options;
  72504. /**
  72505. * The module's name
  72506. */
  72507. static readonly Name: string;
  72508. /**
  72509. * The (Babylon) version of this module.
  72510. * This is an integer representing the implementation version.
  72511. * This number does not correspond to the webxr specs version
  72512. */
  72513. static readonly Version: number;
  72514. /**
  72515. * Observers registered here will be executed when a new plane was added to the session
  72516. */
  72517. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72518. /**
  72519. * Observers registered here will be executed when a plane is no longer detected in the session
  72520. */
  72521. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72522. /**
  72523. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72524. * This can execute N times every frame
  72525. */
  72526. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72527. private _enabled;
  72528. private _detectedPlanes;
  72529. private _lastFrameDetected;
  72530. /**
  72531. * construct a new Plane Detector
  72532. * @param _xrSessionManager an instance of xr Session manager
  72533. * @param _options configuration to use when constructing this feature
  72534. */
  72535. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72536. private _init;
  72537. protected _onXRFrame(frame: XRFrame): void;
  72538. /**
  72539. * Dispose this feature and all of the resources attached
  72540. */
  72541. dispose(): void;
  72542. private _updatePlaneWithXRPlane;
  72543. /**
  72544. * avoiding using Array.find for global support.
  72545. * @param xrPlane the plane to find in the array
  72546. */
  72547. private findIndexInPlaneArray;
  72548. }
  72549. }
  72550. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72551. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72552. import { Observable } from "babylonjs/Misc/observable";
  72553. import { Matrix } from "babylonjs/Maths/math.vector";
  72554. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72555. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72556. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72557. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72558. /**
  72559. * Configuration options of the anchor system
  72560. */
  72561. export interface IWebXRAnchorSystemOptions {
  72562. /**
  72563. * a node that will be used to convert local to world coordinates
  72564. */
  72565. worldParentNode?: TransformNode;
  72566. /**
  72567. * should the anchor system use plane detection.
  72568. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72569. */
  72570. usePlaneDetection?: boolean;
  72571. /**
  72572. * Should a new anchor be added every time a select event is triggered
  72573. */
  72574. addAnchorOnSelect?: boolean;
  72575. }
  72576. /**
  72577. * A babylon container for an XR Anchor
  72578. */
  72579. export interface IWebXRAnchor {
  72580. /**
  72581. * A babylon-assigned ID for this anchor
  72582. */
  72583. id: number;
  72584. /**
  72585. * The native anchor object
  72586. */
  72587. xrAnchor: XRAnchor;
  72588. /**
  72589. * Transformation matrix to apply to an object attached to this anchor
  72590. */
  72591. transformationMatrix: Matrix;
  72592. }
  72593. /**
  72594. * An implementation of the anchor system of WebXR.
  72595. * Note that the current documented implementation is not available in any browser. Future implementations
  72596. * will use the frame to create an anchor and not the session or a detected plane
  72597. * For further information see https://github.com/immersive-web/anchors/
  72598. */
  72599. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72600. private _options;
  72601. /**
  72602. * The module's name
  72603. */
  72604. static readonly Name: string;
  72605. /**
  72606. * The (Babylon) version of this module.
  72607. * This is an integer representing the implementation version.
  72608. * This number does not correspond to the webxr specs version
  72609. */
  72610. static readonly Version: number;
  72611. /**
  72612. * Observers registered here will be executed when a new anchor was added to the session
  72613. */
  72614. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72615. /**
  72616. * Observers registered here will be executed when an existing anchor updates
  72617. * This can execute N times every frame
  72618. */
  72619. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72620. /**
  72621. * Observers registered here will be executed when an anchor was removed from the session
  72622. */
  72623. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72624. private _planeDetector;
  72625. private _hitTestModule;
  72626. private _enabled;
  72627. private _trackedAnchors;
  72628. private _lastFrameDetected;
  72629. /**
  72630. * constructs a new anchor system
  72631. * @param _xrSessionManager an instance of WebXRSessionManager
  72632. * @param _options configuration object for this feature
  72633. */
  72634. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72635. /**
  72636. * set the plane detector to use in order to create anchors from frames
  72637. * @param planeDetector the plane-detector module to use
  72638. * @param enable enable plane-anchors. default is true
  72639. */
  72640. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72641. /**
  72642. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72643. * @param hitTestModule the hit-test module to use.
  72644. */
  72645. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72646. /**
  72647. * attach this feature
  72648. * Will usually be called by the features manager
  72649. *
  72650. * @returns true if successful.
  72651. */
  72652. attach(): boolean;
  72653. /**
  72654. * detach this feature.
  72655. * Will usually be called by the features manager
  72656. *
  72657. * @returns true if successful.
  72658. */
  72659. detach(): boolean;
  72660. /**
  72661. * Dispose this feature and all of the resources attached
  72662. */
  72663. dispose(): void;
  72664. protected _onXRFrame(frame: XRFrame): void;
  72665. private _onSelect;
  72666. /**
  72667. * Add anchor at a specific XR point.
  72668. *
  72669. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72670. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72671. * @returns a promise the fulfills when the anchor was created
  72672. */
  72673. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72674. private _updateAnchorWithXRFrame;
  72675. /**
  72676. * avoiding using Array.find for global support.
  72677. * @param xrAnchor the plane to find in the array
  72678. */
  72679. private _findIndexInAnchorArray;
  72680. }
  72681. }
  72682. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72683. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72685. import { Observable } from "babylonjs/Misc/observable";
  72686. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72687. /**
  72688. * Options interface for the background remover plugin
  72689. */
  72690. export interface IWebXRBackgroundRemoverOptions {
  72691. /**
  72692. * don't disable the environment helper
  72693. */
  72694. ignoreEnvironmentHelper?: boolean;
  72695. /**
  72696. * flags to configure the removal of the environment helper.
  72697. * If not set, the entire background will be removed. If set, flags should be set as well.
  72698. */
  72699. environmentHelperRemovalFlags?: {
  72700. /**
  72701. * Should the skybox be removed (default false)
  72702. */
  72703. skyBox?: boolean;
  72704. /**
  72705. * Should the ground be removed (default false)
  72706. */
  72707. ground?: boolean;
  72708. };
  72709. /**
  72710. * Further background meshes to disable when entering AR
  72711. */
  72712. backgroundMeshes?: AbstractMesh[];
  72713. }
  72714. /**
  72715. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72716. */
  72717. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72718. /**
  72719. * read-only options to be used in this module
  72720. */
  72721. readonly options: IWebXRBackgroundRemoverOptions;
  72722. /**
  72723. * The module's name
  72724. */
  72725. static readonly Name: string;
  72726. /**
  72727. * The (Babylon) version of this module.
  72728. * This is an integer representing the implementation version.
  72729. * This number does not correspond to the webxr specs version
  72730. */
  72731. static readonly Version: number;
  72732. /**
  72733. * registered observers will be triggered when the background state changes
  72734. */
  72735. onBackgroundStateChangedObservable: Observable<boolean>;
  72736. /**
  72737. * constructs a new background remover module
  72738. * @param _xrSessionManager the session manager for this module
  72739. * @param options read-only options to be used in this module
  72740. */
  72741. constructor(_xrSessionManager: WebXRSessionManager,
  72742. /**
  72743. * read-only options to be used in this module
  72744. */
  72745. options?: IWebXRBackgroundRemoverOptions);
  72746. /**
  72747. * attach this feature
  72748. * Will usually be called by the features manager
  72749. *
  72750. * @returns true if successful.
  72751. */
  72752. attach(): boolean;
  72753. /**
  72754. * detach this feature.
  72755. * Will usually be called by the features manager
  72756. *
  72757. * @returns true if successful.
  72758. */
  72759. detach(): boolean;
  72760. private _setBackgroundState;
  72761. /**
  72762. * Dispose this feature and all of the resources attached
  72763. */
  72764. dispose(): void;
  72765. protected _onXRFrame(_xrFrame: XRFrame): void;
  72766. }
  72767. }
  72768. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72769. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72770. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72771. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72772. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72773. /**
  72774. * Options for the controller physics feature
  72775. */
  72776. export class IWebXRControllerPhysicsOptions {
  72777. /**
  72778. * the xr input to use with this pointer selection
  72779. */
  72780. xrInput: WebXRInput;
  72781. /**
  72782. * The physics properties of the future impostors
  72783. */
  72784. physicsProperties?: {
  72785. /**
  72786. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72787. * Note that this requires a physics engine that supports mesh impostors!
  72788. */
  72789. useControllerMesh?: boolean;
  72790. /**
  72791. * The type of impostor to create. Default is sphere
  72792. */
  72793. impostorType?: number;
  72794. /**
  72795. * the size of the impostor. Defaults to 10cm
  72796. */
  72797. impostorSize?: number | {
  72798. width: number;
  72799. height: number;
  72800. depth: number;
  72801. };
  72802. /**
  72803. * Friction definitions
  72804. */
  72805. friction?: number;
  72806. /**
  72807. * Restitution
  72808. */
  72809. restitution?: number;
  72810. };
  72811. }
  72812. /**
  72813. * Add physics impostor to your webxr controllers,
  72814. * including naive calculation of their linear and angular velocity
  72815. */
  72816. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72817. private readonly _options;
  72818. /**
  72819. * The module's name
  72820. */
  72821. static readonly Name: string;
  72822. /**
  72823. * The (Babylon) version of this module.
  72824. * This is an integer representing the implementation version.
  72825. * This number does not correspond to the webxr specs version
  72826. */
  72827. static readonly Version: number;
  72828. private _lastTimestamp;
  72829. private _delta;
  72830. private _controllers;
  72831. private _tmpVector;
  72832. private _tmpQuaternion;
  72833. /**
  72834. * Construct a new Controller Physics Feature
  72835. * @param _xrSessionManager the corresponding xr session manager
  72836. * @param _options options to create this feature with
  72837. */
  72838. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72839. /**
  72840. * Update the physics properties provided in the constructor
  72841. * @param newProperties the new properties object
  72842. */
  72843. setPhysicsProperties(newProperties: {
  72844. impostorType?: number;
  72845. impostorSize?: number | {
  72846. width: number;
  72847. height: number;
  72848. depth: number;
  72849. };
  72850. friction?: number;
  72851. restitution?: number;
  72852. }): void;
  72853. /**
  72854. * attach this feature
  72855. * Will usually be called by the features manager
  72856. *
  72857. * @returns true if successful.
  72858. */
  72859. attach(): boolean;
  72860. /**
  72861. * detach this feature.
  72862. * Will usually be called by the features manager
  72863. *
  72864. * @returns true if successful.
  72865. */
  72866. detach(): boolean;
  72867. /**
  72868. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72869. * @param xrController the controller to add
  72870. */
  72871. addController(xrController: WebXRInputSource): void;
  72872. private _debugMode;
  72873. /**
  72874. * @hidden
  72875. * enable debugging - will show console outputs and the impostor mesh
  72876. */
  72877. _enablePhysicsDebug(): void;
  72878. private _attachController;
  72879. private _detachController;
  72880. protected _onXRFrame(_xrFrame: any): void;
  72881. }
  72882. }
  72883. declare module "babylonjs/XR/features/index" {
  72884. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72885. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72886. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72887. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72888. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72889. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72890. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72891. }
  72892. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72893. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72895. import { Scene } from "babylonjs/scene";
  72896. /**
  72897. * The motion controller class for all microsoft mixed reality controllers
  72898. */
  72899. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72900. /**
  72901. * The base url used to load the left and right controller models
  72902. */
  72903. static MODEL_BASE_URL: string;
  72904. /**
  72905. * The name of the left controller model file
  72906. */
  72907. static MODEL_LEFT_FILENAME: string;
  72908. /**
  72909. * The name of the right controller model file
  72910. */
  72911. static MODEL_RIGHT_FILENAME: string;
  72912. profileId: string;
  72913. protected readonly _mapping: {
  72914. defaultButton: {
  72915. "valueNodeName": string;
  72916. "unpressedNodeName": string;
  72917. "pressedNodeName": string;
  72918. };
  72919. defaultAxis: {
  72920. "valueNodeName": string;
  72921. "minNodeName": string;
  72922. "maxNodeName": string;
  72923. };
  72924. buttons: {
  72925. "xr-standard-trigger": {
  72926. "rootNodeName": string;
  72927. "componentProperty": string;
  72928. "states": string[];
  72929. };
  72930. "xr-standard-squeeze": {
  72931. "rootNodeName": string;
  72932. "componentProperty": string;
  72933. "states": string[];
  72934. };
  72935. "xr-standard-touchpad": {
  72936. "rootNodeName": string;
  72937. "labelAnchorNodeName": string;
  72938. "touchPointNodeName": string;
  72939. };
  72940. "xr-standard-thumbstick": {
  72941. "rootNodeName": string;
  72942. "componentProperty": string;
  72943. "states": string[];
  72944. };
  72945. };
  72946. axes: {
  72947. "xr-standard-touchpad": {
  72948. "x-axis": {
  72949. "rootNodeName": string;
  72950. };
  72951. "y-axis": {
  72952. "rootNodeName": string;
  72953. };
  72954. };
  72955. "xr-standard-thumbstick": {
  72956. "x-axis": {
  72957. "rootNodeName": string;
  72958. };
  72959. "y-axis": {
  72960. "rootNodeName": string;
  72961. };
  72962. };
  72963. };
  72964. };
  72965. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72966. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72967. protected _getFilenameAndPath(): {
  72968. filename: string;
  72969. path: string;
  72970. };
  72971. protected _updateModel(): void;
  72972. protected _getModelLoadingConstraints(): boolean;
  72973. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72974. }
  72975. }
  72976. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72977. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72979. import { Scene } from "babylonjs/scene";
  72980. /**
  72981. * The motion controller class for oculus touch (quest, rift).
  72982. * This class supports legacy mapping as well the standard xr mapping
  72983. */
  72984. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72985. private _forceLegacyControllers;
  72986. /**
  72987. * The base url used to load the left and right controller models
  72988. */
  72989. static MODEL_BASE_URL: string;
  72990. /**
  72991. * The name of the left controller model file
  72992. */
  72993. static MODEL_LEFT_FILENAME: string;
  72994. /**
  72995. * The name of the right controller model file
  72996. */
  72997. static MODEL_RIGHT_FILENAME: string;
  72998. /**
  72999. * Base Url for the Quest controller model.
  73000. */
  73001. static QUEST_MODEL_BASE_URL: string;
  73002. profileId: string;
  73003. private _modelRootNode;
  73004. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73005. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73006. protected _getFilenameAndPath(): {
  73007. filename: string;
  73008. path: string;
  73009. };
  73010. /**
  73011. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73012. * between the touch and touch 2.
  73013. */
  73014. private _isQuest;
  73015. protected _updateModel(): void;
  73016. protected _getModelLoadingConstraints(): boolean;
  73017. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73018. }
  73019. }
  73020. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73021. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73022. import { Scene } from "babylonjs/scene";
  73023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73024. /**
  73025. * The motion controller class for the standard HTC-Vive controllers
  73026. */
  73027. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73028. /**
  73029. * The base url used to load the left and right controller models
  73030. */
  73031. static MODEL_BASE_URL: string;
  73032. /**
  73033. * File name for the controller model.
  73034. */
  73035. static MODEL_FILENAME: string;
  73036. profileId: string;
  73037. private _modelRootNode;
  73038. /**
  73039. * Create a new Vive motion controller object
  73040. * @param scene the scene to use to create this controller
  73041. * @param gamepadObject the corresponding gamepad object
  73042. * @param handness the handness of the controller
  73043. */
  73044. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73045. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73046. protected _getFilenameAndPath(): {
  73047. filename: string;
  73048. path: string;
  73049. };
  73050. protected _updateModel(): void;
  73051. protected _getModelLoadingConstraints(): boolean;
  73052. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73053. }
  73054. }
  73055. declare module "babylonjs/XR/motionController/index" {
  73056. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73057. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73058. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73059. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73060. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73061. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73062. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73063. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73064. }
  73065. declare module "babylonjs/XR/index" {
  73066. export * from "babylonjs/XR/webXRCamera";
  73067. export * from "babylonjs/XR/webXREnterExitUI";
  73068. export * from "babylonjs/XR/webXRExperienceHelper";
  73069. export * from "babylonjs/XR/webXRInput";
  73070. export * from "babylonjs/XR/webXRInputSource";
  73071. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73072. export * from "babylonjs/XR/webXRTypes";
  73073. export * from "babylonjs/XR/webXRSessionManager";
  73074. export * from "babylonjs/XR/webXRDefaultExperience";
  73075. export * from "babylonjs/XR/webXRFeaturesManager";
  73076. export * from "babylonjs/XR/features/index";
  73077. export * from "babylonjs/XR/motionController/index";
  73078. }
  73079. declare module "babylonjs/index" {
  73080. export * from "babylonjs/abstractScene";
  73081. export * from "babylonjs/Actions/index";
  73082. export * from "babylonjs/Animations/index";
  73083. export * from "babylonjs/assetContainer";
  73084. export * from "babylonjs/Audio/index";
  73085. export * from "babylonjs/Behaviors/index";
  73086. export * from "babylonjs/Bones/index";
  73087. export * from "babylonjs/Cameras/index";
  73088. export * from "babylonjs/Collisions/index";
  73089. export * from "babylonjs/Culling/index";
  73090. export * from "babylonjs/Debug/index";
  73091. export * from "babylonjs/Engines/index";
  73092. export * from "babylonjs/Events/index";
  73093. export * from "babylonjs/Gamepads/index";
  73094. export * from "babylonjs/Gizmos/index";
  73095. export * from "babylonjs/Helpers/index";
  73096. export * from "babylonjs/Instrumentation/index";
  73097. export * from "babylonjs/Layers/index";
  73098. export * from "babylonjs/LensFlares/index";
  73099. export * from "babylonjs/Lights/index";
  73100. export * from "babylonjs/Loading/index";
  73101. export * from "babylonjs/Materials/index";
  73102. export * from "babylonjs/Maths/index";
  73103. export * from "babylonjs/Meshes/index";
  73104. export * from "babylonjs/Morph/index";
  73105. export * from "babylonjs/Navigation/index";
  73106. export * from "babylonjs/node";
  73107. export * from "babylonjs/Offline/index";
  73108. export * from "babylonjs/Particles/index";
  73109. export * from "babylonjs/Physics/index";
  73110. export * from "babylonjs/PostProcesses/index";
  73111. export * from "babylonjs/Probes/index";
  73112. export * from "babylonjs/Rendering/index";
  73113. export * from "babylonjs/scene";
  73114. export * from "babylonjs/sceneComponent";
  73115. export * from "babylonjs/Sprites/index";
  73116. export * from "babylonjs/States/index";
  73117. export * from "babylonjs/Misc/index";
  73118. export * from "babylonjs/XR/index";
  73119. export * from "babylonjs/types";
  73120. }
  73121. declare module "babylonjs/Animations/pathCursor" {
  73122. import { Vector3 } from "babylonjs/Maths/math.vector";
  73123. import { Path2 } from "babylonjs/Maths/math.path";
  73124. /**
  73125. * A cursor which tracks a point on a path
  73126. */
  73127. export class PathCursor {
  73128. private path;
  73129. /**
  73130. * Stores path cursor callbacks for when an onchange event is triggered
  73131. */
  73132. private _onchange;
  73133. /**
  73134. * The value of the path cursor
  73135. */
  73136. value: number;
  73137. /**
  73138. * The animation array of the path cursor
  73139. */
  73140. animations: Animation[];
  73141. /**
  73142. * Initializes the path cursor
  73143. * @param path The path to track
  73144. */
  73145. constructor(path: Path2);
  73146. /**
  73147. * Gets the cursor point on the path
  73148. * @returns A point on the path cursor at the cursor location
  73149. */
  73150. getPoint(): Vector3;
  73151. /**
  73152. * Moves the cursor ahead by the step amount
  73153. * @param step The amount to move the cursor forward
  73154. * @returns This path cursor
  73155. */
  73156. moveAhead(step?: number): PathCursor;
  73157. /**
  73158. * Moves the cursor behind by the step amount
  73159. * @param step The amount to move the cursor back
  73160. * @returns This path cursor
  73161. */
  73162. moveBack(step?: number): PathCursor;
  73163. /**
  73164. * Moves the cursor by the step amount
  73165. * If the step amount is greater than one, an exception is thrown
  73166. * @param step The amount to move the cursor
  73167. * @returns This path cursor
  73168. */
  73169. move(step: number): PathCursor;
  73170. /**
  73171. * Ensures that the value is limited between zero and one
  73172. * @returns This path cursor
  73173. */
  73174. private ensureLimits;
  73175. /**
  73176. * Runs onchange callbacks on change (used by the animation engine)
  73177. * @returns This path cursor
  73178. */
  73179. private raiseOnChange;
  73180. /**
  73181. * Executes a function on change
  73182. * @param f A path cursor onchange callback
  73183. * @returns This path cursor
  73184. */
  73185. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73186. }
  73187. }
  73188. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73189. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73190. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73191. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73192. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73193. }
  73194. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73195. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73196. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73197. }
  73198. declare module "babylonjs/Engines/Processors/index" {
  73199. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73200. export * from "babylonjs/Engines/Processors/Expressions/index";
  73201. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73202. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73203. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73204. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73205. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73206. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73207. }
  73208. declare module "babylonjs/Legacy/legacy" {
  73209. import * as Babylon from "babylonjs/index";
  73210. export * from "babylonjs/index";
  73211. }
  73212. declare module "babylonjs/Shaders/blur.fragment" {
  73213. /** @hidden */
  73214. export var blurPixelShader: {
  73215. name: string;
  73216. shader: string;
  73217. };
  73218. }
  73219. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73220. /** @hidden */
  73221. export var pointCloudVertexDeclaration: {
  73222. name: string;
  73223. shader: string;
  73224. };
  73225. }
  73226. declare module "babylonjs" {
  73227. export * from "babylonjs/Legacy/legacy";
  73228. }
  73229. declare module BABYLON {
  73230. /** Alias type for value that can be null */
  73231. export type Nullable<T> = T | null;
  73232. /**
  73233. * Alias type for number that are floats
  73234. * @ignorenaming
  73235. */
  73236. export type float = number;
  73237. /**
  73238. * Alias type for number that are doubles.
  73239. * @ignorenaming
  73240. */
  73241. export type double = number;
  73242. /**
  73243. * Alias type for number that are integer
  73244. * @ignorenaming
  73245. */
  73246. export type int = number;
  73247. /** Alias type for number array or Float32Array */
  73248. export type FloatArray = number[] | Float32Array;
  73249. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73250. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73251. /**
  73252. * Alias for types that can be used by a Buffer or VertexBuffer.
  73253. */
  73254. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73255. /**
  73256. * Alias type for primitive types
  73257. * @ignorenaming
  73258. */
  73259. type Primitive = undefined | null | boolean | string | number | Function;
  73260. /**
  73261. * Type modifier to make all the properties of an object Readonly
  73262. */
  73263. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73264. /**
  73265. * Type modifier to make all the properties of an object Readonly recursively
  73266. */
  73267. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73268. /**
  73269. * Type modifier to make object properties readonly.
  73270. */
  73271. export type DeepImmutableObject<T> = {
  73272. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73273. };
  73274. /** @hidden */
  73275. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73276. }
  73277. }
  73278. declare module BABYLON {
  73279. /**
  73280. * A class serves as a medium between the observable and its observers
  73281. */
  73282. export class EventState {
  73283. /**
  73284. * Create a new EventState
  73285. * @param mask defines the mask associated with this state
  73286. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73287. * @param target defines the original target of the state
  73288. * @param currentTarget defines the current target of the state
  73289. */
  73290. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73291. /**
  73292. * Initialize the current event state
  73293. * @param mask defines the mask associated with this state
  73294. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73295. * @param target defines the original target of the state
  73296. * @param currentTarget defines the current target of the state
  73297. * @returns the current event state
  73298. */
  73299. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73300. /**
  73301. * An Observer can set this property to true to prevent subsequent observers of being notified
  73302. */
  73303. skipNextObservers: boolean;
  73304. /**
  73305. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73306. */
  73307. mask: number;
  73308. /**
  73309. * The object that originally notified the event
  73310. */
  73311. target?: any;
  73312. /**
  73313. * The current object in the bubbling phase
  73314. */
  73315. currentTarget?: any;
  73316. /**
  73317. * This will be populated with the return value of the last function that was executed.
  73318. * If it is the first function in the callback chain it will be the event data.
  73319. */
  73320. lastReturnValue?: any;
  73321. }
  73322. /**
  73323. * Represent an Observer registered to a given Observable object.
  73324. */
  73325. export class Observer<T> {
  73326. /**
  73327. * Defines the callback to call when the observer is notified
  73328. */
  73329. callback: (eventData: T, eventState: EventState) => void;
  73330. /**
  73331. * Defines the mask of the observer (used to filter notifications)
  73332. */
  73333. mask: number;
  73334. /**
  73335. * Defines the current scope used to restore the JS context
  73336. */
  73337. scope: any;
  73338. /** @hidden */
  73339. _willBeUnregistered: boolean;
  73340. /**
  73341. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73342. */
  73343. unregisterOnNextCall: boolean;
  73344. /**
  73345. * Creates a new observer
  73346. * @param callback defines the callback to call when the observer is notified
  73347. * @param mask defines the mask of the observer (used to filter notifications)
  73348. * @param scope defines the current scope used to restore the JS context
  73349. */
  73350. constructor(
  73351. /**
  73352. * Defines the callback to call when the observer is notified
  73353. */
  73354. callback: (eventData: T, eventState: EventState) => void,
  73355. /**
  73356. * Defines the mask of the observer (used to filter notifications)
  73357. */
  73358. mask: number,
  73359. /**
  73360. * Defines the current scope used to restore the JS context
  73361. */
  73362. scope?: any);
  73363. }
  73364. /**
  73365. * Represent a list of observers registered to multiple Observables object.
  73366. */
  73367. export class MultiObserver<T> {
  73368. private _observers;
  73369. private _observables;
  73370. /**
  73371. * Release associated resources
  73372. */
  73373. dispose(): void;
  73374. /**
  73375. * Raise a callback when one of the observable will notify
  73376. * @param observables defines a list of observables to watch
  73377. * @param callback defines the callback to call on notification
  73378. * @param mask defines the mask used to filter notifications
  73379. * @param scope defines the current scope used to restore the JS context
  73380. * @returns the new MultiObserver
  73381. */
  73382. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73383. }
  73384. /**
  73385. * The Observable class is a simple implementation of the Observable pattern.
  73386. *
  73387. * 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.
  73388. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73389. * 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).
  73390. * 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.
  73391. */
  73392. export class Observable<T> {
  73393. private _observers;
  73394. private _eventState;
  73395. private _onObserverAdded;
  73396. /**
  73397. * Gets the list of observers
  73398. */
  73399. get observers(): Array<Observer<T>>;
  73400. /**
  73401. * Creates a new observable
  73402. * @param onObserverAdded defines a callback to call when a new observer is added
  73403. */
  73404. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73405. /**
  73406. * Create a new Observer with the specified callback
  73407. * @param callback the callback that will be executed for that Observer
  73408. * @param mask the mask used to filter observers
  73409. * @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.
  73410. * @param scope optional scope for the callback to be called from
  73411. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73412. * @returns the new observer created for the callback
  73413. */
  73414. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73415. /**
  73416. * Create a new Observer with the specified callback and unregisters after the next notification
  73417. * @param callback the callback that will be executed for that Observer
  73418. * @returns the new observer created for the callback
  73419. */
  73420. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73421. /**
  73422. * Remove an Observer from the Observable object
  73423. * @param observer the instance of the Observer to remove
  73424. * @returns false if it doesn't belong to this Observable
  73425. */
  73426. remove(observer: Nullable<Observer<T>>): boolean;
  73427. /**
  73428. * Remove a callback from the Observable object
  73429. * @param callback the callback to remove
  73430. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73431. * @returns false if it doesn't belong to this Observable
  73432. */
  73433. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73434. private _deferUnregister;
  73435. private _remove;
  73436. /**
  73437. * Moves the observable to the top of the observer list making it get called first when notified
  73438. * @param observer the observer to move
  73439. */
  73440. makeObserverTopPriority(observer: Observer<T>): void;
  73441. /**
  73442. * Moves the observable to the bottom of the observer list making it get called last when notified
  73443. * @param observer the observer to move
  73444. */
  73445. makeObserverBottomPriority(observer: Observer<T>): void;
  73446. /**
  73447. * Notify all Observers by calling their respective callback with the given data
  73448. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73449. * @param eventData defines the data to send to all observers
  73450. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73451. * @param target defines the original target of the state
  73452. * @param currentTarget defines the current target of the state
  73453. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73454. */
  73455. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73456. /**
  73457. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73458. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73459. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73460. * and it is crucial that all callbacks will be executed.
  73461. * The order of the callbacks is kept, callbacks are not executed parallel.
  73462. *
  73463. * @param eventData The data to be sent to each callback
  73464. * @param mask is used to filter observers defaults to -1
  73465. * @param target defines the callback target (see EventState)
  73466. * @param currentTarget defines he current object in the bubbling phase
  73467. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73468. */
  73469. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73470. /**
  73471. * Notify a specific observer
  73472. * @param observer defines the observer to notify
  73473. * @param eventData defines the data to be sent to each callback
  73474. * @param mask is used to filter observers defaults to -1
  73475. */
  73476. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73477. /**
  73478. * Gets a boolean indicating if the observable has at least one observer
  73479. * @returns true is the Observable has at least one Observer registered
  73480. */
  73481. hasObservers(): boolean;
  73482. /**
  73483. * Clear the list of observers
  73484. */
  73485. clear(): void;
  73486. /**
  73487. * Clone the current observable
  73488. * @returns a new observable
  73489. */
  73490. clone(): Observable<T>;
  73491. /**
  73492. * Does this observable handles observer registered with a given mask
  73493. * @param mask defines the mask to be tested
  73494. * @return whether or not one observer registered with the given mask is handeled
  73495. **/
  73496. hasSpecificMask(mask?: number): boolean;
  73497. }
  73498. }
  73499. declare module BABYLON {
  73500. /**
  73501. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73502. * Babylon.js
  73503. */
  73504. export class DomManagement {
  73505. /**
  73506. * Checks if the window object exists
  73507. * @returns true if the window object exists
  73508. */
  73509. static IsWindowObjectExist(): boolean;
  73510. /**
  73511. * Checks if the navigator object exists
  73512. * @returns true if the navigator object exists
  73513. */
  73514. static IsNavigatorAvailable(): boolean;
  73515. /**
  73516. * Extracts text content from a DOM element hierarchy
  73517. * @param element defines the root element
  73518. * @returns a string
  73519. */
  73520. static GetDOMTextContent(element: HTMLElement): string;
  73521. }
  73522. }
  73523. declare module BABYLON {
  73524. /**
  73525. * Logger used througouht the application to allow configuration of
  73526. * the log level required for the messages.
  73527. */
  73528. export class Logger {
  73529. /**
  73530. * No log
  73531. */
  73532. static readonly NoneLogLevel: number;
  73533. /**
  73534. * Only message logs
  73535. */
  73536. static readonly MessageLogLevel: number;
  73537. /**
  73538. * Only warning logs
  73539. */
  73540. static readonly WarningLogLevel: number;
  73541. /**
  73542. * Only error logs
  73543. */
  73544. static readonly ErrorLogLevel: number;
  73545. /**
  73546. * All logs
  73547. */
  73548. static readonly AllLogLevel: number;
  73549. private static _LogCache;
  73550. /**
  73551. * Gets a value indicating the number of loading errors
  73552. * @ignorenaming
  73553. */
  73554. static errorsCount: number;
  73555. /**
  73556. * Callback called when a new log is added
  73557. */
  73558. static OnNewCacheEntry: (entry: string) => void;
  73559. private static _AddLogEntry;
  73560. private static _FormatMessage;
  73561. private static _LogDisabled;
  73562. private static _LogEnabled;
  73563. private static _WarnDisabled;
  73564. private static _WarnEnabled;
  73565. private static _ErrorDisabled;
  73566. private static _ErrorEnabled;
  73567. /**
  73568. * Log a message to the console
  73569. */
  73570. static Log: (message: string) => void;
  73571. /**
  73572. * Write a warning message to the console
  73573. */
  73574. static Warn: (message: string) => void;
  73575. /**
  73576. * Write an error message to the console
  73577. */
  73578. static Error: (message: string) => void;
  73579. /**
  73580. * Gets current log cache (list of logs)
  73581. */
  73582. static get LogCache(): string;
  73583. /**
  73584. * Clears the log cache
  73585. */
  73586. static ClearLogCache(): void;
  73587. /**
  73588. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73589. */
  73590. static set LogLevels(level: number);
  73591. }
  73592. }
  73593. declare module BABYLON {
  73594. /** @hidden */
  73595. export class _TypeStore {
  73596. /** @hidden */
  73597. static RegisteredTypes: {
  73598. [key: string]: Object;
  73599. };
  73600. /** @hidden */
  73601. static GetClass(fqdn: string): any;
  73602. }
  73603. }
  73604. declare module BABYLON {
  73605. /**
  73606. * Helper to manipulate strings
  73607. */
  73608. export class StringTools {
  73609. /**
  73610. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73611. * @param str Source string
  73612. * @param suffix Suffix to search for in the source string
  73613. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73614. */
  73615. static EndsWith(str: string, suffix: string): boolean;
  73616. /**
  73617. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73618. * @param str Source string
  73619. * @param suffix Suffix to search for in the source string
  73620. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73621. */
  73622. static StartsWith(str: string, suffix: string): boolean;
  73623. /**
  73624. * Decodes a buffer into a string
  73625. * @param buffer The buffer to decode
  73626. * @returns The decoded string
  73627. */
  73628. static Decode(buffer: Uint8Array | Uint16Array): string;
  73629. /**
  73630. * Encode a buffer to a base64 string
  73631. * @param buffer defines the buffer to encode
  73632. * @returns the encoded string
  73633. */
  73634. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73635. }
  73636. }
  73637. declare module BABYLON {
  73638. /**
  73639. * Class containing a set of static utilities functions for deep copy.
  73640. */
  73641. export class DeepCopier {
  73642. /**
  73643. * Tries to copy an object by duplicating every property
  73644. * @param source defines the source object
  73645. * @param destination defines the target object
  73646. * @param doNotCopyList defines a list of properties to avoid
  73647. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73648. */
  73649. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73650. }
  73651. }
  73652. declare module BABYLON {
  73653. /**
  73654. * Class containing a set of static utilities functions for precision date
  73655. */
  73656. export class PrecisionDate {
  73657. /**
  73658. * Gets either window.performance.now() if supported or Date.now() else
  73659. */
  73660. static get Now(): number;
  73661. }
  73662. }
  73663. declare module BABYLON {
  73664. /** @hidden */
  73665. export class _DevTools {
  73666. static WarnImport(name: string): string;
  73667. }
  73668. }
  73669. declare module BABYLON {
  73670. /**
  73671. * Interface used to define the mechanism to get data from the network
  73672. */
  73673. export interface IWebRequest {
  73674. /**
  73675. * Returns client's response url
  73676. */
  73677. responseURL: string;
  73678. /**
  73679. * Returns client's status
  73680. */
  73681. status: number;
  73682. /**
  73683. * Returns client's status as a text
  73684. */
  73685. statusText: string;
  73686. }
  73687. }
  73688. declare module BABYLON {
  73689. /**
  73690. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73691. */
  73692. export class WebRequest implements IWebRequest {
  73693. private _xhr;
  73694. /**
  73695. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73696. * i.e. when loading files, where the server/service expects an Authorization header
  73697. */
  73698. static CustomRequestHeaders: {
  73699. [key: string]: string;
  73700. };
  73701. /**
  73702. * Add callback functions in this array to update all the requests before they get sent to the network
  73703. */
  73704. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73705. private _injectCustomRequestHeaders;
  73706. /**
  73707. * Gets or sets a function to be called when loading progress changes
  73708. */
  73709. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73710. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73711. /**
  73712. * Returns client's state
  73713. */
  73714. get readyState(): number;
  73715. /**
  73716. * Returns client's status
  73717. */
  73718. get status(): number;
  73719. /**
  73720. * Returns client's status as a text
  73721. */
  73722. get statusText(): string;
  73723. /**
  73724. * Returns client's response
  73725. */
  73726. get response(): any;
  73727. /**
  73728. * Returns client's response url
  73729. */
  73730. get responseURL(): string;
  73731. /**
  73732. * Returns client's response as text
  73733. */
  73734. get responseText(): string;
  73735. /**
  73736. * Gets or sets the expected response type
  73737. */
  73738. get responseType(): XMLHttpRequestResponseType;
  73739. set responseType(value: XMLHttpRequestResponseType);
  73740. /** @hidden */
  73741. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73742. /** @hidden */
  73743. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73744. /**
  73745. * Cancels any network activity
  73746. */
  73747. abort(): void;
  73748. /**
  73749. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73750. * @param body defines an optional request body
  73751. */
  73752. send(body?: Document | BodyInit | null): void;
  73753. /**
  73754. * Sets the request method, request URL
  73755. * @param method defines the method to use (GET, POST, etc..)
  73756. * @param url defines the url to connect with
  73757. */
  73758. open(method: string, url: string): void;
  73759. /**
  73760. * Sets the value of a request header.
  73761. * @param name The name of the header whose value is to be set
  73762. * @param value The value to set as the body of the header
  73763. */
  73764. setRequestHeader(name: string, value: string): void;
  73765. /**
  73766. * Get the string containing the text of a particular header's value.
  73767. * @param name The name of the header
  73768. * @returns The string containing the text of the given header name
  73769. */
  73770. getResponseHeader(name: string): Nullable<string>;
  73771. }
  73772. }
  73773. declare module BABYLON {
  73774. /**
  73775. * File request interface
  73776. */
  73777. export interface IFileRequest {
  73778. /**
  73779. * Raised when the request is complete (success or error).
  73780. */
  73781. onCompleteObservable: Observable<IFileRequest>;
  73782. /**
  73783. * Aborts the request for a file.
  73784. */
  73785. abort: () => void;
  73786. }
  73787. }
  73788. declare module BABYLON {
  73789. /**
  73790. * Define options used to create a render target texture
  73791. */
  73792. export class RenderTargetCreationOptions {
  73793. /**
  73794. * Specifies is mipmaps must be generated
  73795. */
  73796. generateMipMaps?: boolean;
  73797. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73798. generateDepthBuffer?: boolean;
  73799. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73800. generateStencilBuffer?: boolean;
  73801. /** Defines texture type (int by default) */
  73802. type?: number;
  73803. /** Defines sampling mode (trilinear by default) */
  73804. samplingMode?: number;
  73805. /** Defines format (RGBA by default) */
  73806. format?: number;
  73807. }
  73808. }
  73809. declare module BABYLON {
  73810. /** Defines the cross module used constants to avoid circular dependncies */
  73811. export class Constants {
  73812. /** Defines that alpha blending is disabled */
  73813. static readonly ALPHA_DISABLE: number;
  73814. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73815. static readonly ALPHA_ADD: number;
  73816. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73817. static readonly ALPHA_COMBINE: number;
  73818. /** Defines that alpha blending is DEST - SRC * DEST */
  73819. static readonly ALPHA_SUBTRACT: number;
  73820. /** Defines that alpha blending is SRC * DEST */
  73821. static readonly ALPHA_MULTIPLY: number;
  73822. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73823. static readonly ALPHA_MAXIMIZED: number;
  73824. /** Defines that alpha blending is SRC + DEST */
  73825. static readonly ALPHA_ONEONE: number;
  73826. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73827. static readonly ALPHA_PREMULTIPLIED: number;
  73828. /**
  73829. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73830. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73831. */
  73832. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73833. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73834. static readonly ALPHA_INTERPOLATE: number;
  73835. /**
  73836. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73837. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73838. */
  73839. static readonly ALPHA_SCREENMODE: number;
  73840. /**
  73841. * Defines that alpha blending is SRC + DST
  73842. * Alpha will be set to SRC ALPHA + DST ALPHA
  73843. */
  73844. static readonly ALPHA_ONEONE_ONEONE: number;
  73845. /**
  73846. * Defines that alpha blending is SRC * DST ALPHA + DST
  73847. * Alpha will be set to 0
  73848. */
  73849. static readonly ALPHA_ALPHATOCOLOR: number;
  73850. /**
  73851. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73852. */
  73853. static readonly ALPHA_REVERSEONEMINUS: number;
  73854. /**
  73855. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73856. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73857. */
  73858. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73859. /**
  73860. * Defines that alpha blending is SRC + DST
  73861. * Alpha will be set to SRC ALPHA
  73862. */
  73863. static readonly ALPHA_ONEONE_ONEZERO: number;
  73864. /**
  73865. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73866. * Alpha will be set to DST ALPHA
  73867. */
  73868. static readonly ALPHA_EXCLUSION: number;
  73869. /** Defines that alpha blending equation a SUM */
  73870. static readonly ALPHA_EQUATION_ADD: number;
  73871. /** Defines that alpha blending equation a SUBSTRACTION */
  73872. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73873. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73874. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73875. /** Defines that alpha blending equation a MAX operation */
  73876. static readonly ALPHA_EQUATION_MAX: number;
  73877. /** Defines that alpha blending equation a MIN operation */
  73878. static readonly ALPHA_EQUATION_MIN: number;
  73879. /**
  73880. * Defines that alpha blending equation a DARKEN operation:
  73881. * It takes the min of the src and sums the alpha channels.
  73882. */
  73883. static readonly ALPHA_EQUATION_DARKEN: number;
  73884. /** Defines that the ressource is not delayed*/
  73885. static readonly DELAYLOADSTATE_NONE: number;
  73886. /** Defines that the ressource was successfully delay loaded */
  73887. static readonly DELAYLOADSTATE_LOADED: number;
  73888. /** Defines that the ressource is currently delay loading */
  73889. static readonly DELAYLOADSTATE_LOADING: number;
  73890. /** Defines that the ressource is delayed and has not started loading */
  73891. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73892. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73893. static readonly NEVER: number;
  73894. /** 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 */
  73895. static readonly ALWAYS: number;
  73896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73897. static readonly LESS: number;
  73898. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73899. static readonly EQUAL: number;
  73900. /** 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 */
  73901. static readonly LEQUAL: number;
  73902. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73903. static readonly GREATER: number;
  73904. /** 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 */
  73905. static readonly GEQUAL: number;
  73906. /** 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 */
  73907. static readonly NOTEQUAL: number;
  73908. /** Passed to stencilOperation to specify that stencil value must be kept */
  73909. static readonly KEEP: number;
  73910. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73911. static readonly REPLACE: number;
  73912. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73913. static readonly INCR: number;
  73914. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73915. static readonly DECR: number;
  73916. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73917. static readonly INVERT: number;
  73918. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73919. static readonly INCR_WRAP: number;
  73920. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73921. static readonly DECR_WRAP: number;
  73922. /** Texture is not repeating outside of 0..1 UVs */
  73923. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73924. /** Texture is repeating outside of 0..1 UVs */
  73925. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73926. /** Texture is repeating and mirrored */
  73927. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73928. /** ALPHA */
  73929. static readonly TEXTUREFORMAT_ALPHA: number;
  73930. /** LUMINANCE */
  73931. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73932. /** LUMINANCE_ALPHA */
  73933. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73934. /** RGB */
  73935. static readonly TEXTUREFORMAT_RGB: number;
  73936. /** RGBA */
  73937. static readonly TEXTUREFORMAT_RGBA: number;
  73938. /** RED */
  73939. static readonly TEXTUREFORMAT_RED: number;
  73940. /** RED (2nd reference) */
  73941. static readonly TEXTUREFORMAT_R: number;
  73942. /** RG */
  73943. static readonly TEXTUREFORMAT_RG: number;
  73944. /** RED_INTEGER */
  73945. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73946. /** RED_INTEGER (2nd reference) */
  73947. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73948. /** RG_INTEGER */
  73949. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73950. /** RGB_INTEGER */
  73951. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73952. /** RGBA_INTEGER */
  73953. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73954. /** UNSIGNED_BYTE */
  73955. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73956. /** UNSIGNED_BYTE (2nd reference) */
  73957. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73958. /** FLOAT */
  73959. static readonly TEXTURETYPE_FLOAT: number;
  73960. /** HALF_FLOAT */
  73961. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73962. /** BYTE */
  73963. static readonly TEXTURETYPE_BYTE: number;
  73964. /** SHORT */
  73965. static readonly TEXTURETYPE_SHORT: number;
  73966. /** UNSIGNED_SHORT */
  73967. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73968. /** INT */
  73969. static readonly TEXTURETYPE_INT: number;
  73970. /** UNSIGNED_INT */
  73971. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73972. /** UNSIGNED_SHORT_4_4_4_4 */
  73973. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73974. /** UNSIGNED_SHORT_5_5_5_1 */
  73975. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73976. /** UNSIGNED_SHORT_5_6_5 */
  73977. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73978. /** UNSIGNED_INT_2_10_10_10_REV */
  73979. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73980. /** UNSIGNED_INT_24_8 */
  73981. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73982. /** UNSIGNED_INT_10F_11F_11F_REV */
  73983. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73984. /** UNSIGNED_INT_5_9_9_9_REV */
  73985. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73986. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73987. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73988. /** nearest is mag = nearest and min = nearest and no mip */
  73989. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73990. /** mag = nearest and min = nearest and mip = none */
  73991. static readonly TEXTURE_NEAREST_NEAREST: number;
  73992. /** Bilinear is mag = linear and min = linear and no mip */
  73993. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73994. /** mag = linear and min = linear and mip = none */
  73995. static readonly TEXTURE_LINEAR_LINEAR: number;
  73996. /** Trilinear is mag = linear and min = linear and mip = linear */
  73997. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73998. /** Trilinear is mag = linear and min = linear and mip = linear */
  73999. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74000. /** mag = nearest and min = nearest and mip = nearest */
  74001. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74002. /** mag = nearest and min = linear and mip = nearest */
  74003. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74004. /** mag = nearest and min = linear and mip = linear */
  74005. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74006. /** mag = nearest and min = linear and mip = none */
  74007. static readonly TEXTURE_NEAREST_LINEAR: number;
  74008. /** nearest is mag = nearest and min = nearest and mip = linear */
  74009. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74010. /** mag = linear and min = nearest and mip = nearest */
  74011. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74012. /** mag = linear and min = nearest and mip = linear */
  74013. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74014. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74015. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74016. /** mag = linear and min = nearest and mip = none */
  74017. static readonly TEXTURE_LINEAR_NEAREST: number;
  74018. /** Explicit coordinates mode */
  74019. static readonly TEXTURE_EXPLICIT_MODE: number;
  74020. /** Spherical coordinates mode */
  74021. static readonly TEXTURE_SPHERICAL_MODE: number;
  74022. /** Planar coordinates mode */
  74023. static readonly TEXTURE_PLANAR_MODE: number;
  74024. /** Cubic coordinates mode */
  74025. static readonly TEXTURE_CUBIC_MODE: number;
  74026. /** Projection coordinates mode */
  74027. static readonly TEXTURE_PROJECTION_MODE: number;
  74028. /** Skybox coordinates mode */
  74029. static readonly TEXTURE_SKYBOX_MODE: number;
  74030. /** Inverse Cubic coordinates mode */
  74031. static readonly TEXTURE_INVCUBIC_MODE: number;
  74032. /** Equirectangular coordinates mode */
  74033. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74034. /** Equirectangular Fixed coordinates mode */
  74035. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74036. /** Equirectangular Fixed Mirrored coordinates mode */
  74037. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74038. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74039. static readonly SCALEMODE_FLOOR: number;
  74040. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74041. static readonly SCALEMODE_NEAREST: number;
  74042. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74043. static readonly SCALEMODE_CEILING: number;
  74044. /**
  74045. * The dirty texture flag value
  74046. */
  74047. static readonly MATERIAL_TextureDirtyFlag: number;
  74048. /**
  74049. * The dirty light flag value
  74050. */
  74051. static readonly MATERIAL_LightDirtyFlag: number;
  74052. /**
  74053. * The dirty fresnel flag value
  74054. */
  74055. static readonly MATERIAL_FresnelDirtyFlag: number;
  74056. /**
  74057. * The dirty attribute flag value
  74058. */
  74059. static readonly MATERIAL_AttributesDirtyFlag: number;
  74060. /**
  74061. * The dirty misc flag value
  74062. */
  74063. static readonly MATERIAL_MiscDirtyFlag: number;
  74064. /**
  74065. * The all dirty flag value
  74066. */
  74067. static readonly MATERIAL_AllDirtyFlag: number;
  74068. /**
  74069. * Returns the triangle fill mode
  74070. */
  74071. static readonly MATERIAL_TriangleFillMode: number;
  74072. /**
  74073. * Returns the wireframe mode
  74074. */
  74075. static readonly MATERIAL_WireFrameFillMode: number;
  74076. /**
  74077. * Returns the point fill mode
  74078. */
  74079. static readonly MATERIAL_PointFillMode: number;
  74080. /**
  74081. * Returns the point list draw mode
  74082. */
  74083. static readonly MATERIAL_PointListDrawMode: number;
  74084. /**
  74085. * Returns the line list draw mode
  74086. */
  74087. static readonly MATERIAL_LineListDrawMode: number;
  74088. /**
  74089. * Returns the line loop draw mode
  74090. */
  74091. static readonly MATERIAL_LineLoopDrawMode: number;
  74092. /**
  74093. * Returns the line strip draw mode
  74094. */
  74095. static readonly MATERIAL_LineStripDrawMode: number;
  74096. /**
  74097. * Returns the triangle strip draw mode
  74098. */
  74099. static readonly MATERIAL_TriangleStripDrawMode: number;
  74100. /**
  74101. * Returns the triangle fan draw mode
  74102. */
  74103. static readonly MATERIAL_TriangleFanDrawMode: number;
  74104. /**
  74105. * Stores the clock-wise side orientation
  74106. */
  74107. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74108. /**
  74109. * Stores the counter clock-wise side orientation
  74110. */
  74111. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74112. /**
  74113. * Nothing
  74114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74115. */
  74116. static readonly ACTION_NothingTrigger: number;
  74117. /**
  74118. * On pick
  74119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74120. */
  74121. static readonly ACTION_OnPickTrigger: number;
  74122. /**
  74123. * On left pick
  74124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74125. */
  74126. static readonly ACTION_OnLeftPickTrigger: number;
  74127. /**
  74128. * On right pick
  74129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74130. */
  74131. static readonly ACTION_OnRightPickTrigger: number;
  74132. /**
  74133. * On center pick
  74134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74135. */
  74136. static readonly ACTION_OnCenterPickTrigger: number;
  74137. /**
  74138. * On pick down
  74139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74140. */
  74141. static readonly ACTION_OnPickDownTrigger: number;
  74142. /**
  74143. * On double pick
  74144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74145. */
  74146. static readonly ACTION_OnDoublePickTrigger: number;
  74147. /**
  74148. * On pick up
  74149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74150. */
  74151. static readonly ACTION_OnPickUpTrigger: number;
  74152. /**
  74153. * On pick out.
  74154. * This trigger will only be raised if you also declared a OnPickDown
  74155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74156. */
  74157. static readonly ACTION_OnPickOutTrigger: number;
  74158. /**
  74159. * On long press
  74160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74161. */
  74162. static readonly ACTION_OnLongPressTrigger: number;
  74163. /**
  74164. * On pointer over
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74166. */
  74167. static readonly ACTION_OnPointerOverTrigger: number;
  74168. /**
  74169. * On pointer out
  74170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74171. */
  74172. static readonly ACTION_OnPointerOutTrigger: number;
  74173. /**
  74174. * On every frame
  74175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74176. */
  74177. static readonly ACTION_OnEveryFrameTrigger: number;
  74178. /**
  74179. * On intersection enter
  74180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74181. */
  74182. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74183. /**
  74184. * On intersection exit
  74185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74186. */
  74187. static readonly ACTION_OnIntersectionExitTrigger: number;
  74188. /**
  74189. * On key down
  74190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74191. */
  74192. static readonly ACTION_OnKeyDownTrigger: number;
  74193. /**
  74194. * On key up
  74195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74196. */
  74197. static readonly ACTION_OnKeyUpTrigger: number;
  74198. /**
  74199. * Billboard mode will only apply to Y axis
  74200. */
  74201. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74202. /**
  74203. * Billboard mode will apply to all axes
  74204. */
  74205. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74206. /**
  74207. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74208. */
  74209. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74210. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74211. * Test order :
  74212. * Is the bounding sphere outside the frustum ?
  74213. * If not, are the bounding box vertices outside the frustum ?
  74214. * It not, then the cullable object is in the frustum.
  74215. */
  74216. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74217. /** Culling strategy : Bounding Sphere Only.
  74218. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74219. * It's also less accurate than the standard because some not visible objects can still be selected.
  74220. * Test : is the bounding sphere outside the frustum ?
  74221. * If not, then the cullable object is in the frustum.
  74222. */
  74223. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74224. /** Culling strategy : Optimistic Inclusion.
  74225. * This in an inclusion test first, then the standard exclusion test.
  74226. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74227. * 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.
  74228. * Anyway, it's as accurate as the standard strategy.
  74229. * Test :
  74230. * Is the cullable object bounding sphere center in the frustum ?
  74231. * If not, apply the default culling strategy.
  74232. */
  74233. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74234. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74235. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74236. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74237. * 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.
  74238. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74239. * Test :
  74240. * Is the cullable object bounding sphere center in the frustum ?
  74241. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74242. */
  74243. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74244. /**
  74245. * No logging while loading
  74246. */
  74247. static readonly SCENELOADER_NO_LOGGING: number;
  74248. /**
  74249. * Minimal logging while loading
  74250. */
  74251. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74252. /**
  74253. * Summary logging while loading
  74254. */
  74255. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74256. /**
  74257. * Detailled logging while loading
  74258. */
  74259. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * This represents the required contract to create a new type of texture loader.
  74265. */
  74266. export interface IInternalTextureLoader {
  74267. /**
  74268. * Defines wether the loader supports cascade loading the different faces.
  74269. */
  74270. supportCascades: boolean;
  74271. /**
  74272. * This returns if the loader support the current file information.
  74273. * @param extension defines the file extension of the file being loaded
  74274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74275. * @param fallback defines the fallback internal texture if any
  74276. * @param isBase64 defines whether the texture is encoded as a base64
  74277. * @param isBuffer defines whether the texture data are stored as a buffer
  74278. * @returns true if the loader can load the specified file
  74279. */
  74280. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74281. /**
  74282. * Transform the url before loading if required.
  74283. * @param rootUrl the url of the texture
  74284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74285. * @returns the transformed texture
  74286. */
  74287. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74288. /**
  74289. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74290. * @param rootUrl the url of the texture
  74291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74292. * @returns the fallback texture
  74293. */
  74294. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74295. /**
  74296. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74297. * @param data contains the texture data
  74298. * @param texture defines the BabylonJS internal texture
  74299. * @param createPolynomials will be true if polynomials have been requested
  74300. * @param onLoad defines the callback to trigger once the texture is ready
  74301. * @param onError defines the callback to trigger in case of error
  74302. */
  74303. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74304. /**
  74305. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74306. * @param data contains the texture data
  74307. * @param texture defines the BabylonJS internal texture
  74308. * @param callback defines the method to call once ready to upload
  74309. */
  74310. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * Class used to store and describe the pipeline context associated with an effect
  74316. */
  74317. export interface IPipelineContext {
  74318. /**
  74319. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74320. */
  74321. isAsync: boolean;
  74322. /**
  74323. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74324. */
  74325. isReady: boolean;
  74326. /** @hidden */
  74327. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * Class used to store gfx data (like WebGLBuffer)
  74333. */
  74334. export class DataBuffer {
  74335. /**
  74336. * Gets or sets the number of objects referencing this buffer
  74337. */
  74338. references: number;
  74339. /** Gets or sets the size of the underlying buffer */
  74340. capacity: number;
  74341. /**
  74342. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74343. */
  74344. is32Bits: boolean;
  74345. /**
  74346. * Gets the underlying buffer
  74347. */
  74348. get underlyingResource(): any;
  74349. }
  74350. }
  74351. declare module BABYLON {
  74352. /** @hidden */
  74353. export interface IShaderProcessor {
  74354. attributeProcessor?: (attribute: string) => string;
  74355. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74356. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74357. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74358. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74359. lineProcessor?: (line: string, isFragment: boolean) => string;
  74360. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74361. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74362. }
  74363. }
  74364. declare module BABYLON {
  74365. /** @hidden */
  74366. export interface ProcessingOptions {
  74367. defines: string[];
  74368. indexParameters: any;
  74369. isFragment: boolean;
  74370. shouldUseHighPrecisionShader: boolean;
  74371. supportsUniformBuffers: boolean;
  74372. shadersRepository: string;
  74373. includesShadersStore: {
  74374. [key: string]: string;
  74375. };
  74376. processor?: IShaderProcessor;
  74377. version: string;
  74378. platformName: string;
  74379. lookForClosingBracketForUniformBuffer?: boolean;
  74380. }
  74381. }
  74382. declare module BABYLON {
  74383. /** @hidden */
  74384. export class ShaderCodeNode {
  74385. line: string;
  74386. children: ShaderCodeNode[];
  74387. additionalDefineKey?: string;
  74388. additionalDefineValue?: string;
  74389. isValid(preprocessors: {
  74390. [key: string]: string;
  74391. }): boolean;
  74392. process(preprocessors: {
  74393. [key: string]: string;
  74394. }, options: ProcessingOptions): string;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /** @hidden */
  74399. export class ShaderCodeCursor {
  74400. private _lines;
  74401. lineIndex: number;
  74402. get currentLine(): string;
  74403. get canRead(): boolean;
  74404. set lines(value: string[]);
  74405. }
  74406. }
  74407. declare module BABYLON {
  74408. /** @hidden */
  74409. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74410. process(preprocessors: {
  74411. [key: string]: string;
  74412. }, options: ProcessingOptions): string;
  74413. }
  74414. }
  74415. declare module BABYLON {
  74416. /** @hidden */
  74417. export class ShaderDefineExpression {
  74418. isTrue(preprocessors: {
  74419. [key: string]: string;
  74420. }): boolean;
  74421. }
  74422. }
  74423. declare module BABYLON {
  74424. /** @hidden */
  74425. export class ShaderCodeTestNode extends ShaderCodeNode {
  74426. testExpression: ShaderDefineExpression;
  74427. isValid(preprocessors: {
  74428. [key: string]: string;
  74429. }): boolean;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /** @hidden */
  74434. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74435. define: string;
  74436. not: boolean;
  74437. constructor(define: string, not?: boolean);
  74438. isTrue(preprocessors: {
  74439. [key: string]: string;
  74440. }): boolean;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /** @hidden */
  74445. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74446. leftOperand: ShaderDefineExpression;
  74447. rightOperand: ShaderDefineExpression;
  74448. isTrue(preprocessors: {
  74449. [key: string]: string;
  74450. }): boolean;
  74451. }
  74452. }
  74453. declare module BABYLON {
  74454. /** @hidden */
  74455. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74456. leftOperand: ShaderDefineExpression;
  74457. rightOperand: ShaderDefineExpression;
  74458. isTrue(preprocessors: {
  74459. [key: string]: string;
  74460. }): boolean;
  74461. }
  74462. }
  74463. declare module BABYLON {
  74464. /** @hidden */
  74465. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74466. define: string;
  74467. operand: string;
  74468. testValue: string;
  74469. constructor(define: string, operand: string, testValue: string);
  74470. isTrue(preprocessors: {
  74471. [key: string]: string;
  74472. }): boolean;
  74473. }
  74474. }
  74475. declare module BABYLON {
  74476. /**
  74477. * Class used to enable access to offline support
  74478. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74479. */
  74480. export interface IOfflineProvider {
  74481. /**
  74482. * Gets a boolean indicating if scene must be saved in the database
  74483. */
  74484. enableSceneOffline: boolean;
  74485. /**
  74486. * Gets a boolean indicating if textures must be saved in the database
  74487. */
  74488. enableTexturesOffline: boolean;
  74489. /**
  74490. * Open the offline support and make it available
  74491. * @param successCallback defines the callback to call on success
  74492. * @param errorCallback defines the callback to call on error
  74493. */
  74494. open(successCallback: () => void, errorCallback: () => void): void;
  74495. /**
  74496. * Loads an image from the offline support
  74497. * @param url defines the url to load from
  74498. * @param image defines the target DOM image
  74499. */
  74500. loadImage(url: string, image: HTMLImageElement): void;
  74501. /**
  74502. * Loads a file from offline support
  74503. * @param url defines the URL to load from
  74504. * @param sceneLoaded defines a callback to call on success
  74505. * @param progressCallBack defines a callback to call when progress changed
  74506. * @param errorCallback defines a callback to call on error
  74507. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74508. */
  74509. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74510. }
  74511. }
  74512. declare module BABYLON {
  74513. /**
  74514. * Class used to help managing file picking and drag'n'drop
  74515. * File Storage
  74516. */
  74517. export class FilesInputStore {
  74518. /**
  74519. * List of files ready to be loaded
  74520. */
  74521. static FilesToLoad: {
  74522. [key: string]: File;
  74523. };
  74524. }
  74525. }
  74526. declare module BABYLON {
  74527. /**
  74528. * Class used to define a retry strategy when error happens while loading assets
  74529. */
  74530. export class RetryStrategy {
  74531. /**
  74532. * Function used to defines an exponential back off strategy
  74533. * @param maxRetries defines the maximum number of retries (3 by default)
  74534. * @param baseInterval defines the interval between retries
  74535. * @returns the strategy function to use
  74536. */
  74537. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74538. }
  74539. }
  74540. declare module BABYLON {
  74541. /**
  74542. * @ignore
  74543. * Application error to support additional information when loading a file
  74544. */
  74545. export abstract class BaseError extends Error {
  74546. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /** @ignore */
  74551. export class LoadFileError extends BaseError {
  74552. request?: WebRequest;
  74553. file?: File;
  74554. /**
  74555. * Creates a new LoadFileError
  74556. * @param message defines the message of the error
  74557. * @param request defines the optional web request
  74558. * @param file defines the optional file
  74559. */
  74560. constructor(message: string, object?: WebRequest | File);
  74561. }
  74562. /** @ignore */
  74563. export class RequestFileError extends BaseError {
  74564. request: WebRequest;
  74565. /**
  74566. * Creates a new LoadFileError
  74567. * @param message defines the message of the error
  74568. * @param request defines the optional web request
  74569. */
  74570. constructor(message: string, request: WebRequest);
  74571. }
  74572. /** @ignore */
  74573. export class ReadFileError extends BaseError {
  74574. file: File;
  74575. /**
  74576. * Creates a new ReadFileError
  74577. * @param message defines the message of the error
  74578. * @param file defines the optional file
  74579. */
  74580. constructor(message: string, file: File);
  74581. }
  74582. /**
  74583. * @hidden
  74584. */
  74585. export class FileTools {
  74586. /**
  74587. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74588. */
  74589. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74590. /**
  74591. * Gets or sets the base URL to use to load assets
  74592. */
  74593. static BaseUrl: string;
  74594. /**
  74595. * Default behaviour for cors in the application.
  74596. * It can be a string if the expected behavior is identical in the entire app.
  74597. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74598. */
  74599. static CorsBehavior: string | ((url: string | string[]) => string);
  74600. /**
  74601. * Gets or sets a function used to pre-process url before using them to load assets
  74602. */
  74603. static PreprocessUrl: (url: string) => string;
  74604. /**
  74605. * Removes unwanted characters from an url
  74606. * @param url defines the url to clean
  74607. * @returns the cleaned url
  74608. */
  74609. private static _CleanUrl;
  74610. /**
  74611. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74612. * @param url define the url we are trying
  74613. * @param element define the dom element where to configure the cors policy
  74614. */
  74615. static SetCorsBehavior(url: string | string[], element: {
  74616. crossOrigin: string | null;
  74617. }): void;
  74618. /**
  74619. * Loads an image as an HTMLImageElement.
  74620. * @param input url string, ArrayBuffer, or Blob to load
  74621. * @param onLoad callback called when the image successfully loads
  74622. * @param onError callback called when the image fails to load
  74623. * @param offlineProvider offline provider for caching
  74624. * @param mimeType optional mime type
  74625. * @returns the HTMLImageElement of the loaded image
  74626. */
  74627. 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>;
  74628. /**
  74629. * Reads a file from a File object
  74630. * @param file defines the file to load
  74631. * @param onSuccess defines the callback to call when data is loaded
  74632. * @param onProgress defines the callback to call during loading process
  74633. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74634. * @param onError defines the callback to call when an error occurs
  74635. * @returns a file request object
  74636. */
  74637. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74638. /**
  74639. * Loads a file from a url
  74640. * @param url url to load
  74641. * @param onSuccess callback called when the file successfully loads
  74642. * @param onProgress callback called while file is loading (if the server supports this mode)
  74643. * @param offlineProvider defines the offline provider for caching
  74644. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74645. * @param onError callback called when the file fails to load
  74646. * @returns a file request object
  74647. */
  74648. 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;
  74649. /**
  74650. * Loads a file
  74651. * @param url url to load
  74652. * @param onSuccess callback called when the file successfully loads
  74653. * @param onProgress callback called while file is loading (if the server supports this mode)
  74654. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74655. * @param onError callback called when the file fails to load
  74656. * @param onOpened callback called when the web request is opened
  74657. * @returns a file request object
  74658. */
  74659. 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;
  74660. /**
  74661. * Checks if the loaded document was accessed via `file:`-Protocol.
  74662. * @returns boolean
  74663. */
  74664. static IsFileURL(): boolean;
  74665. }
  74666. }
  74667. declare module BABYLON {
  74668. /** @hidden */
  74669. export class ShaderProcessor {
  74670. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74671. private static _ProcessPrecision;
  74672. private static _ExtractOperation;
  74673. private static _BuildSubExpression;
  74674. private static _BuildExpression;
  74675. private static _MoveCursorWithinIf;
  74676. private static _MoveCursor;
  74677. private static _EvaluatePreProcessors;
  74678. private static _PreparePreProcessors;
  74679. private static _ProcessShaderConversion;
  74680. private static _ProcessIncludes;
  74681. /**
  74682. * Loads a file from a url
  74683. * @param url url to load
  74684. * @param onSuccess callback called when the file successfully loads
  74685. * @param onProgress callback called while file is loading (if the server supports this mode)
  74686. * @param offlineProvider defines the offline provider for caching
  74687. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74688. * @param onError callback called when the file fails to load
  74689. * @returns a file request object
  74690. * @hidden
  74691. */
  74692. 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;
  74693. }
  74694. }
  74695. declare module BABYLON {
  74696. /**
  74697. * @hidden
  74698. */
  74699. export interface IColor4Like {
  74700. r: float;
  74701. g: float;
  74702. b: float;
  74703. a: float;
  74704. }
  74705. /**
  74706. * @hidden
  74707. */
  74708. export interface IColor3Like {
  74709. r: float;
  74710. g: float;
  74711. b: float;
  74712. }
  74713. /**
  74714. * @hidden
  74715. */
  74716. export interface IVector4Like {
  74717. x: float;
  74718. y: float;
  74719. z: float;
  74720. w: float;
  74721. }
  74722. /**
  74723. * @hidden
  74724. */
  74725. export interface IVector3Like {
  74726. x: float;
  74727. y: float;
  74728. z: float;
  74729. }
  74730. /**
  74731. * @hidden
  74732. */
  74733. export interface IVector2Like {
  74734. x: float;
  74735. y: float;
  74736. }
  74737. /**
  74738. * @hidden
  74739. */
  74740. export interface IMatrixLike {
  74741. toArray(): DeepImmutable<Float32Array>;
  74742. updateFlag: int;
  74743. }
  74744. /**
  74745. * @hidden
  74746. */
  74747. export interface IViewportLike {
  74748. x: float;
  74749. y: float;
  74750. width: float;
  74751. height: float;
  74752. }
  74753. /**
  74754. * @hidden
  74755. */
  74756. export interface IPlaneLike {
  74757. normal: IVector3Like;
  74758. d: float;
  74759. normalize(): void;
  74760. }
  74761. }
  74762. declare module BABYLON {
  74763. /**
  74764. * Interface used to define common properties for effect fallbacks
  74765. */
  74766. export interface IEffectFallbacks {
  74767. /**
  74768. * Removes the defines that should be removed when falling back.
  74769. * @param currentDefines defines the current define statements for the shader.
  74770. * @param effect defines the current effect we try to compile
  74771. * @returns The resulting defines with defines of the current rank removed.
  74772. */
  74773. reduce(currentDefines: string, effect: Effect): string;
  74774. /**
  74775. * Removes the fallback from the bound mesh.
  74776. */
  74777. unBindMesh(): void;
  74778. /**
  74779. * Checks to see if more fallbacks are still availible.
  74780. */
  74781. hasMoreFallbacks: boolean;
  74782. }
  74783. }
  74784. declare module BABYLON {
  74785. /**
  74786. * Class used to evalaute queries containing `and` and `or` operators
  74787. */
  74788. export class AndOrNotEvaluator {
  74789. /**
  74790. * Evaluate a query
  74791. * @param query defines the query to evaluate
  74792. * @param evaluateCallback defines the callback used to filter result
  74793. * @returns true if the query matches
  74794. */
  74795. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74796. private static _HandleParenthesisContent;
  74797. private static _SimplifyNegation;
  74798. }
  74799. }
  74800. declare module BABYLON {
  74801. /**
  74802. * Class used to store custom tags
  74803. */
  74804. export class Tags {
  74805. /**
  74806. * Adds support for tags on the given object
  74807. * @param obj defines the object to use
  74808. */
  74809. static EnableFor(obj: any): void;
  74810. /**
  74811. * Removes tags support
  74812. * @param obj defines the object to use
  74813. */
  74814. static DisableFor(obj: any): void;
  74815. /**
  74816. * Gets a boolean indicating if the given object has tags
  74817. * @param obj defines the object to use
  74818. * @returns a boolean
  74819. */
  74820. static HasTags(obj: any): boolean;
  74821. /**
  74822. * Gets the tags available on a given object
  74823. * @param obj defines the object to use
  74824. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74825. * @returns the tags
  74826. */
  74827. static GetTags(obj: any, asString?: boolean): any;
  74828. /**
  74829. * Adds tags to an object
  74830. * @param obj defines the object to use
  74831. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74832. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74833. */
  74834. static AddTagsTo(obj: any, tagsString: string): void;
  74835. /**
  74836. * @hidden
  74837. */
  74838. static _AddTagTo(obj: any, tag: string): void;
  74839. /**
  74840. * Removes specific tags from a specific object
  74841. * @param obj defines the object to use
  74842. * @param tagsString defines the tags to remove
  74843. */
  74844. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74845. /**
  74846. * @hidden
  74847. */
  74848. static _RemoveTagFrom(obj: any, tag: string): void;
  74849. /**
  74850. * Defines if tags hosted on an object match a given query
  74851. * @param obj defines the object to use
  74852. * @param tagsQuery defines the tag query
  74853. * @returns a boolean
  74854. */
  74855. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74856. }
  74857. }
  74858. declare module BABYLON {
  74859. /**
  74860. * Scalar computation library
  74861. */
  74862. export class Scalar {
  74863. /**
  74864. * Two pi constants convenient for computation.
  74865. */
  74866. static TwoPi: number;
  74867. /**
  74868. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74869. * @param a number
  74870. * @param b number
  74871. * @param epsilon (default = 1.401298E-45)
  74872. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74873. */
  74874. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74875. /**
  74876. * Returns a string : the upper case translation of the number i to hexadecimal.
  74877. * @param i number
  74878. * @returns the upper case translation of the number i to hexadecimal.
  74879. */
  74880. static ToHex(i: number): string;
  74881. /**
  74882. * Returns -1 if value is negative and +1 is value is positive.
  74883. * @param value the value
  74884. * @returns the value itself if it's equal to zero.
  74885. */
  74886. static Sign(value: number): number;
  74887. /**
  74888. * Returns the value itself if it's between min and max.
  74889. * Returns min if the value is lower than min.
  74890. * Returns max if the value is greater than max.
  74891. * @param value the value to clmap
  74892. * @param min the min value to clamp to (default: 0)
  74893. * @param max the max value to clamp to (default: 1)
  74894. * @returns the clamped value
  74895. */
  74896. static Clamp(value: number, min?: number, max?: number): number;
  74897. /**
  74898. * the log2 of value.
  74899. * @param value the value to compute log2 of
  74900. * @returns the log2 of value.
  74901. */
  74902. static Log2(value: number): number;
  74903. /**
  74904. * Loops the value, so that it is never larger than length and never smaller than 0.
  74905. *
  74906. * This is similar to the modulo operator but it works with floating point numbers.
  74907. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74908. * With t = 5 and length = 2.5, the result would be 0.0.
  74909. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74910. * @param value the value
  74911. * @param length the length
  74912. * @returns the looped value
  74913. */
  74914. static Repeat(value: number, length: number): number;
  74915. /**
  74916. * Normalize the value between 0.0 and 1.0 using min and max values
  74917. * @param value value to normalize
  74918. * @param min max to normalize between
  74919. * @param max min to normalize between
  74920. * @returns the normalized value
  74921. */
  74922. static Normalize(value: number, min: number, max: number): number;
  74923. /**
  74924. * Denormalize the value from 0.0 and 1.0 using min and max values
  74925. * @param normalized value to denormalize
  74926. * @param min max to denormalize between
  74927. * @param max min to denormalize between
  74928. * @returns the denormalized value
  74929. */
  74930. static Denormalize(normalized: number, min: number, max: number): number;
  74931. /**
  74932. * Calculates the shortest difference between two given angles given in degrees.
  74933. * @param current current angle in degrees
  74934. * @param target target angle in degrees
  74935. * @returns the delta
  74936. */
  74937. static DeltaAngle(current: number, target: number): number;
  74938. /**
  74939. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74940. * @param tx value
  74941. * @param length length
  74942. * @returns The returned value will move back and forth between 0 and length
  74943. */
  74944. static PingPong(tx: number, length: number): number;
  74945. /**
  74946. * Interpolates between min and max with smoothing at the limits.
  74947. *
  74948. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74949. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74950. * @param from from
  74951. * @param to to
  74952. * @param tx value
  74953. * @returns the smooth stepped value
  74954. */
  74955. static SmoothStep(from: number, to: number, tx: number): number;
  74956. /**
  74957. * Moves a value current towards target.
  74958. *
  74959. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74960. * Negative values of maxDelta pushes the value away from target.
  74961. * @param current current value
  74962. * @param target target value
  74963. * @param maxDelta max distance to move
  74964. * @returns resulting value
  74965. */
  74966. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74967. /**
  74968. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74969. *
  74970. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74971. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74972. * @param current current value
  74973. * @param target target value
  74974. * @param maxDelta max distance to move
  74975. * @returns resulting angle
  74976. */
  74977. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74978. /**
  74979. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74980. * @param start start value
  74981. * @param end target value
  74982. * @param amount amount to lerp between
  74983. * @returns the lerped value
  74984. */
  74985. static Lerp(start: number, end: number, amount: number): number;
  74986. /**
  74987. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74988. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74989. * @param start start value
  74990. * @param end target value
  74991. * @param amount amount to lerp between
  74992. * @returns the lerped value
  74993. */
  74994. static LerpAngle(start: number, end: number, amount: number): number;
  74995. /**
  74996. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74997. * @param a start value
  74998. * @param b target value
  74999. * @param value value between a and b
  75000. * @returns the inverseLerp value
  75001. */
  75002. static InverseLerp(a: number, b: number, value: number): number;
  75003. /**
  75004. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75005. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75006. * @param value1 spline value
  75007. * @param tangent1 spline value
  75008. * @param value2 spline value
  75009. * @param tangent2 spline value
  75010. * @param amount input value
  75011. * @returns hermite result
  75012. */
  75013. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75014. /**
  75015. * Returns a random float number between and min and max values
  75016. * @param min min value of random
  75017. * @param max max value of random
  75018. * @returns random value
  75019. */
  75020. static RandomRange(min: number, max: number): number;
  75021. /**
  75022. * This function returns percentage of a number in a given range.
  75023. *
  75024. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75025. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75026. * @param number to convert to percentage
  75027. * @param min min range
  75028. * @param max max range
  75029. * @returns the percentage
  75030. */
  75031. static RangeToPercent(number: number, min: number, max: number): number;
  75032. /**
  75033. * This function returns number that corresponds to the percentage in a given range.
  75034. *
  75035. * PercentToRange(0.34,0,100) will return 34.
  75036. * @param percent to convert to number
  75037. * @param min min range
  75038. * @param max max range
  75039. * @returns the number
  75040. */
  75041. static PercentToRange(percent: number, min: number, max: number): number;
  75042. /**
  75043. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75044. * @param angle The angle to normalize in radian.
  75045. * @return The converted angle.
  75046. */
  75047. static NormalizeRadians(angle: number): number;
  75048. }
  75049. }
  75050. declare module BABYLON {
  75051. /**
  75052. * Constant used to convert a value to gamma space
  75053. * @ignorenaming
  75054. */
  75055. export const ToGammaSpace: number;
  75056. /**
  75057. * Constant used to convert a value to linear space
  75058. * @ignorenaming
  75059. */
  75060. export const ToLinearSpace = 2.2;
  75061. /**
  75062. * Constant used to define the minimal number value in Babylon.js
  75063. * @ignorenaming
  75064. */
  75065. let Epsilon: number;
  75066. }
  75067. declare module BABYLON {
  75068. /**
  75069. * Class used to represent a viewport on screen
  75070. */
  75071. export class Viewport {
  75072. /** viewport left coordinate */
  75073. x: number;
  75074. /** viewport top coordinate */
  75075. y: number;
  75076. /**viewport width */
  75077. width: number;
  75078. /** viewport height */
  75079. height: number;
  75080. /**
  75081. * Creates a Viewport object located at (x, y) and sized (width, height)
  75082. * @param x defines viewport left coordinate
  75083. * @param y defines viewport top coordinate
  75084. * @param width defines the viewport width
  75085. * @param height defines the viewport height
  75086. */
  75087. constructor(
  75088. /** viewport left coordinate */
  75089. x: number,
  75090. /** viewport top coordinate */
  75091. y: number,
  75092. /**viewport width */
  75093. width: number,
  75094. /** viewport height */
  75095. height: number);
  75096. /**
  75097. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75098. * @param renderWidth defines the rendering width
  75099. * @param renderHeight defines the rendering height
  75100. * @returns a new Viewport
  75101. */
  75102. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75103. /**
  75104. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75105. * @param renderWidth defines the rendering width
  75106. * @param renderHeight defines the rendering height
  75107. * @param ref defines the target viewport
  75108. * @returns the current viewport
  75109. */
  75110. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75111. /**
  75112. * Returns a new Viewport copied from the current one
  75113. * @returns a new Viewport
  75114. */
  75115. clone(): Viewport;
  75116. }
  75117. }
  75118. declare module BABYLON {
  75119. /**
  75120. * Class containing a set of static utilities functions for arrays.
  75121. */
  75122. export class ArrayTools {
  75123. /**
  75124. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75125. * @param size the number of element to construct and put in the array
  75126. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75127. * @returns a new array filled with new objects
  75128. */
  75129. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75130. }
  75131. }
  75132. declare module BABYLON {
  75133. /**
  75134. * Class representing a vector containing 2 coordinates
  75135. */
  75136. export class Vector2 {
  75137. /** defines the first coordinate */
  75138. x: number;
  75139. /** defines the second coordinate */
  75140. y: number;
  75141. /**
  75142. * Creates a new Vector2 from the given x and y coordinates
  75143. * @param x defines the first coordinate
  75144. * @param y defines the second coordinate
  75145. */
  75146. constructor(
  75147. /** defines the first coordinate */
  75148. x?: number,
  75149. /** defines the second coordinate */
  75150. y?: number);
  75151. /**
  75152. * Gets a string with the Vector2 coordinates
  75153. * @returns a string with the Vector2 coordinates
  75154. */
  75155. toString(): string;
  75156. /**
  75157. * Gets class name
  75158. * @returns the string "Vector2"
  75159. */
  75160. getClassName(): string;
  75161. /**
  75162. * Gets current vector hash code
  75163. * @returns the Vector2 hash code as a number
  75164. */
  75165. getHashCode(): number;
  75166. /**
  75167. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75168. * @param array defines the source array
  75169. * @param index defines the offset in source array
  75170. * @returns the current Vector2
  75171. */
  75172. toArray(array: FloatArray, index?: number): Vector2;
  75173. /**
  75174. * Copy the current vector to an array
  75175. * @returns a new array with 2 elements: the Vector2 coordinates.
  75176. */
  75177. asArray(): number[];
  75178. /**
  75179. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75180. * @param source defines the source Vector2
  75181. * @returns the current updated Vector2
  75182. */
  75183. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75184. /**
  75185. * Sets the Vector2 coordinates with the given floats
  75186. * @param x defines the first coordinate
  75187. * @param y defines the second coordinate
  75188. * @returns the current updated Vector2
  75189. */
  75190. copyFromFloats(x: number, y: number): Vector2;
  75191. /**
  75192. * Sets the Vector2 coordinates with the given floats
  75193. * @param x defines the first coordinate
  75194. * @param y defines the second coordinate
  75195. * @returns the current updated Vector2
  75196. */
  75197. set(x: number, y: number): Vector2;
  75198. /**
  75199. * Add another vector with the current one
  75200. * @param otherVector defines the other vector
  75201. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75202. */
  75203. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75204. /**
  75205. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75206. * @param otherVector defines the other vector
  75207. * @param result defines the target vector
  75208. * @returns the unmodified current Vector2
  75209. */
  75210. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75211. /**
  75212. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75213. * @param otherVector defines the other vector
  75214. * @returns the current updated Vector2
  75215. */
  75216. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75217. /**
  75218. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75219. * @param otherVector defines the other vector
  75220. * @returns a new Vector2
  75221. */
  75222. addVector3(otherVector: Vector3): Vector2;
  75223. /**
  75224. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75225. * @param otherVector defines the other vector
  75226. * @returns a new Vector2
  75227. */
  75228. subtract(otherVector: Vector2): Vector2;
  75229. /**
  75230. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75231. * @param otherVector defines the other vector
  75232. * @param result defines the target vector
  75233. * @returns the unmodified current Vector2
  75234. */
  75235. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75236. /**
  75237. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75238. * @param otherVector defines the other vector
  75239. * @returns the current updated Vector2
  75240. */
  75241. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75242. /**
  75243. * Multiplies in place the current Vector2 coordinates by the given ones
  75244. * @param otherVector defines the other vector
  75245. * @returns the current updated Vector2
  75246. */
  75247. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75248. /**
  75249. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75250. * @param otherVector defines the other vector
  75251. * @returns a new Vector2
  75252. */
  75253. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75254. /**
  75255. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75256. * @param otherVector defines the other vector
  75257. * @param result defines the target vector
  75258. * @returns the unmodified current Vector2
  75259. */
  75260. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75261. /**
  75262. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75263. * @param x defines the first coordinate
  75264. * @param y defines the second coordinate
  75265. * @returns a new Vector2
  75266. */
  75267. multiplyByFloats(x: number, y: number): Vector2;
  75268. /**
  75269. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75270. * @param otherVector defines the other vector
  75271. * @returns a new Vector2
  75272. */
  75273. divide(otherVector: Vector2): Vector2;
  75274. /**
  75275. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75276. * @param otherVector defines the other vector
  75277. * @param result defines the target vector
  75278. * @returns the unmodified current Vector2
  75279. */
  75280. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75281. /**
  75282. * Divides the current Vector2 coordinates by the given ones
  75283. * @param otherVector defines the other vector
  75284. * @returns the current updated Vector2
  75285. */
  75286. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75287. /**
  75288. * Gets a new Vector2 with current Vector2 negated coordinates
  75289. * @returns a new Vector2
  75290. */
  75291. negate(): Vector2;
  75292. /**
  75293. * Negate this vector in place
  75294. * @returns this
  75295. */
  75296. negateInPlace(): Vector2;
  75297. /**
  75298. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75299. * @param result defines the Vector3 object where to store the result
  75300. * @returns the current Vector2
  75301. */
  75302. negateToRef(result: Vector2): Vector2;
  75303. /**
  75304. * Multiply the Vector2 coordinates by scale
  75305. * @param scale defines the scaling factor
  75306. * @returns the current updated Vector2
  75307. */
  75308. scaleInPlace(scale: number): Vector2;
  75309. /**
  75310. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75311. * @param scale defines the scaling factor
  75312. * @returns a new Vector2
  75313. */
  75314. scale(scale: number): Vector2;
  75315. /**
  75316. * Scale the current Vector2 values by a factor to a given Vector2
  75317. * @param scale defines the scale factor
  75318. * @param result defines the Vector2 object where to store the result
  75319. * @returns the unmodified current Vector2
  75320. */
  75321. scaleToRef(scale: number, result: Vector2): Vector2;
  75322. /**
  75323. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75324. * @param scale defines the scale factor
  75325. * @param result defines the Vector2 object where to store the result
  75326. * @returns the unmodified current Vector2
  75327. */
  75328. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75329. /**
  75330. * Gets a boolean if two vectors are equals
  75331. * @param otherVector defines the other vector
  75332. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75333. */
  75334. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75335. /**
  75336. * Gets a boolean if two vectors are equals (using an epsilon value)
  75337. * @param otherVector defines the other vector
  75338. * @param epsilon defines the minimal distance to consider equality
  75339. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75340. */
  75341. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75342. /**
  75343. * Gets a new Vector2 from current Vector2 floored values
  75344. * @returns a new Vector2
  75345. */
  75346. floor(): Vector2;
  75347. /**
  75348. * Gets a new Vector2 from current Vector2 floored values
  75349. * @returns a new Vector2
  75350. */
  75351. fract(): Vector2;
  75352. /**
  75353. * Gets the length of the vector
  75354. * @returns the vector length (float)
  75355. */
  75356. length(): number;
  75357. /**
  75358. * Gets the vector squared length
  75359. * @returns the vector squared length (float)
  75360. */
  75361. lengthSquared(): number;
  75362. /**
  75363. * Normalize the vector
  75364. * @returns the current updated Vector2
  75365. */
  75366. normalize(): Vector2;
  75367. /**
  75368. * Gets a new Vector2 copied from the Vector2
  75369. * @returns a new Vector2
  75370. */
  75371. clone(): Vector2;
  75372. /**
  75373. * Gets a new Vector2(0, 0)
  75374. * @returns a new Vector2
  75375. */
  75376. static Zero(): Vector2;
  75377. /**
  75378. * Gets a new Vector2(1, 1)
  75379. * @returns a new Vector2
  75380. */
  75381. static One(): Vector2;
  75382. /**
  75383. * Gets a new Vector2 set from the given index element of the given array
  75384. * @param array defines the data source
  75385. * @param offset defines the offset in the data source
  75386. * @returns a new Vector2
  75387. */
  75388. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75389. /**
  75390. * Sets "result" from the given index element of the given array
  75391. * @param array defines the data source
  75392. * @param offset defines the offset in the data source
  75393. * @param result defines the target vector
  75394. */
  75395. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75396. /**
  75397. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75398. * @param value1 defines 1st point of control
  75399. * @param value2 defines 2nd point of control
  75400. * @param value3 defines 3rd point of control
  75401. * @param value4 defines 4th point of control
  75402. * @param amount defines the interpolation factor
  75403. * @returns a new Vector2
  75404. */
  75405. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75406. /**
  75407. * 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".
  75408. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75409. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75410. * @param value defines the value to clamp
  75411. * @param min defines the lower limit
  75412. * @param max defines the upper limit
  75413. * @returns a new Vector2
  75414. */
  75415. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75416. /**
  75417. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75418. * @param value1 defines the 1st control point
  75419. * @param tangent1 defines the outgoing tangent
  75420. * @param value2 defines the 2nd control point
  75421. * @param tangent2 defines the incoming tangent
  75422. * @param amount defines the interpolation factor
  75423. * @returns a new Vector2
  75424. */
  75425. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75426. /**
  75427. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75428. * @param start defines the start vector
  75429. * @param end defines the end vector
  75430. * @param amount defines the interpolation factor
  75431. * @returns a new Vector2
  75432. */
  75433. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75434. /**
  75435. * Gets the dot product of the vector "left" and the vector "right"
  75436. * @param left defines first vector
  75437. * @param right defines second vector
  75438. * @returns the dot product (float)
  75439. */
  75440. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75441. /**
  75442. * Returns a new Vector2 equal to the normalized given vector
  75443. * @param vector defines the vector to normalize
  75444. * @returns a new Vector2
  75445. */
  75446. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75447. /**
  75448. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75449. * @param left defines 1st vector
  75450. * @param right defines 2nd vector
  75451. * @returns a new Vector2
  75452. */
  75453. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75454. /**
  75455. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75456. * @param left defines 1st vector
  75457. * @param right defines 2nd vector
  75458. * @returns a new Vector2
  75459. */
  75460. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75461. /**
  75462. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75463. * @param vector defines the vector to transform
  75464. * @param transformation defines the matrix to apply
  75465. * @returns a new Vector2
  75466. */
  75467. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75468. /**
  75469. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75470. * @param vector defines the vector to transform
  75471. * @param transformation defines the matrix to apply
  75472. * @param result defines the target vector
  75473. */
  75474. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75475. /**
  75476. * Determines if a given vector is included in a triangle
  75477. * @param p defines the vector to test
  75478. * @param p0 defines 1st triangle point
  75479. * @param p1 defines 2nd triangle point
  75480. * @param p2 defines 3rd triangle point
  75481. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75482. */
  75483. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75484. /**
  75485. * Gets the distance between the vectors "value1" and "value2"
  75486. * @param value1 defines first vector
  75487. * @param value2 defines second vector
  75488. * @returns the distance between vectors
  75489. */
  75490. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75491. /**
  75492. * Returns the squared distance between the vectors "value1" and "value2"
  75493. * @param value1 defines first vector
  75494. * @param value2 defines second vector
  75495. * @returns the squared distance between vectors
  75496. */
  75497. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75498. /**
  75499. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75500. * @param value1 defines first vector
  75501. * @param value2 defines second vector
  75502. * @returns a new Vector2
  75503. */
  75504. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75505. /**
  75506. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75507. * @param p defines the middle point
  75508. * @param segA defines one point of the segment
  75509. * @param segB defines the other point of the segment
  75510. * @returns the shortest distance
  75511. */
  75512. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75513. }
  75514. /**
  75515. * Class used to store (x,y,z) vector representation
  75516. * A Vector3 is the main object used in 3D geometry
  75517. * It can represent etiher the coordinates of a point the space, either a direction
  75518. * Reminder: js uses a left handed forward facing system
  75519. */
  75520. export class Vector3 {
  75521. /**
  75522. * Defines the first coordinates (on X axis)
  75523. */
  75524. x: number;
  75525. /**
  75526. * Defines the second coordinates (on Y axis)
  75527. */
  75528. y: number;
  75529. /**
  75530. * Defines the third coordinates (on Z axis)
  75531. */
  75532. z: number;
  75533. private static _UpReadOnly;
  75534. private static _ZeroReadOnly;
  75535. /**
  75536. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75537. * @param x defines the first coordinates (on X axis)
  75538. * @param y defines the second coordinates (on Y axis)
  75539. * @param z defines the third coordinates (on Z axis)
  75540. */
  75541. constructor(
  75542. /**
  75543. * Defines the first coordinates (on X axis)
  75544. */
  75545. x?: number,
  75546. /**
  75547. * Defines the second coordinates (on Y axis)
  75548. */
  75549. y?: number,
  75550. /**
  75551. * Defines the third coordinates (on Z axis)
  75552. */
  75553. z?: number);
  75554. /**
  75555. * Creates a string representation of the Vector3
  75556. * @returns a string with the Vector3 coordinates.
  75557. */
  75558. toString(): string;
  75559. /**
  75560. * Gets the class name
  75561. * @returns the string "Vector3"
  75562. */
  75563. getClassName(): string;
  75564. /**
  75565. * Creates the Vector3 hash code
  75566. * @returns a number which tends to be unique between Vector3 instances
  75567. */
  75568. getHashCode(): number;
  75569. /**
  75570. * Creates an array containing three elements : the coordinates of the Vector3
  75571. * @returns a new array of numbers
  75572. */
  75573. asArray(): number[];
  75574. /**
  75575. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75576. * @param array defines the destination array
  75577. * @param index defines the offset in the destination array
  75578. * @returns the current Vector3
  75579. */
  75580. toArray(array: FloatArray, index?: number): Vector3;
  75581. /**
  75582. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75583. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75584. */
  75585. toQuaternion(): Quaternion;
  75586. /**
  75587. * Adds the given vector to the current Vector3
  75588. * @param otherVector defines the second operand
  75589. * @returns the current updated Vector3
  75590. */
  75591. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75592. /**
  75593. * Adds the given coordinates to the current Vector3
  75594. * @param x defines the x coordinate of the operand
  75595. * @param y defines the y coordinate of the operand
  75596. * @param z defines the z coordinate of the operand
  75597. * @returns the current updated Vector3
  75598. */
  75599. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75600. /**
  75601. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75602. * @param otherVector defines the second operand
  75603. * @returns the resulting Vector3
  75604. */
  75605. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75606. /**
  75607. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75608. * @param otherVector defines the second operand
  75609. * @param result defines the Vector3 object where to store the result
  75610. * @returns the current Vector3
  75611. */
  75612. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75613. /**
  75614. * Subtract the given vector from the current Vector3
  75615. * @param otherVector defines the second operand
  75616. * @returns the current updated Vector3
  75617. */
  75618. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75619. /**
  75620. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75621. * @param otherVector defines the second operand
  75622. * @returns the resulting Vector3
  75623. */
  75624. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75625. /**
  75626. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75627. * @param otherVector defines the second operand
  75628. * @param result defines the Vector3 object where to store the result
  75629. * @returns the current Vector3
  75630. */
  75631. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75632. /**
  75633. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75634. * @param x defines the x coordinate of the operand
  75635. * @param y defines the y coordinate of the operand
  75636. * @param z defines the z coordinate of the operand
  75637. * @returns the resulting Vector3
  75638. */
  75639. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75640. /**
  75641. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75642. * @param x defines the x coordinate of the operand
  75643. * @param y defines the y coordinate of the operand
  75644. * @param z defines the z coordinate of the operand
  75645. * @param result defines the Vector3 object where to store the result
  75646. * @returns the current Vector3
  75647. */
  75648. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75649. /**
  75650. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75651. * @returns a new Vector3
  75652. */
  75653. negate(): Vector3;
  75654. /**
  75655. * Negate this vector in place
  75656. * @returns this
  75657. */
  75658. negateInPlace(): Vector3;
  75659. /**
  75660. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75661. * @param result defines the Vector3 object where to store the result
  75662. * @returns the current Vector3
  75663. */
  75664. negateToRef(result: Vector3): Vector3;
  75665. /**
  75666. * Multiplies the Vector3 coordinates by the float "scale"
  75667. * @param scale defines the multiplier factor
  75668. * @returns the current updated Vector3
  75669. */
  75670. scaleInPlace(scale: number): Vector3;
  75671. /**
  75672. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75673. * @param scale defines the multiplier factor
  75674. * @returns a new Vector3
  75675. */
  75676. scale(scale: number): Vector3;
  75677. /**
  75678. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75679. * @param scale defines the multiplier factor
  75680. * @param result defines the Vector3 object where to store the result
  75681. * @returns the current Vector3
  75682. */
  75683. scaleToRef(scale: number, result: Vector3): Vector3;
  75684. /**
  75685. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75686. * @param scale defines the scale factor
  75687. * @param result defines the Vector3 object where to store the result
  75688. * @returns the unmodified current Vector3
  75689. */
  75690. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75691. /**
  75692. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75693. * @param otherVector defines the second operand
  75694. * @returns true if both vectors are equals
  75695. */
  75696. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75697. /**
  75698. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75699. * @param otherVector defines the second operand
  75700. * @param epsilon defines the minimal distance to define values as equals
  75701. * @returns true if both vectors are distant less than epsilon
  75702. */
  75703. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75704. /**
  75705. * Returns true if the current Vector3 coordinates equals the given floats
  75706. * @param x defines the x coordinate of the operand
  75707. * @param y defines the y coordinate of the operand
  75708. * @param z defines the z coordinate of the operand
  75709. * @returns true if both vectors are equals
  75710. */
  75711. equalsToFloats(x: number, y: number, z: number): boolean;
  75712. /**
  75713. * Multiplies the current Vector3 coordinates by the given ones
  75714. * @param otherVector defines the second operand
  75715. * @returns the current updated Vector3
  75716. */
  75717. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75718. /**
  75719. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75720. * @param otherVector defines the second operand
  75721. * @returns the new Vector3
  75722. */
  75723. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75724. /**
  75725. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75726. * @param otherVector defines the second operand
  75727. * @param result defines the Vector3 object where to store the result
  75728. * @returns the current Vector3
  75729. */
  75730. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75731. /**
  75732. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75733. * @param x defines the x coordinate of the operand
  75734. * @param y defines the y coordinate of the operand
  75735. * @param z defines the z coordinate of the operand
  75736. * @returns the new Vector3
  75737. */
  75738. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75739. /**
  75740. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75741. * @param otherVector defines the second operand
  75742. * @returns the new Vector3
  75743. */
  75744. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75745. /**
  75746. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75747. * @param otherVector defines the second operand
  75748. * @param result defines the Vector3 object where to store the result
  75749. * @returns the current Vector3
  75750. */
  75751. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75752. /**
  75753. * Divides the current Vector3 coordinates by the given ones.
  75754. * @param otherVector defines the second operand
  75755. * @returns the current updated Vector3
  75756. */
  75757. divideInPlace(otherVector: Vector3): Vector3;
  75758. /**
  75759. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75760. * @param other defines the second operand
  75761. * @returns the current updated Vector3
  75762. */
  75763. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75764. /**
  75765. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75766. * @param other defines the second operand
  75767. * @returns the current updated Vector3
  75768. */
  75769. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75770. /**
  75771. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75772. * @param x defines the x coordinate of the operand
  75773. * @param y defines the y coordinate of the operand
  75774. * @param z defines the z coordinate of the operand
  75775. * @returns the current updated Vector3
  75776. */
  75777. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75778. /**
  75779. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75780. * @param x defines the x coordinate of the operand
  75781. * @param y defines the y coordinate of the operand
  75782. * @param z defines the z coordinate of the operand
  75783. * @returns the current updated Vector3
  75784. */
  75785. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75786. /**
  75787. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75788. * Check if is non uniform within a certain amount of decimal places to account for this
  75789. * @param epsilon the amount the values can differ
  75790. * @returns if the the vector is non uniform to a certain number of decimal places
  75791. */
  75792. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75793. /**
  75794. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75795. */
  75796. get isNonUniform(): boolean;
  75797. /**
  75798. * Gets a new Vector3 from current Vector3 floored values
  75799. * @returns a new Vector3
  75800. */
  75801. floor(): Vector3;
  75802. /**
  75803. * Gets a new Vector3 from current Vector3 floored values
  75804. * @returns a new Vector3
  75805. */
  75806. fract(): Vector3;
  75807. /**
  75808. * Gets the length of the Vector3
  75809. * @returns the length of the Vector3
  75810. */
  75811. length(): number;
  75812. /**
  75813. * Gets the squared length of the Vector3
  75814. * @returns squared length of the Vector3
  75815. */
  75816. lengthSquared(): number;
  75817. /**
  75818. * Normalize the current Vector3.
  75819. * Please note that this is an in place operation.
  75820. * @returns the current updated Vector3
  75821. */
  75822. normalize(): Vector3;
  75823. /**
  75824. * Reorders the x y z properties of the vector in place
  75825. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75826. * @returns the current updated vector
  75827. */
  75828. reorderInPlace(order: string): this;
  75829. /**
  75830. * Rotates the vector around 0,0,0 by a quaternion
  75831. * @param quaternion the rotation quaternion
  75832. * @param result vector to store the result
  75833. * @returns the resulting vector
  75834. */
  75835. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75836. /**
  75837. * Rotates a vector around a given point
  75838. * @param quaternion the rotation quaternion
  75839. * @param point the point to rotate around
  75840. * @param result vector to store the result
  75841. * @returns the resulting vector
  75842. */
  75843. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75844. /**
  75845. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75846. * The cross product is then orthogonal to both current and "other"
  75847. * @param other defines the right operand
  75848. * @returns the cross product
  75849. */
  75850. cross(other: Vector3): Vector3;
  75851. /**
  75852. * Normalize the current Vector3 with the given input length.
  75853. * Please note that this is an in place operation.
  75854. * @param len the length of the vector
  75855. * @returns the current updated Vector3
  75856. */
  75857. normalizeFromLength(len: number): Vector3;
  75858. /**
  75859. * Normalize the current Vector3 to a new vector
  75860. * @returns the new Vector3
  75861. */
  75862. normalizeToNew(): Vector3;
  75863. /**
  75864. * Normalize the current Vector3 to the reference
  75865. * @param reference define the Vector3 to update
  75866. * @returns the updated Vector3
  75867. */
  75868. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75869. /**
  75870. * Creates a new Vector3 copied from the current Vector3
  75871. * @returns the new Vector3
  75872. */
  75873. clone(): Vector3;
  75874. /**
  75875. * Copies the given vector coordinates to the current Vector3 ones
  75876. * @param source defines the source Vector3
  75877. * @returns the current updated Vector3
  75878. */
  75879. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75880. /**
  75881. * Copies the given floats to the current Vector3 coordinates
  75882. * @param x defines the x coordinate of the operand
  75883. * @param y defines the y coordinate of the operand
  75884. * @param z defines the z coordinate of the operand
  75885. * @returns the current updated Vector3
  75886. */
  75887. copyFromFloats(x: number, y: number, z: number): Vector3;
  75888. /**
  75889. * Copies the given floats to the current Vector3 coordinates
  75890. * @param x defines the x coordinate of the operand
  75891. * @param y defines the y coordinate of the operand
  75892. * @param z defines the z coordinate of the operand
  75893. * @returns the current updated Vector3
  75894. */
  75895. set(x: number, y: number, z: number): Vector3;
  75896. /**
  75897. * Copies the given float to the current Vector3 coordinates
  75898. * @param v defines the x, y and z coordinates of the operand
  75899. * @returns the current updated Vector3
  75900. */
  75901. setAll(v: number): Vector3;
  75902. /**
  75903. * Get the clip factor between two vectors
  75904. * @param vector0 defines the first operand
  75905. * @param vector1 defines the second operand
  75906. * @param axis defines the axis to use
  75907. * @param size defines the size along the axis
  75908. * @returns the clip factor
  75909. */
  75910. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75911. /**
  75912. * Get angle between two vectors
  75913. * @param vector0 angle between vector0 and vector1
  75914. * @param vector1 angle between vector0 and vector1
  75915. * @param normal direction of the normal
  75916. * @return the angle between vector0 and vector1
  75917. */
  75918. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75919. /**
  75920. * Returns a new Vector3 set from the index "offset" of the given array
  75921. * @param array defines the source array
  75922. * @param offset defines the offset in the source array
  75923. * @returns the new Vector3
  75924. */
  75925. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75926. /**
  75927. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75928. * @param array defines the source array
  75929. * @param offset defines the offset in the source array
  75930. * @returns the new Vector3
  75931. * @deprecated Please use FromArray instead.
  75932. */
  75933. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75934. /**
  75935. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75936. * @param array defines the source array
  75937. * @param offset defines the offset in the source array
  75938. * @param result defines the Vector3 where to store the result
  75939. */
  75940. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75941. /**
  75942. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75943. * @param array defines the source array
  75944. * @param offset defines the offset in the source array
  75945. * @param result defines the Vector3 where to store the result
  75946. * @deprecated Please use FromArrayToRef instead.
  75947. */
  75948. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75949. /**
  75950. * Sets the given vector "result" with the given floats.
  75951. * @param x defines the x coordinate of the source
  75952. * @param y defines the y coordinate of the source
  75953. * @param z defines the z coordinate of the source
  75954. * @param result defines the Vector3 where to store the result
  75955. */
  75956. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75957. /**
  75958. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75959. * @returns a new empty Vector3
  75960. */
  75961. static Zero(): Vector3;
  75962. /**
  75963. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75964. * @returns a new unit Vector3
  75965. */
  75966. static One(): Vector3;
  75967. /**
  75968. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75969. * @returns a new up Vector3
  75970. */
  75971. static Up(): Vector3;
  75972. /**
  75973. * Gets a up Vector3 that must not be updated
  75974. */
  75975. static get UpReadOnly(): DeepImmutable<Vector3>;
  75976. /**
  75977. * Gets a zero Vector3 that must not be updated
  75978. */
  75979. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75980. /**
  75981. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75982. * @returns a new down Vector3
  75983. */
  75984. static Down(): Vector3;
  75985. /**
  75986. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75987. * @returns a new forward Vector3
  75988. */
  75989. static Forward(): Vector3;
  75990. /**
  75991. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75992. * @returns a new forward Vector3
  75993. */
  75994. static Backward(): Vector3;
  75995. /**
  75996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75997. * @returns a new right Vector3
  75998. */
  75999. static Right(): Vector3;
  76000. /**
  76001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76002. * @returns a new left Vector3
  76003. */
  76004. static Left(): Vector3;
  76005. /**
  76006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76008. * @param vector defines the Vector3 to transform
  76009. * @param transformation defines the transformation matrix
  76010. * @returns the transformed Vector3
  76011. */
  76012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76013. /**
  76014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76016. * @param vector defines the Vector3 to transform
  76017. * @param transformation defines the transformation matrix
  76018. * @param result defines the Vector3 where to store the result
  76019. */
  76020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76021. /**
  76022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76023. * This method computes tranformed coordinates only, not transformed direction vectors
  76024. * @param x define the x coordinate of the source vector
  76025. * @param y define the y coordinate of the source vector
  76026. * @param z define the z coordinate of the source vector
  76027. * @param transformation defines the transformation matrix
  76028. * @param result defines the Vector3 where to store the result
  76029. */
  76030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76031. /**
  76032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76034. * @param vector defines the Vector3 to transform
  76035. * @param transformation defines the transformation matrix
  76036. * @returns the new Vector3
  76037. */
  76038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76039. /**
  76040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76042. * @param vector defines the Vector3 to transform
  76043. * @param transformation defines the transformation matrix
  76044. * @param result defines the Vector3 where to store the result
  76045. */
  76046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76047. /**
  76048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76050. * @param x define the x coordinate of the source vector
  76051. * @param y define the y coordinate of the source vector
  76052. * @param z define the z coordinate of the source vector
  76053. * @param transformation defines the transformation matrix
  76054. * @param result defines the Vector3 where to store the result
  76055. */
  76056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76057. /**
  76058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76059. * @param value1 defines the first control point
  76060. * @param value2 defines the second control point
  76061. * @param value3 defines the third control point
  76062. * @param value4 defines the fourth control point
  76063. * @param amount defines the amount on the spline to use
  76064. * @returns the new Vector3
  76065. */
  76066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76067. /**
  76068. * 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"
  76069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76071. * @param value defines the current value
  76072. * @param min defines the lower range value
  76073. * @param max defines the upper range value
  76074. * @returns the new Vector3
  76075. */
  76076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76077. /**
  76078. * 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"
  76079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76081. * @param value defines the current value
  76082. * @param min defines the lower range value
  76083. * @param max defines the upper range value
  76084. * @param result defines the Vector3 where to store the result
  76085. */
  76086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76087. /**
  76088. * Checks if a given vector is inside a specific range
  76089. * @param v defines the vector to test
  76090. * @param min defines the minimum range
  76091. * @param max defines the maximum range
  76092. */
  76093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76094. /**
  76095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76096. * @param value1 defines the first control point
  76097. * @param tangent1 defines the first tangent vector
  76098. * @param value2 defines the second control point
  76099. * @param tangent2 defines the second tangent vector
  76100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76101. * @returns the new Vector3
  76102. */
  76103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76104. /**
  76105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76106. * @param start defines the start value
  76107. * @param end defines the end value
  76108. * @param amount max defines amount between both (between 0 and 1)
  76109. * @returns the new Vector3
  76110. */
  76111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76112. /**
  76113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76114. * @param start defines the start value
  76115. * @param end defines the end value
  76116. * @param amount max defines amount between both (between 0 and 1)
  76117. * @param result defines the Vector3 where to store the result
  76118. */
  76119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76120. /**
  76121. * Returns the dot product (float) between the vectors "left" and "right"
  76122. * @param left defines the left operand
  76123. * @param right defines the right operand
  76124. * @returns the dot product
  76125. */
  76126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76127. /**
  76128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76129. * The cross product is then orthogonal to both "left" and "right"
  76130. * @param left defines the left operand
  76131. * @param right defines the right operand
  76132. * @returns the cross product
  76133. */
  76134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76135. /**
  76136. * Sets the given vector "result" with the cross product of "left" and "right"
  76137. * The cross product is then orthogonal to both "left" and "right"
  76138. * @param left defines the left operand
  76139. * @param right defines the right operand
  76140. * @param result defines the Vector3 where to store the result
  76141. */
  76142. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76143. /**
  76144. * Returns a new Vector3 as the normalization of the given vector
  76145. * @param vector defines the Vector3 to normalize
  76146. * @returns the new Vector3
  76147. */
  76148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76149. /**
  76150. * Sets the given vector "result" with the normalization of the given first vector
  76151. * @param vector defines the Vector3 to normalize
  76152. * @param result defines the Vector3 where to store the result
  76153. */
  76154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76155. /**
  76156. * Project a Vector3 onto screen space
  76157. * @param vector defines the Vector3 to project
  76158. * @param world defines the world matrix to use
  76159. * @param transform defines the transform (view x projection) matrix to use
  76160. * @param viewport defines the screen viewport to use
  76161. * @returns the new Vector3
  76162. */
  76163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76164. /** @hidden */
  76165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76166. /**
  76167. * Unproject from screen space to object space
  76168. * @param source defines the screen space Vector3 to use
  76169. * @param viewportWidth defines the current width of the viewport
  76170. * @param viewportHeight defines the current height of the viewport
  76171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76172. * @param transform defines the transform (view x projection) matrix to use
  76173. * @returns the new Vector3
  76174. */
  76175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76176. /**
  76177. * Unproject from screen space to object space
  76178. * @param source defines the screen space Vector3 to use
  76179. * @param viewportWidth defines the current width of the viewport
  76180. * @param viewportHeight defines the current height of the viewport
  76181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76182. * @param view defines the view matrix to use
  76183. * @param projection defines the projection matrix to use
  76184. * @returns the new Vector3
  76185. */
  76186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76187. /**
  76188. * Unproject from screen space to object space
  76189. * @param source defines the screen space Vector3 to use
  76190. * @param viewportWidth defines the current width of the viewport
  76191. * @param viewportHeight defines the current height of the viewport
  76192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76193. * @param view defines the view matrix to use
  76194. * @param projection defines the projection matrix to use
  76195. * @param result defines the Vector3 where to store the result
  76196. */
  76197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76198. /**
  76199. * Unproject from screen space to object space
  76200. * @param sourceX defines the screen space x coordinate to use
  76201. * @param sourceY defines the screen space y coordinate to use
  76202. * @param sourceZ defines the screen space z coordinate to use
  76203. * @param viewportWidth defines the current width of the viewport
  76204. * @param viewportHeight defines the current height of the viewport
  76205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76206. * @param view defines the view matrix to use
  76207. * @param projection defines the projection matrix to use
  76208. * @param result defines the Vector3 where to store the result
  76209. */
  76210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76211. /**
  76212. * Gets the minimal coordinate values between two Vector3
  76213. * @param left defines the first operand
  76214. * @param right defines the second operand
  76215. * @returns the new Vector3
  76216. */
  76217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76218. /**
  76219. * Gets the maximal coordinate values between two Vector3
  76220. * @param left defines the first operand
  76221. * @param right defines the second operand
  76222. * @returns the new Vector3
  76223. */
  76224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76225. /**
  76226. * Returns the distance between the vectors "value1" and "value2"
  76227. * @param value1 defines the first operand
  76228. * @param value2 defines the second operand
  76229. * @returns the distance
  76230. */
  76231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76232. /**
  76233. * Returns the squared distance between the vectors "value1" and "value2"
  76234. * @param value1 defines the first operand
  76235. * @param value2 defines the second operand
  76236. * @returns the squared distance
  76237. */
  76238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76239. /**
  76240. * Returns a new Vector3 located at the center between "value1" and "value2"
  76241. * @param value1 defines the first operand
  76242. * @param value2 defines the second operand
  76243. * @returns the new Vector3
  76244. */
  76245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76246. /**
  76247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76249. * to something in order to rotate it from its local system to the given target system
  76250. * Note: axis1, axis2 and axis3 are normalized during this operation
  76251. * @param axis1 defines the first axis
  76252. * @param axis2 defines the second axis
  76253. * @param axis3 defines the third axis
  76254. * @returns a new Vector3
  76255. */
  76256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76257. /**
  76258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76259. * @param axis1 defines the first axis
  76260. * @param axis2 defines the second axis
  76261. * @param axis3 defines the third axis
  76262. * @param ref defines the Vector3 where to store the result
  76263. */
  76264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76265. }
  76266. /**
  76267. * Vector4 class created for EulerAngle class conversion to Quaternion
  76268. */
  76269. export class Vector4 {
  76270. /** x value of the vector */
  76271. x: number;
  76272. /** y value of the vector */
  76273. y: number;
  76274. /** z value of the vector */
  76275. z: number;
  76276. /** w value of the vector */
  76277. w: number;
  76278. /**
  76279. * Creates a Vector4 object from the given floats.
  76280. * @param x x value of the vector
  76281. * @param y y value of the vector
  76282. * @param z z value of the vector
  76283. * @param w w value of the vector
  76284. */
  76285. constructor(
  76286. /** x value of the vector */
  76287. x: number,
  76288. /** y value of the vector */
  76289. y: number,
  76290. /** z value of the vector */
  76291. z: number,
  76292. /** w value of the vector */
  76293. w: number);
  76294. /**
  76295. * Returns the string with the Vector4 coordinates.
  76296. * @returns a string containing all the vector values
  76297. */
  76298. toString(): string;
  76299. /**
  76300. * Returns the string "Vector4".
  76301. * @returns "Vector4"
  76302. */
  76303. getClassName(): string;
  76304. /**
  76305. * Returns the Vector4 hash code.
  76306. * @returns a unique hash code
  76307. */
  76308. getHashCode(): number;
  76309. /**
  76310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76311. * @returns the resulting array
  76312. */
  76313. asArray(): number[];
  76314. /**
  76315. * Populates the given array from the given index with the Vector4 coordinates.
  76316. * @param array array to populate
  76317. * @param index index of the array to start at (default: 0)
  76318. * @returns the Vector4.
  76319. */
  76320. toArray(array: FloatArray, index?: number): Vector4;
  76321. /**
  76322. * Adds the given vector to the current Vector4.
  76323. * @param otherVector the vector to add
  76324. * @returns the updated Vector4.
  76325. */
  76326. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76327. /**
  76328. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76329. * @param otherVector the vector to add
  76330. * @returns the resulting vector
  76331. */
  76332. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76333. /**
  76334. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76335. * @param otherVector the vector to add
  76336. * @param result the vector to store the result
  76337. * @returns the current Vector4.
  76338. */
  76339. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76340. /**
  76341. * Subtract in place the given vector from the current Vector4.
  76342. * @param otherVector the vector to subtract
  76343. * @returns the updated Vector4.
  76344. */
  76345. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76346. /**
  76347. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76348. * @param otherVector the vector to add
  76349. * @returns the new vector with the result
  76350. */
  76351. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76352. /**
  76353. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76354. * @param otherVector the vector to subtract
  76355. * @param result the vector to store the result
  76356. * @returns the current Vector4.
  76357. */
  76358. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76359. /**
  76360. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76361. */
  76362. /**
  76363. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76364. * @param x value to subtract
  76365. * @param y value to subtract
  76366. * @param z value to subtract
  76367. * @param w value to subtract
  76368. * @returns new vector containing the result
  76369. */
  76370. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76371. /**
  76372. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76373. * @param x value to subtract
  76374. * @param y value to subtract
  76375. * @param z value to subtract
  76376. * @param w value to subtract
  76377. * @param result the vector to store the result in
  76378. * @returns the current Vector4.
  76379. */
  76380. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76381. /**
  76382. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76383. * @returns a new vector with the negated values
  76384. */
  76385. negate(): Vector4;
  76386. /**
  76387. * Negate this vector in place
  76388. * @returns this
  76389. */
  76390. negateInPlace(): Vector4;
  76391. /**
  76392. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76393. * @param result defines the Vector3 object where to store the result
  76394. * @returns the current Vector4
  76395. */
  76396. negateToRef(result: Vector4): Vector4;
  76397. /**
  76398. * Multiplies the current Vector4 coordinates by scale (float).
  76399. * @param scale the number to scale with
  76400. * @returns the updated Vector4.
  76401. */
  76402. scaleInPlace(scale: number): Vector4;
  76403. /**
  76404. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76405. * @param scale the number to scale with
  76406. * @returns a new vector with the result
  76407. */
  76408. scale(scale: number): Vector4;
  76409. /**
  76410. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76411. * @param scale the number to scale with
  76412. * @param result a vector to store the result in
  76413. * @returns the current Vector4.
  76414. */
  76415. scaleToRef(scale: number, result: Vector4): Vector4;
  76416. /**
  76417. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76418. * @param scale defines the scale factor
  76419. * @param result defines the Vector4 object where to store the result
  76420. * @returns the unmodified current Vector4
  76421. */
  76422. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76423. /**
  76424. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76425. * @param otherVector the vector to compare against
  76426. * @returns true if they are equal
  76427. */
  76428. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76429. /**
  76430. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76431. * @param otherVector vector to compare against
  76432. * @param epsilon (Default: very small number)
  76433. * @returns true if they are equal
  76434. */
  76435. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76436. /**
  76437. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76438. * @param x x value to compare against
  76439. * @param y y value to compare against
  76440. * @param z z value to compare against
  76441. * @param w w value to compare against
  76442. * @returns true if equal
  76443. */
  76444. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76445. /**
  76446. * Multiplies in place the current Vector4 by the given one.
  76447. * @param otherVector vector to multiple with
  76448. * @returns the updated Vector4.
  76449. */
  76450. multiplyInPlace(otherVector: Vector4): Vector4;
  76451. /**
  76452. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76453. * @param otherVector vector to multiple with
  76454. * @returns resulting new vector
  76455. */
  76456. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76457. /**
  76458. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76459. * @param otherVector vector to multiple with
  76460. * @param result vector to store the result
  76461. * @returns the current Vector4.
  76462. */
  76463. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76464. /**
  76465. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76466. * @param x x value multiply with
  76467. * @param y y value multiply with
  76468. * @param z z value multiply with
  76469. * @param w w value multiply with
  76470. * @returns resulting new vector
  76471. */
  76472. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76473. /**
  76474. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76475. * @param otherVector vector to devide with
  76476. * @returns resulting new vector
  76477. */
  76478. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76479. /**
  76480. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76481. * @param otherVector vector to devide with
  76482. * @param result vector to store the result
  76483. * @returns the current Vector4.
  76484. */
  76485. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76486. /**
  76487. * Divides the current Vector3 coordinates by the given ones.
  76488. * @param otherVector vector to devide with
  76489. * @returns the updated Vector3.
  76490. */
  76491. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76492. /**
  76493. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76494. * @param other defines the second operand
  76495. * @returns the current updated Vector4
  76496. */
  76497. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76498. /**
  76499. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76500. * @param other defines the second operand
  76501. * @returns the current updated Vector4
  76502. */
  76503. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76504. /**
  76505. * Gets a new Vector4 from current Vector4 floored values
  76506. * @returns a new Vector4
  76507. */
  76508. floor(): Vector4;
  76509. /**
  76510. * Gets a new Vector4 from current Vector3 floored values
  76511. * @returns a new Vector4
  76512. */
  76513. fract(): Vector4;
  76514. /**
  76515. * Returns the Vector4 length (float).
  76516. * @returns the length
  76517. */
  76518. length(): number;
  76519. /**
  76520. * Returns the Vector4 squared length (float).
  76521. * @returns the length squared
  76522. */
  76523. lengthSquared(): number;
  76524. /**
  76525. * Normalizes in place the Vector4.
  76526. * @returns the updated Vector4.
  76527. */
  76528. normalize(): Vector4;
  76529. /**
  76530. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76531. * @returns this converted to a new vector3
  76532. */
  76533. toVector3(): Vector3;
  76534. /**
  76535. * Returns a new Vector4 copied from the current one.
  76536. * @returns the new cloned vector
  76537. */
  76538. clone(): Vector4;
  76539. /**
  76540. * Updates the current Vector4 with the given one coordinates.
  76541. * @param source the source vector to copy from
  76542. * @returns the updated Vector4.
  76543. */
  76544. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76545. /**
  76546. * Updates the current Vector4 coordinates with the given floats.
  76547. * @param x float to copy from
  76548. * @param y float to copy from
  76549. * @param z float to copy from
  76550. * @param w float to copy from
  76551. * @returns the updated Vector4.
  76552. */
  76553. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76554. /**
  76555. * Updates the current Vector4 coordinates with the given floats.
  76556. * @param x float to set from
  76557. * @param y float to set from
  76558. * @param z float to set from
  76559. * @param w float to set from
  76560. * @returns the updated Vector4.
  76561. */
  76562. set(x: number, y: number, z: number, w: number): Vector4;
  76563. /**
  76564. * Copies the given float to the current Vector3 coordinates
  76565. * @param v defines the x, y, z and w coordinates of the operand
  76566. * @returns the current updated Vector3
  76567. */
  76568. setAll(v: number): Vector4;
  76569. /**
  76570. * Returns a new Vector4 set from the starting index of the given array.
  76571. * @param array the array to pull values from
  76572. * @param offset the offset into the array to start at
  76573. * @returns the new vector
  76574. */
  76575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76576. /**
  76577. * Updates the given vector "result" from the starting index of the given array.
  76578. * @param array the array to pull values from
  76579. * @param offset the offset into the array to start at
  76580. * @param result the vector to store the result in
  76581. */
  76582. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76583. /**
  76584. * Updates the given vector "result" from the starting index of the given Float32Array.
  76585. * @param array the array to pull values from
  76586. * @param offset the offset into the array to start at
  76587. * @param result the vector to store the result in
  76588. */
  76589. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76590. /**
  76591. * Updates the given vector "result" coordinates from the given floats.
  76592. * @param x float to set from
  76593. * @param y float to set from
  76594. * @param z float to set from
  76595. * @param w float to set from
  76596. * @param result the vector to the floats in
  76597. */
  76598. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76599. /**
  76600. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76601. * @returns the new vector
  76602. */
  76603. static Zero(): Vector4;
  76604. /**
  76605. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76606. * @returns the new vector
  76607. */
  76608. static One(): Vector4;
  76609. /**
  76610. * Returns a new normalized Vector4 from the given one.
  76611. * @param vector the vector to normalize
  76612. * @returns the vector
  76613. */
  76614. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76615. /**
  76616. * Updates the given vector "result" from the normalization of the given one.
  76617. * @param vector the vector to normalize
  76618. * @param result the vector to store the result in
  76619. */
  76620. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76621. /**
  76622. * Returns a vector with the minimum values from the left and right vectors
  76623. * @param left left vector to minimize
  76624. * @param right right vector to minimize
  76625. * @returns a new vector with the minimum of the left and right vector values
  76626. */
  76627. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76628. /**
  76629. * Returns a vector with the maximum values from the left and right vectors
  76630. * @param left left vector to maximize
  76631. * @param right right vector to maximize
  76632. * @returns a new vector with the maximum of the left and right vector values
  76633. */
  76634. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76635. /**
  76636. * Returns the distance (float) between the vectors "value1" and "value2".
  76637. * @param value1 value to calulate the distance between
  76638. * @param value2 value to calulate the distance between
  76639. * @return the distance between the two vectors
  76640. */
  76641. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76642. /**
  76643. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76644. * @param value1 value to calulate the distance between
  76645. * @param value2 value to calulate the distance between
  76646. * @return the distance between the two vectors squared
  76647. */
  76648. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76649. /**
  76650. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76651. * @param value1 value to calulate the center between
  76652. * @param value2 value to calulate the center between
  76653. * @return the center between the two vectors
  76654. */
  76655. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76656. /**
  76657. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76658. * This methods computes transformed normalized direction vectors only.
  76659. * @param vector the vector to transform
  76660. * @param transformation the transformation matrix to apply
  76661. * @returns the new vector
  76662. */
  76663. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76664. /**
  76665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76666. * This methods computes transformed normalized direction vectors only.
  76667. * @param vector the vector to transform
  76668. * @param transformation the transformation matrix to apply
  76669. * @param result the vector to store the result in
  76670. */
  76671. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76672. /**
  76673. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76674. * This methods computes transformed normalized direction vectors only.
  76675. * @param x value to transform
  76676. * @param y value to transform
  76677. * @param z value to transform
  76678. * @param w value to transform
  76679. * @param transformation the transformation matrix to apply
  76680. * @param result the vector to store the results in
  76681. */
  76682. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76683. /**
  76684. * Creates a new Vector4 from a Vector3
  76685. * @param source defines the source data
  76686. * @param w defines the 4th component (default is 0)
  76687. * @returns a new Vector4
  76688. */
  76689. static FromVector3(source: Vector3, w?: number): Vector4;
  76690. }
  76691. /**
  76692. * Class used to store quaternion data
  76693. * @see https://en.wikipedia.org/wiki/Quaternion
  76694. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76695. */
  76696. export class Quaternion {
  76697. /** defines the first component (0 by default) */
  76698. x: number;
  76699. /** defines the second component (0 by default) */
  76700. y: number;
  76701. /** defines the third component (0 by default) */
  76702. z: number;
  76703. /** defines the fourth component (1.0 by default) */
  76704. w: number;
  76705. /**
  76706. * Creates a new Quaternion from the given floats
  76707. * @param x defines the first component (0 by default)
  76708. * @param y defines the second component (0 by default)
  76709. * @param z defines the third component (0 by default)
  76710. * @param w defines the fourth component (1.0 by default)
  76711. */
  76712. constructor(
  76713. /** defines the first component (0 by default) */
  76714. x?: number,
  76715. /** defines the second component (0 by default) */
  76716. y?: number,
  76717. /** defines the third component (0 by default) */
  76718. z?: number,
  76719. /** defines the fourth component (1.0 by default) */
  76720. w?: number);
  76721. /**
  76722. * Gets a string representation for the current quaternion
  76723. * @returns a string with the Quaternion coordinates
  76724. */
  76725. toString(): string;
  76726. /**
  76727. * Gets the class name of the quaternion
  76728. * @returns the string "Quaternion"
  76729. */
  76730. getClassName(): string;
  76731. /**
  76732. * Gets a hash code for this quaternion
  76733. * @returns the quaternion hash code
  76734. */
  76735. getHashCode(): number;
  76736. /**
  76737. * Copy the quaternion to an array
  76738. * @returns a new array populated with 4 elements from the quaternion coordinates
  76739. */
  76740. asArray(): number[];
  76741. /**
  76742. * Check if two quaternions are equals
  76743. * @param otherQuaternion defines the second operand
  76744. * @return true if the current quaternion and the given one coordinates are strictly equals
  76745. */
  76746. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76747. /**
  76748. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76749. * @param otherQuaternion defines the other quaternion
  76750. * @param epsilon defines the minimal distance to consider equality
  76751. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76752. */
  76753. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76754. /**
  76755. * Clone the current quaternion
  76756. * @returns a new quaternion copied from the current one
  76757. */
  76758. clone(): Quaternion;
  76759. /**
  76760. * Copy a quaternion to the current one
  76761. * @param other defines the other quaternion
  76762. * @returns the updated current quaternion
  76763. */
  76764. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76765. /**
  76766. * Updates the current quaternion with the given float coordinates
  76767. * @param x defines the x coordinate
  76768. * @param y defines the y coordinate
  76769. * @param z defines the z coordinate
  76770. * @param w defines the w coordinate
  76771. * @returns the updated current quaternion
  76772. */
  76773. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76774. /**
  76775. * Updates the current quaternion from the given float coordinates
  76776. * @param x defines the x coordinate
  76777. * @param y defines the y coordinate
  76778. * @param z defines the z coordinate
  76779. * @param w defines the w coordinate
  76780. * @returns the updated current quaternion
  76781. */
  76782. set(x: number, y: number, z: number, w: number): Quaternion;
  76783. /**
  76784. * Adds two quaternions
  76785. * @param other defines the second operand
  76786. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76787. */
  76788. add(other: DeepImmutable<Quaternion>): Quaternion;
  76789. /**
  76790. * Add a quaternion to the current one
  76791. * @param other defines the quaternion to add
  76792. * @returns the current quaternion
  76793. */
  76794. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76795. /**
  76796. * Subtract two quaternions
  76797. * @param other defines the second operand
  76798. * @returns a new quaternion as the subtraction result of the given one from the current one
  76799. */
  76800. subtract(other: Quaternion): Quaternion;
  76801. /**
  76802. * Multiplies the current quaternion by a scale factor
  76803. * @param value defines the scale factor
  76804. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76805. */
  76806. scale(value: number): Quaternion;
  76807. /**
  76808. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76809. * @param scale defines the scale factor
  76810. * @param result defines the Quaternion object where to store the result
  76811. * @returns the unmodified current quaternion
  76812. */
  76813. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76814. /**
  76815. * Multiplies in place the current quaternion by a scale factor
  76816. * @param value defines the scale factor
  76817. * @returns the current modified quaternion
  76818. */
  76819. scaleInPlace(value: number): Quaternion;
  76820. /**
  76821. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76822. * @param scale defines the scale factor
  76823. * @param result defines the Quaternion object where to store the result
  76824. * @returns the unmodified current quaternion
  76825. */
  76826. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76827. /**
  76828. * Multiplies two quaternions
  76829. * @param q1 defines the second operand
  76830. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76831. */
  76832. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76833. /**
  76834. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76835. * @param q1 defines the second operand
  76836. * @param result defines the target quaternion
  76837. * @returns the current quaternion
  76838. */
  76839. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76840. /**
  76841. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76842. * @param q1 defines the second operand
  76843. * @returns the currentupdated quaternion
  76844. */
  76845. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76846. /**
  76847. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76848. * @param ref defines the target quaternion
  76849. * @returns the current quaternion
  76850. */
  76851. conjugateToRef(ref: Quaternion): Quaternion;
  76852. /**
  76853. * Conjugates in place (1-q) the current quaternion
  76854. * @returns the current updated quaternion
  76855. */
  76856. conjugateInPlace(): Quaternion;
  76857. /**
  76858. * Conjugates in place (1-q) the current quaternion
  76859. * @returns a new quaternion
  76860. */
  76861. conjugate(): Quaternion;
  76862. /**
  76863. * Gets length of current quaternion
  76864. * @returns the quaternion length (float)
  76865. */
  76866. length(): number;
  76867. /**
  76868. * Normalize in place the current quaternion
  76869. * @returns the current updated quaternion
  76870. */
  76871. normalize(): Quaternion;
  76872. /**
  76873. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76874. * @param order is a reserved parameter and is ignore for now
  76875. * @returns a new Vector3 containing the Euler angles
  76876. */
  76877. toEulerAngles(order?: string): Vector3;
  76878. /**
  76879. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76880. * @param result defines the vector which will be filled with the Euler angles
  76881. * @param order is a reserved parameter and is ignore for now
  76882. * @returns the current unchanged quaternion
  76883. */
  76884. toEulerAnglesToRef(result: Vector3): Quaternion;
  76885. /**
  76886. * Updates the given rotation matrix with the current quaternion values
  76887. * @param result defines the target matrix
  76888. * @returns the current unchanged quaternion
  76889. */
  76890. toRotationMatrix(result: Matrix): Quaternion;
  76891. /**
  76892. * Updates the current quaternion from the given rotation matrix values
  76893. * @param matrix defines the source matrix
  76894. * @returns the current updated quaternion
  76895. */
  76896. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76897. /**
  76898. * Creates a new quaternion from a rotation matrix
  76899. * @param matrix defines the source matrix
  76900. * @returns a new quaternion created from the given rotation matrix values
  76901. */
  76902. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76903. /**
  76904. * Updates the given quaternion with the given rotation matrix values
  76905. * @param matrix defines the source matrix
  76906. * @param result defines the target quaternion
  76907. */
  76908. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76909. /**
  76910. * Returns the dot product (float) between the quaternions "left" and "right"
  76911. * @param left defines the left operand
  76912. * @param right defines the right operand
  76913. * @returns the dot product
  76914. */
  76915. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76916. /**
  76917. * Checks if the two quaternions are close to each other
  76918. * @param quat0 defines the first quaternion to check
  76919. * @param quat1 defines the second quaternion to check
  76920. * @returns true if the two quaternions are close to each other
  76921. */
  76922. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76923. /**
  76924. * Creates an empty quaternion
  76925. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76926. */
  76927. static Zero(): Quaternion;
  76928. /**
  76929. * Inverse a given quaternion
  76930. * @param q defines the source quaternion
  76931. * @returns a new quaternion as the inverted current quaternion
  76932. */
  76933. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76934. /**
  76935. * Inverse a given quaternion
  76936. * @param q defines the source quaternion
  76937. * @param result the quaternion the result will be stored in
  76938. * @returns the result quaternion
  76939. */
  76940. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76941. /**
  76942. * Creates an identity quaternion
  76943. * @returns the identity quaternion
  76944. */
  76945. static Identity(): Quaternion;
  76946. /**
  76947. * Gets a boolean indicating if the given quaternion is identity
  76948. * @param quaternion defines the quaternion to check
  76949. * @returns true if the quaternion is identity
  76950. */
  76951. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76952. /**
  76953. * Creates a quaternion from a rotation around an axis
  76954. * @param axis defines the axis to use
  76955. * @param angle defines the angle to use
  76956. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76957. */
  76958. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76959. /**
  76960. * Creates a rotation around an axis and stores it into the given quaternion
  76961. * @param axis defines the axis to use
  76962. * @param angle defines the angle to use
  76963. * @param result defines the target quaternion
  76964. * @returns the target quaternion
  76965. */
  76966. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76967. /**
  76968. * Creates a new quaternion from data stored into an array
  76969. * @param array defines the data source
  76970. * @param offset defines the offset in the source array where the data starts
  76971. * @returns a new quaternion
  76972. */
  76973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76974. /**
  76975. * Create a quaternion from Euler rotation angles
  76976. * @param x Pitch
  76977. * @param y Yaw
  76978. * @param z Roll
  76979. * @returns the new Quaternion
  76980. */
  76981. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76982. /**
  76983. * Updates a quaternion from Euler rotation angles
  76984. * @param x Pitch
  76985. * @param y Yaw
  76986. * @param z Roll
  76987. * @param result the quaternion to store the result
  76988. * @returns the updated quaternion
  76989. */
  76990. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76991. /**
  76992. * Create a quaternion from Euler rotation vector
  76993. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76994. * @returns the new Quaternion
  76995. */
  76996. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76997. /**
  76998. * Updates a quaternion from Euler rotation vector
  76999. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77000. * @param result the quaternion to store the result
  77001. * @returns the updated quaternion
  77002. */
  77003. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77004. /**
  77005. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77006. * @param yaw defines the rotation around Y axis
  77007. * @param pitch defines the rotation around X axis
  77008. * @param roll defines the rotation around Z axis
  77009. * @returns the new quaternion
  77010. */
  77011. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77012. /**
  77013. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77014. * @param yaw defines the rotation around Y axis
  77015. * @param pitch defines the rotation around X axis
  77016. * @param roll defines the rotation around Z axis
  77017. * @param result defines the target quaternion
  77018. */
  77019. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77020. /**
  77021. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77022. * @param alpha defines the rotation around first axis
  77023. * @param beta defines the rotation around second axis
  77024. * @param gamma defines the rotation around third axis
  77025. * @returns the new quaternion
  77026. */
  77027. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77028. /**
  77029. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77030. * @param alpha defines the rotation around first axis
  77031. * @param beta defines the rotation around second axis
  77032. * @param gamma defines the rotation around third axis
  77033. * @param result defines the target quaternion
  77034. */
  77035. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77036. /**
  77037. * 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)
  77038. * @param axis1 defines the first axis
  77039. * @param axis2 defines the second axis
  77040. * @param axis3 defines the third axis
  77041. * @returns the new quaternion
  77042. */
  77043. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77044. /**
  77045. * 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
  77046. * @param axis1 defines the first axis
  77047. * @param axis2 defines the second axis
  77048. * @param axis3 defines the third axis
  77049. * @param ref defines the target quaternion
  77050. */
  77051. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77052. /**
  77053. * Interpolates between two quaternions
  77054. * @param left defines first quaternion
  77055. * @param right defines second quaternion
  77056. * @param amount defines the gradient to use
  77057. * @returns the new interpolated quaternion
  77058. */
  77059. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77060. /**
  77061. * Interpolates between two quaternions and stores it into a target quaternion
  77062. * @param left defines first quaternion
  77063. * @param right defines second quaternion
  77064. * @param amount defines the gradient to use
  77065. * @param result defines the target quaternion
  77066. */
  77067. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77068. /**
  77069. * Interpolate between two quaternions using Hermite interpolation
  77070. * @param value1 defines first quaternion
  77071. * @param tangent1 defines the incoming tangent
  77072. * @param value2 defines second quaternion
  77073. * @param tangent2 defines the outgoing tangent
  77074. * @param amount defines the target quaternion
  77075. * @returns the new interpolated quaternion
  77076. */
  77077. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77078. }
  77079. /**
  77080. * Class used to store matrix data (4x4)
  77081. */
  77082. export class Matrix {
  77083. private static _updateFlagSeed;
  77084. private static _identityReadOnly;
  77085. private _isIdentity;
  77086. private _isIdentityDirty;
  77087. private _isIdentity3x2;
  77088. private _isIdentity3x2Dirty;
  77089. /**
  77090. * Gets the update flag of the matrix which is an unique number for the matrix.
  77091. * It will be incremented every time the matrix data change.
  77092. * You can use it to speed the comparison between two versions of the same matrix.
  77093. */
  77094. updateFlag: number;
  77095. private readonly _m;
  77096. /**
  77097. * Gets the internal data of the matrix
  77098. */
  77099. get m(): DeepImmutable<Float32Array>;
  77100. /** @hidden */
  77101. _markAsUpdated(): void;
  77102. /** @hidden */
  77103. private _updateIdentityStatus;
  77104. /**
  77105. * Creates an empty matrix (filled with zeros)
  77106. */
  77107. constructor();
  77108. /**
  77109. * Check if the current matrix is identity
  77110. * @returns true is the matrix is the identity matrix
  77111. */
  77112. isIdentity(): boolean;
  77113. /**
  77114. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77115. * @returns true is the matrix is the identity matrix
  77116. */
  77117. isIdentityAs3x2(): boolean;
  77118. /**
  77119. * Gets the determinant of the matrix
  77120. * @returns the matrix determinant
  77121. */
  77122. determinant(): number;
  77123. /**
  77124. * Returns the matrix as a Float32Array
  77125. * @returns the matrix underlying array
  77126. */
  77127. toArray(): DeepImmutable<Float32Array>;
  77128. /**
  77129. * Returns the matrix as a Float32Array
  77130. * @returns the matrix underlying array.
  77131. */
  77132. asArray(): DeepImmutable<Float32Array>;
  77133. /**
  77134. * Inverts the current matrix in place
  77135. * @returns the current inverted matrix
  77136. */
  77137. invert(): Matrix;
  77138. /**
  77139. * Sets all the matrix elements to zero
  77140. * @returns the current matrix
  77141. */
  77142. reset(): Matrix;
  77143. /**
  77144. * Adds the current matrix with a second one
  77145. * @param other defines the matrix to add
  77146. * @returns a new matrix as the addition of the current matrix and the given one
  77147. */
  77148. add(other: DeepImmutable<Matrix>): Matrix;
  77149. /**
  77150. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77151. * @param other defines the matrix to add
  77152. * @param result defines the target matrix
  77153. * @returns the current matrix
  77154. */
  77155. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77156. /**
  77157. * Adds in place the given matrix to the current matrix
  77158. * @param other defines the second operand
  77159. * @returns the current updated matrix
  77160. */
  77161. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77162. /**
  77163. * Sets the given matrix to the current inverted Matrix
  77164. * @param other defines the target matrix
  77165. * @returns the unmodified current matrix
  77166. */
  77167. invertToRef(other: Matrix): Matrix;
  77168. /**
  77169. * add a value at the specified position in the current Matrix
  77170. * @param index the index of the value within the matrix. between 0 and 15.
  77171. * @param value the value to be added
  77172. * @returns the current updated matrix
  77173. */
  77174. addAtIndex(index: number, value: number): Matrix;
  77175. /**
  77176. * mutiply the specified position in the current Matrix by a value
  77177. * @param index the index of the value within the matrix. between 0 and 15.
  77178. * @param value the value to be added
  77179. * @returns the current updated matrix
  77180. */
  77181. multiplyAtIndex(index: number, value: number): Matrix;
  77182. /**
  77183. * Inserts the translation vector (using 3 floats) in the current matrix
  77184. * @param x defines the 1st component of the translation
  77185. * @param y defines the 2nd component of the translation
  77186. * @param z defines the 3rd component of the translation
  77187. * @returns the current updated matrix
  77188. */
  77189. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77190. /**
  77191. * Adds the translation vector (using 3 floats) in the current matrix
  77192. * @param x defines the 1st component of the translation
  77193. * @param y defines the 2nd component of the translation
  77194. * @param z defines the 3rd component of the translation
  77195. * @returns the current updated matrix
  77196. */
  77197. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77198. /**
  77199. * Inserts the translation vector in the current matrix
  77200. * @param vector3 defines the translation to insert
  77201. * @returns the current updated matrix
  77202. */
  77203. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77204. /**
  77205. * Gets the translation value of the current matrix
  77206. * @returns a new Vector3 as the extracted translation from the matrix
  77207. */
  77208. getTranslation(): Vector3;
  77209. /**
  77210. * Fill a Vector3 with the extracted translation from the matrix
  77211. * @param result defines the Vector3 where to store the translation
  77212. * @returns the current matrix
  77213. */
  77214. getTranslationToRef(result: Vector3): Matrix;
  77215. /**
  77216. * Remove rotation and scaling part from the matrix
  77217. * @returns the updated matrix
  77218. */
  77219. removeRotationAndScaling(): Matrix;
  77220. /**
  77221. * Multiply two matrices
  77222. * @param other defines the second operand
  77223. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77224. */
  77225. multiply(other: DeepImmutable<Matrix>): Matrix;
  77226. /**
  77227. * Copy the current matrix from the given one
  77228. * @param other defines the source matrix
  77229. * @returns the current updated matrix
  77230. */
  77231. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77232. /**
  77233. * Populates the given array from the starting index with the current matrix values
  77234. * @param array defines the target array
  77235. * @param offset defines the offset in the target array where to start storing values
  77236. * @returns the current matrix
  77237. */
  77238. copyToArray(array: Float32Array, offset?: number): Matrix;
  77239. /**
  77240. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77241. * @param other defines the second operand
  77242. * @param result defines the matrix where to store the multiplication
  77243. * @returns the current matrix
  77244. */
  77245. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77246. /**
  77247. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77248. * @param other defines the second operand
  77249. * @param result defines the array where to store the multiplication
  77250. * @param offset defines the offset in the target array where to start storing values
  77251. * @returns the current matrix
  77252. */
  77253. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77254. /**
  77255. * Check equality between this matrix and a second one
  77256. * @param value defines the second matrix to compare
  77257. * @returns true is the current matrix and the given one values are strictly equal
  77258. */
  77259. equals(value: DeepImmutable<Matrix>): boolean;
  77260. /**
  77261. * Clone the current matrix
  77262. * @returns a new matrix from the current matrix
  77263. */
  77264. clone(): Matrix;
  77265. /**
  77266. * Returns the name of the current matrix class
  77267. * @returns the string "Matrix"
  77268. */
  77269. getClassName(): string;
  77270. /**
  77271. * Gets the hash code of the current matrix
  77272. * @returns the hash code
  77273. */
  77274. getHashCode(): number;
  77275. /**
  77276. * Decomposes the current Matrix into a translation, rotation and scaling components
  77277. * @param scale defines the scale vector3 given as a reference to update
  77278. * @param rotation defines the rotation quaternion given as a reference to update
  77279. * @param translation defines the translation vector3 given as a reference to update
  77280. * @returns true if operation was successful
  77281. */
  77282. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77283. /**
  77284. * Gets specific row of the matrix
  77285. * @param index defines the number of the row to get
  77286. * @returns the index-th row of the current matrix as a new Vector4
  77287. */
  77288. getRow(index: number): Nullable<Vector4>;
  77289. /**
  77290. * Sets the index-th row of the current matrix to the vector4 values
  77291. * @param index defines the number of the row to set
  77292. * @param row defines the target vector4
  77293. * @returns the updated current matrix
  77294. */
  77295. setRow(index: number, row: Vector4): Matrix;
  77296. /**
  77297. * Compute the transpose of the matrix
  77298. * @returns the new transposed matrix
  77299. */
  77300. transpose(): Matrix;
  77301. /**
  77302. * Compute the transpose of the matrix and store it in a given matrix
  77303. * @param result defines the target matrix
  77304. * @returns the current matrix
  77305. */
  77306. transposeToRef(result: Matrix): Matrix;
  77307. /**
  77308. * Sets the index-th row of the current matrix with the given 4 x float values
  77309. * @param index defines the row index
  77310. * @param x defines the x component to set
  77311. * @param y defines the y component to set
  77312. * @param z defines the z component to set
  77313. * @param w defines the w component to set
  77314. * @returns the updated current matrix
  77315. */
  77316. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77317. /**
  77318. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77319. * @param scale defines the scale factor
  77320. * @returns a new matrix
  77321. */
  77322. scale(scale: number): Matrix;
  77323. /**
  77324. * Scale the current matrix values by a factor to a given result matrix
  77325. * @param scale defines the scale factor
  77326. * @param result defines the matrix to store the result
  77327. * @returns the current matrix
  77328. */
  77329. scaleToRef(scale: number, result: Matrix): Matrix;
  77330. /**
  77331. * Scale the current matrix values by a factor and add the result to a given matrix
  77332. * @param scale defines the scale factor
  77333. * @param result defines the Matrix to store the result
  77334. * @returns the current matrix
  77335. */
  77336. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77337. /**
  77338. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77339. * @param ref matrix to store the result
  77340. */
  77341. toNormalMatrix(ref: Matrix): void;
  77342. /**
  77343. * Gets only rotation part of the current matrix
  77344. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77345. */
  77346. getRotationMatrix(): Matrix;
  77347. /**
  77348. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77349. * @param result defines the target matrix to store data to
  77350. * @returns the current matrix
  77351. */
  77352. getRotationMatrixToRef(result: Matrix): Matrix;
  77353. /**
  77354. * Toggles model matrix from being right handed to left handed in place and vice versa
  77355. */
  77356. toggleModelMatrixHandInPlace(): void;
  77357. /**
  77358. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77359. */
  77360. toggleProjectionMatrixHandInPlace(): void;
  77361. /**
  77362. * Creates a matrix from an array
  77363. * @param array defines the source array
  77364. * @param offset defines an offset in the source array
  77365. * @returns a new Matrix set from the starting index of the given array
  77366. */
  77367. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77368. /**
  77369. * Copy the content of an array into a given matrix
  77370. * @param array defines the source array
  77371. * @param offset defines an offset in the source array
  77372. * @param result defines the target matrix
  77373. */
  77374. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77375. /**
  77376. * Stores an array into a matrix after having multiplied each component by a given factor
  77377. * @param array defines the source array
  77378. * @param offset defines the offset in the source array
  77379. * @param scale defines the scaling factor
  77380. * @param result defines the target matrix
  77381. */
  77382. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77383. /**
  77384. * Gets an identity matrix that must not be updated
  77385. */
  77386. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77387. /**
  77388. * Stores a list of values (16) inside a given matrix
  77389. * @param initialM11 defines 1st value of 1st row
  77390. * @param initialM12 defines 2nd value of 1st row
  77391. * @param initialM13 defines 3rd value of 1st row
  77392. * @param initialM14 defines 4th value of 1st row
  77393. * @param initialM21 defines 1st value of 2nd row
  77394. * @param initialM22 defines 2nd value of 2nd row
  77395. * @param initialM23 defines 3rd value of 2nd row
  77396. * @param initialM24 defines 4th value of 2nd row
  77397. * @param initialM31 defines 1st value of 3rd row
  77398. * @param initialM32 defines 2nd value of 3rd row
  77399. * @param initialM33 defines 3rd value of 3rd row
  77400. * @param initialM34 defines 4th value of 3rd row
  77401. * @param initialM41 defines 1st value of 4th row
  77402. * @param initialM42 defines 2nd value of 4th row
  77403. * @param initialM43 defines 3rd value of 4th row
  77404. * @param initialM44 defines 4th value of 4th row
  77405. * @param result defines the target matrix
  77406. */
  77407. 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;
  77408. /**
  77409. * Creates new matrix from a list of values (16)
  77410. * @param initialM11 defines 1st value of 1st row
  77411. * @param initialM12 defines 2nd value of 1st row
  77412. * @param initialM13 defines 3rd value of 1st row
  77413. * @param initialM14 defines 4th value of 1st row
  77414. * @param initialM21 defines 1st value of 2nd row
  77415. * @param initialM22 defines 2nd value of 2nd row
  77416. * @param initialM23 defines 3rd value of 2nd row
  77417. * @param initialM24 defines 4th value of 2nd row
  77418. * @param initialM31 defines 1st value of 3rd row
  77419. * @param initialM32 defines 2nd value of 3rd row
  77420. * @param initialM33 defines 3rd value of 3rd row
  77421. * @param initialM34 defines 4th value of 3rd row
  77422. * @param initialM41 defines 1st value of 4th row
  77423. * @param initialM42 defines 2nd value of 4th row
  77424. * @param initialM43 defines 3rd value of 4th row
  77425. * @param initialM44 defines 4th value of 4th row
  77426. * @returns the new matrix
  77427. */
  77428. 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;
  77429. /**
  77430. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77431. * @param scale defines the scale vector3
  77432. * @param rotation defines the rotation quaternion
  77433. * @param translation defines the translation vector3
  77434. * @returns a new matrix
  77435. */
  77436. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77437. /**
  77438. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77439. * @param scale defines the scale vector3
  77440. * @param rotation defines the rotation quaternion
  77441. * @param translation defines the translation vector3
  77442. * @param result defines the target matrix
  77443. */
  77444. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77445. /**
  77446. * Creates a new identity matrix
  77447. * @returns a new identity matrix
  77448. */
  77449. static Identity(): Matrix;
  77450. /**
  77451. * Creates a new identity matrix and stores the result in a given matrix
  77452. * @param result defines the target matrix
  77453. */
  77454. static IdentityToRef(result: Matrix): void;
  77455. /**
  77456. * Creates a new zero matrix
  77457. * @returns a new zero matrix
  77458. */
  77459. static Zero(): Matrix;
  77460. /**
  77461. * Creates a new rotation matrix for "angle" radians around the X axis
  77462. * @param angle defines the angle (in radians) to use
  77463. * @return the new matrix
  77464. */
  77465. static RotationX(angle: number): Matrix;
  77466. /**
  77467. * Creates a new matrix as the invert of a given matrix
  77468. * @param source defines the source matrix
  77469. * @returns the new matrix
  77470. */
  77471. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77472. /**
  77473. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77474. * @param angle defines the angle (in radians) to use
  77475. * @param result defines the target matrix
  77476. */
  77477. static RotationXToRef(angle: number, result: Matrix): void;
  77478. /**
  77479. * Creates a new rotation matrix for "angle" radians around the Y axis
  77480. * @param angle defines the angle (in radians) to use
  77481. * @return the new matrix
  77482. */
  77483. static RotationY(angle: number): Matrix;
  77484. /**
  77485. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77486. * @param angle defines the angle (in radians) to use
  77487. * @param result defines the target matrix
  77488. */
  77489. static RotationYToRef(angle: number, result: Matrix): void;
  77490. /**
  77491. * Creates a new rotation matrix for "angle" radians around the Z axis
  77492. * @param angle defines the angle (in radians) to use
  77493. * @return the new matrix
  77494. */
  77495. static RotationZ(angle: number): Matrix;
  77496. /**
  77497. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77498. * @param angle defines the angle (in radians) to use
  77499. * @param result defines the target matrix
  77500. */
  77501. static RotationZToRef(angle: number, result: Matrix): void;
  77502. /**
  77503. * Creates a new rotation matrix for "angle" radians around the given axis
  77504. * @param axis defines the axis to use
  77505. * @param angle defines the angle (in radians) to use
  77506. * @return the new matrix
  77507. */
  77508. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77509. /**
  77510. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77511. * @param axis defines the axis to use
  77512. * @param angle defines the angle (in radians) to use
  77513. * @param result defines the target matrix
  77514. */
  77515. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77516. /**
  77517. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77518. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77519. * @param from defines the vector to align
  77520. * @param to defines the vector to align to
  77521. * @param result defines the target matrix
  77522. */
  77523. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77524. /**
  77525. * Creates a rotation matrix
  77526. * @param yaw defines the yaw angle in radians (Y axis)
  77527. * @param pitch defines the pitch angle in radians (X axis)
  77528. * @param roll defines the roll angle in radians (X axis)
  77529. * @returns the new rotation matrix
  77530. */
  77531. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77532. /**
  77533. * Creates a rotation matrix and stores it in a given matrix
  77534. * @param yaw defines the yaw angle in radians (Y axis)
  77535. * @param pitch defines the pitch angle in radians (X axis)
  77536. * @param roll defines the roll angle in radians (X axis)
  77537. * @param result defines the target matrix
  77538. */
  77539. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77540. /**
  77541. * Creates a scaling matrix
  77542. * @param x defines the scale factor on X axis
  77543. * @param y defines the scale factor on Y axis
  77544. * @param z defines the scale factor on Z axis
  77545. * @returns the new matrix
  77546. */
  77547. static Scaling(x: number, y: number, z: number): Matrix;
  77548. /**
  77549. * Creates a scaling matrix and stores it in a given matrix
  77550. * @param x defines the scale factor on X axis
  77551. * @param y defines the scale factor on Y axis
  77552. * @param z defines the scale factor on Z axis
  77553. * @param result defines the target matrix
  77554. */
  77555. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77556. /**
  77557. * Creates a translation matrix
  77558. * @param x defines the translation on X axis
  77559. * @param y defines the translation on Y axis
  77560. * @param z defines the translationon Z axis
  77561. * @returns the new matrix
  77562. */
  77563. static Translation(x: number, y: number, z: number): Matrix;
  77564. /**
  77565. * Creates a translation matrix and stores it in a given matrix
  77566. * @param x defines the translation on X axis
  77567. * @param y defines the translation on Y axis
  77568. * @param z defines the translationon Z axis
  77569. * @param result defines the target matrix
  77570. */
  77571. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77572. /**
  77573. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77574. * @param startValue defines the start value
  77575. * @param endValue defines the end value
  77576. * @param gradient defines the gradient factor
  77577. * @returns the new matrix
  77578. */
  77579. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77580. /**
  77581. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77582. * @param startValue defines the start value
  77583. * @param endValue defines the end value
  77584. * @param gradient defines the gradient factor
  77585. * @param result defines the Matrix object where to store data
  77586. */
  77587. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77588. /**
  77589. * Builds a new matrix whose values are computed by:
  77590. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77591. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77592. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77593. * @param startValue defines the first matrix
  77594. * @param endValue defines the second matrix
  77595. * @param gradient defines the gradient between the two matrices
  77596. * @returns the new matrix
  77597. */
  77598. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77599. /**
  77600. * Update a matrix to values which are computed by:
  77601. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77602. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77603. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77604. * @param startValue defines the first matrix
  77605. * @param endValue defines the second matrix
  77606. * @param gradient defines the gradient between the two matrices
  77607. * @param result defines the target matrix
  77608. */
  77609. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77610. /**
  77611. * 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"
  77612. * This function works in left handed mode
  77613. * @param eye defines the final position of the entity
  77614. * @param target defines where the entity should look at
  77615. * @param up defines the up vector for the entity
  77616. * @returns the new matrix
  77617. */
  77618. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77619. /**
  77620. * 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".
  77621. * This function works in left handed mode
  77622. * @param eye defines the final position of the entity
  77623. * @param target defines where the entity should look at
  77624. * @param up defines the up vector for the entity
  77625. * @param result defines the target matrix
  77626. */
  77627. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77628. /**
  77629. * 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"
  77630. * This function works in right handed mode
  77631. * @param eye defines the final position of the entity
  77632. * @param target defines where the entity should look at
  77633. * @param up defines the up vector for the entity
  77634. * @returns the new matrix
  77635. */
  77636. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77637. /**
  77638. * 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".
  77639. * This function works in right handed mode
  77640. * @param eye defines the final position of the entity
  77641. * @param target defines where the entity should look at
  77642. * @param up defines the up vector for the entity
  77643. * @param result defines the target matrix
  77644. */
  77645. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77646. /**
  77647. * Create a left-handed orthographic projection matrix
  77648. * @param width defines the viewport width
  77649. * @param height defines the viewport height
  77650. * @param znear defines the near clip plane
  77651. * @param zfar defines the far clip plane
  77652. * @returns a new matrix as a left-handed orthographic projection matrix
  77653. */
  77654. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77655. /**
  77656. * Store a left-handed orthographic projection to a given matrix
  77657. * @param width defines the viewport width
  77658. * @param height defines the viewport height
  77659. * @param znear defines the near clip plane
  77660. * @param zfar defines the far clip plane
  77661. * @param result defines the target matrix
  77662. */
  77663. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77664. /**
  77665. * Create a left-handed orthographic projection matrix
  77666. * @param left defines the viewport left coordinate
  77667. * @param right defines the viewport right coordinate
  77668. * @param bottom defines the viewport bottom coordinate
  77669. * @param top defines the viewport top coordinate
  77670. * @param znear defines the near clip plane
  77671. * @param zfar defines the far clip plane
  77672. * @returns a new matrix as a left-handed orthographic projection matrix
  77673. */
  77674. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77675. /**
  77676. * Stores a left-handed orthographic projection into a given matrix
  77677. * @param left defines the viewport left coordinate
  77678. * @param right defines the viewport right coordinate
  77679. * @param bottom defines the viewport bottom coordinate
  77680. * @param top defines the viewport top coordinate
  77681. * @param znear defines the near clip plane
  77682. * @param zfar defines the far clip plane
  77683. * @param result defines the target matrix
  77684. */
  77685. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77686. /**
  77687. * Creates a right-handed orthographic projection matrix
  77688. * @param left defines the viewport left coordinate
  77689. * @param right defines the viewport right coordinate
  77690. * @param bottom defines the viewport bottom coordinate
  77691. * @param top defines the viewport top coordinate
  77692. * @param znear defines the near clip plane
  77693. * @param zfar defines the far clip plane
  77694. * @returns a new matrix as a right-handed orthographic projection matrix
  77695. */
  77696. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77697. /**
  77698. * Stores a right-handed orthographic projection into a given matrix
  77699. * @param left defines the viewport left coordinate
  77700. * @param right defines the viewport right coordinate
  77701. * @param bottom defines the viewport bottom coordinate
  77702. * @param top defines the viewport top coordinate
  77703. * @param znear defines the near clip plane
  77704. * @param zfar defines the far clip plane
  77705. * @param result defines the target matrix
  77706. */
  77707. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77708. /**
  77709. * Creates a left-handed perspective projection matrix
  77710. * @param width defines the viewport width
  77711. * @param height defines the viewport height
  77712. * @param znear defines the near clip plane
  77713. * @param zfar defines the far clip plane
  77714. * @returns a new matrix as a left-handed perspective projection matrix
  77715. */
  77716. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77717. /**
  77718. * Creates a left-handed perspective projection matrix
  77719. * @param fov defines the horizontal field of view
  77720. * @param aspect defines the aspect ratio
  77721. * @param znear defines the near clip plane
  77722. * @param zfar defines the far clip plane
  77723. * @returns a new matrix as a left-handed perspective projection matrix
  77724. */
  77725. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77726. /**
  77727. * Stores a left-handed perspective projection into a given matrix
  77728. * @param fov defines the horizontal field of view
  77729. * @param aspect defines the aspect ratio
  77730. * @param znear defines the near clip plane
  77731. * @param zfar defines the far clip plane
  77732. * @param result defines the target matrix
  77733. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77734. */
  77735. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77736. /**
  77737. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77738. * @param fov defines the horizontal field of view
  77739. * @param aspect defines the aspect ratio
  77740. * @param znear defines the near clip plane
  77741. * @param zfar not used as infinity is used as far clip
  77742. * @param result defines the target matrix
  77743. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77744. */
  77745. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77746. /**
  77747. * Creates a right-handed perspective projection matrix
  77748. * @param fov defines the horizontal field of view
  77749. * @param aspect defines the aspect ratio
  77750. * @param znear defines the near clip plane
  77751. * @param zfar defines the far clip plane
  77752. * @returns a new matrix as a right-handed perspective projection matrix
  77753. */
  77754. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77755. /**
  77756. * Stores a right-handed perspective projection into a given matrix
  77757. * @param fov defines the horizontal field of view
  77758. * @param aspect defines the aspect ratio
  77759. * @param znear defines the near clip plane
  77760. * @param zfar defines the far clip plane
  77761. * @param result defines the target matrix
  77762. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77763. */
  77764. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77765. /**
  77766. * Stores a right-handed perspective projection into a given matrix
  77767. * @param fov defines the horizontal field of view
  77768. * @param aspect defines the aspect ratio
  77769. * @param znear defines the near clip plane
  77770. * @param zfar not used as infinity is used as far clip
  77771. * @param result defines the target matrix
  77772. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77773. */
  77774. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77775. /**
  77776. * Stores a perspective projection for WebVR info a given matrix
  77777. * @param fov defines the field of view
  77778. * @param znear defines the near clip plane
  77779. * @param zfar defines the far clip plane
  77780. * @param result defines the target matrix
  77781. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77782. */
  77783. static PerspectiveFovWebVRToRef(fov: {
  77784. upDegrees: number;
  77785. downDegrees: number;
  77786. leftDegrees: number;
  77787. rightDegrees: number;
  77788. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77789. /**
  77790. * Computes a complete transformation matrix
  77791. * @param viewport defines the viewport to use
  77792. * @param world defines the world matrix
  77793. * @param view defines the view matrix
  77794. * @param projection defines the projection matrix
  77795. * @param zmin defines the near clip plane
  77796. * @param zmax defines the far clip plane
  77797. * @returns the transformation matrix
  77798. */
  77799. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77800. /**
  77801. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77802. * @param matrix defines the matrix to use
  77803. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77804. */
  77805. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77806. /**
  77807. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77808. * @param matrix defines the matrix to use
  77809. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77810. */
  77811. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77812. /**
  77813. * Compute the transpose of a given matrix
  77814. * @param matrix defines the matrix to transpose
  77815. * @returns the new matrix
  77816. */
  77817. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77818. /**
  77819. * Compute the transpose of a matrix and store it in a target matrix
  77820. * @param matrix defines the matrix to transpose
  77821. * @param result defines the target matrix
  77822. */
  77823. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77824. /**
  77825. * Computes a reflection matrix from a plane
  77826. * @param plane defines the reflection plane
  77827. * @returns a new matrix
  77828. */
  77829. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77830. /**
  77831. * Computes a reflection matrix from a plane
  77832. * @param plane defines the reflection plane
  77833. * @param result defines the target matrix
  77834. */
  77835. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77836. /**
  77837. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77838. * @param xaxis defines the value of the 1st axis
  77839. * @param yaxis defines the value of the 2nd axis
  77840. * @param zaxis defines the value of the 3rd axis
  77841. * @param result defines the target matrix
  77842. */
  77843. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77844. /**
  77845. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77846. * @param quat defines the quaternion to use
  77847. * @param result defines the target matrix
  77848. */
  77849. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77850. }
  77851. /**
  77852. * @hidden
  77853. */
  77854. export class TmpVectors {
  77855. static Vector2: Vector2[];
  77856. static Vector3: Vector3[];
  77857. static Vector4: Vector4[];
  77858. static Quaternion: Quaternion[];
  77859. static Matrix: Matrix[];
  77860. }
  77861. }
  77862. declare module BABYLON {
  77863. /**
  77864. * Defines potential orientation for back face culling
  77865. */
  77866. export enum Orientation {
  77867. /**
  77868. * Clockwise
  77869. */
  77870. CW = 0,
  77871. /** Counter clockwise */
  77872. CCW = 1
  77873. }
  77874. /** Class used to represent a Bezier curve */
  77875. export class BezierCurve {
  77876. /**
  77877. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77878. * @param t defines the time
  77879. * @param x1 defines the left coordinate on X axis
  77880. * @param y1 defines the left coordinate on Y axis
  77881. * @param x2 defines the right coordinate on X axis
  77882. * @param y2 defines the right coordinate on Y axis
  77883. * @returns the interpolated value
  77884. */
  77885. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77886. }
  77887. /**
  77888. * Defines angle representation
  77889. */
  77890. export class Angle {
  77891. private _radians;
  77892. /**
  77893. * Creates an Angle object of "radians" radians (float).
  77894. * @param radians the angle in radians
  77895. */
  77896. constructor(radians: number);
  77897. /**
  77898. * Get value in degrees
  77899. * @returns the Angle value in degrees (float)
  77900. */
  77901. degrees(): number;
  77902. /**
  77903. * Get value in radians
  77904. * @returns the Angle value in radians (float)
  77905. */
  77906. radians(): number;
  77907. /**
  77908. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77909. * @param a defines first vector
  77910. * @param b defines second vector
  77911. * @returns a new Angle
  77912. */
  77913. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77914. /**
  77915. * Gets a new Angle object from the given float in radians
  77916. * @param radians defines the angle value in radians
  77917. * @returns a new Angle
  77918. */
  77919. static FromRadians(radians: number): Angle;
  77920. /**
  77921. * Gets a new Angle object from the given float in degrees
  77922. * @param degrees defines the angle value in degrees
  77923. * @returns a new Angle
  77924. */
  77925. static FromDegrees(degrees: number): Angle;
  77926. }
  77927. /**
  77928. * This represents an arc in a 2d space.
  77929. */
  77930. export class Arc2 {
  77931. /** Defines the start point of the arc */
  77932. startPoint: Vector2;
  77933. /** Defines the mid point of the arc */
  77934. midPoint: Vector2;
  77935. /** Defines the end point of the arc */
  77936. endPoint: Vector2;
  77937. /**
  77938. * Defines the center point of the arc.
  77939. */
  77940. centerPoint: Vector2;
  77941. /**
  77942. * Defines the radius of the arc.
  77943. */
  77944. radius: number;
  77945. /**
  77946. * Defines the angle of the arc (from mid point to end point).
  77947. */
  77948. angle: Angle;
  77949. /**
  77950. * Defines the start angle of the arc (from start point to middle point).
  77951. */
  77952. startAngle: Angle;
  77953. /**
  77954. * Defines the orientation of the arc (clock wise/counter clock wise).
  77955. */
  77956. orientation: Orientation;
  77957. /**
  77958. * Creates an Arc object from the three given points : start, middle and end.
  77959. * @param startPoint Defines the start point of the arc
  77960. * @param midPoint Defines the midlle point of the arc
  77961. * @param endPoint Defines the end point of the arc
  77962. */
  77963. constructor(
  77964. /** Defines the start point of the arc */
  77965. startPoint: Vector2,
  77966. /** Defines the mid point of the arc */
  77967. midPoint: Vector2,
  77968. /** Defines the end point of the arc */
  77969. endPoint: Vector2);
  77970. }
  77971. /**
  77972. * Represents a 2D path made up of multiple 2D points
  77973. */
  77974. export class Path2 {
  77975. private _points;
  77976. private _length;
  77977. /**
  77978. * If the path start and end point are the same
  77979. */
  77980. closed: boolean;
  77981. /**
  77982. * Creates a Path2 object from the starting 2D coordinates x and y.
  77983. * @param x the starting points x value
  77984. * @param y the starting points y value
  77985. */
  77986. constructor(x: number, y: number);
  77987. /**
  77988. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77989. * @param x the added points x value
  77990. * @param y the added points y value
  77991. * @returns the updated Path2.
  77992. */
  77993. addLineTo(x: number, y: number): Path2;
  77994. /**
  77995. * 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.
  77996. * @param midX middle point x value
  77997. * @param midY middle point y value
  77998. * @param endX end point x value
  77999. * @param endY end point y value
  78000. * @param numberOfSegments (default: 36)
  78001. * @returns the updated Path2.
  78002. */
  78003. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78004. /**
  78005. * Closes the Path2.
  78006. * @returns the Path2.
  78007. */
  78008. close(): Path2;
  78009. /**
  78010. * Gets the sum of the distance between each sequential point in the path
  78011. * @returns the Path2 total length (float).
  78012. */
  78013. length(): number;
  78014. /**
  78015. * Gets the points which construct the path
  78016. * @returns the Path2 internal array of points.
  78017. */
  78018. getPoints(): Vector2[];
  78019. /**
  78020. * Retreives the point at the distance aways from the starting point
  78021. * @param normalizedLengthPosition the length along the path to retreive the point from
  78022. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78023. */
  78024. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78025. /**
  78026. * Creates a new path starting from an x and y position
  78027. * @param x starting x value
  78028. * @param y starting y value
  78029. * @returns a new Path2 starting at the coordinates (x, y).
  78030. */
  78031. static StartingAt(x: number, y: number): Path2;
  78032. }
  78033. /**
  78034. * Represents a 3D path made up of multiple 3D points
  78035. */
  78036. export class Path3D {
  78037. /**
  78038. * an array of Vector3, the curve axis of the Path3D
  78039. */
  78040. path: Vector3[];
  78041. private _curve;
  78042. private _distances;
  78043. private _tangents;
  78044. private _normals;
  78045. private _binormals;
  78046. private _raw;
  78047. private _alignTangentsWithPath;
  78048. private readonly _pointAtData;
  78049. /**
  78050. * new Path3D(path, normal, raw)
  78051. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78052. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78053. * @param path an array of Vector3, the curve axis of the Path3D
  78054. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78055. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78056. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78057. */
  78058. constructor(
  78059. /**
  78060. * an array of Vector3, the curve axis of the Path3D
  78061. */
  78062. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  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. getCurve(): Vector3[];
  78068. /**
  78069. * Returns the Path3D array of successive Vector3 designing its curve.
  78070. * @returns the Path3D array of successive Vector3 designing its curve.
  78071. */
  78072. getPoints(): Vector3[];
  78073. /**
  78074. * @returns the computed length (float) of the path.
  78075. */
  78076. length(): number;
  78077. /**
  78078. * Returns an array populated with tangent vectors on each Path3D curve point.
  78079. * @returns an array populated with tangent vectors on each Path3D curve point.
  78080. */
  78081. getTangents(): Vector3[];
  78082. /**
  78083. * Returns an array populated with normal vectors on each Path3D curve point.
  78084. * @returns an array populated with normal vectors on each Path3D curve point.
  78085. */
  78086. getNormals(): Vector3[];
  78087. /**
  78088. * Returns an array populated with binormal vectors on each Path3D curve point.
  78089. * @returns an array populated with binormal vectors on each Path3D curve point.
  78090. */
  78091. getBinormals(): Vector3[];
  78092. /**
  78093. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78094. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78095. */
  78096. getDistances(): number[];
  78097. /**
  78098. * Returns an interpolated point along this path
  78099. * @param position the position of the point along this path, from 0.0 to 1.0
  78100. * @returns a new Vector3 as the point
  78101. */
  78102. getPointAt(position: number): Vector3;
  78103. /**
  78104. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78105. * @param position the position of the point along this path, from 0.0 to 1.0
  78106. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78107. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78108. */
  78109. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78110. /**
  78111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78112. * @param position the position of the point along this path, from 0.0 to 1.0
  78113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78114. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78115. */
  78116. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78117. /**
  78118. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78119. * @param position the position of the point along this path, from 0.0 to 1.0
  78120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78121. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78122. */
  78123. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78124. /**
  78125. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78126. * @param position the position of the point along this path, from 0.0 to 1.0
  78127. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78128. */
  78129. getDistanceAt(position: number): number;
  78130. /**
  78131. * Returns the array index of the previous point of an interpolated point along this path
  78132. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78133. * @returns the array index
  78134. */
  78135. getPreviousPointIndexAt(position: number): number;
  78136. /**
  78137. * 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)
  78138. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78139. * @returns the sub position
  78140. */
  78141. getSubPositionAt(position: number): number;
  78142. /**
  78143. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78144. * @param target the vector of which to get the closest position to
  78145. * @returns the position of the closest virtual point on this path to the target vector
  78146. */
  78147. getClosestPositionTo(target: Vector3): number;
  78148. /**
  78149. * Returns a sub path (slice) of this path
  78150. * @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
  78151. * @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
  78152. * @returns a sub path (slice) of this path
  78153. */
  78154. slice(start?: number, end?: number): Path3D;
  78155. /**
  78156. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78157. * @param path path which all values are copied into the curves points
  78158. * @param firstNormal which should be projected onto the curve
  78159. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78160. * @returns the same object updated.
  78161. */
  78162. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78163. private _compute;
  78164. private _getFirstNonNullVector;
  78165. private _getLastNonNullVector;
  78166. private _normalVector;
  78167. /**
  78168. * Updates the point at data for an interpolated point along this curve
  78169. * @param position the position of the point along this curve, from 0.0 to 1.0
  78170. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78171. * @returns the (updated) point at data
  78172. */
  78173. private _updatePointAtData;
  78174. /**
  78175. * Updates the point at data from the specified parameters
  78176. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78177. * @param point the interpolated point
  78178. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78179. */
  78180. private _setPointAtData;
  78181. /**
  78182. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78183. */
  78184. private _updateInterpolationMatrix;
  78185. }
  78186. /**
  78187. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78188. * A Curve3 is designed from a series of successive Vector3.
  78189. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78190. */
  78191. export class Curve3 {
  78192. private _points;
  78193. private _length;
  78194. /**
  78195. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78196. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78197. * @param v1 (Vector3) the control point
  78198. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78199. * @param nbPoints (integer) the wanted number of points in the curve
  78200. * @returns the created Curve3
  78201. */
  78202. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78203. /**
  78204. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78205. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78206. * @param v1 (Vector3) the first control point
  78207. * @param v2 (Vector3) the second control point
  78208. * @param v3 (Vector3) the end point of the Cubic Bezier
  78209. * @param nbPoints (integer) the wanted number of points in the curve
  78210. * @returns the created Curve3
  78211. */
  78212. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78213. /**
  78214. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78215. * @param p1 (Vector3) the origin point of the Hermite Spline
  78216. * @param t1 (Vector3) the tangent vector at the origin point
  78217. * @param p2 (Vector3) the end point of the Hermite Spline
  78218. * @param t2 (Vector3) the tangent vector at the end point
  78219. * @param nbPoints (integer) the wanted number of points in the curve
  78220. * @returns the created Curve3
  78221. */
  78222. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78223. /**
  78224. * Returns a Curve3 object along a CatmullRom Spline curve :
  78225. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78226. * @param nbPoints (integer) the wanted number of points between each curve control points
  78227. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78228. * @returns the created Curve3
  78229. */
  78230. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78231. /**
  78232. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78233. * A Curve3 is designed from a series of successive Vector3.
  78234. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78235. * @param points points which make up the curve
  78236. */
  78237. constructor(points: Vector3[]);
  78238. /**
  78239. * @returns the Curve3 stored array of successive Vector3
  78240. */
  78241. getPoints(): Vector3[];
  78242. /**
  78243. * @returns the computed length (float) of the curve.
  78244. */
  78245. length(): number;
  78246. /**
  78247. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78248. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78249. * curveA and curveB keep unchanged.
  78250. * @param curve the curve to continue from this curve
  78251. * @returns the newly constructed curve
  78252. */
  78253. continue(curve: DeepImmutable<Curve3>): Curve3;
  78254. private _computeLength;
  78255. }
  78256. }
  78257. declare module BABYLON {
  78258. /**
  78259. * This represents the main contract an easing function should follow.
  78260. * Easing functions are used throughout the animation system.
  78261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78262. */
  78263. export interface IEasingFunction {
  78264. /**
  78265. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78266. * of the easing function.
  78267. * The link below provides some of the most common examples of easing functions.
  78268. * @see https://easings.net/
  78269. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78270. * @returns the corresponding value on the curve defined by the easing function
  78271. */
  78272. ease(gradient: number): number;
  78273. }
  78274. /**
  78275. * Base class used for every default easing function.
  78276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78277. */
  78278. export class EasingFunction implements IEasingFunction {
  78279. /**
  78280. * Interpolation follows the mathematical formula associated with the easing function.
  78281. */
  78282. static readonly EASINGMODE_EASEIN: number;
  78283. /**
  78284. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78285. */
  78286. static readonly EASINGMODE_EASEOUT: number;
  78287. /**
  78288. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78289. */
  78290. static readonly EASINGMODE_EASEINOUT: number;
  78291. private _easingMode;
  78292. /**
  78293. * Sets the easing mode of the current function.
  78294. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78295. */
  78296. setEasingMode(easingMode: number): void;
  78297. /**
  78298. * Gets the current easing mode.
  78299. * @returns the easing mode
  78300. */
  78301. getEasingMode(): number;
  78302. /**
  78303. * @hidden
  78304. */
  78305. easeInCore(gradient: number): number;
  78306. /**
  78307. * Given an input gradient between 0 and 1, this returns the corresponding value
  78308. * of the easing function.
  78309. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78310. * @returns the corresponding value on the curve defined by the easing function
  78311. */
  78312. ease(gradient: number): number;
  78313. }
  78314. /**
  78315. * Easing function with a circle shape (see link below).
  78316. * @see https://easings.net/#easeInCirc
  78317. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78318. */
  78319. export class CircleEase extends EasingFunction implements IEasingFunction {
  78320. /** @hidden */
  78321. easeInCore(gradient: number): number;
  78322. }
  78323. /**
  78324. * Easing function with a ease back shape (see link below).
  78325. * @see https://easings.net/#easeInBack
  78326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78327. */
  78328. export class BackEase extends EasingFunction implements IEasingFunction {
  78329. /** Defines the amplitude of the function */
  78330. amplitude: number;
  78331. /**
  78332. * Instantiates a back ease easing
  78333. * @see https://easings.net/#easeInBack
  78334. * @param amplitude Defines the amplitude of the function
  78335. */
  78336. constructor(
  78337. /** Defines the amplitude of the function */
  78338. amplitude?: number);
  78339. /** @hidden */
  78340. easeInCore(gradient: number): number;
  78341. }
  78342. /**
  78343. * Easing function with a bouncing shape (see link below).
  78344. * @see https://easings.net/#easeInBounce
  78345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78346. */
  78347. export class BounceEase extends EasingFunction implements IEasingFunction {
  78348. /** Defines the number of bounces */
  78349. bounces: number;
  78350. /** Defines the amplitude of the bounce */
  78351. bounciness: number;
  78352. /**
  78353. * Instantiates a bounce easing
  78354. * @see https://easings.net/#easeInBounce
  78355. * @param bounces Defines the number of bounces
  78356. * @param bounciness Defines the amplitude of the bounce
  78357. */
  78358. constructor(
  78359. /** Defines the number of bounces */
  78360. bounces?: number,
  78361. /** Defines the amplitude of the bounce */
  78362. bounciness?: number);
  78363. /** @hidden */
  78364. easeInCore(gradient: number): number;
  78365. }
  78366. /**
  78367. * Easing function with a power of 3 shape (see link below).
  78368. * @see https://easings.net/#easeInCubic
  78369. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78370. */
  78371. export class CubicEase extends EasingFunction implements IEasingFunction {
  78372. /** @hidden */
  78373. easeInCore(gradient: number): number;
  78374. }
  78375. /**
  78376. * Easing function with an elastic shape (see link below).
  78377. * @see https://easings.net/#easeInElastic
  78378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78379. */
  78380. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78381. /** Defines the number of oscillations*/
  78382. oscillations: number;
  78383. /** Defines the amplitude of the oscillations*/
  78384. springiness: number;
  78385. /**
  78386. * Instantiates an elastic easing function
  78387. * @see https://easings.net/#easeInElastic
  78388. * @param oscillations Defines the number of oscillations
  78389. * @param springiness Defines the amplitude of the oscillations
  78390. */
  78391. constructor(
  78392. /** Defines the number of oscillations*/
  78393. oscillations?: number,
  78394. /** Defines the amplitude of the oscillations*/
  78395. springiness?: number);
  78396. /** @hidden */
  78397. easeInCore(gradient: number): number;
  78398. }
  78399. /**
  78400. * Easing function with an exponential shape (see link below).
  78401. * @see https://easings.net/#easeInExpo
  78402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78403. */
  78404. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78405. /** Defines the exponent of the function */
  78406. exponent: number;
  78407. /**
  78408. * Instantiates an exponential easing function
  78409. * @see https://easings.net/#easeInExpo
  78410. * @param exponent Defines the exponent of the function
  78411. */
  78412. constructor(
  78413. /** Defines the exponent of the function */
  78414. exponent?: number);
  78415. /** @hidden */
  78416. easeInCore(gradient: number): number;
  78417. }
  78418. /**
  78419. * Easing function with a power shape (see link below).
  78420. * @see https://easings.net/#easeInQuad
  78421. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78422. */
  78423. export class PowerEase extends EasingFunction implements IEasingFunction {
  78424. /** Defines the power of the function */
  78425. power: number;
  78426. /**
  78427. * Instantiates an power base easing function
  78428. * @see https://easings.net/#easeInQuad
  78429. * @param power Defines the power of the function
  78430. */
  78431. constructor(
  78432. /** Defines the power of the function */
  78433. power?: number);
  78434. /** @hidden */
  78435. easeInCore(gradient: number): number;
  78436. }
  78437. /**
  78438. * Easing function with a power of 2 shape (see link below).
  78439. * @see https://easings.net/#easeInQuad
  78440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78441. */
  78442. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78443. /** @hidden */
  78444. easeInCore(gradient: number): number;
  78445. }
  78446. /**
  78447. * Easing function with a power of 4 shape (see link below).
  78448. * @see https://easings.net/#easeInQuart
  78449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78450. */
  78451. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78452. /** @hidden */
  78453. easeInCore(gradient: number): number;
  78454. }
  78455. /**
  78456. * Easing function with a power of 5 shape (see link below).
  78457. * @see https://easings.net/#easeInQuint
  78458. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78459. */
  78460. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78461. /** @hidden */
  78462. easeInCore(gradient: number): number;
  78463. }
  78464. /**
  78465. * Easing function with a sin shape (see link below).
  78466. * @see https://easings.net/#easeInSine
  78467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78468. */
  78469. export class SineEase extends EasingFunction implements IEasingFunction {
  78470. /** @hidden */
  78471. easeInCore(gradient: number): number;
  78472. }
  78473. /**
  78474. * Easing function with a bezier shape (see link below).
  78475. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78477. */
  78478. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78479. /** Defines the x component of the start tangent in the bezier curve */
  78480. x1: number;
  78481. /** Defines the y component of the start tangent in the bezier curve */
  78482. y1: number;
  78483. /** Defines the x component of the end tangent in the bezier curve */
  78484. x2: number;
  78485. /** Defines the y component of the end tangent in the bezier curve */
  78486. y2: number;
  78487. /**
  78488. * Instantiates a bezier function
  78489. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78490. * @param x1 Defines the x component of the start tangent in the bezier curve
  78491. * @param y1 Defines the y component of the start tangent in the bezier curve
  78492. * @param x2 Defines the x component of the end tangent in the bezier curve
  78493. * @param y2 Defines the y component of the end tangent in the bezier curve
  78494. */
  78495. constructor(
  78496. /** Defines the x component of the start tangent in the bezier curve */
  78497. x1?: number,
  78498. /** Defines the y component of the start tangent in the bezier curve */
  78499. y1?: number,
  78500. /** Defines the x component of the end tangent in the bezier curve */
  78501. x2?: number,
  78502. /** Defines the y component of the end tangent in the bezier curve */
  78503. y2?: number);
  78504. /** @hidden */
  78505. easeInCore(gradient: number): number;
  78506. }
  78507. }
  78508. declare module BABYLON {
  78509. /**
  78510. * Class used to hold a RBG color
  78511. */
  78512. export class Color3 {
  78513. /**
  78514. * Defines the red component (between 0 and 1, default is 0)
  78515. */
  78516. r: number;
  78517. /**
  78518. * Defines the green component (between 0 and 1, default is 0)
  78519. */
  78520. g: number;
  78521. /**
  78522. * Defines the blue component (between 0 and 1, default is 0)
  78523. */
  78524. b: number;
  78525. /**
  78526. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78527. * @param r defines the red component (between 0 and 1, default is 0)
  78528. * @param g defines the green component (between 0 and 1, default is 0)
  78529. * @param b defines the blue component (between 0 and 1, default is 0)
  78530. */
  78531. constructor(
  78532. /**
  78533. * Defines the red component (between 0 and 1, default is 0)
  78534. */
  78535. r?: number,
  78536. /**
  78537. * Defines the green component (between 0 and 1, default is 0)
  78538. */
  78539. g?: number,
  78540. /**
  78541. * Defines the blue component (between 0 and 1, default is 0)
  78542. */
  78543. b?: number);
  78544. /**
  78545. * Creates a string with the Color3 current values
  78546. * @returns the string representation of the Color3 object
  78547. */
  78548. toString(): string;
  78549. /**
  78550. * Returns the string "Color3"
  78551. * @returns "Color3"
  78552. */
  78553. getClassName(): string;
  78554. /**
  78555. * Compute the Color3 hash code
  78556. * @returns an unique number that can be used to hash Color3 objects
  78557. */
  78558. getHashCode(): number;
  78559. /**
  78560. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78561. * @param array defines the array where to store the r,g,b components
  78562. * @param index defines an optional index in the target array to define where to start storing values
  78563. * @returns the current Color3 object
  78564. */
  78565. toArray(array: FloatArray, index?: number): Color3;
  78566. /**
  78567. * Returns a new Color4 object from the current Color3 and the given alpha
  78568. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78569. * @returns a new Color4 object
  78570. */
  78571. toColor4(alpha?: number): Color4;
  78572. /**
  78573. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78574. * @returns the new array
  78575. */
  78576. asArray(): number[];
  78577. /**
  78578. * Returns the luminance value
  78579. * @returns a float value
  78580. */
  78581. toLuminance(): number;
  78582. /**
  78583. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78584. * @param otherColor defines the second operand
  78585. * @returns the new Color3 object
  78586. */
  78587. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78588. /**
  78589. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78590. * @param otherColor defines the second operand
  78591. * @param result defines the Color3 object where to store the result
  78592. * @returns the current Color3
  78593. */
  78594. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78595. /**
  78596. * Determines equality between Color3 objects
  78597. * @param otherColor defines the second operand
  78598. * @returns true if the rgb values are equal to the given ones
  78599. */
  78600. equals(otherColor: DeepImmutable<Color3>): boolean;
  78601. /**
  78602. * Determines equality between the current Color3 object and a set of r,b,g values
  78603. * @param r defines the red component to check
  78604. * @param g defines the green component to check
  78605. * @param b defines the blue component to check
  78606. * @returns true if the rgb values are equal to the given ones
  78607. */
  78608. equalsFloats(r: number, g: number, b: number): boolean;
  78609. /**
  78610. * Multiplies in place each rgb value by scale
  78611. * @param scale defines the scaling factor
  78612. * @returns the updated Color3
  78613. */
  78614. scale(scale: number): Color3;
  78615. /**
  78616. * Multiplies the rgb values by scale and stores the result into "result"
  78617. * @param scale defines the scaling factor
  78618. * @param result defines the Color3 object where to store the result
  78619. * @returns the unmodified current Color3
  78620. */
  78621. scaleToRef(scale: number, result: Color3): Color3;
  78622. /**
  78623. * Scale the current Color3 values by a factor and add the result to a given Color3
  78624. * @param scale defines the scale factor
  78625. * @param result defines color to store the result into
  78626. * @returns the unmodified current Color3
  78627. */
  78628. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78629. /**
  78630. * Clamps the rgb values by the min and max values and stores the result into "result"
  78631. * @param min defines minimum clamping value (default is 0)
  78632. * @param max defines maximum clamping value (default is 1)
  78633. * @param result defines color to store the result into
  78634. * @returns the original Color3
  78635. */
  78636. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78637. /**
  78638. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78639. * @param otherColor defines the second operand
  78640. * @returns the new Color3
  78641. */
  78642. add(otherColor: DeepImmutable<Color3>): Color3;
  78643. /**
  78644. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78645. * @param otherColor defines the second operand
  78646. * @param result defines Color3 object to store the result into
  78647. * @returns the unmodified current Color3
  78648. */
  78649. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78650. /**
  78651. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78652. * @param otherColor defines the second operand
  78653. * @returns the new Color3
  78654. */
  78655. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78656. /**
  78657. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78658. * @param otherColor defines the second operand
  78659. * @param result defines Color3 object to store the result into
  78660. * @returns the unmodified current Color3
  78661. */
  78662. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78663. /**
  78664. * Copy the current object
  78665. * @returns a new Color3 copied the current one
  78666. */
  78667. clone(): Color3;
  78668. /**
  78669. * Copies the rgb values from the source in the current Color3
  78670. * @param source defines the source Color3 object
  78671. * @returns the updated Color3 object
  78672. */
  78673. copyFrom(source: DeepImmutable<Color3>): Color3;
  78674. /**
  78675. * Updates the Color3 rgb values from the given floats
  78676. * @param r defines the red component to read from
  78677. * @param g defines the green component to read from
  78678. * @param b defines the blue component to read from
  78679. * @returns the current Color3 object
  78680. */
  78681. copyFromFloats(r: number, g: number, b: number): Color3;
  78682. /**
  78683. * Updates the Color3 rgb values from the given floats
  78684. * @param r defines the red component to read from
  78685. * @param g defines the green component to read from
  78686. * @param b defines the blue component to read from
  78687. * @returns the current Color3 object
  78688. */
  78689. set(r: number, g: number, b: number): Color3;
  78690. /**
  78691. * Compute the Color3 hexadecimal code as a string
  78692. * @returns a string containing the hexadecimal representation of the Color3 object
  78693. */
  78694. toHexString(): string;
  78695. /**
  78696. * Computes a new Color3 converted from the current one to linear space
  78697. * @returns a new Color3 object
  78698. */
  78699. toLinearSpace(): Color3;
  78700. /**
  78701. * Converts current color in rgb space to HSV values
  78702. * @returns a new color3 representing the HSV values
  78703. */
  78704. toHSV(): Color3;
  78705. /**
  78706. * Converts current color in rgb space to HSV values
  78707. * @param result defines the Color3 where to store the HSV values
  78708. */
  78709. toHSVToRef(result: Color3): void;
  78710. /**
  78711. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78712. * @param convertedColor defines the Color3 object where to store the linear space version
  78713. * @returns the unmodified Color3
  78714. */
  78715. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78716. /**
  78717. * Computes a new Color3 converted from the current one to gamma space
  78718. * @returns a new Color3 object
  78719. */
  78720. toGammaSpace(): Color3;
  78721. /**
  78722. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78723. * @param convertedColor defines the Color3 object where to store the gamma space version
  78724. * @returns the unmodified Color3
  78725. */
  78726. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78727. private static _BlackReadOnly;
  78728. /**
  78729. * Convert Hue, saturation and value to a Color3 (RGB)
  78730. * @param hue defines the hue
  78731. * @param saturation defines the saturation
  78732. * @param value defines the value
  78733. * @param result defines the Color3 where to store the RGB values
  78734. */
  78735. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78736. /**
  78737. * Creates a new Color3 from the string containing valid hexadecimal values
  78738. * @param hex defines a string containing valid hexadecimal values
  78739. * @returns a new Color3 object
  78740. */
  78741. static FromHexString(hex: string): Color3;
  78742. /**
  78743. * Creates a new Color3 from the starting index of the given array
  78744. * @param array defines the source array
  78745. * @param offset defines an offset in the source array
  78746. * @returns a new Color3 object
  78747. */
  78748. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78749. /**
  78750. * Creates a new Color3 from integer values (< 256)
  78751. * @param r defines the red component to read from (value between 0 and 255)
  78752. * @param g defines the green component to read from (value between 0 and 255)
  78753. * @param b defines the blue component to read from (value between 0 and 255)
  78754. * @returns a new Color3 object
  78755. */
  78756. static FromInts(r: number, g: number, b: number): Color3;
  78757. /**
  78758. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78759. * @param start defines the start Color3 value
  78760. * @param end defines the end Color3 value
  78761. * @param amount defines the gradient value between start and end
  78762. * @returns a new Color3 object
  78763. */
  78764. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78765. /**
  78766. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78767. * @param left defines the start value
  78768. * @param right defines the end value
  78769. * @param amount defines the gradient factor
  78770. * @param result defines the Color3 object where to store the result
  78771. */
  78772. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78773. /**
  78774. * Returns a Color3 value containing a red color
  78775. * @returns a new Color3 object
  78776. */
  78777. static Red(): Color3;
  78778. /**
  78779. * Returns a Color3 value containing a green color
  78780. * @returns a new Color3 object
  78781. */
  78782. static Green(): Color3;
  78783. /**
  78784. * Returns a Color3 value containing a blue color
  78785. * @returns a new Color3 object
  78786. */
  78787. static Blue(): Color3;
  78788. /**
  78789. * Returns a Color3 value containing a black color
  78790. * @returns a new Color3 object
  78791. */
  78792. static Black(): Color3;
  78793. /**
  78794. * Gets a Color3 value containing a black color that must not be updated
  78795. */
  78796. static get BlackReadOnly(): DeepImmutable<Color3>;
  78797. /**
  78798. * Returns a Color3 value containing a white color
  78799. * @returns a new Color3 object
  78800. */
  78801. static White(): Color3;
  78802. /**
  78803. * Returns a Color3 value containing a purple color
  78804. * @returns a new Color3 object
  78805. */
  78806. static Purple(): Color3;
  78807. /**
  78808. * Returns a Color3 value containing a magenta color
  78809. * @returns a new Color3 object
  78810. */
  78811. static Magenta(): Color3;
  78812. /**
  78813. * Returns a Color3 value containing a yellow color
  78814. * @returns a new Color3 object
  78815. */
  78816. static Yellow(): Color3;
  78817. /**
  78818. * Returns a Color3 value containing a gray color
  78819. * @returns a new Color3 object
  78820. */
  78821. static Gray(): Color3;
  78822. /**
  78823. * Returns a Color3 value containing a teal color
  78824. * @returns a new Color3 object
  78825. */
  78826. static Teal(): Color3;
  78827. /**
  78828. * Returns a Color3 value containing a random color
  78829. * @returns a new Color3 object
  78830. */
  78831. static Random(): Color3;
  78832. }
  78833. /**
  78834. * Class used to hold a RBGA color
  78835. */
  78836. export class Color4 {
  78837. /**
  78838. * Defines the red component (between 0 and 1, default is 0)
  78839. */
  78840. r: number;
  78841. /**
  78842. * Defines the green component (between 0 and 1, default is 0)
  78843. */
  78844. g: number;
  78845. /**
  78846. * Defines the blue component (between 0 and 1, default is 0)
  78847. */
  78848. b: number;
  78849. /**
  78850. * Defines the alpha component (between 0 and 1, default is 1)
  78851. */
  78852. a: number;
  78853. /**
  78854. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78855. * @param r defines the red component (between 0 and 1, default is 0)
  78856. * @param g defines the green component (between 0 and 1, default is 0)
  78857. * @param b defines the blue component (between 0 and 1, default is 0)
  78858. * @param a defines the alpha component (between 0 and 1, default is 1)
  78859. */
  78860. constructor(
  78861. /**
  78862. * Defines the red component (between 0 and 1, default is 0)
  78863. */
  78864. r?: number,
  78865. /**
  78866. * Defines the green component (between 0 and 1, default is 0)
  78867. */
  78868. g?: number,
  78869. /**
  78870. * Defines the blue component (between 0 and 1, default is 0)
  78871. */
  78872. b?: number,
  78873. /**
  78874. * Defines the alpha component (between 0 and 1, default is 1)
  78875. */
  78876. a?: number);
  78877. /**
  78878. * Adds in place the given Color4 values to the current Color4 object
  78879. * @param right defines the second operand
  78880. * @returns the current updated Color4 object
  78881. */
  78882. addInPlace(right: DeepImmutable<Color4>): Color4;
  78883. /**
  78884. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78885. * @returns the new array
  78886. */
  78887. asArray(): number[];
  78888. /**
  78889. * Stores from the starting index in the given array the Color4 successive values
  78890. * @param array defines the array where to store the r,g,b components
  78891. * @param index defines an optional index in the target array to define where to start storing values
  78892. * @returns the current Color4 object
  78893. */
  78894. toArray(array: number[], index?: number): Color4;
  78895. /**
  78896. * Determines equality between Color4 objects
  78897. * @param otherColor defines the second operand
  78898. * @returns true if the rgba values are equal to the given ones
  78899. */
  78900. equals(otherColor: DeepImmutable<Color4>): boolean;
  78901. /**
  78902. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78903. * @param right defines the second operand
  78904. * @returns a new Color4 object
  78905. */
  78906. add(right: DeepImmutable<Color4>): Color4;
  78907. /**
  78908. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78909. * @param right defines the second operand
  78910. * @returns a new Color4 object
  78911. */
  78912. subtract(right: DeepImmutable<Color4>): Color4;
  78913. /**
  78914. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78915. * @param right defines the second operand
  78916. * @param result defines the Color4 object where to store the result
  78917. * @returns the current Color4 object
  78918. */
  78919. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78920. /**
  78921. * Creates a new Color4 with the current Color4 values multiplied by scale
  78922. * @param scale defines the scaling factor to apply
  78923. * @returns a new Color4 object
  78924. */
  78925. scale(scale: number): Color4;
  78926. /**
  78927. * Multiplies the current Color4 values by scale and stores the result in "result"
  78928. * @param scale defines the scaling factor to apply
  78929. * @param result defines the Color4 object where to store the result
  78930. * @returns the current unmodified Color4
  78931. */
  78932. scaleToRef(scale: number, result: Color4): Color4;
  78933. /**
  78934. * Scale the current Color4 values by a factor and add the result to a given Color4
  78935. * @param scale defines the scale factor
  78936. * @param result defines the Color4 object where to store the result
  78937. * @returns the unmodified current Color4
  78938. */
  78939. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78940. /**
  78941. * Clamps the rgb values by the min and max values and stores the result into "result"
  78942. * @param min defines minimum clamping value (default is 0)
  78943. * @param max defines maximum clamping value (default is 1)
  78944. * @param result defines color to store the result into.
  78945. * @returns the cuurent Color4
  78946. */
  78947. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78948. /**
  78949. * Multipy an Color4 value by another and return a new Color4 object
  78950. * @param color defines the Color4 value to multiply by
  78951. * @returns a new Color4 object
  78952. */
  78953. multiply(color: Color4): Color4;
  78954. /**
  78955. * Multipy a Color4 value by another and push the result in a reference value
  78956. * @param color defines the Color4 value to multiply by
  78957. * @param result defines the Color4 to fill the result in
  78958. * @returns the result Color4
  78959. */
  78960. multiplyToRef(color: Color4, result: Color4): Color4;
  78961. /**
  78962. * Creates a string with the Color4 current values
  78963. * @returns the string representation of the Color4 object
  78964. */
  78965. toString(): string;
  78966. /**
  78967. * Returns the string "Color4"
  78968. * @returns "Color4"
  78969. */
  78970. getClassName(): string;
  78971. /**
  78972. * Compute the Color4 hash code
  78973. * @returns an unique number that can be used to hash Color4 objects
  78974. */
  78975. getHashCode(): number;
  78976. /**
  78977. * Creates a new Color4 copied from the current one
  78978. * @returns a new Color4 object
  78979. */
  78980. clone(): Color4;
  78981. /**
  78982. * Copies the given Color4 values into the current one
  78983. * @param source defines the source Color4 object
  78984. * @returns the current updated Color4 object
  78985. */
  78986. copyFrom(source: Color4): Color4;
  78987. /**
  78988. * Copies the given float values into the current one
  78989. * @param r defines the red component to read from
  78990. * @param g defines the green component to read from
  78991. * @param b defines the blue component to read from
  78992. * @param a defines the alpha component to read from
  78993. * @returns the current updated Color4 object
  78994. */
  78995. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78996. /**
  78997. * Copies the given float values into the current one
  78998. * @param r defines the red component to read from
  78999. * @param g defines the green component to read from
  79000. * @param b defines the blue component to read from
  79001. * @param a defines the alpha component to read from
  79002. * @returns the current updated Color4 object
  79003. */
  79004. set(r: number, g: number, b: number, a: number): Color4;
  79005. /**
  79006. * Compute the Color4 hexadecimal code as a string
  79007. * @returns a string containing the hexadecimal representation of the Color4 object
  79008. */
  79009. toHexString(): string;
  79010. /**
  79011. * Computes a new Color4 converted from the current one to linear space
  79012. * @returns a new Color4 object
  79013. */
  79014. toLinearSpace(): Color4;
  79015. /**
  79016. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79017. * @param convertedColor defines the Color4 object where to store the linear space version
  79018. * @returns the unmodified Color4
  79019. */
  79020. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79021. /**
  79022. * Computes a new Color4 converted from the current one to gamma space
  79023. * @returns a new Color4 object
  79024. */
  79025. toGammaSpace(): Color4;
  79026. /**
  79027. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79028. * @param convertedColor defines the Color4 object where to store the gamma space version
  79029. * @returns the unmodified Color4
  79030. */
  79031. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79032. /**
  79033. * Creates a new Color4 from the string containing valid hexadecimal values
  79034. * @param hex defines a string containing valid hexadecimal values
  79035. * @returns a new Color4 object
  79036. */
  79037. static FromHexString(hex: string): Color4;
  79038. /**
  79039. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79040. * @param left defines the start value
  79041. * @param right defines the end value
  79042. * @param amount defines the gradient factor
  79043. * @returns a new Color4 object
  79044. */
  79045. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79046. /**
  79047. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79048. * @param left defines the start value
  79049. * @param right defines the end value
  79050. * @param amount defines the gradient factor
  79051. * @param result defines the Color4 object where to store data
  79052. */
  79053. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79054. /**
  79055. * Creates a new Color4 from a Color3 and an alpha value
  79056. * @param color3 defines the source Color3 to read from
  79057. * @param alpha defines the alpha component (1.0 by default)
  79058. * @returns a new Color4 object
  79059. */
  79060. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79061. /**
  79062. * Creates a new Color4 from the starting index element of the given array
  79063. * @param array defines the source array to read from
  79064. * @param offset defines the offset in the source array
  79065. * @returns a new Color4 object
  79066. */
  79067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79068. /**
  79069. * Creates a new Color3 from integer values (< 256)
  79070. * @param r defines the red component to read from (value between 0 and 255)
  79071. * @param g defines the green component to read from (value between 0 and 255)
  79072. * @param b defines the blue component to read from (value between 0 and 255)
  79073. * @param a defines the alpha component to read from (value between 0 and 255)
  79074. * @returns a new Color3 object
  79075. */
  79076. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79077. /**
  79078. * Check the content of a given array and convert it to an array containing RGBA data
  79079. * If the original array was already containing count * 4 values then it is returned directly
  79080. * @param colors defines the array to check
  79081. * @param count defines the number of RGBA data to expect
  79082. * @returns an array containing count * 4 values (RGBA)
  79083. */
  79084. static CheckColors4(colors: number[], count: number): number[];
  79085. }
  79086. /**
  79087. * @hidden
  79088. */
  79089. export class TmpColors {
  79090. static Color3: Color3[];
  79091. static Color4: Color4[];
  79092. }
  79093. }
  79094. declare module BABYLON {
  79095. /**
  79096. * Defines an interface which represents an animation key frame
  79097. */
  79098. export interface IAnimationKey {
  79099. /**
  79100. * Frame of the key frame
  79101. */
  79102. frame: number;
  79103. /**
  79104. * Value at the specifies key frame
  79105. */
  79106. value: any;
  79107. /**
  79108. * The input tangent for the cubic hermite spline
  79109. */
  79110. inTangent?: any;
  79111. /**
  79112. * The output tangent for the cubic hermite spline
  79113. */
  79114. outTangent?: any;
  79115. /**
  79116. * The animation interpolation type
  79117. */
  79118. interpolation?: AnimationKeyInterpolation;
  79119. }
  79120. /**
  79121. * Enum for the animation key frame interpolation type
  79122. */
  79123. export enum AnimationKeyInterpolation {
  79124. /**
  79125. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79126. */
  79127. STEP = 1
  79128. }
  79129. }
  79130. declare module BABYLON {
  79131. /**
  79132. * Represents the range of an animation
  79133. */
  79134. export class AnimationRange {
  79135. /**The name of the animation range**/
  79136. name: string;
  79137. /**The starting frame of the animation */
  79138. from: number;
  79139. /**The ending frame of the animation*/
  79140. to: number;
  79141. /**
  79142. * Initializes the range of an animation
  79143. * @param name The name of the animation range
  79144. * @param from The starting frame of the animation
  79145. * @param to The ending frame of the animation
  79146. */
  79147. constructor(
  79148. /**The name of the animation range**/
  79149. name: string,
  79150. /**The starting frame of the animation */
  79151. from: number,
  79152. /**The ending frame of the animation*/
  79153. to: number);
  79154. /**
  79155. * Makes a copy of the animation range
  79156. * @returns A copy of the animation range
  79157. */
  79158. clone(): AnimationRange;
  79159. }
  79160. }
  79161. declare module BABYLON {
  79162. /**
  79163. * Composed of a frame, and an action function
  79164. */
  79165. export class AnimationEvent {
  79166. /** The frame for which the event is triggered **/
  79167. frame: number;
  79168. /** The event to perform when triggered **/
  79169. action: (currentFrame: number) => void;
  79170. /** Specifies if the event should be triggered only once**/
  79171. onlyOnce?: boolean | undefined;
  79172. /**
  79173. * Specifies if the animation event is done
  79174. */
  79175. isDone: boolean;
  79176. /**
  79177. * Initializes the animation event
  79178. * @param frame The frame for which the event is triggered
  79179. * @param action The event to perform when triggered
  79180. * @param onlyOnce Specifies if the event should be triggered only once
  79181. */
  79182. constructor(
  79183. /** The frame for which the event is triggered **/
  79184. frame: number,
  79185. /** The event to perform when triggered **/
  79186. action: (currentFrame: number) => void,
  79187. /** Specifies if the event should be triggered only once**/
  79188. onlyOnce?: boolean | undefined);
  79189. /** @hidden */
  79190. _clone(): AnimationEvent;
  79191. }
  79192. }
  79193. declare module BABYLON {
  79194. /**
  79195. * Interface used to define a behavior
  79196. */
  79197. export interface Behavior<T> {
  79198. /** gets or sets behavior's name */
  79199. name: string;
  79200. /**
  79201. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79202. */
  79203. init(): void;
  79204. /**
  79205. * Called when the behavior is attached to a target
  79206. * @param target defines the target where the behavior is attached to
  79207. */
  79208. attach(target: T): void;
  79209. /**
  79210. * Called when the behavior is detached from its target
  79211. */
  79212. detach(): void;
  79213. }
  79214. /**
  79215. * Interface implemented by classes supporting behaviors
  79216. */
  79217. export interface IBehaviorAware<T> {
  79218. /**
  79219. * Attach a behavior
  79220. * @param behavior defines the behavior to attach
  79221. * @returns the current host
  79222. */
  79223. addBehavior(behavior: Behavior<T>): T;
  79224. /**
  79225. * Remove a behavior from the current object
  79226. * @param behavior defines the behavior to detach
  79227. * @returns the current host
  79228. */
  79229. removeBehavior(behavior: Behavior<T>): T;
  79230. /**
  79231. * Gets a behavior using its name to search
  79232. * @param name defines the name to search
  79233. * @returns the behavior or null if not found
  79234. */
  79235. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79236. }
  79237. }
  79238. declare module BABYLON {
  79239. /**
  79240. * Defines an array and its length.
  79241. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79242. */
  79243. export interface ISmartArrayLike<T> {
  79244. /**
  79245. * The data of the array.
  79246. */
  79247. data: Array<T>;
  79248. /**
  79249. * The active length of the array.
  79250. */
  79251. length: number;
  79252. }
  79253. /**
  79254. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79255. */
  79256. export class SmartArray<T> implements ISmartArrayLike<T> {
  79257. /**
  79258. * The full set of data from the array.
  79259. */
  79260. data: Array<T>;
  79261. /**
  79262. * The active length of the array.
  79263. */
  79264. length: number;
  79265. protected _id: number;
  79266. /**
  79267. * Instantiates a Smart Array.
  79268. * @param capacity defines the default capacity of the array.
  79269. */
  79270. constructor(capacity: number);
  79271. /**
  79272. * Pushes a value at the end of the active data.
  79273. * @param value defines the object to push in the array.
  79274. */
  79275. push(value: T): void;
  79276. /**
  79277. * Iterates over the active data and apply the lambda to them.
  79278. * @param func defines the action to apply on each value.
  79279. */
  79280. forEach(func: (content: T) => void): void;
  79281. /**
  79282. * Sorts the full sets of data.
  79283. * @param compareFn defines the comparison function to apply.
  79284. */
  79285. sort(compareFn: (a: T, b: T) => number): void;
  79286. /**
  79287. * Resets the active data to an empty array.
  79288. */
  79289. reset(): void;
  79290. /**
  79291. * Releases all the data from the array as well as the array.
  79292. */
  79293. dispose(): void;
  79294. /**
  79295. * Concats the active data with a given array.
  79296. * @param array defines the data to concatenate with.
  79297. */
  79298. concat(array: any): void;
  79299. /**
  79300. * Returns the position of a value in the active data.
  79301. * @param value defines the value to find the index for
  79302. * @returns the index if found in the active data otherwise -1
  79303. */
  79304. indexOf(value: T): number;
  79305. /**
  79306. * Returns whether an element is part of the active data.
  79307. * @param value defines the value to look for
  79308. * @returns true if found in the active data otherwise false
  79309. */
  79310. contains(value: T): boolean;
  79311. private static _GlobalId;
  79312. }
  79313. /**
  79314. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79315. * The data in this array can only be present once
  79316. */
  79317. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79318. private _duplicateId;
  79319. /**
  79320. * Pushes a value at the end of the active data.
  79321. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79322. * @param value defines the object to push in the array.
  79323. */
  79324. push(value: T): void;
  79325. /**
  79326. * Pushes a value at the end of the active data.
  79327. * If the data is already present, it won t be added again
  79328. * @param value defines the object to push in the array.
  79329. * @returns true if added false if it was already present
  79330. */
  79331. pushNoDuplicate(value: T): boolean;
  79332. /**
  79333. * Resets the active data to an empty array.
  79334. */
  79335. reset(): void;
  79336. /**
  79337. * Concats the active data with a given array.
  79338. * This ensures no dupplicate will be present in the result.
  79339. * @param array defines the data to concatenate with.
  79340. */
  79341. concatWithNoDuplicate(array: any): void;
  79342. }
  79343. }
  79344. declare module BABYLON {
  79345. /**
  79346. * @ignore
  79347. * This is a list of all the different input types that are available in the application.
  79348. * Fo instance: ArcRotateCameraGamepadInput...
  79349. */
  79350. export var CameraInputTypes: {};
  79351. /**
  79352. * This is the contract to implement in order to create a new input class.
  79353. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79354. */
  79355. export interface ICameraInput<TCamera extends Camera> {
  79356. /**
  79357. * Defines the camera the input is attached to.
  79358. */
  79359. camera: Nullable<TCamera>;
  79360. /**
  79361. * Gets the class name of the current intput.
  79362. * @returns the class name
  79363. */
  79364. getClassName(): string;
  79365. /**
  79366. * Get the friendly name associated with the input class.
  79367. * @returns the input friendly name
  79368. */
  79369. getSimpleName(): string;
  79370. /**
  79371. * Attach the input controls to a specific dom element to get the input from.
  79372. * @param element Defines the element the controls should be listened from
  79373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79374. */
  79375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79376. /**
  79377. * Detach the current controls from the specified dom element.
  79378. * @param element Defines the element to stop listening the inputs from
  79379. */
  79380. detachControl(element: Nullable<HTMLElement>): void;
  79381. /**
  79382. * Update the current camera state depending on the inputs that have been used this frame.
  79383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79384. */
  79385. checkInputs?: () => void;
  79386. }
  79387. /**
  79388. * Represents a map of input types to input instance or input index to input instance.
  79389. */
  79390. export interface CameraInputsMap<TCamera extends Camera> {
  79391. /**
  79392. * Accessor to the input by input type.
  79393. */
  79394. [name: string]: ICameraInput<TCamera>;
  79395. /**
  79396. * Accessor to the input by input index.
  79397. */
  79398. [idx: number]: ICameraInput<TCamera>;
  79399. }
  79400. /**
  79401. * This represents the input manager used within a camera.
  79402. * It helps dealing with all the different kind of input attached to a camera.
  79403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79404. */
  79405. export class CameraInputsManager<TCamera extends Camera> {
  79406. /**
  79407. * Defines the list of inputs attahed to the camera.
  79408. */
  79409. attached: CameraInputsMap<TCamera>;
  79410. /**
  79411. * Defines the dom element the camera is collecting inputs from.
  79412. * This is null if the controls have not been attached.
  79413. */
  79414. attachedElement: Nullable<HTMLElement>;
  79415. /**
  79416. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79417. */
  79418. noPreventDefault: boolean;
  79419. /**
  79420. * Defined the camera the input manager belongs to.
  79421. */
  79422. camera: TCamera;
  79423. /**
  79424. * Update the current camera state depending on the inputs that have been used this frame.
  79425. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79426. */
  79427. checkInputs: () => void;
  79428. /**
  79429. * Instantiate a new Camera Input Manager.
  79430. * @param camera Defines the camera the input manager blongs to
  79431. */
  79432. constructor(camera: TCamera);
  79433. /**
  79434. * Add an input method to a camera
  79435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79436. * @param input camera input method
  79437. */
  79438. add(input: ICameraInput<TCamera>): void;
  79439. /**
  79440. * Remove a specific input method from a camera
  79441. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79442. * @param inputToRemove camera input method
  79443. */
  79444. remove(inputToRemove: ICameraInput<TCamera>): void;
  79445. /**
  79446. * Remove a specific input type from a camera
  79447. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79448. * @param inputType the type of the input to remove
  79449. */
  79450. removeByType(inputType: string): void;
  79451. private _addCheckInputs;
  79452. /**
  79453. * Attach the input controls to the currently attached dom element to listen the events from.
  79454. * @param input Defines the input to attach
  79455. */
  79456. attachInput(input: ICameraInput<TCamera>): void;
  79457. /**
  79458. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79459. * @param element Defines the dom element to collect the events from
  79460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79461. */
  79462. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79463. /**
  79464. * Detach the current manager inputs controls from a specific dom element.
  79465. * @param element Defines the dom element to collect the events from
  79466. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79467. */
  79468. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79469. /**
  79470. * Rebuild the dynamic inputCheck function from the current list of
  79471. * defined inputs in the manager.
  79472. */
  79473. rebuildInputCheck(): void;
  79474. /**
  79475. * Remove all attached input methods from a camera
  79476. */
  79477. clear(): void;
  79478. /**
  79479. * Serialize the current input manager attached to a camera.
  79480. * This ensures than once parsed,
  79481. * the input associated to the camera will be identical to the current ones
  79482. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79483. */
  79484. serialize(serializedCamera: any): void;
  79485. /**
  79486. * Parses an input manager serialized JSON to restore the previous list of inputs
  79487. * and states associated to a camera.
  79488. * @param parsedCamera Defines the JSON to parse
  79489. */
  79490. parse(parsedCamera: any): void;
  79491. }
  79492. }
  79493. declare module BABYLON {
  79494. /**
  79495. * Class used to store data that will be store in GPU memory
  79496. */
  79497. export class Buffer {
  79498. private _engine;
  79499. private _buffer;
  79500. /** @hidden */
  79501. _data: Nullable<DataArray>;
  79502. private _updatable;
  79503. private _instanced;
  79504. private _divisor;
  79505. /**
  79506. * Gets the byte stride.
  79507. */
  79508. readonly byteStride: number;
  79509. /**
  79510. * Constructor
  79511. * @param engine the engine
  79512. * @param data the data to use for this buffer
  79513. * @param updatable whether the data is updatable
  79514. * @param stride the stride (optional)
  79515. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79516. * @param instanced whether the buffer is instanced (optional)
  79517. * @param useBytes set to true if the stride in in bytes (optional)
  79518. * @param divisor sets an optional divisor for instances (1 by default)
  79519. */
  79520. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79521. /**
  79522. * Create a new VertexBuffer based on the current buffer
  79523. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79524. * @param offset defines offset in the buffer (0 by default)
  79525. * @param size defines the size in floats of attributes (position is 3 for instance)
  79526. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79527. * @param instanced defines if the vertex buffer contains indexed data
  79528. * @param useBytes defines if the offset and stride are in bytes *
  79529. * @param divisor sets an optional divisor for instances (1 by default)
  79530. * @returns the new vertex buffer
  79531. */
  79532. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79533. /**
  79534. * Gets a boolean indicating if the Buffer is updatable?
  79535. * @returns true if the buffer is updatable
  79536. */
  79537. isUpdatable(): boolean;
  79538. /**
  79539. * Gets current buffer's data
  79540. * @returns a DataArray or null
  79541. */
  79542. getData(): Nullable<DataArray>;
  79543. /**
  79544. * Gets underlying native buffer
  79545. * @returns underlying native buffer
  79546. */
  79547. getBuffer(): Nullable<DataBuffer>;
  79548. /**
  79549. * Gets the stride in float32 units (i.e. byte stride / 4).
  79550. * May not be an integer if the byte stride is not divisible by 4.
  79551. * @returns the stride in float32 units
  79552. * @deprecated Please use byteStride instead.
  79553. */
  79554. getStrideSize(): number;
  79555. /**
  79556. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79557. * @param data defines the data to store
  79558. */
  79559. create(data?: Nullable<DataArray>): void;
  79560. /** @hidden */
  79561. _rebuild(): void;
  79562. /**
  79563. * Update current buffer data
  79564. * @param data defines the data to store
  79565. */
  79566. update(data: DataArray): void;
  79567. /**
  79568. * Updates the data directly.
  79569. * @param data the new data
  79570. * @param offset the new offset
  79571. * @param vertexCount the vertex count (optional)
  79572. * @param useBytes set to true if the offset is in bytes
  79573. */
  79574. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79575. /**
  79576. * Release all resources
  79577. */
  79578. dispose(): void;
  79579. }
  79580. /**
  79581. * Specialized buffer used to store vertex data
  79582. */
  79583. export class VertexBuffer {
  79584. /** @hidden */
  79585. _buffer: Buffer;
  79586. private _kind;
  79587. private _size;
  79588. private _ownsBuffer;
  79589. private _instanced;
  79590. private _instanceDivisor;
  79591. /**
  79592. * The byte type.
  79593. */
  79594. static readonly BYTE: number;
  79595. /**
  79596. * The unsigned byte type.
  79597. */
  79598. static readonly UNSIGNED_BYTE: number;
  79599. /**
  79600. * The short type.
  79601. */
  79602. static readonly SHORT: number;
  79603. /**
  79604. * The unsigned short type.
  79605. */
  79606. static readonly UNSIGNED_SHORT: number;
  79607. /**
  79608. * The integer type.
  79609. */
  79610. static readonly INT: number;
  79611. /**
  79612. * The unsigned integer type.
  79613. */
  79614. static readonly UNSIGNED_INT: number;
  79615. /**
  79616. * The float type.
  79617. */
  79618. static readonly FLOAT: number;
  79619. /**
  79620. * Gets or sets the instance divisor when in instanced mode
  79621. */
  79622. get instanceDivisor(): number;
  79623. set instanceDivisor(value: number);
  79624. /**
  79625. * Gets the byte stride.
  79626. */
  79627. readonly byteStride: number;
  79628. /**
  79629. * Gets the byte offset.
  79630. */
  79631. readonly byteOffset: number;
  79632. /**
  79633. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79634. */
  79635. readonly normalized: boolean;
  79636. /**
  79637. * Gets the data type of each component in the array.
  79638. */
  79639. readonly type: number;
  79640. /**
  79641. * Constructor
  79642. * @param engine the engine
  79643. * @param data the data to use for this vertex buffer
  79644. * @param kind the vertex buffer kind
  79645. * @param updatable whether the data is updatable
  79646. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79647. * @param stride the stride (optional)
  79648. * @param instanced whether the buffer is instanced (optional)
  79649. * @param offset the offset of the data (optional)
  79650. * @param size the number of components (optional)
  79651. * @param type the type of the component (optional)
  79652. * @param normalized whether the data contains normalized data (optional)
  79653. * @param useBytes set to true if stride and offset are in bytes (optional)
  79654. * @param divisor defines the instance divisor to use (1 by default)
  79655. */
  79656. 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);
  79657. /** @hidden */
  79658. _rebuild(): void;
  79659. /**
  79660. * Returns the kind of the VertexBuffer (string)
  79661. * @returns a string
  79662. */
  79663. getKind(): string;
  79664. /**
  79665. * Gets a boolean indicating if the VertexBuffer is updatable?
  79666. * @returns true if the buffer is updatable
  79667. */
  79668. isUpdatable(): boolean;
  79669. /**
  79670. * Gets current buffer's data
  79671. * @returns a DataArray or null
  79672. */
  79673. getData(): Nullable<DataArray>;
  79674. /**
  79675. * Gets underlying native buffer
  79676. * @returns underlying native buffer
  79677. */
  79678. getBuffer(): Nullable<DataBuffer>;
  79679. /**
  79680. * Gets the stride in float32 units (i.e. byte stride / 4).
  79681. * May not be an integer if the byte stride is not divisible by 4.
  79682. * @returns the stride in float32 units
  79683. * @deprecated Please use byteStride instead.
  79684. */
  79685. getStrideSize(): number;
  79686. /**
  79687. * Returns the offset as a multiple of the type byte length.
  79688. * @returns the offset in bytes
  79689. * @deprecated Please use byteOffset instead.
  79690. */
  79691. getOffset(): number;
  79692. /**
  79693. * Returns the number of components per vertex attribute (integer)
  79694. * @returns the size in float
  79695. */
  79696. getSize(): number;
  79697. /**
  79698. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79699. * @returns true if this buffer is instanced
  79700. */
  79701. getIsInstanced(): boolean;
  79702. /**
  79703. * Returns the instancing divisor, zero for non-instanced (integer).
  79704. * @returns a number
  79705. */
  79706. getInstanceDivisor(): number;
  79707. /**
  79708. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79709. * @param data defines the data to store
  79710. */
  79711. create(data?: DataArray): void;
  79712. /**
  79713. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79714. * This function will create a new buffer if the current one is not updatable
  79715. * @param data defines the data to store
  79716. */
  79717. update(data: DataArray): void;
  79718. /**
  79719. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79720. * Returns the directly updated WebGLBuffer.
  79721. * @param data the new data
  79722. * @param offset the new offset
  79723. * @param useBytes set to true if the offset is in bytes
  79724. */
  79725. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79726. /**
  79727. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79728. */
  79729. dispose(): void;
  79730. /**
  79731. * Enumerates each value of this vertex buffer as numbers.
  79732. * @param count the number of values to enumerate
  79733. * @param callback the callback function called for each value
  79734. */
  79735. forEach(count: number, callback: (value: number, index: number) => void): void;
  79736. /**
  79737. * Positions
  79738. */
  79739. static readonly PositionKind: string;
  79740. /**
  79741. * Normals
  79742. */
  79743. static readonly NormalKind: string;
  79744. /**
  79745. * Tangents
  79746. */
  79747. static readonly TangentKind: string;
  79748. /**
  79749. * Texture coordinates
  79750. */
  79751. static readonly UVKind: string;
  79752. /**
  79753. * Texture coordinates 2
  79754. */
  79755. static readonly UV2Kind: string;
  79756. /**
  79757. * Texture coordinates 3
  79758. */
  79759. static readonly UV3Kind: string;
  79760. /**
  79761. * Texture coordinates 4
  79762. */
  79763. static readonly UV4Kind: string;
  79764. /**
  79765. * Texture coordinates 5
  79766. */
  79767. static readonly UV5Kind: string;
  79768. /**
  79769. * Texture coordinates 6
  79770. */
  79771. static readonly UV6Kind: string;
  79772. /**
  79773. * Colors
  79774. */
  79775. static readonly ColorKind: string;
  79776. /**
  79777. * Matrix indices (for bones)
  79778. */
  79779. static readonly MatricesIndicesKind: string;
  79780. /**
  79781. * Matrix weights (for bones)
  79782. */
  79783. static readonly MatricesWeightsKind: string;
  79784. /**
  79785. * Additional matrix indices (for bones)
  79786. */
  79787. static readonly MatricesIndicesExtraKind: string;
  79788. /**
  79789. * Additional matrix weights (for bones)
  79790. */
  79791. static readonly MatricesWeightsExtraKind: string;
  79792. /**
  79793. * Deduces the stride given a kind.
  79794. * @param kind The kind string to deduce
  79795. * @returns The deduced stride
  79796. */
  79797. static DeduceStride(kind: string): number;
  79798. /**
  79799. * Gets the byte length of the given type.
  79800. * @param type the type
  79801. * @returns the number of bytes
  79802. */
  79803. static GetTypeByteLength(type: number): number;
  79804. /**
  79805. * Enumerates each value of the given parameters as numbers.
  79806. * @param data the data to enumerate
  79807. * @param byteOffset the byte offset of the data
  79808. * @param byteStride the byte stride of the data
  79809. * @param componentCount the number of components per element
  79810. * @param componentType the type of the component
  79811. * @param count the number of values to enumerate
  79812. * @param normalized whether the data is normalized
  79813. * @param callback the callback function called for each value
  79814. */
  79815. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79816. private static _GetFloatValue;
  79817. }
  79818. }
  79819. declare module BABYLON {
  79820. /**
  79821. * @hidden
  79822. */
  79823. export class IntersectionInfo {
  79824. bu: Nullable<number>;
  79825. bv: Nullable<number>;
  79826. distance: number;
  79827. faceId: number;
  79828. subMeshId: number;
  79829. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79830. }
  79831. }
  79832. declare module BABYLON {
  79833. /**
  79834. * Represens a plane by the equation ax + by + cz + d = 0
  79835. */
  79836. export class Plane {
  79837. private static _TmpMatrix;
  79838. /**
  79839. * Normal of the plane (a,b,c)
  79840. */
  79841. normal: Vector3;
  79842. /**
  79843. * d component of the plane
  79844. */
  79845. d: number;
  79846. /**
  79847. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79848. * @param a a component of the plane
  79849. * @param b b component of the plane
  79850. * @param c c component of the plane
  79851. * @param d d component of the plane
  79852. */
  79853. constructor(a: number, b: number, c: number, d: number);
  79854. /**
  79855. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79856. */
  79857. asArray(): number[];
  79858. /**
  79859. * @returns a new plane copied from the current Plane.
  79860. */
  79861. clone(): Plane;
  79862. /**
  79863. * @returns the string "Plane".
  79864. */
  79865. getClassName(): string;
  79866. /**
  79867. * @returns the Plane hash code.
  79868. */
  79869. getHashCode(): number;
  79870. /**
  79871. * Normalize the current Plane in place.
  79872. * @returns the updated Plane.
  79873. */
  79874. normalize(): Plane;
  79875. /**
  79876. * Applies a transformation the plane and returns the result
  79877. * @param transformation the transformation matrix to be applied to the plane
  79878. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79879. */
  79880. transform(transformation: DeepImmutable<Matrix>): Plane;
  79881. /**
  79882. * Calcualtte the dot product between the point and the plane normal
  79883. * @param point point to calculate the dot product with
  79884. * @returns the dot product (float) of the point coordinates and the plane normal.
  79885. */
  79886. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79887. /**
  79888. * Updates the current Plane from the plane defined by the three given points.
  79889. * @param point1 one of the points used to contruct the plane
  79890. * @param point2 one of the points used to contruct the plane
  79891. * @param point3 one of the points used to contruct the plane
  79892. * @returns the updated Plane.
  79893. */
  79894. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79895. /**
  79896. * Checks if the plane is facing a given direction
  79897. * @param direction the direction to check if the plane is facing
  79898. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79899. * @returns True is the vector "direction" is the same side than the plane normal.
  79900. */
  79901. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79902. /**
  79903. * Calculates the distance to a point
  79904. * @param point point to calculate distance to
  79905. * @returns the signed distance (float) from the given point to the Plane.
  79906. */
  79907. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79908. /**
  79909. * Creates a plane from an array
  79910. * @param array the array to create a plane from
  79911. * @returns a new Plane from the given array.
  79912. */
  79913. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79914. /**
  79915. * Creates a plane from three points
  79916. * @param point1 point used to create the plane
  79917. * @param point2 point used to create the plane
  79918. * @param point3 point used to create the plane
  79919. * @returns a new Plane defined by the three given points.
  79920. */
  79921. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79922. /**
  79923. * Creates a plane from an origin point and a normal
  79924. * @param origin origin of the plane to be constructed
  79925. * @param normal normal of the plane to be constructed
  79926. * @returns a new Plane the normal vector to this plane at the given origin point.
  79927. * Note : the vector "normal" is updated because normalized.
  79928. */
  79929. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79930. /**
  79931. * Calculates the distance from a plane and a point
  79932. * @param origin origin of the plane to be constructed
  79933. * @param normal normal of the plane to be constructed
  79934. * @param point point to calculate distance to
  79935. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79936. */
  79937. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79938. }
  79939. }
  79940. declare module BABYLON {
  79941. /**
  79942. * Class used to store bounding sphere information
  79943. */
  79944. export class BoundingSphere {
  79945. /**
  79946. * Gets the center of the bounding sphere in local space
  79947. */
  79948. readonly center: Vector3;
  79949. /**
  79950. * Radius of the bounding sphere in local space
  79951. */
  79952. radius: number;
  79953. /**
  79954. * Gets the center of the bounding sphere in world space
  79955. */
  79956. readonly centerWorld: Vector3;
  79957. /**
  79958. * Radius of the bounding sphere in world space
  79959. */
  79960. radiusWorld: number;
  79961. /**
  79962. * Gets the minimum vector in local space
  79963. */
  79964. readonly minimum: Vector3;
  79965. /**
  79966. * Gets the maximum vector in local space
  79967. */
  79968. readonly maximum: Vector3;
  79969. private _worldMatrix;
  79970. private static readonly TmpVector3;
  79971. /**
  79972. * Creates a new bounding sphere
  79973. * @param min defines the minimum vector (in local space)
  79974. * @param max defines the maximum vector (in local space)
  79975. * @param worldMatrix defines the new world matrix
  79976. */
  79977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79978. /**
  79979. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79980. * @param min defines the new minimum vector (in local space)
  79981. * @param max defines the new maximum vector (in local space)
  79982. * @param worldMatrix defines the new world matrix
  79983. */
  79984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79985. /**
  79986. * Scale the current bounding sphere by applying a scale factor
  79987. * @param factor defines the scale factor to apply
  79988. * @returns the current bounding box
  79989. */
  79990. scale(factor: number): BoundingSphere;
  79991. /**
  79992. * Gets the world matrix of the bounding box
  79993. * @returns a matrix
  79994. */
  79995. getWorldMatrix(): DeepImmutable<Matrix>;
  79996. /** @hidden */
  79997. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79998. /**
  79999. * Tests if the bounding sphere is intersecting the frustum planes
  80000. * @param frustumPlanes defines the frustum planes to test
  80001. * @returns true if there is an intersection
  80002. */
  80003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80004. /**
  80005. * Tests if the bounding sphere center is in between the frustum planes.
  80006. * Used for optimistic fast inclusion.
  80007. * @param frustumPlanes defines the frustum planes to test
  80008. * @returns true if the sphere center is in between the frustum planes
  80009. */
  80010. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80011. /**
  80012. * Tests if a point is inside the bounding sphere
  80013. * @param point defines the point to test
  80014. * @returns true if the point is inside the bounding sphere
  80015. */
  80016. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80017. /**
  80018. * Checks if two sphere intersct
  80019. * @param sphere0 sphere 0
  80020. * @param sphere1 sphere 1
  80021. * @returns true if the speres intersect
  80022. */
  80023. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80024. }
  80025. }
  80026. declare module BABYLON {
  80027. /**
  80028. * Class used to store bounding box information
  80029. */
  80030. export class BoundingBox implements ICullable {
  80031. /**
  80032. * Gets the 8 vectors representing the bounding box in local space
  80033. */
  80034. readonly vectors: Vector3[];
  80035. /**
  80036. * Gets the center of the bounding box in local space
  80037. */
  80038. readonly center: Vector3;
  80039. /**
  80040. * Gets the center of the bounding box in world space
  80041. */
  80042. readonly centerWorld: Vector3;
  80043. /**
  80044. * Gets the extend size in local space
  80045. */
  80046. readonly extendSize: Vector3;
  80047. /**
  80048. * Gets the extend size in world space
  80049. */
  80050. readonly extendSizeWorld: Vector3;
  80051. /**
  80052. * Gets the OBB (object bounding box) directions
  80053. */
  80054. readonly directions: Vector3[];
  80055. /**
  80056. * Gets the 8 vectors representing the bounding box in world space
  80057. */
  80058. readonly vectorsWorld: Vector3[];
  80059. /**
  80060. * Gets the minimum vector in world space
  80061. */
  80062. readonly minimumWorld: Vector3;
  80063. /**
  80064. * Gets the maximum vector in world space
  80065. */
  80066. readonly maximumWorld: Vector3;
  80067. /**
  80068. * Gets the minimum vector in local space
  80069. */
  80070. readonly minimum: Vector3;
  80071. /**
  80072. * Gets the maximum vector in local space
  80073. */
  80074. readonly maximum: Vector3;
  80075. private _worldMatrix;
  80076. private static readonly TmpVector3;
  80077. /**
  80078. * @hidden
  80079. */
  80080. _tag: number;
  80081. /**
  80082. * Creates a new bounding box
  80083. * @param min defines the minimum vector (in local space)
  80084. * @param max defines the maximum vector (in local space)
  80085. * @param worldMatrix defines the new world matrix
  80086. */
  80087. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80088. /**
  80089. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80090. * @param min defines the new minimum vector (in local space)
  80091. * @param max defines the new maximum vector (in local space)
  80092. * @param worldMatrix defines the new world matrix
  80093. */
  80094. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80095. /**
  80096. * Scale the current bounding box by applying a scale factor
  80097. * @param factor defines the scale factor to apply
  80098. * @returns the current bounding box
  80099. */
  80100. scale(factor: number): BoundingBox;
  80101. /**
  80102. * Gets the world matrix of the bounding box
  80103. * @returns a matrix
  80104. */
  80105. getWorldMatrix(): DeepImmutable<Matrix>;
  80106. /** @hidden */
  80107. _update(world: DeepImmutable<Matrix>): void;
  80108. /**
  80109. * Tests if the bounding box is intersecting the frustum planes
  80110. * @param frustumPlanes defines the frustum planes to test
  80111. * @returns true if there is an intersection
  80112. */
  80113. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80114. /**
  80115. * Tests if the bounding box is entirely inside the frustum planes
  80116. * @param frustumPlanes defines the frustum planes to test
  80117. * @returns true if there is an inclusion
  80118. */
  80119. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80120. /**
  80121. * Tests if a point is inside the bounding box
  80122. * @param point defines the point to test
  80123. * @returns true if the point is inside the bounding box
  80124. */
  80125. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80126. /**
  80127. * Tests if the bounding box intersects with a bounding sphere
  80128. * @param sphere defines the sphere to test
  80129. * @returns true if there is an intersection
  80130. */
  80131. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80132. /**
  80133. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80134. * @param min defines the min vector to use
  80135. * @param max defines the max vector to use
  80136. * @returns true if there is an intersection
  80137. */
  80138. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80139. /**
  80140. * Tests if two bounding boxes are intersections
  80141. * @param box0 defines the first box to test
  80142. * @param box1 defines the second box to test
  80143. * @returns true if there is an intersection
  80144. */
  80145. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80146. /**
  80147. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80148. * @param minPoint defines the minimum vector of the bounding box
  80149. * @param maxPoint defines the maximum vector of the bounding box
  80150. * @param sphereCenter defines the sphere center
  80151. * @param sphereRadius defines the sphere radius
  80152. * @returns true if there is an intersection
  80153. */
  80154. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80155. /**
  80156. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80157. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80158. * @param frustumPlanes defines the frustum planes to test
  80159. * @return true if there is an inclusion
  80160. */
  80161. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80162. /**
  80163. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80164. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80165. * @param frustumPlanes defines the frustum planes to test
  80166. * @return true if there is an intersection
  80167. */
  80168. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80169. }
  80170. }
  80171. declare module BABYLON {
  80172. /** @hidden */
  80173. export class Collider {
  80174. /** Define if a collision was found */
  80175. collisionFound: boolean;
  80176. /**
  80177. * Define last intersection point in local space
  80178. */
  80179. intersectionPoint: Vector3;
  80180. /**
  80181. * Define last collided mesh
  80182. */
  80183. collidedMesh: Nullable<AbstractMesh>;
  80184. private _collisionPoint;
  80185. private _planeIntersectionPoint;
  80186. private _tempVector;
  80187. private _tempVector2;
  80188. private _tempVector3;
  80189. private _tempVector4;
  80190. private _edge;
  80191. private _baseToVertex;
  80192. private _destinationPoint;
  80193. private _slidePlaneNormal;
  80194. private _displacementVector;
  80195. /** @hidden */
  80196. _radius: Vector3;
  80197. /** @hidden */
  80198. _retry: number;
  80199. private _velocity;
  80200. private _basePoint;
  80201. private _epsilon;
  80202. /** @hidden */
  80203. _velocityWorldLength: number;
  80204. /** @hidden */
  80205. _basePointWorld: Vector3;
  80206. private _velocityWorld;
  80207. private _normalizedVelocity;
  80208. /** @hidden */
  80209. _initialVelocity: Vector3;
  80210. /** @hidden */
  80211. _initialPosition: Vector3;
  80212. private _nearestDistance;
  80213. private _collisionMask;
  80214. get collisionMask(): number;
  80215. set collisionMask(mask: number);
  80216. /**
  80217. * Gets the plane normal used to compute the sliding response (in local space)
  80218. */
  80219. get slidePlaneNormal(): Vector3;
  80220. /** @hidden */
  80221. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80222. /** @hidden */
  80223. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80224. /** @hidden */
  80225. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80226. /** @hidden */
  80227. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80228. /** @hidden */
  80229. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80230. /** @hidden */
  80231. _getResponse(pos: Vector3, vel: Vector3): void;
  80232. }
  80233. }
  80234. declare module BABYLON {
  80235. /**
  80236. * Interface for cullable objects
  80237. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80238. */
  80239. export interface ICullable {
  80240. /**
  80241. * Checks if the object or part of the object is in the frustum
  80242. * @param frustumPlanes Camera near/planes
  80243. * @returns true if the object is in frustum otherwise false
  80244. */
  80245. isInFrustum(frustumPlanes: Plane[]): boolean;
  80246. /**
  80247. * Checks if a cullable object (mesh...) is in the camera frustum
  80248. * Unlike isInFrustum this cheks the full bounding box
  80249. * @param frustumPlanes Camera near/planes
  80250. * @returns true if the object is in frustum otherwise false
  80251. */
  80252. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80253. }
  80254. /**
  80255. * Info for a bounding data of a mesh
  80256. */
  80257. export class BoundingInfo implements ICullable {
  80258. /**
  80259. * Bounding box for the mesh
  80260. */
  80261. readonly boundingBox: BoundingBox;
  80262. /**
  80263. * Bounding sphere for the mesh
  80264. */
  80265. readonly boundingSphere: BoundingSphere;
  80266. private _isLocked;
  80267. private static readonly TmpVector3;
  80268. /**
  80269. * Constructs bounding info
  80270. * @param minimum min vector of the bounding box/sphere
  80271. * @param maximum max vector of the bounding box/sphere
  80272. * @param worldMatrix defines the new world matrix
  80273. */
  80274. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80275. /**
  80276. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80277. * @param min defines the new minimum vector (in local space)
  80278. * @param max defines the new maximum vector (in local space)
  80279. * @param worldMatrix defines the new world matrix
  80280. */
  80281. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80282. /**
  80283. * min vector of the bounding box/sphere
  80284. */
  80285. get minimum(): Vector3;
  80286. /**
  80287. * max vector of the bounding box/sphere
  80288. */
  80289. get maximum(): Vector3;
  80290. /**
  80291. * If the info is locked and won't be updated to avoid perf overhead
  80292. */
  80293. get isLocked(): boolean;
  80294. set isLocked(value: boolean);
  80295. /**
  80296. * Updates the bounding sphere and box
  80297. * @param world world matrix to be used to update
  80298. */
  80299. update(world: DeepImmutable<Matrix>): void;
  80300. /**
  80301. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80302. * @param center New center of the bounding info
  80303. * @param extend New extend of the bounding info
  80304. * @returns the current bounding info
  80305. */
  80306. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80307. /**
  80308. * Scale the current bounding info by applying a scale factor
  80309. * @param factor defines the scale factor to apply
  80310. * @returns the current bounding info
  80311. */
  80312. scale(factor: number): BoundingInfo;
  80313. /**
  80314. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80315. * @param frustumPlanes defines the frustum to test
  80316. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80317. * @returns true if the bounding info is in the frustum planes
  80318. */
  80319. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80320. /**
  80321. * Gets the world distance between the min and max points of the bounding box
  80322. */
  80323. get diagonalLength(): number;
  80324. /**
  80325. * Checks if a cullable object (mesh...) is in the camera frustum
  80326. * Unlike isInFrustum this cheks the full bounding box
  80327. * @param frustumPlanes Camera near/planes
  80328. * @returns true if the object is in frustum otherwise false
  80329. */
  80330. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80331. /** @hidden */
  80332. _checkCollision(collider: Collider): boolean;
  80333. /**
  80334. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80335. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80336. * @param point the point to check intersection with
  80337. * @returns if the point intersects
  80338. */
  80339. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80340. /**
  80341. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80342. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80343. * @param boundingInfo the bounding info to check intersection with
  80344. * @param precise if the intersection should be done using OBB
  80345. * @returns if the bounding info intersects
  80346. */
  80347. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80348. }
  80349. }
  80350. declare module BABYLON {
  80351. /**
  80352. * Extracts minimum and maximum values from a list of indexed positions
  80353. * @param positions defines the positions to use
  80354. * @param indices defines the indices to the positions
  80355. * @param indexStart defines the start index
  80356. * @param indexCount defines the end index
  80357. * @param bias defines bias value to add to the result
  80358. * @return minimum and maximum values
  80359. */
  80360. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80361. minimum: Vector3;
  80362. maximum: Vector3;
  80363. };
  80364. /**
  80365. * Extracts minimum and maximum values from a list of positions
  80366. * @param positions defines the positions to use
  80367. * @param start defines the start index in the positions array
  80368. * @param count defines the number of positions to handle
  80369. * @param bias defines bias value to add to the result
  80370. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80371. * @return minimum and maximum values
  80372. */
  80373. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80374. minimum: Vector3;
  80375. maximum: Vector3;
  80376. };
  80377. }
  80378. declare module BABYLON {
  80379. /** @hidden */
  80380. export class WebGLDataBuffer extends DataBuffer {
  80381. private _buffer;
  80382. constructor(resource: WebGLBuffer);
  80383. get underlyingResource(): any;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. /** @hidden */
  80388. export class WebGLPipelineContext implements IPipelineContext {
  80389. engine: ThinEngine;
  80390. program: Nullable<WebGLProgram>;
  80391. context?: WebGLRenderingContext;
  80392. vertexShader?: WebGLShader;
  80393. fragmentShader?: WebGLShader;
  80394. isParallelCompiled: boolean;
  80395. onCompiled?: () => void;
  80396. transformFeedback?: WebGLTransformFeedback | null;
  80397. vertexCompilationError: Nullable<string>;
  80398. fragmentCompilationError: Nullable<string>;
  80399. programLinkError: Nullable<string>;
  80400. programValidationError: Nullable<string>;
  80401. get isAsync(): boolean;
  80402. get isReady(): boolean;
  80403. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80404. }
  80405. }
  80406. declare module BABYLON {
  80407. interface ThinEngine {
  80408. /**
  80409. * Create an uniform buffer
  80410. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80411. * @param elements defines the content of the uniform buffer
  80412. * @returns the webGL uniform buffer
  80413. */
  80414. createUniformBuffer(elements: FloatArray): DataBuffer;
  80415. /**
  80416. * Create a dynamic uniform buffer
  80417. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80418. * @param elements defines the content of the uniform buffer
  80419. * @returns the webGL uniform buffer
  80420. */
  80421. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80422. /**
  80423. * Update an existing uniform buffer
  80424. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80425. * @param uniformBuffer defines the target uniform buffer
  80426. * @param elements defines the content to update
  80427. * @param offset defines the offset in the uniform buffer where update should start
  80428. * @param count defines the size of the data to update
  80429. */
  80430. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80431. /**
  80432. * Bind an uniform buffer to the current webGL context
  80433. * @param buffer defines the buffer to bind
  80434. */
  80435. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80436. /**
  80437. * Bind a buffer to the current webGL context at a given location
  80438. * @param buffer defines the buffer to bind
  80439. * @param location defines the index where to bind the buffer
  80440. */
  80441. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80442. /**
  80443. * Bind a specific block at a given index in a specific shader program
  80444. * @param pipelineContext defines the pipeline context to use
  80445. * @param blockName defines the block name
  80446. * @param index defines the index where to bind the block
  80447. */
  80448. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80449. }
  80450. }
  80451. declare module BABYLON {
  80452. /**
  80453. * Uniform buffer objects.
  80454. *
  80455. * Handles blocks of uniform on the GPU.
  80456. *
  80457. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80458. *
  80459. * For more information, please refer to :
  80460. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80461. */
  80462. export class UniformBuffer {
  80463. private _engine;
  80464. private _buffer;
  80465. private _data;
  80466. private _bufferData;
  80467. private _dynamic?;
  80468. private _uniformLocations;
  80469. private _uniformSizes;
  80470. private _uniformLocationPointer;
  80471. private _needSync;
  80472. private _noUBO;
  80473. private _currentEffect;
  80474. /** @hidden */
  80475. _alreadyBound: boolean;
  80476. private static _MAX_UNIFORM_SIZE;
  80477. private static _tempBuffer;
  80478. /**
  80479. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80480. * This is dynamic to allow compat with webgl 1 and 2.
  80481. * You will need to pass the name of the uniform as well as the value.
  80482. */
  80483. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80484. /**
  80485. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80486. * This is dynamic to allow compat with webgl 1 and 2.
  80487. * You will need to pass the name of the uniform as well as the value.
  80488. */
  80489. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80490. /**
  80491. * Lambda to Update a single float in a uniform buffer.
  80492. * This is dynamic to allow compat with webgl 1 and 2.
  80493. * You will need to pass the name of the uniform as well as the value.
  80494. */
  80495. updateFloat: (name: string, x: number) => void;
  80496. /**
  80497. * Lambda to Update a vec2 of float in a uniform buffer.
  80498. * This is dynamic to allow compat with webgl 1 and 2.
  80499. * You will need to pass the name of the uniform as well as the value.
  80500. */
  80501. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80502. /**
  80503. * Lambda to Update a vec3 of float in a uniform buffer.
  80504. * This is dynamic to allow compat with webgl 1 and 2.
  80505. * You will need to pass the name of the uniform as well as the value.
  80506. */
  80507. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80508. /**
  80509. * Lambda to Update a vec4 of float in a uniform buffer.
  80510. * This is dynamic to allow compat with webgl 1 and 2.
  80511. * You will need to pass the name of the uniform as well as the value.
  80512. */
  80513. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80514. /**
  80515. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80516. * This is dynamic to allow compat with webgl 1 and 2.
  80517. * You will need to pass the name of the uniform as well as the value.
  80518. */
  80519. updateMatrix: (name: string, mat: Matrix) => void;
  80520. /**
  80521. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80522. * This is dynamic to allow compat with webgl 1 and 2.
  80523. * You will need to pass the name of the uniform as well as the value.
  80524. */
  80525. updateVector3: (name: string, vector: Vector3) => void;
  80526. /**
  80527. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80528. * This is dynamic to allow compat with webgl 1 and 2.
  80529. * You will need to pass the name of the uniform as well as the value.
  80530. */
  80531. updateVector4: (name: string, vector: Vector4) => void;
  80532. /**
  80533. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80534. * This is dynamic to allow compat with webgl 1 and 2.
  80535. * You will need to pass the name of the uniform as well as the value.
  80536. */
  80537. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80538. /**
  80539. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80540. * This is dynamic to allow compat with webgl 1 and 2.
  80541. * You will need to pass the name of the uniform as well as the value.
  80542. */
  80543. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80544. /**
  80545. * Instantiates a new Uniform buffer objects.
  80546. *
  80547. * Handles blocks of uniform on the GPU.
  80548. *
  80549. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80550. *
  80551. * For more information, please refer to :
  80552. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80553. * @param engine Define the engine the buffer is associated with
  80554. * @param data Define the data contained in the buffer
  80555. * @param dynamic Define if the buffer is updatable
  80556. */
  80557. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80558. /**
  80559. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80560. * or just falling back on setUniformXXX calls.
  80561. */
  80562. get useUbo(): boolean;
  80563. /**
  80564. * Indicates if the WebGL underlying uniform buffer is in sync
  80565. * with the javascript cache data.
  80566. */
  80567. get isSync(): boolean;
  80568. /**
  80569. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80570. * Also, a dynamic UniformBuffer will disable cache verification and always
  80571. * update the underlying WebGL uniform buffer to the GPU.
  80572. * @returns if Dynamic, otherwise false
  80573. */
  80574. isDynamic(): boolean;
  80575. /**
  80576. * The data cache on JS side.
  80577. * @returns the underlying data as a float array
  80578. */
  80579. getData(): Float32Array;
  80580. /**
  80581. * The underlying WebGL Uniform buffer.
  80582. * @returns the webgl buffer
  80583. */
  80584. getBuffer(): Nullable<DataBuffer>;
  80585. /**
  80586. * std140 layout specifies how to align data within an UBO structure.
  80587. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80588. * for specs.
  80589. */
  80590. private _fillAlignment;
  80591. /**
  80592. * Adds an uniform in the buffer.
  80593. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80594. * for the layout to be correct !
  80595. * @param name Name of the uniform, as used in the uniform block in the shader.
  80596. * @param size Data size, or data directly.
  80597. */
  80598. addUniform(name: string, size: number | number[]): void;
  80599. /**
  80600. * Adds a Matrix 4x4 to the uniform buffer.
  80601. * @param name Name of the uniform, as used in the uniform block in the shader.
  80602. * @param mat A 4x4 matrix.
  80603. */
  80604. addMatrix(name: string, mat: Matrix): void;
  80605. /**
  80606. * Adds a vec2 to the uniform buffer.
  80607. * @param name Name of the uniform, as used in the uniform block in the shader.
  80608. * @param x Define the x component value of the vec2
  80609. * @param y Define the y component value of the vec2
  80610. */
  80611. addFloat2(name: string, x: number, y: number): void;
  80612. /**
  80613. * Adds a vec3 to the uniform buffer.
  80614. * @param name Name of the uniform, as used in the uniform block in the shader.
  80615. * @param x Define the x component value of the vec3
  80616. * @param y Define the y component value of the vec3
  80617. * @param z Define the z component value of the vec3
  80618. */
  80619. addFloat3(name: string, x: number, y: number, z: number): void;
  80620. /**
  80621. * Adds a vec3 to the uniform buffer.
  80622. * @param name Name of the uniform, as used in the uniform block in the shader.
  80623. * @param color Define the vec3 from a Color
  80624. */
  80625. addColor3(name: string, color: Color3): void;
  80626. /**
  80627. * Adds a vec4 to the uniform buffer.
  80628. * @param name Name of the uniform, as used in the uniform block in the shader.
  80629. * @param color Define the rgb components from a Color
  80630. * @param alpha Define the a component of the vec4
  80631. */
  80632. addColor4(name: string, color: Color3, alpha: number): void;
  80633. /**
  80634. * Adds a vec3 to the uniform buffer.
  80635. * @param name Name of the uniform, as used in the uniform block in the shader.
  80636. * @param vector Define the vec3 components from a Vector
  80637. */
  80638. addVector3(name: string, vector: Vector3): void;
  80639. /**
  80640. * Adds a Matrix 3x3 to the uniform buffer.
  80641. * @param name Name of the uniform, as used in the uniform block in the shader.
  80642. */
  80643. addMatrix3x3(name: string): void;
  80644. /**
  80645. * Adds a Matrix 2x2 to the uniform buffer.
  80646. * @param name Name of the uniform, as used in the uniform block in the shader.
  80647. */
  80648. addMatrix2x2(name: string): void;
  80649. /**
  80650. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80651. */
  80652. create(): void;
  80653. /** @hidden */
  80654. _rebuild(): void;
  80655. /**
  80656. * Updates the WebGL Uniform Buffer on the GPU.
  80657. * If the `dynamic` flag is set to true, no cache comparison is done.
  80658. * Otherwise, the buffer will be updated only if the cache differs.
  80659. */
  80660. update(): void;
  80661. /**
  80662. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80663. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80664. * @param data Define the flattened data
  80665. * @param size Define the size of the data.
  80666. */
  80667. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80668. private _valueCache;
  80669. private _cacheMatrix;
  80670. private _updateMatrix3x3ForUniform;
  80671. private _updateMatrix3x3ForEffect;
  80672. private _updateMatrix2x2ForEffect;
  80673. private _updateMatrix2x2ForUniform;
  80674. private _updateFloatForEffect;
  80675. private _updateFloatForUniform;
  80676. private _updateFloat2ForEffect;
  80677. private _updateFloat2ForUniform;
  80678. private _updateFloat3ForEffect;
  80679. private _updateFloat3ForUniform;
  80680. private _updateFloat4ForEffect;
  80681. private _updateFloat4ForUniform;
  80682. private _updateMatrixForEffect;
  80683. private _updateMatrixForUniform;
  80684. private _updateVector3ForEffect;
  80685. private _updateVector3ForUniform;
  80686. private _updateVector4ForEffect;
  80687. private _updateVector4ForUniform;
  80688. private _updateColor3ForEffect;
  80689. private _updateColor3ForUniform;
  80690. private _updateColor4ForEffect;
  80691. private _updateColor4ForUniform;
  80692. /**
  80693. * Sets a sampler uniform on the effect.
  80694. * @param name Define the name of the sampler.
  80695. * @param texture Define the texture to set in the sampler
  80696. */
  80697. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80698. /**
  80699. * Directly updates the value of the uniform in the cache AND on the GPU.
  80700. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80701. * @param data Define the flattened data
  80702. */
  80703. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80704. /**
  80705. * Binds this uniform buffer to an effect.
  80706. * @param effect Define the effect to bind the buffer to
  80707. * @param name Name of the uniform block in the shader.
  80708. */
  80709. bindToEffect(effect: Effect, name: string): void;
  80710. /**
  80711. * Disposes the uniform buffer.
  80712. */
  80713. dispose(): void;
  80714. }
  80715. }
  80716. declare module BABYLON {
  80717. /**
  80718. * Enum that determines the text-wrapping mode to use.
  80719. */
  80720. export enum InspectableType {
  80721. /**
  80722. * Checkbox for booleans
  80723. */
  80724. Checkbox = 0,
  80725. /**
  80726. * Sliders for numbers
  80727. */
  80728. Slider = 1,
  80729. /**
  80730. * Vector3
  80731. */
  80732. Vector3 = 2,
  80733. /**
  80734. * Quaternions
  80735. */
  80736. Quaternion = 3,
  80737. /**
  80738. * Color3
  80739. */
  80740. Color3 = 4,
  80741. /**
  80742. * String
  80743. */
  80744. String = 5
  80745. }
  80746. /**
  80747. * Interface used to define custom inspectable properties.
  80748. * This interface is used by the inspector to display custom property grids
  80749. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80750. */
  80751. export interface IInspectable {
  80752. /**
  80753. * Gets the label to display
  80754. */
  80755. label: string;
  80756. /**
  80757. * Gets the name of the property to edit
  80758. */
  80759. propertyName: string;
  80760. /**
  80761. * Gets the type of the editor to use
  80762. */
  80763. type: InspectableType;
  80764. /**
  80765. * Gets the minimum value of the property when using in "slider" mode
  80766. */
  80767. min?: number;
  80768. /**
  80769. * Gets the maximum value of the property when using in "slider" mode
  80770. */
  80771. max?: number;
  80772. /**
  80773. * Gets the setp to use when using in "slider" mode
  80774. */
  80775. step?: number;
  80776. }
  80777. }
  80778. declare module BABYLON {
  80779. /**
  80780. * Class used to provide helper for timing
  80781. */
  80782. export class TimingTools {
  80783. /**
  80784. * Polyfill for setImmediate
  80785. * @param action defines the action to execute after the current execution block
  80786. */
  80787. static SetImmediate(action: () => void): void;
  80788. }
  80789. }
  80790. declare module BABYLON {
  80791. /**
  80792. * Class used to enable instatition of objects by class name
  80793. */
  80794. export class InstantiationTools {
  80795. /**
  80796. * Use this object to register external classes like custom textures or material
  80797. * to allow the laoders to instantiate them
  80798. */
  80799. static RegisteredExternalClasses: {
  80800. [key: string]: Object;
  80801. };
  80802. /**
  80803. * Tries to instantiate a new object from a given class name
  80804. * @param className defines the class name to instantiate
  80805. * @returns the new object or null if the system was not able to do the instantiation
  80806. */
  80807. static Instantiate(className: string): any;
  80808. }
  80809. }
  80810. declare module BABYLON {
  80811. /**
  80812. * Define options used to create a depth texture
  80813. */
  80814. export class DepthTextureCreationOptions {
  80815. /** Specifies whether or not a stencil should be allocated in the texture */
  80816. generateStencil?: boolean;
  80817. /** Specifies whether or not bilinear filtering is enable on the texture */
  80818. bilinearFiltering?: boolean;
  80819. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80820. comparisonFunction?: number;
  80821. /** Specifies if the created texture is a cube texture */
  80822. isCube?: boolean;
  80823. }
  80824. }
  80825. declare module BABYLON {
  80826. interface ThinEngine {
  80827. /**
  80828. * Creates a depth stencil cube texture.
  80829. * This is only available in WebGL 2.
  80830. * @param size The size of face edge in the cube texture.
  80831. * @param options The options defining the cube texture.
  80832. * @returns The cube texture
  80833. */
  80834. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80835. /**
  80836. * Creates a cube texture
  80837. * @param rootUrl defines the url where the files to load is located
  80838. * @param scene defines the current scene
  80839. * @param files defines the list of files to load (1 per face)
  80840. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80841. * @param onLoad defines an optional callback raised when the texture is loaded
  80842. * @param onError defines an optional callback raised if there is an issue to load the texture
  80843. * @param format defines the format of the data
  80844. * @param forcedExtension defines the extension to use to pick the right loader
  80845. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80846. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80847. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80848. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80849. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80850. * @returns the cube texture as an InternalTexture
  80851. */
  80852. 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;
  80853. /**
  80854. * Creates a cube texture
  80855. * @param rootUrl defines the url where the files to load is located
  80856. * @param scene defines the current scene
  80857. * @param files defines the list of files to load (1 per face)
  80858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80859. * @param onLoad defines an optional callback raised when the texture is loaded
  80860. * @param onError defines an optional callback raised if there is an issue to load the texture
  80861. * @param format defines the format of the data
  80862. * @param forcedExtension defines the extension to use to pick the right loader
  80863. * @returns the cube texture as an InternalTexture
  80864. */
  80865. 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;
  80866. /**
  80867. * Creates a cube texture
  80868. * @param rootUrl defines the url where the files to load is located
  80869. * @param scene defines the current scene
  80870. * @param files defines the list of files to load (1 per face)
  80871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80872. * @param onLoad defines an optional callback raised when the texture is loaded
  80873. * @param onError defines an optional callback raised if there is an issue to load the texture
  80874. * @param format defines the format of the data
  80875. * @param forcedExtension defines the extension to use to pick the right loader
  80876. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80877. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80878. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80879. * @returns the cube texture as an InternalTexture
  80880. */
  80881. 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;
  80882. /** @hidden */
  80883. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80884. /** @hidden */
  80885. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80886. /** @hidden */
  80887. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80888. /** @hidden */
  80889. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80890. /**
  80891. * @hidden
  80892. */
  80893. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80894. }
  80895. }
  80896. declare module BABYLON {
  80897. /**
  80898. * Class for creating a cube texture
  80899. */
  80900. export class CubeTexture extends BaseTexture {
  80901. private _delayedOnLoad;
  80902. /**
  80903. * Observable triggered once the texture has been loaded.
  80904. */
  80905. onLoadObservable: Observable<CubeTexture>;
  80906. /**
  80907. * The url of the texture
  80908. */
  80909. url: string;
  80910. /**
  80911. * Gets or sets the center of the bounding box associated with the cube texture.
  80912. * It must define where the camera used to render the texture was set
  80913. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80914. */
  80915. boundingBoxPosition: Vector3;
  80916. private _boundingBoxSize;
  80917. /**
  80918. * Gets or sets the size of the bounding box associated with the cube texture
  80919. * When defined, the cubemap will switch to local mode
  80920. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80921. * @example https://www.babylonjs-playground.com/#RNASML
  80922. */
  80923. set boundingBoxSize(value: Vector3);
  80924. /**
  80925. * Returns the bounding box size
  80926. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80927. */
  80928. get boundingBoxSize(): Vector3;
  80929. protected _rotationY: number;
  80930. /**
  80931. * Sets texture matrix rotation angle around Y axis in radians.
  80932. */
  80933. set rotationY(value: number);
  80934. /**
  80935. * Gets texture matrix rotation angle around Y axis radians.
  80936. */
  80937. get rotationY(): number;
  80938. /**
  80939. * Are mip maps generated for this texture or not.
  80940. */
  80941. get noMipmap(): boolean;
  80942. private _noMipmap;
  80943. private _files;
  80944. protected _forcedExtension: Nullable<string>;
  80945. private _extensions;
  80946. private _textureMatrix;
  80947. private _format;
  80948. private _createPolynomials;
  80949. /** @hidden */
  80950. _prefiltered: boolean;
  80951. /**
  80952. * Creates a cube texture from an array of image urls
  80953. * @param files defines an array of image urls
  80954. * @param scene defines the hosting scene
  80955. * @param noMipmap specifies if mip maps are not used
  80956. * @returns a cube texture
  80957. */
  80958. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80959. /**
  80960. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80961. * @param url defines the url of the prefiltered texture
  80962. * @param scene defines the scene the texture is attached to
  80963. * @param forcedExtension defines the extension of the file if different from the url
  80964. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80965. * @return the prefiltered texture
  80966. */
  80967. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80968. /**
  80969. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80970. * as prefiltered data.
  80971. * @param rootUrl defines the url of the texture or the root name of the six images
  80972. * @param scene defines the scene the texture is attached to
  80973. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80974. * @param noMipmap defines if mipmaps should be created or not
  80975. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80976. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80977. * @param onError defines a callback triggered in case of error during load
  80978. * @param format defines the internal format to use for the texture once loaded
  80979. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80980. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80981. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80982. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80983. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80984. * @return the cube texture
  80985. */
  80986. 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);
  80987. /**
  80988. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80989. */
  80990. get isPrefiltered(): boolean;
  80991. /**
  80992. * Get the current class name of the texture useful for serialization or dynamic coding.
  80993. * @returns "CubeTexture"
  80994. */
  80995. getClassName(): string;
  80996. /**
  80997. * Update the url (and optional buffer) of this texture if url was null during construction.
  80998. * @param url the url of the texture
  80999. * @param forcedExtension defines the extension to use
  81000. * @param onLoad callback called when the texture is loaded (defaults to null)
  81001. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81002. */
  81003. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81004. /**
  81005. * Delays loading of the cube texture
  81006. * @param forcedExtension defines the extension to use
  81007. */
  81008. delayLoad(forcedExtension?: string): void;
  81009. /**
  81010. * Returns the reflection texture matrix
  81011. * @returns the reflection texture matrix
  81012. */
  81013. getReflectionTextureMatrix(): Matrix;
  81014. /**
  81015. * Sets the reflection texture matrix
  81016. * @param value Reflection texture matrix
  81017. */
  81018. setReflectionTextureMatrix(value: Matrix): void;
  81019. /**
  81020. * Parses text to create a cube texture
  81021. * @param parsedTexture define the serialized text to read from
  81022. * @param scene defines the hosting scene
  81023. * @param rootUrl defines the root url of the cube texture
  81024. * @returns a cube texture
  81025. */
  81026. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81027. /**
  81028. * Makes a clone, or deep copy, of the cube texture
  81029. * @returns a new cube texture
  81030. */
  81031. clone(): CubeTexture;
  81032. }
  81033. }
  81034. declare module BABYLON {
  81035. /**
  81036. * Manages the defines for the Material
  81037. */
  81038. export class MaterialDefines {
  81039. /** @hidden */
  81040. protected _keys: string[];
  81041. private _isDirty;
  81042. /** @hidden */
  81043. _renderId: number;
  81044. /** @hidden */
  81045. _areLightsDirty: boolean;
  81046. /** @hidden */
  81047. _areLightsDisposed: boolean;
  81048. /** @hidden */
  81049. _areAttributesDirty: boolean;
  81050. /** @hidden */
  81051. _areTexturesDirty: boolean;
  81052. /** @hidden */
  81053. _areFresnelDirty: boolean;
  81054. /** @hidden */
  81055. _areMiscDirty: boolean;
  81056. /** @hidden */
  81057. _areImageProcessingDirty: boolean;
  81058. /** @hidden */
  81059. _normals: boolean;
  81060. /** @hidden */
  81061. _uvs: boolean;
  81062. /** @hidden */
  81063. _needNormals: boolean;
  81064. /** @hidden */
  81065. _needUVs: boolean;
  81066. [id: string]: any;
  81067. /**
  81068. * Specifies if the material needs to be re-calculated
  81069. */
  81070. get isDirty(): boolean;
  81071. /**
  81072. * Marks the material to indicate that it has been re-calculated
  81073. */
  81074. markAsProcessed(): void;
  81075. /**
  81076. * Marks the material to indicate that it needs to be re-calculated
  81077. */
  81078. markAsUnprocessed(): void;
  81079. /**
  81080. * Marks the material to indicate all of its defines need to be re-calculated
  81081. */
  81082. markAllAsDirty(): void;
  81083. /**
  81084. * Marks the material to indicate that image processing needs to be re-calculated
  81085. */
  81086. markAsImageProcessingDirty(): void;
  81087. /**
  81088. * Marks the material to indicate the lights need to be re-calculated
  81089. * @param disposed Defines whether the light is dirty due to dispose or not
  81090. */
  81091. markAsLightDirty(disposed?: boolean): void;
  81092. /**
  81093. * Marks the attribute state as changed
  81094. */
  81095. markAsAttributesDirty(): void;
  81096. /**
  81097. * Marks the texture state as changed
  81098. */
  81099. markAsTexturesDirty(): void;
  81100. /**
  81101. * Marks the fresnel state as changed
  81102. */
  81103. markAsFresnelDirty(): void;
  81104. /**
  81105. * Marks the misc state as changed
  81106. */
  81107. markAsMiscDirty(): void;
  81108. /**
  81109. * Rebuilds the material defines
  81110. */
  81111. rebuild(): void;
  81112. /**
  81113. * Specifies if two material defines are equal
  81114. * @param other - A material define instance to compare to
  81115. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81116. */
  81117. isEqual(other: MaterialDefines): boolean;
  81118. /**
  81119. * Clones this instance's defines to another instance
  81120. * @param other - material defines to clone values to
  81121. */
  81122. cloneTo(other: MaterialDefines): void;
  81123. /**
  81124. * Resets the material define values
  81125. */
  81126. reset(): void;
  81127. /**
  81128. * Converts the material define values to a string
  81129. * @returns - String of material define information
  81130. */
  81131. toString(): string;
  81132. }
  81133. }
  81134. declare module BABYLON {
  81135. /**
  81136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81138. * 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;
  81139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81140. */
  81141. export class ColorCurves {
  81142. private _dirty;
  81143. private _tempColor;
  81144. private _globalCurve;
  81145. private _highlightsCurve;
  81146. private _midtonesCurve;
  81147. private _shadowsCurve;
  81148. private _positiveCurve;
  81149. private _negativeCurve;
  81150. private _globalHue;
  81151. private _globalDensity;
  81152. private _globalSaturation;
  81153. private _globalExposure;
  81154. /**
  81155. * Gets the global Hue value.
  81156. * 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).
  81157. */
  81158. get globalHue(): number;
  81159. /**
  81160. * Sets the global Hue value.
  81161. * 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).
  81162. */
  81163. set globalHue(value: number);
  81164. /**
  81165. * Gets the global Density value.
  81166. * 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.
  81167. * Values less than zero provide a filter of opposite hue.
  81168. */
  81169. get globalDensity(): number;
  81170. /**
  81171. * Sets the global Density value.
  81172. * 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.
  81173. * Values less than zero provide a filter of opposite hue.
  81174. */
  81175. set globalDensity(value: number);
  81176. /**
  81177. * Gets the global Saturation value.
  81178. * 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.
  81179. */
  81180. get globalSaturation(): number;
  81181. /**
  81182. * Sets the global Saturation value.
  81183. * 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.
  81184. */
  81185. set globalSaturation(value: number);
  81186. /**
  81187. * Gets the global Exposure value.
  81188. * 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.
  81189. */
  81190. get globalExposure(): number;
  81191. /**
  81192. * Sets the global Exposure value.
  81193. * 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.
  81194. */
  81195. set globalExposure(value: number);
  81196. private _highlightsHue;
  81197. private _highlightsDensity;
  81198. private _highlightsSaturation;
  81199. private _highlightsExposure;
  81200. /**
  81201. * Gets the highlights Hue value.
  81202. * 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).
  81203. */
  81204. get highlightsHue(): number;
  81205. /**
  81206. * Sets the highlights Hue value.
  81207. * 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).
  81208. */
  81209. set highlightsHue(value: number);
  81210. /**
  81211. * Gets the highlights Density value.
  81212. * 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.
  81213. * Values less than zero provide a filter of opposite hue.
  81214. */
  81215. get highlightsDensity(): number;
  81216. /**
  81217. * Sets the highlights Density value.
  81218. * 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.
  81219. * Values less than zero provide a filter of opposite hue.
  81220. */
  81221. set highlightsDensity(value: number);
  81222. /**
  81223. * Gets the highlights Saturation value.
  81224. * 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.
  81225. */
  81226. get highlightsSaturation(): number;
  81227. /**
  81228. * Sets the highlights Saturation value.
  81229. * 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.
  81230. */
  81231. set highlightsSaturation(value: number);
  81232. /**
  81233. * Gets the highlights Exposure value.
  81234. * 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.
  81235. */
  81236. get highlightsExposure(): number;
  81237. /**
  81238. * Sets the highlights Exposure value.
  81239. * 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.
  81240. */
  81241. set highlightsExposure(value: number);
  81242. private _midtonesHue;
  81243. private _midtonesDensity;
  81244. private _midtonesSaturation;
  81245. private _midtonesExposure;
  81246. /**
  81247. * Gets the midtones Hue value.
  81248. * 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).
  81249. */
  81250. get midtonesHue(): number;
  81251. /**
  81252. * Sets the midtones Hue value.
  81253. * 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).
  81254. */
  81255. set midtonesHue(value: number);
  81256. /**
  81257. * Gets the midtones Density value.
  81258. * 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.
  81259. * Values less than zero provide a filter of opposite hue.
  81260. */
  81261. get midtonesDensity(): number;
  81262. /**
  81263. * Sets the midtones Density value.
  81264. * 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.
  81265. * Values less than zero provide a filter of opposite hue.
  81266. */
  81267. set midtonesDensity(value: number);
  81268. /**
  81269. * Gets the midtones Saturation value.
  81270. * 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.
  81271. */
  81272. get midtonesSaturation(): number;
  81273. /**
  81274. * Sets the midtones Saturation value.
  81275. * 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.
  81276. */
  81277. set midtonesSaturation(value: number);
  81278. /**
  81279. * Gets the midtones Exposure value.
  81280. * 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.
  81281. */
  81282. get midtonesExposure(): number;
  81283. /**
  81284. * Sets the midtones Exposure value.
  81285. * 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.
  81286. */
  81287. set midtonesExposure(value: number);
  81288. private _shadowsHue;
  81289. private _shadowsDensity;
  81290. private _shadowsSaturation;
  81291. private _shadowsExposure;
  81292. /**
  81293. * Gets the shadows Hue value.
  81294. * 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).
  81295. */
  81296. get shadowsHue(): number;
  81297. /**
  81298. * Sets the shadows Hue value.
  81299. * 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).
  81300. */
  81301. set shadowsHue(value: number);
  81302. /**
  81303. * Gets the shadows Density value.
  81304. * 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.
  81305. * Values less than zero provide a filter of opposite hue.
  81306. */
  81307. get shadowsDensity(): number;
  81308. /**
  81309. * Sets the shadows Density value.
  81310. * 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.
  81311. * Values less than zero provide a filter of opposite hue.
  81312. */
  81313. set shadowsDensity(value: number);
  81314. /**
  81315. * Gets the shadows Saturation value.
  81316. * 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.
  81317. */
  81318. get shadowsSaturation(): number;
  81319. /**
  81320. * Sets the shadows Saturation value.
  81321. * 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.
  81322. */
  81323. set shadowsSaturation(value: number);
  81324. /**
  81325. * Gets the shadows Exposure value.
  81326. * 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.
  81327. */
  81328. get shadowsExposure(): number;
  81329. /**
  81330. * Sets the shadows Exposure value.
  81331. * 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.
  81332. */
  81333. set shadowsExposure(value: number);
  81334. /**
  81335. * Returns the class name
  81336. * @returns The class name
  81337. */
  81338. getClassName(): string;
  81339. /**
  81340. * Binds the color curves to the shader.
  81341. * @param colorCurves The color curve to bind
  81342. * @param effect The effect to bind to
  81343. * @param positiveUniform The positive uniform shader parameter
  81344. * @param neutralUniform The neutral uniform shader parameter
  81345. * @param negativeUniform The negative uniform shader parameter
  81346. */
  81347. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81348. /**
  81349. * Prepare the list of uniforms associated with the ColorCurves effects.
  81350. * @param uniformsList The list of uniforms used in the effect
  81351. */
  81352. static PrepareUniforms(uniformsList: string[]): void;
  81353. /**
  81354. * Returns color grading data based on a hue, density, saturation and exposure value.
  81355. * @param filterHue The hue of the color filter.
  81356. * @param filterDensity The density of the color filter.
  81357. * @param saturation The saturation.
  81358. * @param exposure The exposure.
  81359. * @param result The result data container.
  81360. */
  81361. private getColorGradingDataToRef;
  81362. /**
  81363. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81364. * @param value The input slider value in range [-100,100].
  81365. * @returns Adjusted value.
  81366. */
  81367. private static applyColorGradingSliderNonlinear;
  81368. /**
  81369. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81370. * @param hue The hue (H) input.
  81371. * @param saturation The saturation (S) input.
  81372. * @param brightness The brightness (B) input.
  81373. * @result An RGBA color represented as Vector4.
  81374. */
  81375. private static fromHSBToRef;
  81376. /**
  81377. * Returns a value clamped between min and max
  81378. * @param value The value to clamp
  81379. * @param min The minimum of value
  81380. * @param max The maximum of value
  81381. * @returns The clamped value.
  81382. */
  81383. private static clamp;
  81384. /**
  81385. * Clones the current color curve instance.
  81386. * @return The cloned curves
  81387. */
  81388. clone(): ColorCurves;
  81389. /**
  81390. * Serializes the current color curve instance to a json representation.
  81391. * @return a JSON representation
  81392. */
  81393. serialize(): any;
  81394. /**
  81395. * Parses the color curve from a json representation.
  81396. * @param source the JSON source to parse
  81397. * @return The parsed curves
  81398. */
  81399. static Parse(source: any): ColorCurves;
  81400. }
  81401. }
  81402. declare module BABYLON {
  81403. /**
  81404. * Interface to follow in your material defines to integrate easily the
  81405. * Image proccessing functions.
  81406. * @hidden
  81407. */
  81408. export interface IImageProcessingConfigurationDefines {
  81409. IMAGEPROCESSING: boolean;
  81410. VIGNETTE: boolean;
  81411. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81412. VIGNETTEBLENDMODEOPAQUE: boolean;
  81413. TONEMAPPING: boolean;
  81414. TONEMAPPING_ACES: boolean;
  81415. CONTRAST: boolean;
  81416. EXPOSURE: boolean;
  81417. COLORCURVES: boolean;
  81418. COLORGRADING: boolean;
  81419. COLORGRADING3D: boolean;
  81420. SAMPLER3DGREENDEPTH: boolean;
  81421. SAMPLER3DBGRMAP: boolean;
  81422. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81423. }
  81424. /**
  81425. * @hidden
  81426. */
  81427. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81428. IMAGEPROCESSING: boolean;
  81429. VIGNETTE: boolean;
  81430. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81431. VIGNETTEBLENDMODEOPAQUE: boolean;
  81432. TONEMAPPING: boolean;
  81433. TONEMAPPING_ACES: boolean;
  81434. CONTRAST: boolean;
  81435. COLORCURVES: boolean;
  81436. COLORGRADING: boolean;
  81437. COLORGRADING3D: boolean;
  81438. SAMPLER3DGREENDEPTH: boolean;
  81439. SAMPLER3DBGRMAP: boolean;
  81440. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81441. EXPOSURE: boolean;
  81442. constructor();
  81443. }
  81444. /**
  81445. * This groups together the common properties used for image processing either in direct forward pass
  81446. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81447. * or not.
  81448. */
  81449. export class ImageProcessingConfiguration {
  81450. /**
  81451. * Default tone mapping applied in BabylonJS.
  81452. */
  81453. static readonly TONEMAPPING_STANDARD: number;
  81454. /**
  81455. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81456. * to other engines rendering to increase portability.
  81457. */
  81458. static readonly TONEMAPPING_ACES: number;
  81459. /**
  81460. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81461. */
  81462. colorCurves: Nullable<ColorCurves>;
  81463. private _colorCurvesEnabled;
  81464. /**
  81465. * Gets wether the color curves effect is enabled.
  81466. */
  81467. get colorCurvesEnabled(): boolean;
  81468. /**
  81469. * Sets wether the color curves effect is enabled.
  81470. */
  81471. set colorCurvesEnabled(value: boolean);
  81472. private _colorGradingTexture;
  81473. /**
  81474. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81475. */
  81476. get colorGradingTexture(): Nullable<BaseTexture>;
  81477. /**
  81478. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81479. */
  81480. set colorGradingTexture(value: Nullable<BaseTexture>);
  81481. private _colorGradingEnabled;
  81482. /**
  81483. * Gets wether the color grading effect is enabled.
  81484. */
  81485. get colorGradingEnabled(): boolean;
  81486. /**
  81487. * Sets wether the color grading effect is enabled.
  81488. */
  81489. set colorGradingEnabled(value: boolean);
  81490. private _colorGradingWithGreenDepth;
  81491. /**
  81492. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81493. */
  81494. get colorGradingWithGreenDepth(): boolean;
  81495. /**
  81496. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81497. */
  81498. set colorGradingWithGreenDepth(value: boolean);
  81499. private _colorGradingBGR;
  81500. /**
  81501. * Gets wether the color grading texture contains BGR values.
  81502. */
  81503. get colorGradingBGR(): boolean;
  81504. /**
  81505. * Sets wether the color grading texture contains BGR values.
  81506. */
  81507. set colorGradingBGR(value: boolean);
  81508. /** @hidden */
  81509. _exposure: number;
  81510. /**
  81511. * Gets the Exposure used in the effect.
  81512. */
  81513. get exposure(): number;
  81514. /**
  81515. * Sets the Exposure used in the effect.
  81516. */
  81517. set exposure(value: number);
  81518. private _toneMappingEnabled;
  81519. /**
  81520. * Gets wether the tone mapping effect is enabled.
  81521. */
  81522. get toneMappingEnabled(): boolean;
  81523. /**
  81524. * Sets wether the tone mapping effect is enabled.
  81525. */
  81526. set toneMappingEnabled(value: boolean);
  81527. private _toneMappingType;
  81528. /**
  81529. * Gets the type of tone mapping effect.
  81530. */
  81531. get toneMappingType(): number;
  81532. /**
  81533. * Sets the type of tone mapping effect used in BabylonJS.
  81534. */
  81535. set toneMappingType(value: number);
  81536. protected _contrast: number;
  81537. /**
  81538. * Gets the contrast used in the effect.
  81539. */
  81540. get contrast(): number;
  81541. /**
  81542. * Sets the contrast used in the effect.
  81543. */
  81544. set contrast(value: number);
  81545. /**
  81546. * Vignette stretch size.
  81547. */
  81548. vignetteStretch: number;
  81549. /**
  81550. * Vignette centre X Offset.
  81551. */
  81552. vignetteCentreX: number;
  81553. /**
  81554. * Vignette centre Y Offset.
  81555. */
  81556. vignetteCentreY: number;
  81557. /**
  81558. * Vignette weight or intensity of the vignette effect.
  81559. */
  81560. vignetteWeight: number;
  81561. /**
  81562. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81563. * if vignetteEnabled is set to true.
  81564. */
  81565. vignetteColor: Color4;
  81566. /**
  81567. * Camera field of view used by the Vignette effect.
  81568. */
  81569. vignetteCameraFov: number;
  81570. private _vignetteBlendMode;
  81571. /**
  81572. * Gets the vignette blend mode allowing different kind of effect.
  81573. */
  81574. get vignetteBlendMode(): number;
  81575. /**
  81576. * Sets the vignette blend mode allowing different kind of effect.
  81577. */
  81578. set vignetteBlendMode(value: number);
  81579. private _vignetteEnabled;
  81580. /**
  81581. * Gets wether the vignette effect is enabled.
  81582. */
  81583. get vignetteEnabled(): boolean;
  81584. /**
  81585. * Sets wether the vignette effect is enabled.
  81586. */
  81587. set vignetteEnabled(value: boolean);
  81588. private _applyByPostProcess;
  81589. /**
  81590. * Gets wether the image processing is applied through a post process or not.
  81591. */
  81592. get applyByPostProcess(): boolean;
  81593. /**
  81594. * Sets wether the image processing is applied through a post process or not.
  81595. */
  81596. set applyByPostProcess(value: boolean);
  81597. private _isEnabled;
  81598. /**
  81599. * Gets wether the image processing is enabled or not.
  81600. */
  81601. get isEnabled(): boolean;
  81602. /**
  81603. * Sets wether the image processing is enabled or not.
  81604. */
  81605. set isEnabled(value: boolean);
  81606. /**
  81607. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81608. */
  81609. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81610. /**
  81611. * Method called each time the image processing information changes requires to recompile the effect.
  81612. */
  81613. protected _updateParameters(): void;
  81614. /**
  81615. * Gets the current class name.
  81616. * @return "ImageProcessingConfiguration"
  81617. */
  81618. getClassName(): string;
  81619. /**
  81620. * Prepare the list of uniforms associated with the Image Processing effects.
  81621. * @param uniforms The list of uniforms used in the effect
  81622. * @param defines the list of defines currently in use
  81623. */
  81624. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81625. /**
  81626. * Prepare the list of samplers associated with the Image Processing effects.
  81627. * @param samplersList The list of uniforms used in the effect
  81628. * @param defines the list of defines currently in use
  81629. */
  81630. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81631. /**
  81632. * Prepare the list of defines associated to the shader.
  81633. * @param defines the list of defines to complete
  81634. * @param forPostProcess Define if we are currently in post process mode or not
  81635. */
  81636. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81637. /**
  81638. * Returns true if all the image processing information are ready.
  81639. * @returns True if ready, otherwise, false
  81640. */
  81641. isReady(): boolean;
  81642. /**
  81643. * Binds the image processing to the shader.
  81644. * @param effect The effect to bind to
  81645. * @param overrideAspectRatio Override the aspect ratio of the effect
  81646. */
  81647. bind(effect: Effect, overrideAspectRatio?: number): void;
  81648. /**
  81649. * Clones the current image processing instance.
  81650. * @return The cloned image processing
  81651. */
  81652. clone(): ImageProcessingConfiguration;
  81653. /**
  81654. * Serializes the current image processing instance to a json representation.
  81655. * @return a JSON representation
  81656. */
  81657. serialize(): any;
  81658. /**
  81659. * Parses the image processing from a json representation.
  81660. * @param source the JSON source to parse
  81661. * @return The parsed image processing
  81662. */
  81663. static Parse(source: any): ImageProcessingConfiguration;
  81664. private static _VIGNETTEMODE_MULTIPLY;
  81665. private static _VIGNETTEMODE_OPAQUE;
  81666. /**
  81667. * Used to apply the vignette as a mix with the pixel color.
  81668. */
  81669. static get VIGNETTEMODE_MULTIPLY(): number;
  81670. /**
  81671. * Used to apply the vignette as a replacement of the pixel color.
  81672. */
  81673. static get VIGNETTEMODE_OPAQUE(): number;
  81674. }
  81675. }
  81676. declare module BABYLON {
  81677. /** @hidden */
  81678. export var postprocessVertexShader: {
  81679. name: string;
  81680. shader: string;
  81681. };
  81682. }
  81683. declare module BABYLON {
  81684. interface ThinEngine {
  81685. /**
  81686. * Creates a new render target texture
  81687. * @param size defines the size of the texture
  81688. * @param options defines the options used to create the texture
  81689. * @returns a new render target texture stored in an InternalTexture
  81690. */
  81691. createRenderTargetTexture(size: number | {
  81692. width: number;
  81693. height: number;
  81694. layers?: number;
  81695. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81696. /**
  81697. * Creates a depth stencil texture.
  81698. * This is only available in WebGL 2 or with the depth texture extension available.
  81699. * @param size The size of face edge in the texture.
  81700. * @param options The options defining the texture.
  81701. * @returns The texture
  81702. */
  81703. createDepthStencilTexture(size: number | {
  81704. width: number;
  81705. height: number;
  81706. layers?: number;
  81707. }, options: DepthTextureCreationOptions): InternalTexture;
  81708. /** @hidden */
  81709. _createDepthStencilTexture(size: number | {
  81710. width: number;
  81711. height: number;
  81712. layers?: number;
  81713. }, options: DepthTextureCreationOptions): InternalTexture;
  81714. }
  81715. }
  81716. declare module BABYLON {
  81717. /** Defines supported spaces */
  81718. export enum Space {
  81719. /** Local (object) space */
  81720. LOCAL = 0,
  81721. /** World space */
  81722. WORLD = 1,
  81723. /** Bone space */
  81724. BONE = 2
  81725. }
  81726. /** Defines the 3 main axes */
  81727. export class Axis {
  81728. /** X axis */
  81729. static X: Vector3;
  81730. /** Y axis */
  81731. static Y: Vector3;
  81732. /** Z axis */
  81733. static Z: Vector3;
  81734. }
  81735. }
  81736. declare module BABYLON {
  81737. /**
  81738. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81739. * This is the base of the follow, arc rotate cameras and Free camera
  81740. * @see http://doc.babylonjs.com/features/cameras
  81741. */
  81742. export class TargetCamera extends Camera {
  81743. private static _RigCamTransformMatrix;
  81744. private static _TargetTransformMatrix;
  81745. private static _TargetFocalPoint;
  81746. /**
  81747. * Define the current direction the camera is moving to
  81748. */
  81749. cameraDirection: Vector3;
  81750. /**
  81751. * Define the current rotation the camera is rotating to
  81752. */
  81753. cameraRotation: Vector2;
  81754. /**
  81755. * When set, the up vector of the camera will be updated by the rotation of the camera
  81756. */
  81757. updateUpVectorFromRotation: boolean;
  81758. private _tmpQuaternion;
  81759. /**
  81760. * Define the current rotation of the camera
  81761. */
  81762. rotation: Vector3;
  81763. /**
  81764. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81765. */
  81766. rotationQuaternion: Quaternion;
  81767. /**
  81768. * Define the current speed of the camera
  81769. */
  81770. speed: number;
  81771. /**
  81772. * Add constraint to the camera to prevent it to move freely in all directions and
  81773. * around all axis.
  81774. */
  81775. noRotationConstraint: boolean;
  81776. /**
  81777. * Define the current target of the camera as an object or a position.
  81778. */
  81779. lockedTarget: any;
  81780. /** @hidden */
  81781. _currentTarget: Vector3;
  81782. /** @hidden */
  81783. _initialFocalDistance: number;
  81784. /** @hidden */
  81785. _viewMatrix: Matrix;
  81786. /** @hidden */
  81787. _camMatrix: Matrix;
  81788. /** @hidden */
  81789. _cameraTransformMatrix: Matrix;
  81790. /** @hidden */
  81791. _cameraRotationMatrix: Matrix;
  81792. /** @hidden */
  81793. _referencePoint: Vector3;
  81794. /** @hidden */
  81795. _transformedReferencePoint: Vector3;
  81796. protected _globalCurrentTarget: Vector3;
  81797. protected _globalCurrentUpVector: Vector3;
  81798. /** @hidden */
  81799. _reset: () => void;
  81800. private _defaultUp;
  81801. /**
  81802. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81803. * This is the base of the follow, arc rotate cameras and Free camera
  81804. * @see http://doc.babylonjs.com/features/cameras
  81805. * @param name Defines the name of the camera in the scene
  81806. * @param position Defines the start position of the camera in the scene
  81807. * @param scene Defines the scene the camera belongs to
  81808. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81809. */
  81810. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81811. /**
  81812. * Gets the position in front of the camera at a given distance.
  81813. * @param distance The distance from the camera we want the position to be
  81814. * @returns the position
  81815. */
  81816. getFrontPosition(distance: number): Vector3;
  81817. /** @hidden */
  81818. _getLockedTargetPosition(): Nullable<Vector3>;
  81819. private _storedPosition;
  81820. private _storedRotation;
  81821. private _storedRotationQuaternion;
  81822. /**
  81823. * Store current camera state of the camera (fov, position, rotation, etc..)
  81824. * @returns the camera
  81825. */
  81826. storeState(): Camera;
  81827. /**
  81828. * Restored camera state. You must call storeState() first
  81829. * @returns whether it was successful or not
  81830. * @hidden
  81831. */
  81832. _restoreStateValues(): boolean;
  81833. /** @hidden */
  81834. _initCache(): void;
  81835. /** @hidden */
  81836. _updateCache(ignoreParentClass?: boolean): void;
  81837. /** @hidden */
  81838. _isSynchronizedViewMatrix(): boolean;
  81839. /** @hidden */
  81840. _computeLocalCameraSpeed(): number;
  81841. /**
  81842. * Defines the target the camera should look at.
  81843. * @param target Defines the new target as a Vector or a mesh
  81844. */
  81845. setTarget(target: Vector3): void;
  81846. /**
  81847. * Return the current target position of the camera. This value is expressed in local space.
  81848. * @returns the target position
  81849. */
  81850. getTarget(): Vector3;
  81851. /** @hidden */
  81852. _decideIfNeedsToMove(): boolean;
  81853. /** @hidden */
  81854. _updatePosition(): void;
  81855. /** @hidden */
  81856. _checkInputs(): void;
  81857. protected _updateCameraRotationMatrix(): void;
  81858. /**
  81859. * 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)
  81860. * @returns the current camera
  81861. */
  81862. private _rotateUpVectorWithCameraRotationMatrix;
  81863. private _cachedRotationZ;
  81864. private _cachedQuaternionRotationZ;
  81865. /** @hidden */
  81866. _getViewMatrix(): Matrix;
  81867. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81868. /**
  81869. * @hidden
  81870. */
  81871. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81872. /**
  81873. * @hidden
  81874. */
  81875. _updateRigCameras(): void;
  81876. private _getRigCamPositionAndTarget;
  81877. /**
  81878. * Gets the current object class name.
  81879. * @return the class name
  81880. */
  81881. getClassName(): string;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /**
  81886. * Gather the list of keyboard event types as constants.
  81887. */
  81888. export class KeyboardEventTypes {
  81889. /**
  81890. * The keydown event is fired when a key becomes active (pressed).
  81891. */
  81892. static readonly KEYDOWN: number;
  81893. /**
  81894. * The keyup event is fired when a key has been released.
  81895. */
  81896. static readonly KEYUP: number;
  81897. }
  81898. /**
  81899. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81900. */
  81901. export class KeyboardInfo {
  81902. /**
  81903. * Defines the type of event (KeyboardEventTypes)
  81904. */
  81905. type: number;
  81906. /**
  81907. * Defines the related dom event
  81908. */
  81909. event: KeyboardEvent;
  81910. /**
  81911. * Instantiates a new keyboard info.
  81912. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81913. * @param type Defines the type of event (KeyboardEventTypes)
  81914. * @param event Defines the related dom event
  81915. */
  81916. constructor(
  81917. /**
  81918. * Defines the type of event (KeyboardEventTypes)
  81919. */
  81920. type: number,
  81921. /**
  81922. * Defines the related dom event
  81923. */
  81924. event: KeyboardEvent);
  81925. }
  81926. /**
  81927. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81928. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81929. */
  81930. export class KeyboardInfoPre extends KeyboardInfo {
  81931. /**
  81932. * Defines the type of event (KeyboardEventTypes)
  81933. */
  81934. type: number;
  81935. /**
  81936. * Defines the related dom event
  81937. */
  81938. event: KeyboardEvent;
  81939. /**
  81940. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81941. */
  81942. skipOnPointerObservable: boolean;
  81943. /**
  81944. * Instantiates a new keyboard pre info.
  81945. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81946. * @param type Defines the type of event (KeyboardEventTypes)
  81947. * @param event Defines the related dom event
  81948. */
  81949. constructor(
  81950. /**
  81951. * Defines the type of event (KeyboardEventTypes)
  81952. */
  81953. type: number,
  81954. /**
  81955. * Defines the related dom event
  81956. */
  81957. event: KeyboardEvent);
  81958. }
  81959. }
  81960. declare module BABYLON {
  81961. /**
  81962. * Manage the keyboard inputs to control the movement of a free camera.
  81963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81964. */
  81965. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81966. /**
  81967. * Defines the camera the input is attached to.
  81968. */
  81969. camera: FreeCamera;
  81970. /**
  81971. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81972. */
  81973. keysUp: number[];
  81974. /**
  81975. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81976. */
  81977. keysDown: number[];
  81978. /**
  81979. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81980. */
  81981. keysLeft: number[];
  81982. /**
  81983. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81984. */
  81985. keysRight: number[];
  81986. private _keys;
  81987. private _onCanvasBlurObserver;
  81988. private _onKeyboardObserver;
  81989. private _engine;
  81990. private _scene;
  81991. /**
  81992. * Attach the input controls to a specific dom element to get the input from.
  81993. * @param element Defines the element the controls should be listened from
  81994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81995. */
  81996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81997. /**
  81998. * Detach the current controls from the specified dom element.
  81999. * @param element Defines the element to stop listening the inputs from
  82000. */
  82001. detachControl(element: Nullable<HTMLElement>): void;
  82002. /**
  82003. * Update the current camera state depending on the inputs that have been used this frame.
  82004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82005. */
  82006. checkInputs(): void;
  82007. /**
  82008. * Gets the class name of the current intput.
  82009. * @returns the class name
  82010. */
  82011. getClassName(): string;
  82012. /** @hidden */
  82013. _onLostFocus(): void;
  82014. /**
  82015. * Get the friendly name associated with the input class.
  82016. * @returns the input friendly name
  82017. */
  82018. getSimpleName(): string;
  82019. }
  82020. }
  82021. declare module BABYLON {
  82022. /**
  82023. * Interface describing all the common properties and methods a shadow light needs to implement.
  82024. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82025. * as well as binding the different shadow properties to the effects.
  82026. */
  82027. export interface IShadowLight extends Light {
  82028. /**
  82029. * The light id in the scene (used in scene.findLighById for instance)
  82030. */
  82031. id: string;
  82032. /**
  82033. * The position the shdow will be casted from.
  82034. */
  82035. position: Vector3;
  82036. /**
  82037. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82038. */
  82039. direction: Vector3;
  82040. /**
  82041. * The transformed position. Position of the light in world space taking parenting in account.
  82042. */
  82043. transformedPosition: Vector3;
  82044. /**
  82045. * The transformed direction. Direction of the light in world space taking parenting in account.
  82046. */
  82047. transformedDirection: Vector3;
  82048. /**
  82049. * The friendly name of the light in the scene.
  82050. */
  82051. name: string;
  82052. /**
  82053. * Defines the shadow projection clipping minimum z value.
  82054. */
  82055. shadowMinZ: number;
  82056. /**
  82057. * Defines the shadow projection clipping maximum z value.
  82058. */
  82059. shadowMaxZ: number;
  82060. /**
  82061. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82062. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82063. */
  82064. computeTransformedInformation(): boolean;
  82065. /**
  82066. * Gets the scene the light belongs to.
  82067. * @returns The scene
  82068. */
  82069. getScene(): Scene;
  82070. /**
  82071. * Callback defining a custom Projection Matrix Builder.
  82072. * This can be used to override the default projection matrix computation.
  82073. */
  82074. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82075. /**
  82076. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82077. * @param matrix The materix to updated with the projection information
  82078. * @param viewMatrix The transform matrix of the light
  82079. * @param renderList The list of mesh to render in the map
  82080. * @returns The current light
  82081. */
  82082. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82083. /**
  82084. * Gets the current depth scale used in ESM.
  82085. * @returns The scale
  82086. */
  82087. getDepthScale(): number;
  82088. /**
  82089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82090. * @returns true if a cube texture needs to be use
  82091. */
  82092. needCube(): boolean;
  82093. /**
  82094. * Detects if the projection matrix requires to be recomputed this frame.
  82095. * @returns true if it requires to be recomputed otherwise, false.
  82096. */
  82097. needProjectionMatrixCompute(): boolean;
  82098. /**
  82099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82100. */
  82101. forceProjectionMatrixCompute(): void;
  82102. /**
  82103. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82106. */
  82107. getShadowDirection(faceIndex?: number): Vector3;
  82108. /**
  82109. * Gets the minZ used for shadow according to both the scene and the light.
  82110. * @param activeCamera The camera we are returning the min for
  82111. * @returns the depth min z
  82112. */
  82113. getDepthMinZ(activeCamera: Camera): number;
  82114. /**
  82115. * Gets the maxZ used for shadow according to both the scene and the light.
  82116. * @param activeCamera The camera we are returning the max for
  82117. * @returns the depth max z
  82118. */
  82119. getDepthMaxZ(activeCamera: Camera): number;
  82120. }
  82121. /**
  82122. * Base implementation IShadowLight
  82123. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82124. */
  82125. export abstract class ShadowLight extends Light implements IShadowLight {
  82126. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82127. protected _position: Vector3;
  82128. protected _setPosition(value: Vector3): void;
  82129. /**
  82130. * Sets the position the shadow will be casted from. Also use as the light position for both
  82131. * point and spot lights.
  82132. */
  82133. get position(): Vector3;
  82134. /**
  82135. * Sets the position the shadow will be casted from. Also use as the light position for both
  82136. * point and spot lights.
  82137. */
  82138. set position(value: Vector3);
  82139. protected _direction: Vector3;
  82140. protected _setDirection(value: Vector3): void;
  82141. /**
  82142. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82143. * Also use as the light direction on spot and directional lights.
  82144. */
  82145. get direction(): Vector3;
  82146. /**
  82147. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82148. * Also use as the light direction on spot and directional lights.
  82149. */
  82150. set direction(value: Vector3);
  82151. protected _shadowMinZ: number;
  82152. /**
  82153. * Gets the shadow projection clipping minimum z value.
  82154. */
  82155. get shadowMinZ(): number;
  82156. /**
  82157. * Sets the shadow projection clipping minimum z value.
  82158. */
  82159. set shadowMinZ(value: number);
  82160. protected _shadowMaxZ: number;
  82161. /**
  82162. * Sets the shadow projection clipping maximum z value.
  82163. */
  82164. get shadowMaxZ(): number;
  82165. /**
  82166. * Gets the shadow projection clipping maximum z value.
  82167. */
  82168. set shadowMaxZ(value: number);
  82169. /**
  82170. * Callback defining a custom Projection Matrix Builder.
  82171. * This can be used to override the default projection matrix computation.
  82172. */
  82173. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82174. /**
  82175. * The transformed position. Position of the light in world space taking parenting in account.
  82176. */
  82177. transformedPosition: Vector3;
  82178. /**
  82179. * The transformed direction. Direction of the light in world space taking parenting in account.
  82180. */
  82181. transformedDirection: Vector3;
  82182. private _needProjectionMatrixCompute;
  82183. /**
  82184. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82185. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82186. */
  82187. computeTransformedInformation(): boolean;
  82188. /**
  82189. * Return the depth scale used for the shadow map.
  82190. * @returns the depth scale.
  82191. */
  82192. getDepthScale(): number;
  82193. /**
  82194. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82195. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82196. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82197. */
  82198. getShadowDirection(faceIndex?: number): Vector3;
  82199. /**
  82200. * Returns the ShadowLight absolute position in the World.
  82201. * @returns the position vector in world space
  82202. */
  82203. getAbsolutePosition(): Vector3;
  82204. /**
  82205. * Sets the ShadowLight direction toward the passed target.
  82206. * @param target The point to target in local space
  82207. * @returns the updated ShadowLight direction
  82208. */
  82209. setDirectionToTarget(target: Vector3): Vector3;
  82210. /**
  82211. * Returns the light rotation in euler definition.
  82212. * @returns the x y z rotation in local space.
  82213. */
  82214. getRotation(): Vector3;
  82215. /**
  82216. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82217. * @returns true if a cube texture needs to be use
  82218. */
  82219. needCube(): boolean;
  82220. /**
  82221. * Detects if the projection matrix requires to be recomputed this frame.
  82222. * @returns true if it requires to be recomputed otherwise, false.
  82223. */
  82224. needProjectionMatrixCompute(): boolean;
  82225. /**
  82226. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82227. */
  82228. forceProjectionMatrixCompute(): void;
  82229. /** @hidden */
  82230. _initCache(): void;
  82231. /** @hidden */
  82232. _isSynchronized(): boolean;
  82233. /**
  82234. * Computes the world matrix of the node
  82235. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82236. * @returns the world matrix
  82237. */
  82238. computeWorldMatrix(force?: boolean): Matrix;
  82239. /**
  82240. * Gets the minZ used for shadow according to both the scene and the light.
  82241. * @param activeCamera The camera we are returning the min for
  82242. * @returns the depth min z
  82243. */
  82244. getDepthMinZ(activeCamera: Camera): number;
  82245. /**
  82246. * Gets the maxZ used for shadow according to both the scene and the light.
  82247. * @param activeCamera The camera we are returning the max for
  82248. * @returns the depth max z
  82249. */
  82250. getDepthMaxZ(activeCamera: Camera): number;
  82251. /**
  82252. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82253. * @param matrix The materix to updated with the projection information
  82254. * @param viewMatrix The transform matrix of the light
  82255. * @param renderList The list of mesh to render in the map
  82256. * @returns The current light
  82257. */
  82258. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82259. }
  82260. }
  82261. declare module BABYLON {
  82262. /**
  82263. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82264. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82265. */
  82266. export class EffectFallbacks implements IEffectFallbacks {
  82267. private _defines;
  82268. private _currentRank;
  82269. private _maxRank;
  82270. private _mesh;
  82271. /**
  82272. * Removes the fallback from the bound mesh.
  82273. */
  82274. unBindMesh(): void;
  82275. /**
  82276. * Adds a fallback on the specified property.
  82277. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82278. * @param define The name of the define in the shader
  82279. */
  82280. addFallback(rank: number, define: string): void;
  82281. /**
  82282. * Sets the mesh to use CPU skinning when needing to fallback.
  82283. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82284. * @param mesh The mesh to use the fallbacks.
  82285. */
  82286. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82287. /**
  82288. * Checks to see if more fallbacks are still availible.
  82289. */
  82290. get hasMoreFallbacks(): boolean;
  82291. /**
  82292. * Removes the defines that should be removed when falling back.
  82293. * @param currentDefines defines the current define statements for the shader.
  82294. * @param effect defines the current effect we try to compile
  82295. * @returns The resulting defines with defines of the current rank removed.
  82296. */
  82297. reduce(currentDefines: string, effect: Effect): string;
  82298. }
  82299. }
  82300. declare module BABYLON {
  82301. /**
  82302. * "Static Class" containing the most commonly used helper while dealing with material for
  82303. * rendering purpose.
  82304. *
  82305. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82306. *
  82307. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82308. */
  82309. export class MaterialHelper {
  82310. /**
  82311. * Bind the current view position to an effect.
  82312. * @param effect The effect to be bound
  82313. * @param scene The scene the eyes position is used from
  82314. */
  82315. static BindEyePosition(effect: Effect, scene: Scene): void;
  82316. /**
  82317. * Helps preparing the defines values about the UVs in used in the effect.
  82318. * UVs are shared as much as we can accross channels in the shaders.
  82319. * @param texture The texture we are preparing the UVs for
  82320. * @param defines The defines to update
  82321. * @param key The channel key "diffuse", "specular"... used in the shader
  82322. */
  82323. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82324. /**
  82325. * Binds a texture matrix value to its corrsponding uniform
  82326. * @param texture The texture to bind the matrix for
  82327. * @param uniformBuffer The uniform buffer receivin the data
  82328. * @param key The channel key "diffuse", "specular"... used in the shader
  82329. */
  82330. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82331. /**
  82332. * Gets the current status of the fog (should it be enabled?)
  82333. * @param mesh defines the mesh to evaluate for fog support
  82334. * @param scene defines the hosting scene
  82335. * @returns true if fog must be enabled
  82336. */
  82337. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82338. /**
  82339. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82340. * @param mesh defines the current mesh
  82341. * @param scene defines the current scene
  82342. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82343. * @param pointsCloud defines if point cloud rendering has to be turned on
  82344. * @param fogEnabled defines if fog has to be turned on
  82345. * @param alphaTest defines if alpha testing has to be turned on
  82346. * @param defines defines the current list of defines
  82347. */
  82348. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82349. /**
  82350. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82351. * @param scene defines the current scene
  82352. * @param engine defines the current engine
  82353. * @param defines specifies the list of active defines
  82354. * @param useInstances defines if instances have to be turned on
  82355. * @param useClipPlane defines if clip plane have to be turned on
  82356. */
  82357. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82358. /**
  82359. * Prepares the defines for bones
  82360. * @param mesh The mesh containing the geometry data we will draw
  82361. * @param defines The defines to update
  82362. */
  82363. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82364. /**
  82365. * Prepares the defines for morph targets
  82366. * @param mesh The mesh containing the geometry data we will draw
  82367. * @param defines The defines to update
  82368. */
  82369. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82370. /**
  82371. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82372. * @param mesh The mesh containing the geometry data we will draw
  82373. * @param defines The defines to update
  82374. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82375. * @param useBones Precise whether bones should be used or not (override mesh info)
  82376. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82377. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82378. * @returns false if defines are considered not dirty and have not been checked
  82379. */
  82380. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82381. /**
  82382. * Prepares the defines related to multiview
  82383. * @param scene The scene we are intending to draw
  82384. * @param defines The defines to update
  82385. */
  82386. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82387. /**
  82388. * Prepares the defines related to the light information passed in parameter
  82389. * @param scene The scene we are intending to draw
  82390. * @param mesh The mesh the effect is compiling for
  82391. * @param light The light the effect is compiling for
  82392. * @param lightIndex The index of the light
  82393. * @param defines The defines to update
  82394. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82395. * @param state Defines the current state regarding what is needed (normals, etc...)
  82396. */
  82397. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82398. needNormals: boolean;
  82399. needRebuild: boolean;
  82400. shadowEnabled: boolean;
  82401. specularEnabled: boolean;
  82402. lightmapMode: boolean;
  82403. }): void;
  82404. /**
  82405. * Prepares the defines related to the light information passed in parameter
  82406. * @param scene The scene we are intending to draw
  82407. * @param mesh The mesh the effect is compiling for
  82408. * @param defines The defines to update
  82409. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82410. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82411. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82412. * @returns true if normals will be required for the rest of the effect
  82413. */
  82414. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82415. /**
  82416. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82417. * @param lightIndex defines the light index
  82418. * @param uniformsList The uniform list
  82419. * @param samplersList The sampler list
  82420. * @param projectedLightTexture defines if projected texture must be used
  82421. * @param uniformBuffersList defines an optional list of uniform buffers
  82422. */
  82423. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82424. /**
  82425. * Prepares the uniforms and samplers list to be used in the effect
  82426. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82427. * @param samplersList The sampler list
  82428. * @param defines The defines helping in the list generation
  82429. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82430. */
  82431. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82432. /**
  82433. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82434. * @param defines The defines to update while falling back
  82435. * @param fallbacks The authorized effect fallbacks
  82436. * @param maxSimultaneousLights The maximum number of lights allowed
  82437. * @param rank the current rank of the Effect
  82438. * @returns The newly affected rank
  82439. */
  82440. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82441. private static _TmpMorphInfluencers;
  82442. /**
  82443. * Prepares the list of attributes required for morph targets according to the effect defines.
  82444. * @param attribs The current list of supported attribs
  82445. * @param mesh The mesh to prepare the morph targets attributes for
  82446. * @param influencers The number of influencers
  82447. */
  82448. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82449. /**
  82450. * Prepares the list of attributes required for morph targets according to the effect defines.
  82451. * @param attribs The current list of supported attribs
  82452. * @param mesh The mesh to prepare the morph targets attributes for
  82453. * @param defines The current Defines of the effect
  82454. */
  82455. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82456. /**
  82457. * Prepares the list of attributes required for bones according to the effect defines.
  82458. * @param attribs The current list of supported attribs
  82459. * @param mesh The mesh to prepare the bones attributes for
  82460. * @param defines The current Defines of the effect
  82461. * @param fallbacks The current efffect fallback strategy
  82462. */
  82463. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82464. /**
  82465. * Check and prepare the list of attributes required for instances according to the effect defines.
  82466. * @param attribs The current list of supported attribs
  82467. * @param defines The current MaterialDefines of the effect
  82468. */
  82469. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82470. /**
  82471. * Add the list of attributes required for instances to the attribs array.
  82472. * @param attribs The current list of supported attribs
  82473. */
  82474. static PushAttributesForInstances(attribs: string[]): void;
  82475. /**
  82476. * Binds the light information to the effect.
  82477. * @param light The light containing the generator
  82478. * @param effect The effect we are binding the data to
  82479. * @param lightIndex The light index in the effect used to render
  82480. */
  82481. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82482. /**
  82483. * Binds the lights information from the scene to the effect for the given mesh.
  82484. * @param light Light to bind
  82485. * @param lightIndex Light index
  82486. * @param scene The scene where the light belongs to
  82487. * @param effect The effect we are binding the data to
  82488. * @param useSpecular Defines if specular is supported
  82489. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82490. */
  82491. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82492. /**
  82493. * Binds the lights information from the scene to the effect for the given mesh.
  82494. * @param scene The scene the lights belongs to
  82495. * @param mesh The mesh we are binding the information to render
  82496. * @param effect The effect we are binding the data to
  82497. * @param defines The generated defines for the effect
  82498. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82499. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82500. */
  82501. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82502. private static _tempFogColor;
  82503. /**
  82504. * Binds the fog information from the scene to the effect for the given mesh.
  82505. * @param scene The scene the lights belongs to
  82506. * @param mesh The mesh we are binding the information to render
  82507. * @param effect The effect we are binding the data to
  82508. * @param linearSpace Defines if the fog effect is applied in linear space
  82509. */
  82510. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82511. /**
  82512. * Binds the bones information from the mesh to the effect.
  82513. * @param mesh The mesh we are binding the information to render
  82514. * @param effect The effect we are binding the data to
  82515. */
  82516. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82517. /**
  82518. * Binds the morph targets information from the mesh to the effect.
  82519. * @param abstractMesh The mesh we are binding the information to render
  82520. * @param effect The effect we are binding the data to
  82521. */
  82522. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82523. /**
  82524. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82525. * @param defines The generated defines used in the effect
  82526. * @param effect The effect we are binding the data to
  82527. * @param scene The scene we are willing to render with logarithmic scale for
  82528. */
  82529. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82530. /**
  82531. * Binds the clip plane information from the scene to the effect.
  82532. * @param scene The scene the clip plane information are extracted from
  82533. * @param effect The effect we are binding the data to
  82534. */
  82535. static BindClipPlane(effect: Effect, scene: Scene): void;
  82536. }
  82537. }
  82538. declare module BABYLON {
  82539. /** @hidden */
  82540. export var packingFunctions: {
  82541. name: string;
  82542. shader: string;
  82543. };
  82544. }
  82545. declare module BABYLON {
  82546. /** @hidden */
  82547. export var clipPlaneFragmentDeclaration: {
  82548. name: string;
  82549. shader: string;
  82550. };
  82551. }
  82552. declare module BABYLON {
  82553. /** @hidden */
  82554. export var clipPlaneFragment: {
  82555. name: string;
  82556. shader: string;
  82557. };
  82558. }
  82559. declare module BABYLON {
  82560. /** @hidden */
  82561. export var shadowMapPixelShader: {
  82562. name: string;
  82563. shader: string;
  82564. };
  82565. }
  82566. declare module BABYLON {
  82567. /** @hidden */
  82568. export var bonesDeclaration: {
  82569. name: string;
  82570. shader: string;
  82571. };
  82572. }
  82573. declare module BABYLON {
  82574. /** @hidden */
  82575. export var morphTargetsVertexGlobalDeclaration: {
  82576. name: string;
  82577. shader: string;
  82578. };
  82579. }
  82580. declare module BABYLON {
  82581. /** @hidden */
  82582. export var morphTargetsVertexDeclaration: {
  82583. name: string;
  82584. shader: string;
  82585. };
  82586. }
  82587. declare module BABYLON {
  82588. /** @hidden */
  82589. export var instancesDeclaration: {
  82590. name: string;
  82591. shader: string;
  82592. };
  82593. }
  82594. declare module BABYLON {
  82595. /** @hidden */
  82596. export var helperFunctions: {
  82597. name: string;
  82598. shader: string;
  82599. };
  82600. }
  82601. declare module BABYLON {
  82602. /** @hidden */
  82603. export var clipPlaneVertexDeclaration: {
  82604. name: string;
  82605. shader: string;
  82606. };
  82607. }
  82608. declare module BABYLON {
  82609. /** @hidden */
  82610. export var morphTargetsVertex: {
  82611. name: string;
  82612. shader: string;
  82613. };
  82614. }
  82615. declare module BABYLON {
  82616. /** @hidden */
  82617. export var instancesVertex: {
  82618. name: string;
  82619. shader: string;
  82620. };
  82621. }
  82622. declare module BABYLON {
  82623. /** @hidden */
  82624. export var bonesVertex: {
  82625. name: string;
  82626. shader: string;
  82627. };
  82628. }
  82629. declare module BABYLON {
  82630. /** @hidden */
  82631. export var clipPlaneVertex: {
  82632. name: string;
  82633. shader: string;
  82634. };
  82635. }
  82636. declare module BABYLON {
  82637. /** @hidden */
  82638. export var shadowMapVertexShader: {
  82639. name: string;
  82640. shader: string;
  82641. };
  82642. }
  82643. declare module BABYLON {
  82644. /** @hidden */
  82645. export var depthBoxBlurPixelShader: {
  82646. name: string;
  82647. shader: string;
  82648. };
  82649. }
  82650. declare module BABYLON {
  82651. /**
  82652. * Class representing a ray with position and direction
  82653. */
  82654. export class Ray {
  82655. /** origin point */
  82656. origin: Vector3;
  82657. /** direction */
  82658. direction: Vector3;
  82659. /** length of the ray */
  82660. length: number;
  82661. private static readonly TmpVector3;
  82662. private _tmpRay;
  82663. /**
  82664. * Creates a new ray
  82665. * @param origin origin point
  82666. * @param direction direction
  82667. * @param length length of the ray
  82668. */
  82669. constructor(
  82670. /** origin point */
  82671. origin: Vector3,
  82672. /** direction */
  82673. direction: Vector3,
  82674. /** length of the ray */
  82675. length?: number);
  82676. /**
  82677. * Checks if the ray intersects a box
  82678. * @param minimum bound of the box
  82679. * @param maximum bound of the box
  82680. * @param intersectionTreshold extra extend to be added to the box in all direction
  82681. * @returns if the box was hit
  82682. */
  82683. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82684. /**
  82685. * Checks if the ray intersects a box
  82686. * @param box the bounding box to check
  82687. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82688. * @returns if the box was hit
  82689. */
  82690. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82691. /**
  82692. * If the ray hits a sphere
  82693. * @param sphere the bounding sphere to check
  82694. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82695. * @returns true if it hits the sphere
  82696. */
  82697. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82698. /**
  82699. * If the ray hits a triange
  82700. * @param vertex0 triangle vertex
  82701. * @param vertex1 triangle vertex
  82702. * @param vertex2 triangle vertex
  82703. * @returns intersection information if hit
  82704. */
  82705. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82706. /**
  82707. * Checks if ray intersects a plane
  82708. * @param plane the plane to check
  82709. * @returns the distance away it was hit
  82710. */
  82711. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82712. /**
  82713. * Calculate the intercept of a ray on a given axis
  82714. * @param axis to check 'x' | 'y' | 'z'
  82715. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82716. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82717. */
  82718. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82719. /**
  82720. * Checks if ray intersects a mesh
  82721. * @param mesh the mesh to check
  82722. * @param fastCheck if only the bounding box should checked
  82723. * @returns picking info of the intersecton
  82724. */
  82725. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82726. /**
  82727. * Checks if ray intersects a mesh
  82728. * @param meshes the meshes to check
  82729. * @param fastCheck if only the bounding box should checked
  82730. * @param results array to store result in
  82731. * @returns Array of picking infos
  82732. */
  82733. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82734. private _comparePickingInfo;
  82735. private static smallnum;
  82736. private static rayl;
  82737. /**
  82738. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82739. * @param sega the first point of the segment to test the intersection against
  82740. * @param segb the second point of the segment to test the intersection against
  82741. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82742. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82743. */
  82744. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82745. /**
  82746. * Update the ray from viewport position
  82747. * @param x position
  82748. * @param y y position
  82749. * @param viewportWidth viewport width
  82750. * @param viewportHeight viewport height
  82751. * @param world world matrix
  82752. * @param view view matrix
  82753. * @param projection projection matrix
  82754. * @returns this ray updated
  82755. */
  82756. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82757. /**
  82758. * Creates a ray with origin and direction of 0,0,0
  82759. * @returns the new ray
  82760. */
  82761. static Zero(): Ray;
  82762. /**
  82763. * Creates a new ray from screen space and viewport
  82764. * @param x position
  82765. * @param y y position
  82766. * @param viewportWidth viewport width
  82767. * @param viewportHeight viewport height
  82768. * @param world world matrix
  82769. * @param view view matrix
  82770. * @param projection projection matrix
  82771. * @returns new ray
  82772. */
  82773. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82774. /**
  82775. * 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
  82776. * transformed to the given world matrix.
  82777. * @param origin The origin point
  82778. * @param end The end point
  82779. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82780. * @returns the new ray
  82781. */
  82782. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82783. /**
  82784. * Transforms a ray by a matrix
  82785. * @param ray ray to transform
  82786. * @param matrix matrix to apply
  82787. * @returns the resulting new ray
  82788. */
  82789. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82790. /**
  82791. * Transforms a ray by a matrix
  82792. * @param ray ray to transform
  82793. * @param matrix matrix to apply
  82794. * @param result ray to store result in
  82795. */
  82796. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82797. /**
  82798. * Unproject a ray from screen space to object space
  82799. * @param sourceX defines the screen space x coordinate to use
  82800. * @param sourceY defines the screen space y coordinate to use
  82801. * @param viewportWidth defines the current width of the viewport
  82802. * @param viewportHeight defines the current height of the viewport
  82803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82804. * @param view defines the view matrix to use
  82805. * @param projection defines the projection matrix to use
  82806. */
  82807. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82808. }
  82809. /**
  82810. * Type used to define predicate used to select faces when a mesh intersection is detected
  82811. */
  82812. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82813. interface Scene {
  82814. /** @hidden */
  82815. _tempPickingRay: Nullable<Ray>;
  82816. /** @hidden */
  82817. _cachedRayForTransform: Ray;
  82818. /** @hidden */
  82819. _pickWithRayInverseMatrix: Matrix;
  82820. /** @hidden */
  82821. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82822. /** @hidden */
  82823. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82824. }
  82825. }
  82826. declare module BABYLON {
  82827. /**
  82828. * Groups all the scene component constants in one place to ease maintenance.
  82829. * @hidden
  82830. */
  82831. export class SceneComponentConstants {
  82832. static readonly NAME_EFFECTLAYER: string;
  82833. static readonly NAME_LAYER: string;
  82834. static readonly NAME_LENSFLARESYSTEM: string;
  82835. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82836. static readonly NAME_PARTICLESYSTEM: string;
  82837. static readonly NAME_GAMEPAD: string;
  82838. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82839. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82840. static readonly NAME_DEPTHRENDERER: string;
  82841. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82842. static readonly NAME_SPRITE: string;
  82843. static readonly NAME_OUTLINERENDERER: string;
  82844. static readonly NAME_PROCEDURALTEXTURE: string;
  82845. static readonly NAME_SHADOWGENERATOR: string;
  82846. static readonly NAME_OCTREE: string;
  82847. static readonly NAME_PHYSICSENGINE: string;
  82848. static readonly NAME_AUDIO: string;
  82849. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82850. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82851. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82852. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82853. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82854. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82855. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82856. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82857. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82858. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82859. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82860. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82861. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82862. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82863. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82864. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82865. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82866. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82867. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82868. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82869. static readonly STEP_AFTERRENDER_AUDIO: number;
  82870. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82871. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82872. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82873. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82874. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82875. static readonly STEP_POINTERMOVE_SPRITE: number;
  82876. static readonly STEP_POINTERDOWN_SPRITE: number;
  82877. static readonly STEP_POINTERUP_SPRITE: number;
  82878. }
  82879. /**
  82880. * This represents a scene component.
  82881. *
  82882. * This is used to decouple the dependency the scene is having on the different workloads like
  82883. * layers, post processes...
  82884. */
  82885. export interface ISceneComponent {
  82886. /**
  82887. * The name of the component. Each component must have a unique name.
  82888. */
  82889. name: string;
  82890. /**
  82891. * The scene the component belongs to.
  82892. */
  82893. scene: Scene;
  82894. /**
  82895. * Register the component to one instance of a scene.
  82896. */
  82897. register(): void;
  82898. /**
  82899. * Rebuilds the elements related to this component in case of
  82900. * context lost for instance.
  82901. */
  82902. rebuild(): void;
  82903. /**
  82904. * Disposes the component and the associated ressources.
  82905. */
  82906. dispose(): void;
  82907. }
  82908. /**
  82909. * This represents a SERIALIZABLE scene component.
  82910. *
  82911. * This extends Scene Component to add Serialization methods on top.
  82912. */
  82913. export interface ISceneSerializableComponent extends ISceneComponent {
  82914. /**
  82915. * Adds all the elements from the container to the scene
  82916. * @param container the container holding the elements
  82917. */
  82918. addFromContainer(container: AbstractScene): void;
  82919. /**
  82920. * Removes all the elements in the container from the scene
  82921. * @param container contains the elements to remove
  82922. * @param dispose if the removed element should be disposed (default: false)
  82923. */
  82924. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82925. /**
  82926. * Serializes the component data to the specified json object
  82927. * @param serializationObject The object to serialize to
  82928. */
  82929. serialize(serializationObject: any): void;
  82930. }
  82931. /**
  82932. * Strong typing of a Mesh related stage step action
  82933. */
  82934. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82935. /**
  82936. * Strong typing of a Evaluate Sub Mesh related stage step action
  82937. */
  82938. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82939. /**
  82940. * Strong typing of a Active Mesh related stage step action
  82941. */
  82942. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82943. /**
  82944. * Strong typing of a Camera related stage step action
  82945. */
  82946. export type CameraStageAction = (camera: Camera) => void;
  82947. /**
  82948. * Strong typing of a Camera Frame buffer related stage step action
  82949. */
  82950. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82951. /**
  82952. * Strong typing of a Render Target related stage step action
  82953. */
  82954. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82955. /**
  82956. * Strong typing of a RenderingGroup related stage step action
  82957. */
  82958. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82959. /**
  82960. * Strong typing of a Mesh Render related stage step action
  82961. */
  82962. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82963. /**
  82964. * Strong typing of a simple stage step action
  82965. */
  82966. export type SimpleStageAction = () => void;
  82967. /**
  82968. * Strong typing of a render target action.
  82969. */
  82970. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82971. /**
  82972. * Strong typing of a pointer move action.
  82973. */
  82974. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82975. /**
  82976. * Strong typing of a pointer up/down action.
  82977. */
  82978. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82979. /**
  82980. * Representation of a stage in the scene (Basically a list of ordered steps)
  82981. * @hidden
  82982. */
  82983. export class Stage<T extends Function> extends Array<{
  82984. index: number;
  82985. component: ISceneComponent;
  82986. action: T;
  82987. }> {
  82988. /**
  82989. * Hide ctor from the rest of the world.
  82990. * @param items The items to add.
  82991. */
  82992. private constructor();
  82993. /**
  82994. * Creates a new Stage.
  82995. * @returns A new instance of a Stage
  82996. */
  82997. static Create<T extends Function>(): Stage<T>;
  82998. /**
  82999. * Registers a step in an ordered way in the targeted stage.
  83000. * @param index Defines the position to register the step in
  83001. * @param component Defines the component attached to the step
  83002. * @param action Defines the action to launch during the step
  83003. */
  83004. registerStep(index: number, component: ISceneComponent, action: T): void;
  83005. /**
  83006. * Clears all the steps from the stage.
  83007. */
  83008. clear(): void;
  83009. }
  83010. }
  83011. declare module BABYLON {
  83012. interface Scene {
  83013. /** @hidden */
  83014. _pointerOverSprite: Nullable<Sprite>;
  83015. /** @hidden */
  83016. _pickedDownSprite: Nullable<Sprite>;
  83017. /** @hidden */
  83018. _tempSpritePickingRay: Nullable<Ray>;
  83019. /**
  83020. * All of the sprite managers added to this scene
  83021. * @see http://doc.babylonjs.com/babylon101/sprites
  83022. */
  83023. spriteManagers: Array<ISpriteManager>;
  83024. /**
  83025. * An event triggered when sprites rendering is about to start
  83026. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83027. */
  83028. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83029. /**
  83030. * An event triggered when sprites rendering is done
  83031. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83032. */
  83033. onAfterSpritesRenderingObservable: Observable<Scene>;
  83034. /** @hidden */
  83035. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83036. /** Launch a ray to try to pick a sprite in the scene
  83037. * @param x position on screen
  83038. * @param y position on screen
  83039. * @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
  83040. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83041. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83042. * @returns a PickingInfo
  83043. */
  83044. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83045. /** Use the given ray to pick a sprite in the scene
  83046. * @param ray The ray (in world space) to use to pick meshes
  83047. * @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
  83048. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83049. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83050. * @returns a PickingInfo
  83051. */
  83052. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83053. /** @hidden */
  83054. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83055. /** Launch a ray to try to pick sprites in the scene
  83056. * @param x position on screen
  83057. * @param y position on screen
  83058. * @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
  83059. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83060. * @returns a PickingInfo array
  83061. */
  83062. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83063. /** Use the given ray to pick sprites in the scene
  83064. * @param ray The ray (in world space) to use to pick meshes
  83065. * @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
  83066. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83067. * @returns a PickingInfo array
  83068. */
  83069. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83070. /**
  83071. * Force the sprite under the pointer
  83072. * @param sprite defines the sprite to use
  83073. */
  83074. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83075. /**
  83076. * Gets the sprite under the pointer
  83077. * @returns a Sprite or null if no sprite is under the pointer
  83078. */
  83079. getPointerOverSprite(): Nullable<Sprite>;
  83080. }
  83081. /**
  83082. * Defines the sprite scene component responsible to manage sprites
  83083. * in a given scene.
  83084. */
  83085. export class SpriteSceneComponent implements ISceneComponent {
  83086. /**
  83087. * The component name helpfull to identify the component in the list of scene components.
  83088. */
  83089. readonly name: string;
  83090. /**
  83091. * The scene the component belongs to.
  83092. */
  83093. scene: Scene;
  83094. /** @hidden */
  83095. private _spritePredicate;
  83096. /**
  83097. * Creates a new instance of the component for the given scene
  83098. * @param scene Defines the scene to register the component in
  83099. */
  83100. constructor(scene: Scene);
  83101. /**
  83102. * Registers the component in a given scene
  83103. */
  83104. register(): void;
  83105. /**
  83106. * Rebuilds the elements related to this component in case of
  83107. * context lost for instance.
  83108. */
  83109. rebuild(): void;
  83110. /**
  83111. * Disposes the component and the associated ressources.
  83112. */
  83113. dispose(): void;
  83114. private _pickSpriteButKeepRay;
  83115. private _pointerMove;
  83116. private _pointerDown;
  83117. private _pointerUp;
  83118. }
  83119. }
  83120. declare module BABYLON {
  83121. /** @hidden */
  83122. export var fogFragmentDeclaration: {
  83123. name: string;
  83124. shader: string;
  83125. };
  83126. }
  83127. declare module BABYLON {
  83128. /** @hidden */
  83129. export var fogFragment: {
  83130. name: string;
  83131. shader: string;
  83132. };
  83133. }
  83134. declare module BABYLON {
  83135. /** @hidden */
  83136. export var spritesPixelShader: {
  83137. name: string;
  83138. shader: string;
  83139. };
  83140. }
  83141. declare module BABYLON {
  83142. /** @hidden */
  83143. export var fogVertexDeclaration: {
  83144. name: string;
  83145. shader: string;
  83146. };
  83147. }
  83148. declare module BABYLON {
  83149. /** @hidden */
  83150. export var spritesVertexShader: {
  83151. name: string;
  83152. shader: string;
  83153. };
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83158. */
  83159. export interface ISpriteManager extends IDisposable {
  83160. /**
  83161. * Restricts the camera to viewing objects with the same layerMask.
  83162. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83163. */
  83164. layerMask: number;
  83165. /**
  83166. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83167. */
  83168. isPickable: boolean;
  83169. /**
  83170. * Specifies the rendering group id for this mesh (0 by default)
  83171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83172. */
  83173. renderingGroupId: number;
  83174. /**
  83175. * Defines the list of sprites managed by the manager.
  83176. */
  83177. sprites: Array<Sprite>;
  83178. /**
  83179. * Tests the intersection of a sprite with a specific ray.
  83180. * @param ray The ray we are sending to test the collision
  83181. * @param camera The camera space we are sending rays in
  83182. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83183. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83184. * @returns picking info or null.
  83185. */
  83186. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83187. /**
  83188. * Intersects the sprites with a ray
  83189. * @param ray defines the ray to intersect with
  83190. * @param camera defines the current active camera
  83191. * @param predicate defines a predicate used to select candidate sprites
  83192. * @returns null if no hit or a PickingInfo array
  83193. */
  83194. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83195. /**
  83196. * Renders the list of sprites on screen.
  83197. */
  83198. render(): void;
  83199. }
  83200. /**
  83201. * Class used to manage multiple sprites on the same spritesheet
  83202. * @see http://doc.babylonjs.com/babylon101/sprites
  83203. */
  83204. export class SpriteManager implements ISpriteManager {
  83205. /** defines the manager's name */
  83206. name: string;
  83207. /** Gets the list of sprites */
  83208. sprites: Sprite[];
  83209. /** Gets or sets the rendering group id (0 by default) */
  83210. renderingGroupId: number;
  83211. /** Gets or sets camera layer mask */
  83212. layerMask: number;
  83213. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83214. fogEnabled: boolean;
  83215. /** Gets or sets a boolean indicating if the sprites are pickable */
  83216. isPickable: boolean;
  83217. /** Defines the default width of a cell in the spritesheet */
  83218. cellWidth: number;
  83219. /** Defines the default height of a cell in the spritesheet */
  83220. cellHeight: number;
  83221. /** Associative array from JSON sprite data file */
  83222. private _cellData;
  83223. /** Array of sprite names from JSON sprite data file */
  83224. private _spriteMap;
  83225. /** True when packed cell data from JSON file is ready*/
  83226. private _packedAndReady;
  83227. /**
  83228. * An event triggered when the manager is disposed.
  83229. */
  83230. onDisposeObservable: Observable<SpriteManager>;
  83231. private _onDisposeObserver;
  83232. /**
  83233. * Callback called when the manager is disposed
  83234. */
  83235. set onDispose(callback: () => void);
  83236. private _capacity;
  83237. private _fromPacked;
  83238. private _spriteTexture;
  83239. private _epsilon;
  83240. private _scene;
  83241. private _vertexData;
  83242. private _buffer;
  83243. private _vertexBuffers;
  83244. private _indexBuffer;
  83245. private _effectBase;
  83246. private _effectFog;
  83247. /**
  83248. * Gets or sets the spritesheet texture
  83249. */
  83250. get texture(): Texture;
  83251. set texture(value: Texture);
  83252. /**
  83253. * Creates a new sprite manager
  83254. * @param name defines the manager's name
  83255. * @param imgUrl defines the sprite sheet url
  83256. * @param capacity defines the maximum allowed number of sprites
  83257. * @param cellSize defines the size of a sprite cell
  83258. * @param scene defines the hosting scene
  83259. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83260. * @param samplingMode defines the smapling mode to use with spritesheet
  83261. * @param fromPacked set to false; do not alter
  83262. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83263. */
  83264. constructor(
  83265. /** defines the manager's name */
  83266. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83267. private _makePacked;
  83268. private _appendSpriteVertex;
  83269. /**
  83270. * Intersects the sprites with a ray
  83271. * @param ray defines the ray to intersect with
  83272. * @param camera defines the current active camera
  83273. * @param predicate defines a predicate used to select candidate sprites
  83274. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83275. * @returns null if no hit or a PickingInfo
  83276. */
  83277. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83278. /**
  83279. * Intersects the sprites with a ray
  83280. * @param ray defines the ray to intersect with
  83281. * @param camera defines the current active camera
  83282. * @param predicate defines a predicate used to select candidate sprites
  83283. * @returns null if no hit or a PickingInfo array
  83284. */
  83285. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83286. /**
  83287. * Render all child sprites
  83288. */
  83289. render(): void;
  83290. /**
  83291. * Release associated resources
  83292. */
  83293. dispose(): void;
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /** Interface used by value gradients (color, factor, ...) */
  83298. export interface IValueGradient {
  83299. /**
  83300. * Gets or sets the gradient value (between 0 and 1)
  83301. */
  83302. gradient: number;
  83303. }
  83304. /** Class used to store color4 gradient */
  83305. export class ColorGradient implements IValueGradient {
  83306. /**
  83307. * Gets or sets the gradient value (between 0 and 1)
  83308. */
  83309. gradient: number;
  83310. /**
  83311. * Gets or sets first associated color
  83312. */
  83313. color1: Color4;
  83314. /**
  83315. * Gets or sets second associated color
  83316. */
  83317. color2?: Color4;
  83318. /**
  83319. * Will get a color picked randomly between color1 and color2.
  83320. * If color2 is undefined then color1 will be used
  83321. * @param result defines the target Color4 to store the result in
  83322. */
  83323. getColorToRef(result: Color4): void;
  83324. }
  83325. /** Class used to store color 3 gradient */
  83326. export class Color3Gradient implements IValueGradient {
  83327. /**
  83328. * Gets or sets the gradient value (between 0 and 1)
  83329. */
  83330. gradient: number;
  83331. /**
  83332. * Gets or sets the associated color
  83333. */
  83334. color: Color3;
  83335. }
  83336. /** Class used to store factor gradient */
  83337. export class FactorGradient implements IValueGradient {
  83338. /**
  83339. * Gets or sets the gradient value (between 0 and 1)
  83340. */
  83341. gradient: number;
  83342. /**
  83343. * Gets or sets first associated factor
  83344. */
  83345. factor1: number;
  83346. /**
  83347. * Gets or sets second associated factor
  83348. */
  83349. factor2?: number;
  83350. /**
  83351. * Will get a number picked randomly between factor1 and factor2.
  83352. * If factor2 is undefined then factor1 will be used
  83353. * @returns the picked number
  83354. */
  83355. getFactor(): number;
  83356. }
  83357. /**
  83358. * Helper used to simplify some generic gradient tasks
  83359. */
  83360. export class GradientHelper {
  83361. /**
  83362. * Gets the current gradient from an array of IValueGradient
  83363. * @param ratio defines the current ratio to get
  83364. * @param gradients defines the array of IValueGradient
  83365. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83366. */
  83367. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83368. }
  83369. }
  83370. declare module BABYLON {
  83371. /**
  83372. * Interface for the size containing width and height
  83373. */
  83374. export interface ISize {
  83375. /**
  83376. * Width
  83377. */
  83378. width: number;
  83379. /**
  83380. * Heighht
  83381. */
  83382. height: number;
  83383. }
  83384. /**
  83385. * Size containing widht and height
  83386. */
  83387. export class Size implements ISize {
  83388. /**
  83389. * Width
  83390. */
  83391. width: number;
  83392. /**
  83393. * Height
  83394. */
  83395. height: number;
  83396. /**
  83397. * Creates a Size object from the given width and height (floats).
  83398. * @param width width of the new size
  83399. * @param height height of the new size
  83400. */
  83401. constructor(width: number, height: number);
  83402. /**
  83403. * Returns a string with the Size width and height
  83404. * @returns a string with the Size width and height
  83405. */
  83406. toString(): string;
  83407. /**
  83408. * "Size"
  83409. * @returns the string "Size"
  83410. */
  83411. getClassName(): string;
  83412. /**
  83413. * Returns the Size hash code.
  83414. * @returns a hash code for a unique width and height
  83415. */
  83416. getHashCode(): number;
  83417. /**
  83418. * Updates the current size from the given one.
  83419. * @param src the given size
  83420. */
  83421. copyFrom(src: Size): void;
  83422. /**
  83423. * Updates in place the current Size from the given floats.
  83424. * @param width width of the new size
  83425. * @param height height of the new size
  83426. * @returns the updated Size.
  83427. */
  83428. copyFromFloats(width: number, height: number): Size;
  83429. /**
  83430. * Updates in place the current Size from the given floats.
  83431. * @param width width to set
  83432. * @param height height to set
  83433. * @returns the updated Size.
  83434. */
  83435. set(width: number, height: number): Size;
  83436. /**
  83437. * Multiplies the width and height by numbers
  83438. * @param w factor to multiple the width by
  83439. * @param h factor to multiple the height by
  83440. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83441. */
  83442. multiplyByFloats(w: number, h: number): Size;
  83443. /**
  83444. * Clones the size
  83445. * @returns a new Size copied from the given one.
  83446. */
  83447. clone(): Size;
  83448. /**
  83449. * True if the current Size and the given one width and height are strictly equal.
  83450. * @param other the other size to compare against
  83451. * @returns True if the current Size and the given one width and height are strictly equal.
  83452. */
  83453. equals(other: Size): boolean;
  83454. /**
  83455. * The surface of the Size : width * height (float).
  83456. */
  83457. get surface(): number;
  83458. /**
  83459. * Create a new size of zero
  83460. * @returns a new Size set to (0.0, 0.0)
  83461. */
  83462. static Zero(): Size;
  83463. /**
  83464. * Sums the width and height of two sizes
  83465. * @param otherSize size to add to this size
  83466. * @returns a new Size set as the addition result of the current Size and the given one.
  83467. */
  83468. add(otherSize: Size): Size;
  83469. /**
  83470. * Subtracts the width and height of two
  83471. * @param otherSize size to subtract to this size
  83472. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83473. */
  83474. subtract(otherSize: Size): Size;
  83475. /**
  83476. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83477. * @param start starting size to lerp between
  83478. * @param end end size to lerp between
  83479. * @param amount amount to lerp between the start and end values
  83480. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83481. */
  83482. static Lerp(start: Size, end: Size, amount: number): Size;
  83483. }
  83484. }
  83485. declare module BABYLON {
  83486. interface ThinEngine {
  83487. /**
  83488. * Creates a dynamic texture
  83489. * @param width defines the width of the texture
  83490. * @param height defines the height of the texture
  83491. * @param generateMipMaps defines if the engine should generate the mip levels
  83492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83493. * @returns the dynamic texture inside an InternalTexture
  83494. */
  83495. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83496. /**
  83497. * Update the content of a dynamic texture
  83498. * @param texture defines the texture to update
  83499. * @param canvas defines the canvas containing the source
  83500. * @param invertY defines if data must be stored with Y axis inverted
  83501. * @param premulAlpha defines if alpha is stored as premultiplied
  83502. * @param format defines the format of the data
  83503. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83504. */
  83505. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83506. }
  83507. }
  83508. declare module BABYLON {
  83509. /**
  83510. * Helper class used to generate a canvas to manipulate images
  83511. */
  83512. export class CanvasGenerator {
  83513. /**
  83514. * Create a new canvas (or offscreen canvas depending on the context)
  83515. * @param width defines the expected width
  83516. * @param height defines the expected height
  83517. * @return a new canvas or offscreen canvas
  83518. */
  83519. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83520. }
  83521. }
  83522. declare module BABYLON {
  83523. /**
  83524. * A class extending Texture allowing drawing on a texture
  83525. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83526. */
  83527. export class DynamicTexture extends Texture {
  83528. private _generateMipMaps;
  83529. private _canvas;
  83530. private _context;
  83531. private _engine;
  83532. /**
  83533. * Creates a DynamicTexture
  83534. * @param name defines the name of the texture
  83535. * @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
  83536. * @param scene defines the scene where you want the texture
  83537. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83538. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83539. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83540. */
  83541. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83542. /**
  83543. * Get the current class name of the texture useful for serialization or dynamic coding.
  83544. * @returns "DynamicTexture"
  83545. */
  83546. getClassName(): string;
  83547. /**
  83548. * Gets the current state of canRescale
  83549. */
  83550. get canRescale(): boolean;
  83551. private _recreate;
  83552. /**
  83553. * Scales the texture
  83554. * @param ratio the scale factor to apply to both width and height
  83555. */
  83556. scale(ratio: number): void;
  83557. /**
  83558. * Resizes the texture
  83559. * @param width the new width
  83560. * @param height the new height
  83561. */
  83562. scaleTo(width: number, height: number): void;
  83563. /**
  83564. * Gets the context of the canvas used by the texture
  83565. * @returns the canvas context of the dynamic texture
  83566. */
  83567. getContext(): CanvasRenderingContext2D;
  83568. /**
  83569. * Clears the texture
  83570. */
  83571. clear(): void;
  83572. /**
  83573. * Updates the texture
  83574. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83575. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83576. */
  83577. update(invertY?: boolean, premulAlpha?: boolean): void;
  83578. /**
  83579. * Draws text onto the texture
  83580. * @param text defines the text to be drawn
  83581. * @param x defines the placement of the text from the left
  83582. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83583. * @param font defines the font to be used with font-style, font-size, font-name
  83584. * @param color defines the color used for the text
  83585. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83586. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83587. * @param update defines whether texture is immediately update (default is true)
  83588. */
  83589. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83590. /**
  83591. * Clones the texture
  83592. * @returns the clone of the texture.
  83593. */
  83594. clone(): DynamicTexture;
  83595. /**
  83596. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83597. * @returns a serialized dynamic texture object
  83598. */
  83599. serialize(): any;
  83600. /** @hidden */
  83601. _rebuild(): void;
  83602. }
  83603. }
  83604. declare module BABYLON {
  83605. interface Engine {
  83606. /**
  83607. * Creates a raw texture
  83608. * @param data defines the data to store in the texture
  83609. * @param width defines the width of the texture
  83610. * @param height defines the height of the texture
  83611. * @param format defines the format of the data
  83612. * @param generateMipMaps defines if the engine should generate the mip levels
  83613. * @param invertY defines if data must be stored with Y axis inverted
  83614. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83615. * @param compression defines the compression used (null by default)
  83616. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83617. * @returns the raw texture inside an InternalTexture
  83618. */
  83619. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83620. /**
  83621. * Update a raw texture
  83622. * @param texture defines the texture to update
  83623. * @param data defines the data to store in the texture
  83624. * @param format defines the format of the data
  83625. * @param invertY defines if data must be stored with Y axis inverted
  83626. */
  83627. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83628. /**
  83629. * Update a raw texture
  83630. * @param texture defines the texture to update
  83631. * @param data defines the data to store in the texture
  83632. * @param format defines the format of the data
  83633. * @param invertY defines if data must be stored with Y axis inverted
  83634. * @param compression defines the compression used (null by default)
  83635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83636. */
  83637. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83638. /**
  83639. * Creates a new raw cube texture
  83640. * @param data defines the array of data to use to create each face
  83641. * @param size defines the size of the textures
  83642. * @param format defines the format of the data
  83643. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83644. * @param generateMipMaps defines if the engine should generate the mip levels
  83645. * @param invertY defines if data must be stored with Y axis inverted
  83646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83647. * @param compression defines the compression used (null by default)
  83648. * @returns the cube texture as an InternalTexture
  83649. */
  83650. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83651. /**
  83652. * Update a raw cube texture
  83653. * @param texture defines the texture to udpdate
  83654. * @param data defines the data to store
  83655. * @param format defines the data format
  83656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83657. * @param invertY defines if data must be stored with Y axis inverted
  83658. */
  83659. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83660. /**
  83661. * Update a raw cube texture
  83662. * @param texture defines the texture to udpdate
  83663. * @param data defines the data to store
  83664. * @param format defines the data format
  83665. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83666. * @param invertY defines if data must be stored with Y axis inverted
  83667. * @param compression defines the compression used (null by default)
  83668. */
  83669. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83670. /**
  83671. * Update a raw cube texture
  83672. * @param texture defines the texture to udpdate
  83673. * @param data defines the data to store
  83674. * @param format defines the data format
  83675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83676. * @param invertY defines if data must be stored with Y axis inverted
  83677. * @param compression defines the compression used (null by default)
  83678. * @param level defines which level of the texture to update
  83679. */
  83680. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83681. /**
  83682. * Creates a new raw cube texture from a specified url
  83683. * @param url defines the url where the data is located
  83684. * @param scene defines the current scene
  83685. * @param size defines the size of the textures
  83686. * @param format defines the format of the data
  83687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83688. * @param noMipmap defines if the engine should avoid generating the mip levels
  83689. * @param callback defines a callback used to extract texture data from loaded data
  83690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83691. * @param onLoad defines a callback called when texture is loaded
  83692. * @param onError defines a callback called if there is an error
  83693. * @returns the cube texture as an InternalTexture
  83694. */
  83695. 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;
  83696. /**
  83697. * Creates a new raw cube texture from a specified url
  83698. * @param url defines the url where the data is located
  83699. * @param scene defines the current scene
  83700. * @param size defines the size of the textures
  83701. * @param format defines the format of the data
  83702. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83703. * @param noMipmap defines if the engine should avoid generating the mip levels
  83704. * @param callback defines a callback used to extract texture data from loaded data
  83705. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83706. * @param onLoad defines a callback called when texture is loaded
  83707. * @param onError defines a callback called if there is an error
  83708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83709. * @param invertY defines if data must be stored with Y axis inverted
  83710. * @returns the cube texture as an InternalTexture
  83711. */
  83712. 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;
  83713. /**
  83714. * Creates a new raw 3D texture
  83715. * @param data defines the data used to create the texture
  83716. * @param width defines the width of the texture
  83717. * @param height defines the height of the texture
  83718. * @param depth defines the depth of the texture
  83719. * @param format defines the format of the texture
  83720. * @param generateMipMaps defines if the engine must generate mip levels
  83721. * @param invertY defines if data must be stored with Y axis inverted
  83722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83723. * @param compression defines the compressed used (can be null)
  83724. * @param textureType defines the compressed used (can be null)
  83725. * @returns a new raw 3D texture (stored in an InternalTexture)
  83726. */
  83727. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83728. /**
  83729. * Update a raw 3D texture
  83730. * @param texture defines the texture to update
  83731. * @param data defines the data to store
  83732. * @param format defines the data format
  83733. * @param invertY defines if data must be stored with Y axis inverted
  83734. */
  83735. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83736. /**
  83737. * Update a raw 3D texture
  83738. * @param texture defines the texture to update
  83739. * @param data defines the data to store
  83740. * @param format defines the data format
  83741. * @param invertY defines if data must be stored with Y axis inverted
  83742. * @param compression defines the used compression (can be null)
  83743. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83744. */
  83745. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83746. /**
  83747. * Creates a new raw 2D array texture
  83748. * @param data defines the data used to create the texture
  83749. * @param width defines the width of the texture
  83750. * @param height defines the height of the texture
  83751. * @param depth defines the number of layers of the texture
  83752. * @param format defines the format of the texture
  83753. * @param generateMipMaps defines if the engine must generate mip levels
  83754. * @param invertY defines if data must be stored with Y axis inverted
  83755. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83756. * @param compression defines the compressed used (can be null)
  83757. * @param textureType defines the compressed used (can be null)
  83758. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83759. */
  83760. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83761. /**
  83762. * Update a raw 2D array texture
  83763. * @param texture defines the texture to update
  83764. * @param data defines the data to store
  83765. * @param format defines the data format
  83766. * @param invertY defines if data must be stored with Y axis inverted
  83767. */
  83768. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83769. /**
  83770. * Update a raw 2D array texture
  83771. * @param texture defines the texture to update
  83772. * @param data defines the data to store
  83773. * @param format defines the data format
  83774. * @param invertY defines if data must be stored with Y axis inverted
  83775. * @param compression defines the used compression (can be null)
  83776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83777. */
  83778. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83779. }
  83780. }
  83781. declare module BABYLON {
  83782. /**
  83783. * Raw texture can help creating a texture directly from an array of data.
  83784. * This can be super useful if you either get the data from an uncompressed source or
  83785. * if you wish to create your texture pixel by pixel.
  83786. */
  83787. export class RawTexture extends Texture {
  83788. /**
  83789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83790. */
  83791. format: number;
  83792. private _engine;
  83793. /**
  83794. * Instantiates a new RawTexture.
  83795. * Raw texture can help creating a texture directly from an array of data.
  83796. * This can be super useful if you either get the data from an uncompressed source or
  83797. * if you wish to create your texture pixel by pixel.
  83798. * @param data define the array of data to use to create the texture
  83799. * @param width define the width of the texture
  83800. * @param height define the height of the texture
  83801. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83802. * @param scene define the scene the texture belongs to
  83803. * @param generateMipMaps define whether mip maps should be generated or not
  83804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83806. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83807. */
  83808. constructor(data: ArrayBufferView, width: number, height: number,
  83809. /**
  83810. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83811. */
  83812. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83813. /**
  83814. * Updates the texture underlying data.
  83815. * @param data Define the new data of the texture
  83816. */
  83817. update(data: ArrayBufferView): void;
  83818. /**
  83819. * Creates a luminance texture from some data.
  83820. * @param data Define the texture data
  83821. * @param width Define the width of the texture
  83822. * @param height Define the height of the texture
  83823. * @param scene Define the scene the texture belongs to
  83824. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83825. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83826. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83827. * @returns the luminance texture
  83828. */
  83829. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83830. /**
  83831. * Creates a luminance alpha texture from some data.
  83832. * @param data Define the texture data
  83833. * @param width Define the width of the texture
  83834. * @param height Define the height of the texture
  83835. * @param scene Define the scene the texture belongs to
  83836. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83839. * @returns the luminance alpha texture
  83840. */
  83841. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83842. /**
  83843. * Creates an alpha texture from some data.
  83844. * @param data Define the texture data
  83845. * @param width Define the width of the texture
  83846. * @param height Define the height of the texture
  83847. * @param scene Define the scene the texture belongs to
  83848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83851. * @returns the alpha texture
  83852. */
  83853. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83854. /**
  83855. * Creates a RGB texture from some data.
  83856. * @param data Define the texture data
  83857. * @param width Define the width of the texture
  83858. * @param height Define the height of the texture
  83859. * @param scene Define the scene the texture belongs to
  83860. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83861. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83862. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83863. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83864. * @returns the RGB alpha texture
  83865. */
  83866. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83867. /**
  83868. * Creates a RGBA texture from some data.
  83869. * @param data Define the texture data
  83870. * @param width Define the width of the texture
  83871. * @param height Define the height of the texture
  83872. * @param scene Define the scene the texture belongs to
  83873. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83874. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83875. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83876. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83877. * @returns the RGBA texture
  83878. */
  83879. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83880. /**
  83881. * Creates a R texture from some data.
  83882. * @param data Define the texture data
  83883. * @param width Define the width of the texture
  83884. * @param height Define the height of the texture
  83885. * @param scene Define the scene the texture belongs to
  83886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83890. * @returns the R texture
  83891. */
  83892. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83893. }
  83894. }
  83895. declare module BABYLON {
  83896. interface AbstractScene {
  83897. /**
  83898. * The list of procedural textures added to the scene
  83899. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83900. */
  83901. proceduralTextures: Array<ProceduralTexture>;
  83902. }
  83903. /**
  83904. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83905. * in a given scene.
  83906. */
  83907. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83908. /**
  83909. * The component name helpfull to identify the component in the list of scene components.
  83910. */
  83911. readonly name: string;
  83912. /**
  83913. * The scene the component belongs to.
  83914. */
  83915. scene: Scene;
  83916. /**
  83917. * Creates a new instance of the component for the given scene
  83918. * @param scene Defines the scene to register the component in
  83919. */
  83920. constructor(scene: Scene);
  83921. /**
  83922. * Registers the component in a given scene
  83923. */
  83924. register(): void;
  83925. /**
  83926. * Rebuilds the elements related to this component in case of
  83927. * context lost for instance.
  83928. */
  83929. rebuild(): void;
  83930. /**
  83931. * Disposes the component and the associated ressources.
  83932. */
  83933. dispose(): void;
  83934. private _beforeClear;
  83935. }
  83936. }
  83937. declare module BABYLON {
  83938. interface ThinEngine {
  83939. /**
  83940. * Creates a new render target cube texture
  83941. * @param size defines the size of the texture
  83942. * @param options defines the options used to create the texture
  83943. * @returns a new render target cube texture stored in an InternalTexture
  83944. */
  83945. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83946. }
  83947. }
  83948. declare module BABYLON {
  83949. /** @hidden */
  83950. export var proceduralVertexShader: {
  83951. name: string;
  83952. shader: string;
  83953. };
  83954. }
  83955. declare module BABYLON {
  83956. /**
  83957. * 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.
  83958. * This is the base class of any Procedural texture and contains most of the shareable code.
  83959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83960. */
  83961. export class ProceduralTexture extends Texture {
  83962. isCube: boolean;
  83963. /**
  83964. * Define if the texture is enabled or not (disabled texture will not render)
  83965. */
  83966. isEnabled: boolean;
  83967. /**
  83968. * Define if the texture must be cleared before rendering (default is true)
  83969. */
  83970. autoClear: boolean;
  83971. /**
  83972. * Callback called when the texture is generated
  83973. */
  83974. onGenerated: () => void;
  83975. /**
  83976. * Event raised when the texture is generated
  83977. */
  83978. onGeneratedObservable: Observable<ProceduralTexture>;
  83979. /** @hidden */
  83980. _generateMipMaps: boolean;
  83981. /** @hidden **/
  83982. _effect: Effect;
  83983. /** @hidden */
  83984. _textures: {
  83985. [key: string]: Texture;
  83986. };
  83987. private _size;
  83988. private _currentRefreshId;
  83989. private _frameId;
  83990. private _refreshRate;
  83991. private _vertexBuffers;
  83992. private _indexBuffer;
  83993. private _uniforms;
  83994. private _samplers;
  83995. private _fragment;
  83996. private _floats;
  83997. private _ints;
  83998. private _floatsArrays;
  83999. private _colors3;
  84000. private _colors4;
  84001. private _vectors2;
  84002. private _vectors3;
  84003. private _matrices;
  84004. private _fallbackTexture;
  84005. private _fallbackTextureUsed;
  84006. private _engine;
  84007. private _cachedDefines;
  84008. private _contentUpdateId;
  84009. private _contentData;
  84010. /**
  84011. * Instantiates a new procedural texture.
  84012. * 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.
  84013. * This is the base class of any Procedural texture and contains most of the shareable code.
  84014. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84015. * @param name Define the name of the texture
  84016. * @param size Define the size of the texture to create
  84017. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84018. * @param scene Define the scene the texture belongs to
  84019. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84020. * @param generateMipMaps Define if the texture should creates mip maps or not
  84021. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84022. */
  84023. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84024. /**
  84025. * The effect that is created when initializing the post process.
  84026. * @returns The created effect corresponding the the postprocess.
  84027. */
  84028. getEffect(): Effect;
  84029. /**
  84030. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84031. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84032. */
  84033. getContent(): Nullable<ArrayBufferView>;
  84034. private _createIndexBuffer;
  84035. /** @hidden */
  84036. _rebuild(): void;
  84037. /**
  84038. * Resets the texture in order to recreate its associated resources.
  84039. * This can be called in case of context loss
  84040. */
  84041. reset(): void;
  84042. protected _getDefines(): string;
  84043. /**
  84044. * Is the texture ready to be used ? (rendered at least once)
  84045. * @returns true if ready, otherwise, false.
  84046. */
  84047. isReady(): boolean;
  84048. /**
  84049. * Resets the refresh counter of the texture and start bak from scratch.
  84050. * Could be useful to regenerate the texture if it is setup to render only once.
  84051. */
  84052. resetRefreshCounter(): void;
  84053. /**
  84054. * Set the fragment shader to use in order to render the texture.
  84055. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84056. */
  84057. setFragment(fragment: any): void;
  84058. /**
  84059. * Define the refresh rate of the texture or the rendering frequency.
  84060. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84061. */
  84062. get refreshRate(): number;
  84063. set refreshRate(value: number);
  84064. /** @hidden */
  84065. _shouldRender(): boolean;
  84066. /**
  84067. * Get the size the texture is rendering at.
  84068. * @returns the size (texture is always squared)
  84069. */
  84070. getRenderSize(): number;
  84071. /**
  84072. * Resize the texture to new value.
  84073. * @param size Define the new size the texture should have
  84074. * @param generateMipMaps Define whether the new texture should create mip maps
  84075. */
  84076. resize(size: number, generateMipMaps: boolean): void;
  84077. private _checkUniform;
  84078. /**
  84079. * Set a texture in the shader program used to render.
  84080. * @param name Define the name of the uniform samplers as defined in the shader
  84081. * @param texture Define the texture to bind to this sampler
  84082. * @return the texture itself allowing "fluent" like uniform updates
  84083. */
  84084. setTexture(name: string, texture: Texture): ProceduralTexture;
  84085. /**
  84086. * Set a float in the shader.
  84087. * @param name Define the name of the uniform as defined in the shader
  84088. * @param value Define the value to give to the uniform
  84089. * @return the texture itself allowing "fluent" like uniform updates
  84090. */
  84091. setFloat(name: string, value: number): ProceduralTexture;
  84092. /**
  84093. * Set a int in the shader.
  84094. * @param name Define the name of the uniform as defined in the shader
  84095. * @param value Define the value to give to the uniform
  84096. * @return the texture itself allowing "fluent" like uniform updates
  84097. */
  84098. setInt(name: string, value: number): ProceduralTexture;
  84099. /**
  84100. * Set an array of floats in the shader.
  84101. * @param name Define the name of the uniform as defined in the shader
  84102. * @param value Define the value to give to the uniform
  84103. * @return the texture itself allowing "fluent" like uniform updates
  84104. */
  84105. setFloats(name: string, value: number[]): ProceduralTexture;
  84106. /**
  84107. * Set a vec3 in the shader from a Color3.
  84108. * @param name Define the name of the uniform as defined in the shader
  84109. * @param value Define the value to give to the uniform
  84110. * @return the texture itself allowing "fluent" like uniform updates
  84111. */
  84112. setColor3(name: string, value: Color3): ProceduralTexture;
  84113. /**
  84114. * Set a vec4 in the shader from a Color4.
  84115. * @param name Define the name of the uniform as defined in the shader
  84116. * @param value Define the value to give to the uniform
  84117. * @return the texture itself allowing "fluent" like uniform updates
  84118. */
  84119. setColor4(name: string, value: Color4): ProceduralTexture;
  84120. /**
  84121. * Set a vec2 in the shader from a Vector2.
  84122. * @param name Define the name of the uniform as defined in the shader
  84123. * @param value Define the value to give to the uniform
  84124. * @return the texture itself allowing "fluent" like uniform updates
  84125. */
  84126. setVector2(name: string, value: Vector2): ProceduralTexture;
  84127. /**
  84128. * Set a vec3 in the shader from a Vector3.
  84129. * @param name Define the name of the uniform as defined in the shader
  84130. * @param value Define the value to give to the uniform
  84131. * @return the texture itself allowing "fluent" like uniform updates
  84132. */
  84133. setVector3(name: string, value: Vector3): ProceduralTexture;
  84134. /**
  84135. * Set a mat4 in the shader from a MAtrix.
  84136. * @param name Define the name of the uniform as defined in the shader
  84137. * @param value Define the value to give to the uniform
  84138. * @return the texture itself allowing "fluent" like uniform updates
  84139. */
  84140. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84141. /**
  84142. * Render the texture to its associated render target.
  84143. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84144. */
  84145. render(useCameraPostProcess?: boolean): void;
  84146. /**
  84147. * Clone the texture.
  84148. * @returns the cloned texture
  84149. */
  84150. clone(): ProceduralTexture;
  84151. /**
  84152. * Dispose the texture and release its asoociated resources.
  84153. */
  84154. dispose(): void;
  84155. }
  84156. }
  84157. declare module BABYLON {
  84158. /**
  84159. * This represents the base class for particle system in Babylon.
  84160. * 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.
  84161. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84162. * @example https://doc.babylonjs.com/babylon101/particles
  84163. */
  84164. export class BaseParticleSystem {
  84165. /**
  84166. * Source color is added to the destination color without alpha affecting the result
  84167. */
  84168. static BLENDMODE_ONEONE: number;
  84169. /**
  84170. * Blend current color and particle color using particle’s alpha
  84171. */
  84172. static BLENDMODE_STANDARD: number;
  84173. /**
  84174. * Add current color and particle color multiplied by particle’s alpha
  84175. */
  84176. static BLENDMODE_ADD: number;
  84177. /**
  84178. * Multiply current color with particle color
  84179. */
  84180. static BLENDMODE_MULTIPLY: number;
  84181. /**
  84182. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84183. */
  84184. static BLENDMODE_MULTIPLYADD: number;
  84185. /**
  84186. * List of animations used by the particle system.
  84187. */
  84188. animations: Animation[];
  84189. /**
  84190. * The id of the Particle system.
  84191. */
  84192. id: string;
  84193. /**
  84194. * The friendly name of the Particle system.
  84195. */
  84196. name: string;
  84197. /**
  84198. * The rendering group used by the Particle system to chose when to render.
  84199. */
  84200. renderingGroupId: number;
  84201. /**
  84202. * The emitter represents the Mesh or position we are attaching the particle system to.
  84203. */
  84204. emitter: Nullable<AbstractMesh | Vector3>;
  84205. /**
  84206. * The maximum number of particles to emit per frame
  84207. */
  84208. emitRate: number;
  84209. /**
  84210. * If you want to launch only a few particles at once, that can be done, as well.
  84211. */
  84212. manualEmitCount: number;
  84213. /**
  84214. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84215. */
  84216. updateSpeed: number;
  84217. /**
  84218. * The amount of time the particle system is running (depends of the overall update speed).
  84219. */
  84220. targetStopDuration: number;
  84221. /**
  84222. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84223. */
  84224. disposeOnStop: boolean;
  84225. /**
  84226. * Minimum power of emitting particles.
  84227. */
  84228. minEmitPower: number;
  84229. /**
  84230. * Maximum power of emitting particles.
  84231. */
  84232. maxEmitPower: number;
  84233. /**
  84234. * Minimum life time of emitting particles.
  84235. */
  84236. minLifeTime: number;
  84237. /**
  84238. * Maximum life time of emitting particles.
  84239. */
  84240. maxLifeTime: number;
  84241. /**
  84242. * Minimum Size of emitting particles.
  84243. */
  84244. minSize: number;
  84245. /**
  84246. * Maximum Size of emitting particles.
  84247. */
  84248. maxSize: number;
  84249. /**
  84250. * Minimum scale of emitting particles on X axis.
  84251. */
  84252. minScaleX: number;
  84253. /**
  84254. * Maximum scale of emitting particles on X axis.
  84255. */
  84256. maxScaleX: number;
  84257. /**
  84258. * Minimum scale of emitting particles on Y axis.
  84259. */
  84260. minScaleY: number;
  84261. /**
  84262. * Maximum scale of emitting particles on Y axis.
  84263. */
  84264. maxScaleY: number;
  84265. /**
  84266. * Gets or sets the minimal initial rotation in radians.
  84267. */
  84268. minInitialRotation: number;
  84269. /**
  84270. * Gets or sets the maximal initial rotation in radians.
  84271. */
  84272. maxInitialRotation: number;
  84273. /**
  84274. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84275. */
  84276. minAngularSpeed: number;
  84277. /**
  84278. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84279. */
  84280. maxAngularSpeed: number;
  84281. /**
  84282. * The texture used to render each particle. (this can be a spritesheet)
  84283. */
  84284. particleTexture: Nullable<Texture>;
  84285. /**
  84286. * The layer mask we are rendering the particles through.
  84287. */
  84288. layerMask: number;
  84289. /**
  84290. * This can help using your own shader to render the particle system.
  84291. * The according effect will be created
  84292. */
  84293. customShader: any;
  84294. /**
  84295. * By default particle system starts as soon as they are created. This prevents the
  84296. * automatic start to happen and let you decide when to start emitting particles.
  84297. */
  84298. preventAutoStart: boolean;
  84299. private _noiseTexture;
  84300. /**
  84301. * Gets or sets a texture used to add random noise to particle positions
  84302. */
  84303. get noiseTexture(): Nullable<ProceduralTexture>;
  84304. set noiseTexture(value: Nullable<ProceduralTexture>);
  84305. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84306. noiseStrength: Vector3;
  84307. /**
  84308. * Callback triggered when the particle animation is ending.
  84309. */
  84310. onAnimationEnd: Nullable<() => void>;
  84311. /**
  84312. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84313. */
  84314. blendMode: number;
  84315. /**
  84316. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84317. * to override the particles.
  84318. */
  84319. forceDepthWrite: boolean;
  84320. /** 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 */
  84321. preWarmCycles: number;
  84322. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84323. preWarmStepOffset: number;
  84324. /**
  84325. * 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)
  84326. */
  84327. spriteCellChangeSpeed: number;
  84328. /**
  84329. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84330. */
  84331. startSpriteCellID: number;
  84332. /**
  84333. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84334. */
  84335. endSpriteCellID: number;
  84336. /**
  84337. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84338. */
  84339. spriteCellWidth: number;
  84340. /**
  84341. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84342. */
  84343. spriteCellHeight: number;
  84344. /**
  84345. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84346. */
  84347. spriteRandomStartCell: boolean;
  84348. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84349. translationPivot: Vector2;
  84350. /** @hidden */
  84351. protected _isAnimationSheetEnabled: boolean;
  84352. /**
  84353. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84354. */
  84355. beginAnimationOnStart: boolean;
  84356. /**
  84357. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84358. */
  84359. beginAnimationFrom: number;
  84360. /**
  84361. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84362. */
  84363. beginAnimationTo: number;
  84364. /**
  84365. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84366. */
  84367. beginAnimationLoop: boolean;
  84368. /**
  84369. * Gets or sets a world offset applied to all particles
  84370. */
  84371. worldOffset: Vector3;
  84372. /**
  84373. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84374. */
  84375. get isAnimationSheetEnabled(): boolean;
  84376. set isAnimationSheetEnabled(value: boolean);
  84377. /**
  84378. * Get hosting scene
  84379. * @returns the scene
  84380. */
  84381. getScene(): Scene;
  84382. /**
  84383. * You can use gravity if you want to give an orientation to your particles.
  84384. */
  84385. gravity: Vector3;
  84386. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84387. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84388. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84389. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84390. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84391. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84392. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84393. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84394. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84395. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84396. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84397. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84398. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84399. /**
  84400. * Defines the delay in milliseconds before starting the system (0 by default)
  84401. */
  84402. startDelay: number;
  84403. /**
  84404. * Gets the current list of drag gradients.
  84405. * You must use addDragGradient and removeDragGradient to udpate this list
  84406. * @returns the list of drag gradients
  84407. */
  84408. getDragGradients(): Nullable<Array<FactorGradient>>;
  84409. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84410. limitVelocityDamping: number;
  84411. /**
  84412. * Gets the current list of limit velocity gradients.
  84413. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84414. * @returns the list of limit velocity gradients
  84415. */
  84416. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84417. /**
  84418. * Gets the current list of color gradients.
  84419. * You must use addColorGradient and removeColorGradient to udpate this list
  84420. * @returns the list of color gradients
  84421. */
  84422. getColorGradients(): Nullable<Array<ColorGradient>>;
  84423. /**
  84424. * Gets the current list of size gradients.
  84425. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84426. * @returns the list of size gradients
  84427. */
  84428. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84429. /**
  84430. * Gets the current list of color remap gradients.
  84431. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84432. * @returns the list of color remap gradients
  84433. */
  84434. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84435. /**
  84436. * Gets the current list of alpha remap gradients.
  84437. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84438. * @returns the list of alpha remap gradients
  84439. */
  84440. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84441. /**
  84442. * Gets the current list of life time gradients.
  84443. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84444. * @returns the list of life time gradients
  84445. */
  84446. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84447. /**
  84448. * Gets the current list of angular speed gradients.
  84449. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84450. * @returns the list of angular speed gradients
  84451. */
  84452. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84453. /**
  84454. * Gets the current list of velocity gradients.
  84455. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84456. * @returns the list of velocity gradients
  84457. */
  84458. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84459. /**
  84460. * Gets the current list of start size gradients.
  84461. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84462. * @returns the list of start size gradients
  84463. */
  84464. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84465. /**
  84466. * Gets the current list of emit rate gradients.
  84467. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84468. * @returns the list of emit rate gradients
  84469. */
  84470. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84471. /**
  84472. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84474. */
  84475. get direction1(): Vector3;
  84476. set direction1(value: Vector3);
  84477. /**
  84478. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84480. */
  84481. get direction2(): Vector3;
  84482. set direction2(value: Vector3);
  84483. /**
  84484. * 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.
  84485. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84486. */
  84487. get minEmitBox(): Vector3;
  84488. set minEmitBox(value: Vector3);
  84489. /**
  84490. * 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.
  84491. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84492. */
  84493. get maxEmitBox(): Vector3;
  84494. set maxEmitBox(value: Vector3);
  84495. /**
  84496. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84497. */
  84498. color1: Color4;
  84499. /**
  84500. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84501. */
  84502. color2: Color4;
  84503. /**
  84504. * Color the particle will have at the end of its lifetime
  84505. */
  84506. colorDead: Color4;
  84507. /**
  84508. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84509. */
  84510. textureMask: Color4;
  84511. /**
  84512. * The particle emitter type defines the emitter used by the particle system.
  84513. * It can be for example box, sphere, or cone...
  84514. */
  84515. particleEmitterType: IParticleEmitterType;
  84516. /** @hidden */
  84517. _isSubEmitter: boolean;
  84518. /**
  84519. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84520. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84521. */
  84522. billboardMode: number;
  84523. protected _isBillboardBased: boolean;
  84524. /**
  84525. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84526. */
  84527. get isBillboardBased(): boolean;
  84528. set isBillboardBased(value: boolean);
  84529. /**
  84530. * The scene the particle system belongs to.
  84531. */
  84532. protected _scene: Scene;
  84533. /**
  84534. * Local cache of defines for image processing.
  84535. */
  84536. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84537. /**
  84538. * Default configuration related to image processing available in the standard Material.
  84539. */
  84540. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84541. /**
  84542. * Gets the image processing configuration used either in this material.
  84543. */
  84544. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84545. /**
  84546. * Sets the Default image processing configuration used either in the this material.
  84547. *
  84548. * If sets to null, the scene one is in use.
  84549. */
  84550. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84551. /**
  84552. * Attaches a new image processing configuration to the Standard Material.
  84553. * @param configuration
  84554. */
  84555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84556. /** @hidden */
  84557. protected _reset(): void;
  84558. /** @hidden */
  84559. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84560. /**
  84561. * Instantiates a particle system.
  84562. * 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.
  84563. * @param name The name of the particle system
  84564. */
  84565. constructor(name: string);
  84566. /**
  84567. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84568. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84569. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84570. * @returns the emitter
  84571. */
  84572. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84573. /**
  84574. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84575. * @param radius The radius of the hemisphere to emit from
  84576. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84577. * @returns the emitter
  84578. */
  84579. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84580. /**
  84581. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84582. * @param radius The radius of the sphere to emit from
  84583. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84584. * @returns the emitter
  84585. */
  84586. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84587. /**
  84588. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84589. * @param radius The radius of the sphere to emit from
  84590. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84591. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84592. * @returns the emitter
  84593. */
  84594. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84595. /**
  84596. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84597. * @param radius The radius of the emission cylinder
  84598. * @param height The height of the emission cylinder
  84599. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84600. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84601. * @returns the emitter
  84602. */
  84603. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84604. /**
  84605. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84606. * @param radius The radius of the cylinder to emit from
  84607. * @param height The height of the emission cylinder
  84608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84611. * @returns the emitter
  84612. */
  84613. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84614. /**
  84615. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84616. * @param radius The radius of the cone to emit from
  84617. * @param angle The base angle of the cone
  84618. * @returns the emitter
  84619. */
  84620. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84621. /**
  84622. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84625. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84626. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84627. * @returns the emitter
  84628. */
  84629. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84630. }
  84631. }
  84632. declare module BABYLON {
  84633. /**
  84634. * Type of sub emitter
  84635. */
  84636. export enum SubEmitterType {
  84637. /**
  84638. * Attached to the particle over it's lifetime
  84639. */
  84640. ATTACHED = 0,
  84641. /**
  84642. * Created when the particle dies
  84643. */
  84644. END = 1
  84645. }
  84646. /**
  84647. * Sub emitter class used to emit particles from an existing particle
  84648. */
  84649. export class SubEmitter {
  84650. /**
  84651. * the particle system to be used by the sub emitter
  84652. */
  84653. particleSystem: ParticleSystem;
  84654. /**
  84655. * Type of the submitter (Default: END)
  84656. */
  84657. type: SubEmitterType;
  84658. /**
  84659. * 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)
  84660. * Note: This only is supported when using an emitter of type Mesh
  84661. */
  84662. inheritDirection: boolean;
  84663. /**
  84664. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84665. */
  84666. inheritedVelocityAmount: number;
  84667. /**
  84668. * Creates a sub emitter
  84669. * @param particleSystem the particle system to be used by the sub emitter
  84670. */
  84671. constructor(
  84672. /**
  84673. * the particle system to be used by the sub emitter
  84674. */
  84675. particleSystem: ParticleSystem);
  84676. /**
  84677. * Clones the sub emitter
  84678. * @returns the cloned sub emitter
  84679. */
  84680. clone(): SubEmitter;
  84681. /**
  84682. * Serialize current object to a JSON object
  84683. * @returns the serialized object
  84684. */
  84685. serialize(): any;
  84686. /** @hidden */
  84687. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84688. /**
  84689. * Creates a new SubEmitter from a serialized JSON version
  84690. * @param serializationObject defines the JSON object to read from
  84691. * @param scene defines the hosting scene
  84692. * @param rootUrl defines the rootUrl for data loading
  84693. * @returns a new SubEmitter
  84694. */
  84695. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84696. /** Release associated resources */
  84697. dispose(): void;
  84698. }
  84699. }
  84700. declare module BABYLON {
  84701. /** @hidden */
  84702. export var imageProcessingDeclaration: {
  84703. name: string;
  84704. shader: string;
  84705. };
  84706. }
  84707. declare module BABYLON {
  84708. /** @hidden */
  84709. export var imageProcessingFunctions: {
  84710. name: string;
  84711. shader: string;
  84712. };
  84713. }
  84714. declare module BABYLON {
  84715. /** @hidden */
  84716. export var particlesPixelShader: {
  84717. name: string;
  84718. shader: string;
  84719. };
  84720. }
  84721. declare module BABYLON {
  84722. /** @hidden */
  84723. export var particlesVertexShader: {
  84724. name: string;
  84725. shader: string;
  84726. };
  84727. }
  84728. declare module BABYLON {
  84729. /**
  84730. * This represents a particle system in Babylon.
  84731. * 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.
  84732. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84733. * @example https://doc.babylonjs.com/babylon101/particles
  84734. */
  84735. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84736. /**
  84737. * Billboard mode will only apply to Y axis
  84738. */
  84739. static readonly BILLBOARDMODE_Y: number;
  84740. /**
  84741. * Billboard mode will apply to all axes
  84742. */
  84743. static readonly BILLBOARDMODE_ALL: number;
  84744. /**
  84745. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84746. */
  84747. static readonly BILLBOARDMODE_STRETCHED: number;
  84748. /**
  84749. * This function can be defined to provide custom update for active particles.
  84750. * This function will be called instead of regular update (age, position, color, etc.).
  84751. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84752. */
  84753. updateFunction: (particles: Particle[]) => void;
  84754. private _emitterWorldMatrix;
  84755. /**
  84756. * This function can be defined to specify initial direction for every new particle.
  84757. * It by default use the emitterType defined function
  84758. */
  84759. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84760. /**
  84761. * This function can be defined to specify initial position for every new particle.
  84762. * It by default use the emitterType defined function
  84763. */
  84764. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84765. /**
  84766. * @hidden
  84767. */
  84768. _inheritedVelocityOffset: Vector3;
  84769. /**
  84770. * An event triggered when the system is disposed
  84771. */
  84772. onDisposeObservable: Observable<ParticleSystem>;
  84773. private _onDisposeObserver;
  84774. /**
  84775. * Sets a callback that will be triggered when the system is disposed
  84776. */
  84777. set onDispose(callback: () => void);
  84778. private _particles;
  84779. private _epsilon;
  84780. private _capacity;
  84781. private _stockParticles;
  84782. private _newPartsExcess;
  84783. private _vertexData;
  84784. private _vertexBuffer;
  84785. private _vertexBuffers;
  84786. private _spriteBuffer;
  84787. private _indexBuffer;
  84788. private _effect;
  84789. private _customEffect;
  84790. private _cachedDefines;
  84791. private _scaledColorStep;
  84792. private _colorDiff;
  84793. private _scaledDirection;
  84794. private _scaledGravity;
  84795. private _currentRenderId;
  84796. private _alive;
  84797. private _useInstancing;
  84798. private _started;
  84799. private _stopped;
  84800. private _actualFrame;
  84801. private _scaledUpdateSpeed;
  84802. private _vertexBufferSize;
  84803. /** @hidden */
  84804. _currentEmitRateGradient: Nullable<FactorGradient>;
  84805. /** @hidden */
  84806. _currentEmitRate1: number;
  84807. /** @hidden */
  84808. _currentEmitRate2: number;
  84809. /** @hidden */
  84810. _currentStartSizeGradient: Nullable<FactorGradient>;
  84811. /** @hidden */
  84812. _currentStartSize1: number;
  84813. /** @hidden */
  84814. _currentStartSize2: number;
  84815. private readonly _rawTextureWidth;
  84816. private _rampGradientsTexture;
  84817. private _useRampGradients;
  84818. /** Gets or sets a boolean indicating that ramp gradients must be used
  84819. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84820. */
  84821. get useRampGradients(): boolean;
  84822. set useRampGradients(value: boolean);
  84823. /**
  84824. * 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.
  84825. * 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: [])
  84826. */
  84827. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84828. private _subEmitters;
  84829. /**
  84830. * @hidden
  84831. * If the particle systems emitter should be disposed when the particle system is disposed
  84832. */
  84833. _disposeEmitterOnDispose: boolean;
  84834. /**
  84835. * The current active Sub-systems, this property is used by the root particle system only.
  84836. */
  84837. activeSubSystems: Array<ParticleSystem>;
  84838. private _rootParticleSystem;
  84839. /**
  84840. * Gets the current list of active particles
  84841. */
  84842. get particles(): Particle[];
  84843. /**
  84844. * Returns the string "ParticleSystem"
  84845. * @returns a string containing the class name
  84846. */
  84847. getClassName(): string;
  84848. /**
  84849. * Instantiates a particle system.
  84850. * 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.
  84851. * @param name The name of the particle system
  84852. * @param capacity The max number of particles alive at the same time
  84853. * @param scene The scene the particle system belongs to
  84854. * @param customEffect a custom effect used to change the way particles are rendered by default
  84855. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84856. * @param epsilon Offset used to render the particles
  84857. */
  84858. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84859. private _addFactorGradient;
  84860. private _removeFactorGradient;
  84861. /**
  84862. * Adds a new life time gradient
  84863. * @param gradient defines the gradient to use (between 0 and 1)
  84864. * @param factor defines the life time factor to affect to the specified gradient
  84865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84866. * @returns the current particle system
  84867. */
  84868. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84869. /**
  84870. * Remove a specific life time gradient
  84871. * @param gradient defines the gradient to remove
  84872. * @returns the current particle system
  84873. */
  84874. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84875. /**
  84876. * Adds a new size gradient
  84877. * @param gradient defines the gradient to use (between 0 and 1)
  84878. * @param factor defines the size factor to affect to the specified gradient
  84879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84880. * @returns the current particle system
  84881. */
  84882. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84883. /**
  84884. * Remove a specific size gradient
  84885. * @param gradient defines the gradient to remove
  84886. * @returns the current particle system
  84887. */
  84888. removeSizeGradient(gradient: number): IParticleSystem;
  84889. /**
  84890. * Adds a new color remap gradient
  84891. * @param gradient defines the gradient to use (between 0 and 1)
  84892. * @param min defines the color remap minimal range
  84893. * @param max defines the color remap maximal range
  84894. * @returns the current particle system
  84895. */
  84896. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84897. /**
  84898. * Remove a specific color remap gradient
  84899. * @param gradient defines the gradient to remove
  84900. * @returns the current particle system
  84901. */
  84902. removeColorRemapGradient(gradient: number): IParticleSystem;
  84903. /**
  84904. * Adds a new alpha remap gradient
  84905. * @param gradient defines the gradient to use (between 0 and 1)
  84906. * @param min defines the alpha remap minimal range
  84907. * @param max defines the alpha remap maximal range
  84908. * @returns the current particle system
  84909. */
  84910. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84911. /**
  84912. * Remove a specific alpha remap gradient
  84913. * @param gradient defines the gradient to remove
  84914. * @returns the current particle system
  84915. */
  84916. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84917. /**
  84918. * Adds a new angular speed gradient
  84919. * @param gradient defines the gradient to use (between 0 and 1)
  84920. * @param factor defines the angular speed to affect to the specified gradient
  84921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84922. * @returns the current particle system
  84923. */
  84924. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84925. /**
  84926. * Remove a specific angular speed gradient
  84927. * @param gradient defines the gradient to remove
  84928. * @returns the current particle system
  84929. */
  84930. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84931. /**
  84932. * Adds a new velocity gradient
  84933. * @param gradient defines the gradient to use (between 0 and 1)
  84934. * @param factor defines the velocity to affect to the specified gradient
  84935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84936. * @returns the current particle system
  84937. */
  84938. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84939. /**
  84940. * Remove a specific velocity gradient
  84941. * @param gradient defines the gradient to remove
  84942. * @returns the current particle system
  84943. */
  84944. removeVelocityGradient(gradient: number): IParticleSystem;
  84945. /**
  84946. * Adds a new limit velocity gradient
  84947. * @param gradient defines the gradient to use (between 0 and 1)
  84948. * @param factor defines the limit velocity value to affect to the specified gradient
  84949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84950. * @returns the current particle system
  84951. */
  84952. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84953. /**
  84954. * Remove a specific limit velocity gradient
  84955. * @param gradient defines the gradient to remove
  84956. * @returns the current particle system
  84957. */
  84958. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84959. /**
  84960. * Adds a new drag gradient
  84961. * @param gradient defines the gradient to use (between 0 and 1)
  84962. * @param factor defines the drag value to affect to the specified gradient
  84963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84964. * @returns the current particle system
  84965. */
  84966. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84967. /**
  84968. * Remove a specific drag gradient
  84969. * @param gradient defines the gradient to remove
  84970. * @returns the current particle system
  84971. */
  84972. removeDragGradient(gradient: number): IParticleSystem;
  84973. /**
  84974. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84975. * @param gradient defines the gradient to use (between 0 and 1)
  84976. * @param factor defines the emit rate value to affect to the specified gradient
  84977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84978. * @returns the current particle system
  84979. */
  84980. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84981. /**
  84982. * Remove a specific emit rate gradient
  84983. * @param gradient defines the gradient to remove
  84984. * @returns the current particle system
  84985. */
  84986. removeEmitRateGradient(gradient: number): IParticleSystem;
  84987. /**
  84988. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84989. * @param gradient defines the gradient to use (between 0 and 1)
  84990. * @param factor defines the start size value to affect to the specified gradient
  84991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84992. * @returns the current particle system
  84993. */
  84994. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84995. /**
  84996. * Remove a specific start size gradient
  84997. * @param gradient defines the gradient to remove
  84998. * @returns the current particle system
  84999. */
  85000. removeStartSizeGradient(gradient: number): IParticleSystem;
  85001. private _createRampGradientTexture;
  85002. /**
  85003. * Gets the current list of ramp gradients.
  85004. * You must use addRampGradient and removeRampGradient to udpate this list
  85005. * @returns the list of ramp gradients
  85006. */
  85007. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85008. /**
  85009. * Adds a new ramp gradient used to remap particle colors
  85010. * @param gradient defines the gradient to use (between 0 and 1)
  85011. * @param color defines the color to affect to the specified gradient
  85012. * @returns the current particle system
  85013. */
  85014. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85015. /**
  85016. * Remove a specific ramp gradient
  85017. * @param gradient defines the gradient to remove
  85018. * @returns the current particle system
  85019. */
  85020. removeRampGradient(gradient: number): ParticleSystem;
  85021. /**
  85022. * Adds a new color gradient
  85023. * @param gradient defines the gradient to use (between 0 and 1)
  85024. * @param color1 defines the color to affect to the specified gradient
  85025. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85026. * @returns this particle system
  85027. */
  85028. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85029. /**
  85030. * Remove a specific color gradient
  85031. * @param gradient defines the gradient to remove
  85032. * @returns this particle system
  85033. */
  85034. removeColorGradient(gradient: number): IParticleSystem;
  85035. private _fetchR;
  85036. protected _reset(): void;
  85037. private _resetEffect;
  85038. private _createVertexBuffers;
  85039. private _createIndexBuffer;
  85040. /**
  85041. * Gets the maximum number of particles active at the same time.
  85042. * @returns The max number of active particles.
  85043. */
  85044. getCapacity(): number;
  85045. /**
  85046. * Gets whether there are still active particles in the system.
  85047. * @returns True if it is alive, otherwise false.
  85048. */
  85049. isAlive(): boolean;
  85050. /**
  85051. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85052. * @returns True if it has been started, otherwise false.
  85053. */
  85054. isStarted(): boolean;
  85055. private _prepareSubEmitterInternalArray;
  85056. /**
  85057. * Starts the particle system and begins to emit
  85058. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85059. */
  85060. start(delay?: number): void;
  85061. /**
  85062. * Stops the particle system.
  85063. * @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.
  85064. */
  85065. stop(stopSubEmitters?: boolean): void;
  85066. /**
  85067. * Remove all active particles
  85068. */
  85069. reset(): void;
  85070. /**
  85071. * @hidden (for internal use only)
  85072. */
  85073. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85074. /**
  85075. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85076. * Its lifetime will start back at 0.
  85077. */
  85078. recycleParticle: (particle: Particle) => void;
  85079. private _stopSubEmitters;
  85080. private _createParticle;
  85081. private _removeFromRoot;
  85082. private _emitFromParticle;
  85083. private _update;
  85084. /** @hidden */
  85085. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85086. /** @hidden */
  85087. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85088. /** @hidden */
  85089. private _getEffect;
  85090. /**
  85091. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85092. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85093. */
  85094. animate(preWarmOnly?: boolean): void;
  85095. private _appendParticleVertices;
  85096. /**
  85097. * Rebuilds the particle system.
  85098. */
  85099. rebuild(): void;
  85100. /**
  85101. * Is this system ready to be used/rendered
  85102. * @return true if the system is ready
  85103. */
  85104. isReady(): boolean;
  85105. private _render;
  85106. /**
  85107. * Renders the particle system in its current state.
  85108. * @returns the current number of particles
  85109. */
  85110. render(): number;
  85111. /**
  85112. * Disposes the particle system and free the associated resources
  85113. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85114. */
  85115. dispose(disposeTexture?: boolean): void;
  85116. /**
  85117. * Clones the particle system.
  85118. * @param name The name of the cloned object
  85119. * @param newEmitter The new emitter to use
  85120. * @returns the cloned particle system
  85121. */
  85122. clone(name: string, newEmitter: any): ParticleSystem;
  85123. /**
  85124. * Serializes the particle system to a JSON object.
  85125. * @returns the JSON object
  85126. */
  85127. serialize(): any;
  85128. /** @hidden */
  85129. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85130. /** @hidden */
  85131. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85132. /**
  85133. * Parses a JSON object to create a particle system.
  85134. * @param parsedParticleSystem The JSON object to parse
  85135. * @param scene The scene to create the particle system in
  85136. * @param rootUrl The root url to use to load external dependencies like texture
  85137. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85138. * @returns the Parsed particle system
  85139. */
  85140. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85141. }
  85142. }
  85143. declare module BABYLON {
  85144. /**
  85145. * A particle represents one of the element emitted by a particle system.
  85146. * This is mainly define by its coordinates, direction, velocity and age.
  85147. */
  85148. export class Particle {
  85149. /**
  85150. * The particle system the particle belongs to.
  85151. */
  85152. particleSystem: ParticleSystem;
  85153. private static _Count;
  85154. /**
  85155. * Unique ID of the particle
  85156. */
  85157. id: number;
  85158. /**
  85159. * The world position of the particle in the scene.
  85160. */
  85161. position: Vector3;
  85162. /**
  85163. * The world direction of the particle in the scene.
  85164. */
  85165. direction: Vector3;
  85166. /**
  85167. * The color of the particle.
  85168. */
  85169. color: Color4;
  85170. /**
  85171. * The color change of the particle per step.
  85172. */
  85173. colorStep: Color4;
  85174. /**
  85175. * Defines how long will the life of the particle be.
  85176. */
  85177. lifeTime: number;
  85178. /**
  85179. * The current age of the particle.
  85180. */
  85181. age: number;
  85182. /**
  85183. * The current size of the particle.
  85184. */
  85185. size: number;
  85186. /**
  85187. * The current scale of the particle.
  85188. */
  85189. scale: Vector2;
  85190. /**
  85191. * The current angle of the particle.
  85192. */
  85193. angle: number;
  85194. /**
  85195. * Defines how fast is the angle changing.
  85196. */
  85197. angularSpeed: number;
  85198. /**
  85199. * Defines the cell index used by the particle to be rendered from a sprite.
  85200. */
  85201. cellIndex: number;
  85202. /**
  85203. * The information required to support color remapping
  85204. */
  85205. remapData: Vector4;
  85206. /** @hidden */
  85207. _randomCellOffset?: number;
  85208. /** @hidden */
  85209. _initialDirection: Nullable<Vector3>;
  85210. /** @hidden */
  85211. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85212. /** @hidden */
  85213. _initialStartSpriteCellID: number;
  85214. /** @hidden */
  85215. _initialEndSpriteCellID: number;
  85216. /** @hidden */
  85217. _currentColorGradient: Nullable<ColorGradient>;
  85218. /** @hidden */
  85219. _currentColor1: Color4;
  85220. /** @hidden */
  85221. _currentColor2: Color4;
  85222. /** @hidden */
  85223. _currentSizeGradient: Nullable<FactorGradient>;
  85224. /** @hidden */
  85225. _currentSize1: number;
  85226. /** @hidden */
  85227. _currentSize2: number;
  85228. /** @hidden */
  85229. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85230. /** @hidden */
  85231. _currentAngularSpeed1: number;
  85232. /** @hidden */
  85233. _currentAngularSpeed2: number;
  85234. /** @hidden */
  85235. _currentVelocityGradient: Nullable<FactorGradient>;
  85236. /** @hidden */
  85237. _currentVelocity1: number;
  85238. /** @hidden */
  85239. _currentVelocity2: number;
  85240. /** @hidden */
  85241. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85242. /** @hidden */
  85243. _currentLimitVelocity1: number;
  85244. /** @hidden */
  85245. _currentLimitVelocity2: number;
  85246. /** @hidden */
  85247. _currentDragGradient: Nullable<FactorGradient>;
  85248. /** @hidden */
  85249. _currentDrag1: number;
  85250. /** @hidden */
  85251. _currentDrag2: number;
  85252. /** @hidden */
  85253. _randomNoiseCoordinates1: Vector3;
  85254. /** @hidden */
  85255. _randomNoiseCoordinates2: Vector3;
  85256. /**
  85257. * Creates a new instance Particle
  85258. * @param particleSystem the particle system the particle belongs to
  85259. */
  85260. constructor(
  85261. /**
  85262. * The particle system the particle belongs to.
  85263. */
  85264. particleSystem: ParticleSystem);
  85265. private updateCellInfoFromSystem;
  85266. /**
  85267. * Defines how the sprite cell index is updated for the particle
  85268. */
  85269. updateCellIndex(): void;
  85270. /** @hidden */
  85271. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85272. /** @hidden */
  85273. _inheritParticleInfoToSubEmitters(): void;
  85274. /** @hidden */
  85275. _reset(): void;
  85276. /**
  85277. * Copy the properties of particle to another one.
  85278. * @param other the particle to copy the information to.
  85279. */
  85280. copyTo(other: Particle): void;
  85281. }
  85282. }
  85283. declare module BABYLON {
  85284. /**
  85285. * Particle emitter represents a volume emitting particles.
  85286. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85287. */
  85288. export interface IParticleEmitterType {
  85289. /**
  85290. * Called by the particle System when the direction is computed for the created particle.
  85291. * @param worldMatrix is the world matrix of the particle system
  85292. * @param directionToUpdate is the direction vector to update with the result
  85293. * @param particle is the particle we are computed the direction for
  85294. */
  85295. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85296. /**
  85297. * Called by the particle System when the position is computed for the created particle.
  85298. * @param worldMatrix is the world matrix of the particle system
  85299. * @param positionToUpdate is the position vector to update with the result
  85300. * @param particle is the particle we are computed the position for
  85301. */
  85302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85303. /**
  85304. * Clones the current emitter and returns a copy of it
  85305. * @returns the new emitter
  85306. */
  85307. clone(): IParticleEmitterType;
  85308. /**
  85309. * Called by the GPUParticleSystem to setup the update shader
  85310. * @param effect defines the update shader
  85311. */
  85312. applyToShader(effect: Effect): void;
  85313. /**
  85314. * Returns a string to use to update the GPU particles update shader
  85315. * @returns the effect defines string
  85316. */
  85317. getEffectDefines(): string;
  85318. /**
  85319. * Returns a string representing the class name
  85320. * @returns a string containing the class name
  85321. */
  85322. getClassName(): string;
  85323. /**
  85324. * Serializes the particle system to a JSON object.
  85325. * @returns the JSON object
  85326. */
  85327. serialize(): any;
  85328. /**
  85329. * Parse properties from a JSON object
  85330. * @param serializationObject defines the JSON object
  85331. * @param scene defines the hosting scene
  85332. */
  85333. parse(serializationObject: any, scene: Scene): void;
  85334. }
  85335. }
  85336. declare module BABYLON {
  85337. /**
  85338. * Particle emitter emitting particles from the inside of a box.
  85339. * It emits the particles randomly between 2 given directions.
  85340. */
  85341. export class BoxParticleEmitter implements IParticleEmitterType {
  85342. /**
  85343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85344. */
  85345. direction1: Vector3;
  85346. /**
  85347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85348. */
  85349. direction2: Vector3;
  85350. /**
  85351. * 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.
  85352. */
  85353. minEmitBox: Vector3;
  85354. /**
  85355. * 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.
  85356. */
  85357. maxEmitBox: Vector3;
  85358. /**
  85359. * Creates a new instance BoxParticleEmitter
  85360. */
  85361. constructor();
  85362. /**
  85363. * Called by the particle System when the direction is computed for the created particle.
  85364. * @param worldMatrix is the world matrix of the particle system
  85365. * @param directionToUpdate is the direction vector to update with the result
  85366. * @param particle is the particle we are computed the direction for
  85367. */
  85368. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85369. /**
  85370. * Called by the particle System when the position is computed for the created particle.
  85371. * @param worldMatrix is the world matrix of the particle system
  85372. * @param positionToUpdate is the position vector to update with the result
  85373. * @param particle is the particle we are computed the position for
  85374. */
  85375. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85376. /**
  85377. * Clones the current emitter and returns a copy of it
  85378. * @returns the new emitter
  85379. */
  85380. clone(): BoxParticleEmitter;
  85381. /**
  85382. * Called by the GPUParticleSystem to setup the update shader
  85383. * @param effect defines the update shader
  85384. */
  85385. applyToShader(effect: Effect): void;
  85386. /**
  85387. * Returns a string to use to update the GPU particles update shader
  85388. * @returns a string containng the defines string
  85389. */
  85390. getEffectDefines(): string;
  85391. /**
  85392. * Returns the string "BoxParticleEmitter"
  85393. * @returns a string containing the class name
  85394. */
  85395. getClassName(): string;
  85396. /**
  85397. * Serializes the particle system to a JSON object.
  85398. * @returns the JSON object
  85399. */
  85400. serialize(): any;
  85401. /**
  85402. * Parse properties from a JSON object
  85403. * @param serializationObject defines the JSON object
  85404. */
  85405. parse(serializationObject: any): void;
  85406. }
  85407. }
  85408. declare module BABYLON {
  85409. /**
  85410. * Particle emitter emitting particles from the inside of a cone.
  85411. * It emits the particles alongside the cone volume from the base to the particle.
  85412. * The emission direction might be randomized.
  85413. */
  85414. export class ConeParticleEmitter implements IParticleEmitterType {
  85415. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85416. directionRandomizer: number;
  85417. private _radius;
  85418. private _angle;
  85419. private _height;
  85420. /**
  85421. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85422. */
  85423. radiusRange: number;
  85424. /**
  85425. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85426. */
  85427. heightRange: number;
  85428. /**
  85429. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85430. */
  85431. emitFromSpawnPointOnly: boolean;
  85432. /**
  85433. * Gets or sets the radius of the emission cone
  85434. */
  85435. get radius(): number;
  85436. set radius(value: number);
  85437. /**
  85438. * Gets or sets the angle of the emission cone
  85439. */
  85440. get angle(): number;
  85441. set angle(value: number);
  85442. private _buildHeight;
  85443. /**
  85444. * Creates a new instance ConeParticleEmitter
  85445. * @param radius the radius of the emission cone (1 by default)
  85446. * @param angle the cone base angle (PI by default)
  85447. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85448. */
  85449. constructor(radius?: number, angle?: number,
  85450. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85451. directionRandomizer?: number);
  85452. /**
  85453. * Called by the particle System when the direction is computed for the created particle.
  85454. * @param worldMatrix is the world matrix of the particle system
  85455. * @param directionToUpdate is the direction vector to update with the result
  85456. * @param particle is the particle we are computed the direction for
  85457. */
  85458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85459. /**
  85460. * Called by the particle System when the position is computed for the created particle.
  85461. * @param worldMatrix is the world matrix of the particle system
  85462. * @param positionToUpdate is the position vector to update with the result
  85463. * @param particle is the particle we are computed the position for
  85464. */
  85465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85466. /**
  85467. * Clones the current emitter and returns a copy of it
  85468. * @returns the new emitter
  85469. */
  85470. clone(): ConeParticleEmitter;
  85471. /**
  85472. * Called by the GPUParticleSystem to setup the update shader
  85473. * @param effect defines the update shader
  85474. */
  85475. applyToShader(effect: Effect): void;
  85476. /**
  85477. * Returns a string to use to update the GPU particles update shader
  85478. * @returns a string containng the defines string
  85479. */
  85480. getEffectDefines(): string;
  85481. /**
  85482. * Returns the string "ConeParticleEmitter"
  85483. * @returns a string containing the class name
  85484. */
  85485. getClassName(): string;
  85486. /**
  85487. * Serializes the particle system to a JSON object.
  85488. * @returns the JSON object
  85489. */
  85490. serialize(): any;
  85491. /**
  85492. * Parse properties from a JSON object
  85493. * @param serializationObject defines the JSON object
  85494. */
  85495. parse(serializationObject: any): void;
  85496. }
  85497. }
  85498. declare module BABYLON {
  85499. /**
  85500. * Particle emitter emitting particles from the inside of a cylinder.
  85501. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85502. */
  85503. export class CylinderParticleEmitter implements IParticleEmitterType {
  85504. /**
  85505. * The radius of the emission cylinder.
  85506. */
  85507. radius: number;
  85508. /**
  85509. * The height of the emission cylinder.
  85510. */
  85511. height: number;
  85512. /**
  85513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85514. */
  85515. radiusRange: number;
  85516. /**
  85517. * How much to randomize the particle direction [0-1].
  85518. */
  85519. directionRandomizer: number;
  85520. /**
  85521. * Creates a new instance CylinderParticleEmitter
  85522. * @param radius the radius of the emission cylinder (1 by default)
  85523. * @param height the height of the emission cylinder (1 by default)
  85524. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85525. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85526. */
  85527. constructor(
  85528. /**
  85529. * The radius of the emission cylinder.
  85530. */
  85531. radius?: number,
  85532. /**
  85533. * The height of the emission cylinder.
  85534. */
  85535. height?: number,
  85536. /**
  85537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85538. */
  85539. radiusRange?: number,
  85540. /**
  85541. * How much to randomize the particle direction [0-1].
  85542. */
  85543. directionRandomizer?: number);
  85544. /**
  85545. * Called by the particle System when the direction is computed for the created particle.
  85546. * @param worldMatrix is the world matrix of the particle system
  85547. * @param directionToUpdate is the direction vector to update with the result
  85548. * @param particle is the particle we are computed the direction for
  85549. */
  85550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85551. /**
  85552. * Called by the particle System when the position is computed for the created particle.
  85553. * @param worldMatrix is the world matrix of the particle system
  85554. * @param positionToUpdate is the position vector to update with the result
  85555. * @param particle is the particle we are computed the position for
  85556. */
  85557. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85558. /**
  85559. * Clones the current emitter and returns a copy of it
  85560. * @returns the new emitter
  85561. */
  85562. clone(): CylinderParticleEmitter;
  85563. /**
  85564. * Called by the GPUParticleSystem to setup the update shader
  85565. * @param effect defines the update shader
  85566. */
  85567. applyToShader(effect: Effect): void;
  85568. /**
  85569. * Returns a string to use to update the GPU particles update shader
  85570. * @returns a string containng the defines string
  85571. */
  85572. getEffectDefines(): string;
  85573. /**
  85574. * Returns the string "CylinderParticleEmitter"
  85575. * @returns a string containing the class name
  85576. */
  85577. getClassName(): string;
  85578. /**
  85579. * Serializes the particle system to a JSON object.
  85580. * @returns the JSON object
  85581. */
  85582. serialize(): any;
  85583. /**
  85584. * Parse properties from a JSON object
  85585. * @param serializationObject defines the JSON object
  85586. */
  85587. parse(serializationObject: any): void;
  85588. }
  85589. /**
  85590. * Particle emitter emitting particles from the inside of a cylinder.
  85591. * It emits the particles randomly between two vectors.
  85592. */
  85593. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85594. /**
  85595. * The min limit of the emission direction.
  85596. */
  85597. direction1: Vector3;
  85598. /**
  85599. * The max limit of the emission direction.
  85600. */
  85601. direction2: Vector3;
  85602. /**
  85603. * Creates a new instance CylinderDirectedParticleEmitter
  85604. * @param radius the radius of the emission cylinder (1 by default)
  85605. * @param height the height of the emission cylinder (1 by default)
  85606. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85607. * @param direction1 the min limit of the emission direction (up vector by default)
  85608. * @param direction2 the max limit of the emission direction (up vector by default)
  85609. */
  85610. constructor(radius?: number, height?: number, radiusRange?: number,
  85611. /**
  85612. * The min limit of the emission direction.
  85613. */
  85614. direction1?: Vector3,
  85615. /**
  85616. * The max limit of the emission direction.
  85617. */
  85618. direction2?: Vector3);
  85619. /**
  85620. * Called by the particle System when the direction is computed for the created particle.
  85621. * @param worldMatrix is the world matrix of the particle system
  85622. * @param directionToUpdate is the direction vector to update with the result
  85623. * @param particle is the particle we are computed the direction for
  85624. */
  85625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85626. /**
  85627. * Clones the current emitter and returns a copy of it
  85628. * @returns the new emitter
  85629. */
  85630. clone(): CylinderDirectedParticleEmitter;
  85631. /**
  85632. * Called by the GPUParticleSystem to setup the update shader
  85633. * @param effect defines the update shader
  85634. */
  85635. applyToShader(effect: Effect): void;
  85636. /**
  85637. * Returns a string to use to update the GPU particles update shader
  85638. * @returns a string containng the defines string
  85639. */
  85640. getEffectDefines(): string;
  85641. /**
  85642. * Returns the string "CylinderDirectedParticleEmitter"
  85643. * @returns a string containing the class name
  85644. */
  85645. getClassName(): string;
  85646. /**
  85647. * Serializes the particle system to a JSON object.
  85648. * @returns the JSON object
  85649. */
  85650. serialize(): any;
  85651. /**
  85652. * Parse properties from a JSON object
  85653. * @param serializationObject defines the JSON object
  85654. */
  85655. parse(serializationObject: any): void;
  85656. }
  85657. }
  85658. declare module BABYLON {
  85659. /**
  85660. * Particle emitter emitting particles from the inside of a hemisphere.
  85661. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85662. */
  85663. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85664. /**
  85665. * The radius of the emission hemisphere.
  85666. */
  85667. radius: number;
  85668. /**
  85669. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85670. */
  85671. radiusRange: number;
  85672. /**
  85673. * How much to randomize the particle direction [0-1].
  85674. */
  85675. directionRandomizer: number;
  85676. /**
  85677. * Creates a new instance HemisphericParticleEmitter
  85678. * @param radius the radius of the emission hemisphere (1 by default)
  85679. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85680. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85681. */
  85682. constructor(
  85683. /**
  85684. * The radius of the emission hemisphere.
  85685. */
  85686. radius?: number,
  85687. /**
  85688. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85689. */
  85690. radiusRange?: number,
  85691. /**
  85692. * How much to randomize the particle direction [0-1].
  85693. */
  85694. directionRandomizer?: number);
  85695. /**
  85696. * Called by the particle System when the direction is computed for the created particle.
  85697. * @param worldMatrix is the world matrix of the particle system
  85698. * @param directionToUpdate is the direction vector to update with the result
  85699. * @param particle is the particle we are computed the direction for
  85700. */
  85701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85702. /**
  85703. * Called by the particle System when the position is computed for the created particle.
  85704. * @param worldMatrix is the world matrix of the particle system
  85705. * @param positionToUpdate is the position vector to update with the result
  85706. * @param particle is the particle we are computed the position for
  85707. */
  85708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85709. /**
  85710. * Clones the current emitter and returns a copy of it
  85711. * @returns the new emitter
  85712. */
  85713. clone(): HemisphericParticleEmitter;
  85714. /**
  85715. * Called by the GPUParticleSystem to setup the update shader
  85716. * @param effect defines the update shader
  85717. */
  85718. applyToShader(effect: Effect): void;
  85719. /**
  85720. * Returns a string to use to update the GPU particles update shader
  85721. * @returns a string containng the defines string
  85722. */
  85723. getEffectDefines(): string;
  85724. /**
  85725. * Returns the string "HemisphericParticleEmitter"
  85726. * @returns a string containing the class name
  85727. */
  85728. getClassName(): string;
  85729. /**
  85730. * Serializes the particle system to a JSON object.
  85731. * @returns the JSON object
  85732. */
  85733. serialize(): any;
  85734. /**
  85735. * Parse properties from a JSON object
  85736. * @param serializationObject defines the JSON object
  85737. */
  85738. parse(serializationObject: any): void;
  85739. }
  85740. }
  85741. declare module BABYLON {
  85742. /**
  85743. * Particle emitter emitting particles from a point.
  85744. * It emits the particles randomly between 2 given directions.
  85745. */
  85746. export class PointParticleEmitter implements IParticleEmitterType {
  85747. /**
  85748. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85749. */
  85750. direction1: Vector3;
  85751. /**
  85752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85753. */
  85754. direction2: Vector3;
  85755. /**
  85756. * Creates a new instance PointParticleEmitter
  85757. */
  85758. constructor();
  85759. /**
  85760. * Called by the particle System when the direction is computed for the created particle.
  85761. * @param worldMatrix is the world matrix of the particle system
  85762. * @param directionToUpdate is the direction vector to update with the result
  85763. * @param particle is the particle we are computed the direction for
  85764. */
  85765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85766. /**
  85767. * Called by the particle System when the position is computed for the created particle.
  85768. * @param worldMatrix is the world matrix of the particle system
  85769. * @param positionToUpdate is the position vector to update with the result
  85770. * @param particle is the particle we are computed the position for
  85771. */
  85772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85773. /**
  85774. * Clones the current emitter and returns a copy of it
  85775. * @returns the new emitter
  85776. */
  85777. clone(): PointParticleEmitter;
  85778. /**
  85779. * Called by the GPUParticleSystem to setup the update shader
  85780. * @param effect defines the update shader
  85781. */
  85782. applyToShader(effect: Effect): void;
  85783. /**
  85784. * Returns a string to use to update the GPU particles update shader
  85785. * @returns a string containng the defines string
  85786. */
  85787. getEffectDefines(): string;
  85788. /**
  85789. * Returns the string "PointParticleEmitter"
  85790. * @returns a string containing the class name
  85791. */
  85792. getClassName(): string;
  85793. /**
  85794. * Serializes the particle system to a JSON object.
  85795. * @returns the JSON object
  85796. */
  85797. serialize(): any;
  85798. /**
  85799. * Parse properties from a JSON object
  85800. * @param serializationObject defines the JSON object
  85801. */
  85802. parse(serializationObject: any): void;
  85803. }
  85804. }
  85805. declare module BABYLON {
  85806. /**
  85807. * Particle emitter emitting particles from the inside of a sphere.
  85808. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85809. */
  85810. export class SphereParticleEmitter implements IParticleEmitterType {
  85811. /**
  85812. * The radius of the emission sphere.
  85813. */
  85814. radius: number;
  85815. /**
  85816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85817. */
  85818. radiusRange: number;
  85819. /**
  85820. * How much to randomize the particle direction [0-1].
  85821. */
  85822. directionRandomizer: number;
  85823. /**
  85824. * Creates a new instance SphereParticleEmitter
  85825. * @param radius the radius of the emission sphere (1 by default)
  85826. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85827. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85828. */
  85829. constructor(
  85830. /**
  85831. * The radius of the emission sphere.
  85832. */
  85833. radius?: number,
  85834. /**
  85835. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85836. */
  85837. radiusRange?: number,
  85838. /**
  85839. * How much to randomize the particle direction [0-1].
  85840. */
  85841. directionRandomizer?: number);
  85842. /**
  85843. * Called by the particle System when the direction is computed for the created particle.
  85844. * @param worldMatrix is the world matrix of the particle system
  85845. * @param directionToUpdate is the direction vector to update with the result
  85846. * @param particle is the particle we are computed the direction for
  85847. */
  85848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85849. /**
  85850. * Called by the particle System when the position is computed for the created particle.
  85851. * @param worldMatrix is the world matrix of the particle system
  85852. * @param positionToUpdate is the position vector to update with the result
  85853. * @param particle is the particle we are computed the position for
  85854. */
  85855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85856. /**
  85857. * Clones the current emitter and returns a copy of it
  85858. * @returns the new emitter
  85859. */
  85860. clone(): SphereParticleEmitter;
  85861. /**
  85862. * Called by the GPUParticleSystem to setup the update shader
  85863. * @param effect defines the update shader
  85864. */
  85865. applyToShader(effect: Effect): void;
  85866. /**
  85867. * Returns a string to use to update the GPU particles update shader
  85868. * @returns a string containng the defines string
  85869. */
  85870. getEffectDefines(): string;
  85871. /**
  85872. * Returns the string "SphereParticleEmitter"
  85873. * @returns a string containing the class name
  85874. */
  85875. getClassName(): string;
  85876. /**
  85877. * Serializes the particle system to a JSON object.
  85878. * @returns the JSON object
  85879. */
  85880. serialize(): any;
  85881. /**
  85882. * Parse properties from a JSON object
  85883. * @param serializationObject defines the JSON object
  85884. */
  85885. parse(serializationObject: any): void;
  85886. }
  85887. /**
  85888. * Particle emitter emitting particles from the inside of a sphere.
  85889. * It emits the particles randomly between two vectors.
  85890. */
  85891. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85892. /**
  85893. * The min limit of the emission direction.
  85894. */
  85895. direction1: Vector3;
  85896. /**
  85897. * The max limit of the emission direction.
  85898. */
  85899. direction2: Vector3;
  85900. /**
  85901. * Creates a new instance SphereDirectedParticleEmitter
  85902. * @param radius the radius of the emission sphere (1 by default)
  85903. * @param direction1 the min limit of the emission direction (up vector by default)
  85904. * @param direction2 the max limit of the emission direction (up vector by default)
  85905. */
  85906. constructor(radius?: number,
  85907. /**
  85908. * The min limit of the emission direction.
  85909. */
  85910. direction1?: Vector3,
  85911. /**
  85912. * The max limit of the emission direction.
  85913. */
  85914. direction2?: Vector3);
  85915. /**
  85916. * Called by the particle System when the direction is computed for the created particle.
  85917. * @param worldMatrix is the world matrix of the particle system
  85918. * @param directionToUpdate is the direction vector to update with the result
  85919. * @param particle is the particle we are computed the direction for
  85920. */
  85921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85922. /**
  85923. * Clones the current emitter and returns a copy of it
  85924. * @returns the new emitter
  85925. */
  85926. clone(): SphereDirectedParticleEmitter;
  85927. /**
  85928. * Called by the GPUParticleSystem to setup the update shader
  85929. * @param effect defines the update shader
  85930. */
  85931. applyToShader(effect: Effect): void;
  85932. /**
  85933. * Returns a string to use to update the GPU particles update shader
  85934. * @returns a string containng the defines string
  85935. */
  85936. getEffectDefines(): string;
  85937. /**
  85938. * Returns the string "SphereDirectedParticleEmitter"
  85939. * @returns a string containing the class name
  85940. */
  85941. getClassName(): string;
  85942. /**
  85943. * Serializes the particle system to a JSON object.
  85944. * @returns the JSON object
  85945. */
  85946. serialize(): any;
  85947. /**
  85948. * Parse properties from a JSON object
  85949. * @param serializationObject defines the JSON object
  85950. */
  85951. parse(serializationObject: any): void;
  85952. }
  85953. }
  85954. declare module BABYLON {
  85955. /**
  85956. * Particle emitter emitting particles from a custom list of positions.
  85957. */
  85958. export class CustomParticleEmitter implements IParticleEmitterType {
  85959. /**
  85960. * Gets or sets the position generator that will create the inital position of each particle.
  85961. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85962. */
  85963. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  85964. /**
  85965. * Gets or sets the destination generator that will create the final destination of each particle.
  85966. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85967. */
  85968. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  85969. /**
  85970. * Creates a new instance CustomParticleEmitter
  85971. */
  85972. constructor();
  85973. /**
  85974. * Called by the particle System when the direction is computed for the created particle.
  85975. * @param worldMatrix is the world matrix of the particle system
  85976. * @param directionToUpdate is the direction vector to update with the result
  85977. * @param particle is the particle we are computed the direction for
  85978. */
  85979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85980. /**
  85981. * Called by the particle System when the position is computed for the created particle.
  85982. * @param worldMatrix is the world matrix of the particle system
  85983. * @param positionToUpdate is the position vector to update with the result
  85984. * @param particle is the particle we are computed the position for
  85985. */
  85986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85987. /**
  85988. * Clones the current emitter and returns a copy of it
  85989. * @returns the new emitter
  85990. */
  85991. clone(): CustomParticleEmitter;
  85992. /**
  85993. * Called by the GPUParticleSystem to setup the update shader
  85994. * @param effect defines the update shader
  85995. */
  85996. applyToShader(effect: Effect): void;
  85997. /**
  85998. * Returns a string to use to update the GPU particles update shader
  85999. * @returns a string containng the defines string
  86000. */
  86001. getEffectDefines(): string;
  86002. /**
  86003. * Returns the string "PointParticleEmitter"
  86004. * @returns a string containing the class name
  86005. */
  86006. getClassName(): string;
  86007. /**
  86008. * Serializes the particle system to a JSON object.
  86009. * @returns the JSON object
  86010. */
  86011. serialize(): any;
  86012. /**
  86013. * Parse properties from a JSON object
  86014. * @param serializationObject defines the JSON object
  86015. */
  86016. parse(serializationObject: any): void;
  86017. }
  86018. }
  86019. declare module BABYLON {
  86020. /**
  86021. * Particle emitter emitting particles from the inside of a box.
  86022. * It emits the particles randomly between 2 given directions.
  86023. */
  86024. export class MeshParticleEmitter implements IParticleEmitterType {
  86025. /** Defines the mesh to use as source */
  86026. mesh?: AbstractMesh | undefined;
  86027. private _indices;
  86028. private _positions;
  86029. private _normals;
  86030. private _storedNormal;
  86031. /**
  86032. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86033. */
  86034. direction1: Vector3;
  86035. /**
  86036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86037. */
  86038. direction2: Vector3;
  86039. /**
  86040. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86041. */
  86042. useMeshNormalsForDirection: boolean;
  86043. /**
  86044. * Creates a new instance MeshParticleEmitter
  86045. * @param mesh defines the mesh to use as source
  86046. */
  86047. constructor(
  86048. /** Defines the mesh to use as source */
  86049. mesh?: AbstractMesh | undefined);
  86050. /**
  86051. * Called by the particle System when the direction is computed for the created particle.
  86052. * @param worldMatrix is the world matrix of the particle system
  86053. * @param directionToUpdate is the direction vector to update with the result
  86054. * @param particle is the particle we are computed the direction for
  86055. */
  86056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86057. /**
  86058. * Called by the particle System when the position is computed for the created particle.
  86059. * @param worldMatrix is the world matrix of the particle system
  86060. * @param positionToUpdate is the position vector to update with the result
  86061. * @param particle is the particle we are computed the position for
  86062. */
  86063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86064. /**
  86065. * Clones the current emitter and returns a copy of it
  86066. * @returns the new emitter
  86067. */
  86068. clone(): MeshParticleEmitter;
  86069. /**
  86070. * Called by the GPUParticleSystem to setup the update shader
  86071. * @param effect defines the update shader
  86072. */
  86073. applyToShader(effect: Effect): void;
  86074. /**
  86075. * Returns a string to use to update the GPU particles update shader
  86076. * @returns a string containng the defines string
  86077. */
  86078. getEffectDefines(): string;
  86079. /**
  86080. * Returns the string "BoxParticleEmitter"
  86081. * @returns a string containing the class name
  86082. */
  86083. getClassName(): string;
  86084. /**
  86085. * Serializes the particle system to a JSON object.
  86086. * @returns the JSON object
  86087. */
  86088. serialize(): any;
  86089. /**
  86090. * Parse properties from a JSON object
  86091. * @param serializationObject defines the JSON object
  86092. * @param scene defines the hosting scene
  86093. */
  86094. parse(serializationObject: any, scene: Scene): void;
  86095. }
  86096. }
  86097. declare module BABYLON {
  86098. /**
  86099. * Interface representing a particle system in Babylon.js.
  86100. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86101. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86102. */
  86103. export interface IParticleSystem {
  86104. /**
  86105. * List of animations used by the particle system.
  86106. */
  86107. animations: Animation[];
  86108. /**
  86109. * The id of the Particle system.
  86110. */
  86111. id: string;
  86112. /**
  86113. * The name of the Particle system.
  86114. */
  86115. name: string;
  86116. /**
  86117. * The emitter represents the Mesh or position we are attaching the particle system to.
  86118. */
  86119. emitter: Nullable<AbstractMesh | Vector3>;
  86120. /**
  86121. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86122. */
  86123. isBillboardBased: boolean;
  86124. /**
  86125. * The rendering group used by the Particle system to chose when to render.
  86126. */
  86127. renderingGroupId: number;
  86128. /**
  86129. * The layer mask we are rendering the particles through.
  86130. */
  86131. layerMask: number;
  86132. /**
  86133. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86134. */
  86135. updateSpeed: number;
  86136. /**
  86137. * The amount of time the particle system is running (depends of the overall update speed).
  86138. */
  86139. targetStopDuration: number;
  86140. /**
  86141. * The texture used to render each particle. (this can be a spritesheet)
  86142. */
  86143. particleTexture: Nullable<Texture>;
  86144. /**
  86145. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86146. */
  86147. blendMode: number;
  86148. /**
  86149. * Minimum life time of emitting particles.
  86150. */
  86151. minLifeTime: number;
  86152. /**
  86153. * Maximum life time of emitting particles.
  86154. */
  86155. maxLifeTime: number;
  86156. /**
  86157. * Minimum Size of emitting particles.
  86158. */
  86159. minSize: number;
  86160. /**
  86161. * Maximum Size of emitting particles.
  86162. */
  86163. maxSize: number;
  86164. /**
  86165. * Minimum scale of emitting particles on X axis.
  86166. */
  86167. minScaleX: number;
  86168. /**
  86169. * Maximum scale of emitting particles on X axis.
  86170. */
  86171. maxScaleX: number;
  86172. /**
  86173. * Minimum scale of emitting particles on Y axis.
  86174. */
  86175. minScaleY: number;
  86176. /**
  86177. * Maximum scale of emitting particles on Y axis.
  86178. */
  86179. maxScaleY: number;
  86180. /**
  86181. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86182. */
  86183. color1: Color4;
  86184. /**
  86185. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86186. */
  86187. color2: Color4;
  86188. /**
  86189. * Color the particle will have at the end of its lifetime.
  86190. */
  86191. colorDead: Color4;
  86192. /**
  86193. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86194. */
  86195. emitRate: number;
  86196. /**
  86197. * You can use gravity if you want to give an orientation to your particles.
  86198. */
  86199. gravity: Vector3;
  86200. /**
  86201. * Minimum power of emitting particles.
  86202. */
  86203. minEmitPower: number;
  86204. /**
  86205. * Maximum power of emitting particles.
  86206. */
  86207. maxEmitPower: number;
  86208. /**
  86209. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86210. */
  86211. minAngularSpeed: number;
  86212. /**
  86213. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86214. */
  86215. maxAngularSpeed: number;
  86216. /**
  86217. * Gets or sets the minimal initial rotation in radians.
  86218. */
  86219. minInitialRotation: number;
  86220. /**
  86221. * Gets or sets the maximal initial rotation in radians.
  86222. */
  86223. maxInitialRotation: number;
  86224. /**
  86225. * The particle emitter type defines the emitter used by the particle system.
  86226. * It can be for example box, sphere, or cone...
  86227. */
  86228. particleEmitterType: Nullable<IParticleEmitterType>;
  86229. /**
  86230. * Defines the delay in milliseconds before starting the system (0 by default)
  86231. */
  86232. startDelay: number;
  86233. /**
  86234. * 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
  86235. */
  86236. preWarmCycles: number;
  86237. /**
  86238. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86239. */
  86240. preWarmStepOffset: number;
  86241. /**
  86242. * 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)
  86243. */
  86244. spriteCellChangeSpeed: number;
  86245. /**
  86246. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86247. */
  86248. startSpriteCellID: number;
  86249. /**
  86250. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86251. */
  86252. endSpriteCellID: number;
  86253. /**
  86254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86255. */
  86256. spriteCellWidth: number;
  86257. /**
  86258. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86259. */
  86260. spriteCellHeight: number;
  86261. /**
  86262. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86263. */
  86264. spriteRandomStartCell: boolean;
  86265. /**
  86266. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86267. */
  86268. isAnimationSheetEnabled: boolean;
  86269. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86270. translationPivot: Vector2;
  86271. /**
  86272. * Gets or sets a texture used to add random noise to particle positions
  86273. */
  86274. noiseTexture: Nullable<BaseTexture>;
  86275. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86276. noiseStrength: Vector3;
  86277. /**
  86278. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86279. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86280. */
  86281. billboardMode: number;
  86282. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86283. limitVelocityDamping: number;
  86284. /**
  86285. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86286. */
  86287. beginAnimationOnStart: boolean;
  86288. /**
  86289. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86290. */
  86291. beginAnimationFrom: number;
  86292. /**
  86293. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86294. */
  86295. beginAnimationTo: number;
  86296. /**
  86297. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86298. */
  86299. beginAnimationLoop: boolean;
  86300. /**
  86301. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86302. */
  86303. disposeOnStop: boolean;
  86304. /**
  86305. * Gets the maximum number of particles active at the same time.
  86306. * @returns The max number of active particles.
  86307. */
  86308. getCapacity(): number;
  86309. /**
  86310. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86311. * @returns True if it has been started, otherwise false.
  86312. */
  86313. isStarted(): boolean;
  86314. /**
  86315. * Animates the particle system for this frame.
  86316. */
  86317. animate(): void;
  86318. /**
  86319. * Renders the particle system in its current state.
  86320. * @returns the current number of particles
  86321. */
  86322. render(): number;
  86323. /**
  86324. * Dispose the particle system and frees its associated resources.
  86325. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86326. */
  86327. dispose(disposeTexture?: boolean): void;
  86328. /**
  86329. * Clones the particle system.
  86330. * @param name The name of the cloned object
  86331. * @param newEmitter The new emitter to use
  86332. * @returns the cloned particle system
  86333. */
  86334. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86335. /**
  86336. * Serializes the particle system to a JSON object.
  86337. * @returns the JSON object
  86338. */
  86339. serialize(): any;
  86340. /**
  86341. * Rebuild the particle system
  86342. */
  86343. rebuild(): void;
  86344. /**
  86345. * Starts the particle system and begins to emit
  86346. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86347. */
  86348. start(delay?: number): void;
  86349. /**
  86350. * Stops the particle system.
  86351. */
  86352. stop(): void;
  86353. /**
  86354. * Remove all active particles
  86355. */
  86356. reset(): void;
  86357. /**
  86358. * Is this system ready to be used/rendered
  86359. * @return true if the system is ready
  86360. */
  86361. isReady(): boolean;
  86362. /**
  86363. * Adds a new color gradient
  86364. * @param gradient defines the gradient to use (between 0 and 1)
  86365. * @param color1 defines the color to affect to the specified gradient
  86366. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86367. * @returns the current particle system
  86368. */
  86369. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86370. /**
  86371. * Remove a specific color gradient
  86372. * @param gradient defines the gradient to remove
  86373. * @returns the current particle system
  86374. */
  86375. removeColorGradient(gradient: number): IParticleSystem;
  86376. /**
  86377. * Adds a new size gradient
  86378. * @param gradient defines the gradient to use (between 0 and 1)
  86379. * @param factor defines the size factor to affect to the specified gradient
  86380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86381. * @returns the current particle system
  86382. */
  86383. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86384. /**
  86385. * Remove a specific size gradient
  86386. * @param gradient defines the gradient to remove
  86387. * @returns the current particle system
  86388. */
  86389. removeSizeGradient(gradient: number): IParticleSystem;
  86390. /**
  86391. * Gets the current list of color gradients.
  86392. * You must use addColorGradient and removeColorGradient to udpate this list
  86393. * @returns the list of color gradients
  86394. */
  86395. getColorGradients(): Nullable<Array<ColorGradient>>;
  86396. /**
  86397. * Gets the current list of size gradients.
  86398. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86399. * @returns the list of size gradients
  86400. */
  86401. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86402. /**
  86403. * Gets the current list of angular speed gradients.
  86404. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86405. * @returns the list of angular speed gradients
  86406. */
  86407. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86408. /**
  86409. * Adds a new angular speed gradient
  86410. * @param gradient defines the gradient to use (between 0 and 1)
  86411. * @param factor defines the angular speed to affect to the specified gradient
  86412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86413. * @returns the current particle system
  86414. */
  86415. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86416. /**
  86417. * Remove a specific angular speed gradient
  86418. * @param gradient defines the gradient to remove
  86419. * @returns the current particle system
  86420. */
  86421. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86422. /**
  86423. * Gets the current list of velocity gradients.
  86424. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86425. * @returns the list of velocity gradients
  86426. */
  86427. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86428. /**
  86429. * Adds a new velocity gradient
  86430. * @param gradient defines the gradient to use (between 0 and 1)
  86431. * @param factor defines the velocity to affect to the specified gradient
  86432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86433. * @returns the current particle system
  86434. */
  86435. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86436. /**
  86437. * Remove a specific velocity gradient
  86438. * @param gradient defines the gradient to remove
  86439. * @returns the current particle system
  86440. */
  86441. removeVelocityGradient(gradient: number): IParticleSystem;
  86442. /**
  86443. * Gets the current list of limit velocity gradients.
  86444. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86445. * @returns the list of limit velocity gradients
  86446. */
  86447. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86448. /**
  86449. * Adds a new limit velocity gradient
  86450. * @param gradient defines the gradient to use (between 0 and 1)
  86451. * @param factor defines the limit velocity to affect to the specified gradient
  86452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86453. * @returns the current particle system
  86454. */
  86455. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86456. /**
  86457. * Remove a specific limit velocity gradient
  86458. * @param gradient defines the gradient to remove
  86459. * @returns the current particle system
  86460. */
  86461. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86462. /**
  86463. * Adds a new drag gradient
  86464. * @param gradient defines the gradient to use (between 0 and 1)
  86465. * @param factor defines the drag to affect to the specified gradient
  86466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86467. * @returns the current particle system
  86468. */
  86469. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86470. /**
  86471. * Remove a specific drag gradient
  86472. * @param gradient defines the gradient to remove
  86473. * @returns the current particle system
  86474. */
  86475. removeDragGradient(gradient: number): IParticleSystem;
  86476. /**
  86477. * Gets the current list of drag gradients.
  86478. * You must use addDragGradient and removeDragGradient to udpate this list
  86479. * @returns the list of drag gradients
  86480. */
  86481. getDragGradients(): Nullable<Array<FactorGradient>>;
  86482. /**
  86483. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86484. * @param gradient defines the gradient to use (between 0 and 1)
  86485. * @param factor defines the emit rate to affect to the specified gradient
  86486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86487. * @returns the current particle system
  86488. */
  86489. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86490. /**
  86491. * Remove a specific emit rate gradient
  86492. * @param gradient defines the gradient to remove
  86493. * @returns the current particle system
  86494. */
  86495. removeEmitRateGradient(gradient: number): IParticleSystem;
  86496. /**
  86497. * Gets the current list of emit rate gradients.
  86498. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86499. * @returns the list of emit rate gradients
  86500. */
  86501. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86502. /**
  86503. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86504. * @param gradient defines the gradient to use (between 0 and 1)
  86505. * @param factor defines the start size to affect to the specified gradient
  86506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86507. * @returns the current particle system
  86508. */
  86509. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86510. /**
  86511. * Remove a specific start size gradient
  86512. * @param gradient defines the gradient to remove
  86513. * @returns the current particle system
  86514. */
  86515. removeStartSizeGradient(gradient: number): IParticleSystem;
  86516. /**
  86517. * Gets the current list of start size gradients.
  86518. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86519. * @returns the list of start size gradients
  86520. */
  86521. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86522. /**
  86523. * Adds a new life time gradient
  86524. * @param gradient defines the gradient to use (between 0 and 1)
  86525. * @param factor defines the life time factor to affect to the specified gradient
  86526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86527. * @returns the current particle system
  86528. */
  86529. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86530. /**
  86531. * Remove a specific life time gradient
  86532. * @param gradient defines the gradient to remove
  86533. * @returns the current particle system
  86534. */
  86535. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86536. /**
  86537. * Gets the current list of life time gradients.
  86538. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86539. * @returns the list of life time gradients
  86540. */
  86541. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86542. /**
  86543. * Gets the current list of color gradients.
  86544. * You must use addColorGradient and removeColorGradient to udpate this list
  86545. * @returns the list of color gradients
  86546. */
  86547. getColorGradients(): Nullable<Array<ColorGradient>>;
  86548. /**
  86549. * Adds a new ramp gradient used to remap particle colors
  86550. * @param gradient defines the gradient to use (between 0 and 1)
  86551. * @param color defines the color to affect to the specified gradient
  86552. * @returns the current particle system
  86553. */
  86554. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86555. /**
  86556. * Gets the current list of ramp gradients.
  86557. * You must use addRampGradient and removeRampGradient to udpate this list
  86558. * @returns the list of ramp gradients
  86559. */
  86560. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86561. /** Gets or sets a boolean indicating that ramp gradients must be used
  86562. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86563. */
  86564. useRampGradients: boolean;
  86565. /**
  86566. * Adds a new color remap gradient
  86567. * @param gradient defines the gradient to use (between 0 and 1)
  86568. * @param min defines the color remap minimal range
  86569. * @param max defines the color remap maximal range
  86570. * @returns the current particle system
  86571. */
  86572. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86573. /**
  86574. * Gets the current list of color remap gradients.
  86575. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86576. * @returns the list of color remap gradients
  86577. */
  86578. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86579. /**
  86580. * Adds a new alpha remap gradient
  86581. * @param gradient defines the gradient to use (between 0 and 1)
  86582. * @param min defines the alpha remap minimal range
  86583. * @param max defines the alpha remap maximal range
  86584. * @returns the current particle system
  86585. */
  86586. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86587. /**
  86588. * Gets the current list of alpha remap gradients.
  86589. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86590. * @returns the list of alpha remap gradients
  86591. */
  86592. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86593. /**
  86594. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86597. * @returns the emitter
  86598. */
  86599. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86600. /**
  86601. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86602. * @param radius The radius of the hemisphere to emit from
  86603. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86604. * @returns the emitter
  86605. */
  86606. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86607. /**
  86608. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86609. * @param radius The radius of the sphere to emit from
  86610. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86611. * @returns the emitter
  86612. */
  86613. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86614. /**
  86615. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86616. * @param radius The radius of the sphere to emit from
  86617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86619. * @returns the emitter
  86620. */
  86621. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86622. /**
  86623. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86624. * @param radius The radius of the emission cylinder
  86625. * @param height The height of the emission cylinder
  86626. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86627. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86628. * @returns the emitter
  86629. */
  86630. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86631. /**
  86632. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86633. * @param radius The radius of the cylinder to emit from
  86634. * @param height The height of the emission cylinder
  86635. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86638. * @returns the emitter
  86639. */
  86640. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86641. /**
  86642. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86643. * @param radius The radius of the cone to emit from
  86644. * @param angle The base angle of the cone
  86645. * @returns the emitter
  86646. */
  86647. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86648. /**
  86649. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86652. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86653. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86654. * @returns the emitter
  86655. */
  86656. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86657. /**
  86658. * Get hosting scene
  86659. * @returns the scene
  86660. */
  86661. getScene(): Scene;
  86662. }
  86663. }
  86664. declare module BABYLON {
  86665. /**
  86666. * 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.
  86667. * @see https://doc.babylonjs.com/how_to/transformnode
  86668. */
  86669. export class TransformNode extends Node {
  86670. /**
  86671. * Object will not rotate to face the camera
  86672. */
  86673. static BILLBOARDMODE_NONE: number;
  86674. /**
  86675. * Object will rotate to face the camera but only on the x axis
  86676. */
  86677. static BILLBOARDMODE_X: number;
  86678. /**
  86679. * Object will rotate to face the camera but only on the y axis
  86680. */
  86681. static BILLBOARDMODE_Y: number;
  86682. /**
  86683. * Object will rotate to face the camera but only on the z axis
  86684. */
  86685. static BILLBOARDMODE_Z: number;
  86686. /**
  86687. * Object will rotate to face the camera
  86688. */
  86689. static BILLBOARDMODE_ALL: number;
  86690. /**
  86691. * Object will rotate to face the camera's position instead of orientation
  86692. */
  86693. static BILLBOARDMODE_USE_POSITION: number;
  86694. private _forward;
  86695. private _forwardInverted;
  86696. private _up;
  86697. private _right;
  86698. private _rightInverted;
  86699. private _position;
  86700. private _rotation;
  86701. private _rotationQuaternion;
  86702. protected _scaling: Vector3;
  86703. protected _isDirty: boolean;
  86704. private _transformToBoneReferal;
  86705. private _isAbsoluteSynced;
  86706. private _billboardMode;
  86707. /**
  86708. * Gets or sets the billboard mode. Default is 0.
  86709. *
  86710. * | Value | Type | Description |
  86711. * | --- | --- | --- |
  86712. * | 0 | BILLBOARDMODE_NONE | |
  86713. * | 1 | BILLBOARDMODE_X | |
  86714. * | 2 | BILLBOARDMODE_Y | |
  86715. * | 4 | BILLBOARDMODE_Z | |
  86716. * | 7 | BILLBOARDMODE_ALL | |
  86717. *
  86718. */
  86719. get billboardMode(): number;
  86720. set billboardMode(value: number);
  86721. private _preserveParentRotationForBillboard;
  86722. /**
  86723. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86724. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86725. */
  86726. get preserveParentRotationForBillboard(): boolean;
  86727. set preserveParentRotationForBillboard(value: boolean);
  86728. /**
  86729. * 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
  86730. */
  86731. scalingDeterminant: number;
  86732. private _infiniteDistance;
  86733. /**
  86734. * Gets or sets the distance of the object to max, often used by skybox
  86735. */
  86736. get infiniteDistance(): boolean;
  86737. set infiniteDistance(value: boolean);
  86738. /**
  86739. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86740. * By default the system will update normals to compensate
  86741. */
  86742. ignoreNonUniformScaling: boolean;
  86743. /**
  86744. * 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
  86745. */
  86746. reIntegrateRotationIntoRotationQuaternion: boolean;
  86747. /** @hidden */
  86748. _poseMatrix: Nullable<Matrix>;
  86749. /** @hidden */
  86750. _localMatrix: Matrix;
  86751. private _usePivotMatrix;
  86752. private _absolutePosition;
  86753. private _absoluteScaling;
  86754. private _absoluteRotationQuaternion;
  86755. private _pivotMatrix;
  86756. private _pivotMatrixInverse;
  86757. protected _postMultiplyPivotMatrix: boolean;
  86758. protected _isWorldMatrixFrozen: boolean;
  86759. /** @hidden */
  86760. _indexInSceneTransformNodesArray: number;
  86761. /**
  86762. * An event triggered after the world matrix is updated
  86763. */
  86764. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86765. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86766. /**
  86767. * Gets a string identifying the name of the class
  86768. * @returns "TransformNode" string
  86769. */
  86770. getClassName(): string;
  86771. /**
  86772. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86773. */
  86774. get position(): Vector3;
  86775. set position(newPosition: Vector3);
  86776. /**
  86777. * 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)).
  86778. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86779. */
  86780. get rotation(): Vector3;
  86781. set rotation(newRotation: Vector3);
  86782. /**
  86783. * 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)).
  86784. */
  86785. get scaling(): Vector3;
  86786. set scaling(newScaling: Vector3);
  86787. /**
  86788. * 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).
  86789. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86790. */
  86791. get rotationQuaternion(): Nullable<Quaternion>;
  86792. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86793. /**
  86794. * The forward direction of that transform in world space.
  86795. */
  86796. get forward(): Vector3;
  86797. /**
  86798. * The up direction of that transform in world space.
  86799. */
  86800. get up(): Vector3;
  86801. /**
  86802. * The right direction of that transform in world space.
  86803. */
  86804. get right(): Vector3;
  86805. /**
  86806. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86807. * @param matrix the matrix to copy the pose from
  86808. * @returns this TransformNode.
  86809. */
  86810. updatePoseMatrix(matrix: Matrix): TransformNode;
  86811. /**
  86812. * Returns the mesh Pose matrix.
  86813. * @returns the pose matrix
  86814. */
  86815. getPoseMatrix(): Matrix;
  86816. /** @hidden */
  86817. _isSynchronized(): boolean;
  86818. /** @hidden */
  86819. _initCache(): void;
  86820. /**
  86821. * Flag the transform node as dirty (Forcing it to update everything)
  86822. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86823. * @returns this transform node
  86824. */
  86825. markAsDirty(property: string): TransformNode;
  86826. /**
  86827. * Returns the current mesh absolute position.
  86828. * Returns a Vector3.
  86829. */
  86830. get absolutePosition(): Vector3;
  86831. /**
  86832. * Returns the current mesh absolute scaling.
  86833. * Returns a Vector3.
  86834. */
  86835. get absoluteScaling(): Vector3;
  86836. /**
  86837. * Returns the current mesh absolute rotation.
  86838. * Returns a Quaternion.
  86839. */
  86840. get absoluteRotationQuaternion(): Quaternion;
  86841. /**
  86842. * Sets a new matrix to apply before all other transformation
  86843. * @param matrix defines the transform matrix
  86844. * @returns the current TransformNode
  86845. */
  86846. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86847. /**
  86848. * Sets a new pivot matrix to the current node
  86849. * @param matrix defines the new pivot matrix to use
  86850. * @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
  86851. * @returns the current TransformNode
  86852. */
  86853. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86854. /**
  86855. * Returns the mesh pivot matrix.
  86856. * Default : Identity.
  86857. * @returns the matrix
  86858. */
  86859. getPivotMatrix(): Matrix;
  86860. /**
  86861. * Instantiate (when possible) or clone that node with its hierarchy
  86862. * @param newParent defines the new parent to use for the instance (or clone)
  86863. * @param options defines options to configure how copy is done
  86864. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86865. * @returns an instance (or a clone) of the current node with its hiearchy
  86866. */
  86867. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86868. doNotInstantiate: boolean;
  86869. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86870. /**
  86871. * Prevents the World matrix to be computed any longer
  86872. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86873. * @returns the TransformNode.
  86874. */
  86875. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86876. /**
  86877. * Allows back the World matrix computation.
  86878. * @returns the TransformNode.
  86879. */
  86880. unfreezeWorldMatrix(): this;
  86881. /**
  86882. * True if the World matrix has been frozen.
  86883. */
  86884. get isWorldMatrixFrozen(): boolean;
  86885. /**
  86886. * Retuns the mesh absolute position in the World.
  86887. * @returns a Vector3.
  86888. */
  86889. getAbsolutePosition(): Vector3;
  86890. /**
  86891. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86892. * @param absolutePosition the absolute position to set
  86893. * @returns the TransformNode.
  86894. */
  86895. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86896. /**
  86897. * Sets the mesh position in its local space.
  86898. * @param vector3 the position to set in localspace
  86899. * @returns the TransformNode.
  86900. */
  86901. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86902. /**
  86903. * Returns the mesh position in the local space from the current World matrix values.
  86904. * @returns a new Vector3.
  86905. */
  86906. getPositionExpressedInLocalSpace(): Vector3;
  86907. /**
  86908. * Translates the mesh along the passed Vector3 in its local space.
  86909. * @param vector3 the distance to translate in localspace
  86910. * @returns the TransformNode.
  86911. */
  86912. locallyTranslate(vector3: Vector3): TransformNode;
  86913. private static _lookAtVectorCache;
  86914. /**
  86915. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86916. * @param targetPoint the position (must be in same space as current mesh) to look at
  86917. * @param yawCor optional yaw (y-axis) correction in radians
  86918. * @param pitchCor optional pitch (x-axis) correction in radians
  86919. * @param rollCor optional roll (z-axis) correction in radians
  86920. * @param space the choosen space of the target
  86921. * @returns the TransformNode.
  86922. */
  86923. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86924. /**
  86925. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86926. * This Vector3 is expressed in the World space.
  86927. * @param localAxis axis to rotate
  86928. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86929. */
  86930. getDirection(localAxis: Vector3): Vector3;
  86931. /**
  86932. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86933. * localAxis is expressed in the mesh local space.
  86934. * result is computed in the Wordl space from the mesh World matrix.
  86935. * @param localAxis axis to rotate
  86936. * @param result the resulting transformnode
  86937. * @returns this TransformNode.
  86938. */
  86939. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86940. /**
  86941. * Sets this transform node rotation to the given local axis.
  86942. * @param localAxis the axis in local space
  86943. * @param yawCor optional yaw (y-axis) correction in radians
  86944. * @param pitchCor optional pitch (x-axis) correction in radians
  86945. * @param rollCor optional roll (z-axis) correction in radians
  86946. * @returns this TransformNode
  86947. */
  86948. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86949. /**
  86950. * Sets a new pivot point to the current node
  86951. * @param point defines the new pivot point to use
  86952. * @param space defines if the point is in world or local space (local by default)
  86953. * @returns the current TransformNode
  86954. */
  86955. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86956. /**
  86957. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86958. * @returns the pivot point
  86959. */
  86960. getPivotPoint(): Vector3;
  86961. /**
  86962. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86963. * @param result the vector3 to store the result
  86964. * @returns this TransformNode.
  86965. */
  86966. getPivotPointToRef(result: Vector3): TransformNode;
  86967. /**
  86968. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86969. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86970. */
  86971. getAbsolutePivotPoint(): Vector3;
  86972. /**
  86973. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86974. * @param result vector3 to store the result
  86975. * @returns this TransformNode.
  86976. */
  86977. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86978. /**
  86979. * Defines the passed node as the parent of the current node.
  86980. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86981. * @see https://doc.babylonjs.com/how_to/parenting
  86982. * @param node the node ot set as the parent
  86983. * @returns this TransformNode.
  86984. */
  86985. setParent(node: Nullable<Node>): TransformNode;
  86986. private _nonUniformScaling;
  86987. /**
  86988. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86989. */
  86990. get nonUniformScaling(): boolean;
  86991. /** @hidden */
  86992. _updateNonUniformScalingState(value: boolean): boolean;
  86993. /**
  86994. * Attach the current TransformNode to another TransformNode associated with a bone
  86995. * @param bone Bone affecting the TransformNode
  86996. * @param affectedTransformNode TransformNode associated with the bone
  86997. * @returns this object
  86998. */
  86999. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87000. /**
  87001. * Detach the transform node if its associated with a bone
  87002. * @returns this object
  87003. */
  87004. detachFromBone(): TransformNode;
  87005. private static _rotationAxisCache;
  87006. /**
  87007. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87008. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87009. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87010. * The passed axis is also normalized.
  87011. * @param axis the axis to rotate around
  87012. * @param amount the amount to rotate in radians
  87013. * @param space Space to rotate in (Default: local)
  87014. * @returns the TransformNode.
  87015. */
  87016. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87017. /**
  87018. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87019. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87020. * The passed axis is also normalized. .
  87021. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87022. * @param point the point to rotate around
  87023. * @param axis the axis to rotate around
  87024. * @param amount the amount to rotate in radians
  87025. * @returns the TransformNode
  87026. */
  87027. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87028. /**
  87029. * Translates the mesh along the axis vector for the passed distance in the given space.
  87030. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87031. * @param axis the axis to translate in
  87032. * @param distance the distance to translate
  87033. * @param space Space to rotate in (Default: local)
  87034. * @returns the TransformNode.
  87035. */
  87036. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87037. /**
  87038. * Adds a rotation step to the mesh current rotation.
  87039. * x, y, z are Euler angles expressed in radians.
  87040. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87041. * This means this rotation is made in the mesh local space only.
  87042. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87043. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87044. * ```javascript
  87045. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87046. * ```
  87047. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87048. * 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.
  87049. * @param x Rotation to add
  87050. * @param y Rotation to add
  87051. * @param z Rotation to add
  87052. * @returns the TransformNode.
  87053. */
  87054. addRotation(x: number, y: number, z: number): TransformNode;
  87055. /**
  87056. * @hidden
  87057. */
  87058. protected _getEffectiveParent(): Nullable<Node>;
  87059. /**
  87060. * Computes the world matrix of the node
  87061. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87062. * @returns the world matrix
  87063. */
  87064. computeWorldMatrix(force?: boolean): Matrix;
  87065. /**
  87066. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87067. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87068. */
  87069. resetLocalMatrix(independentOfChildren?: boolean): void;
  87070. protected _afterComputeWorldMatrix(): void;
  87071. /**
  87072. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87073. * @param func callback function to add
  87074. *
  87075. * @returns the TransformNode.
  87076. */
  87077. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87078. /**
  87079. * Removes a registered callback function.
  87080. * @param func callback function to remove
  87081. * @returns the TransformNode.
  87082. */
  87083. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87084. /**
  87085. * Gets the position of the current mesh in camera space
  87086. * @param camera defines the camera to use
  87087. * @returns a position
  87088. */
  87089. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87090. /**
  87091. * Returns the distance from the mesh to the active camera
  87092. * @param camera defines the camera to use
  87093. * @returns the distance
  87094. */
  87095. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87096. /**
  87097. * Clone the current transform node
  87098. * @param name Name of the new clone
  87099. * @param newParent New parent for the clone
  87100. * @param doNotCloneChildren Do not clone children hierarchy
  87101. * @returns the new transform node
  87102. */
  87103. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87104. /**
  87105. * Serializes the objects information.
  87106. * @param currentSerializationObject defines the object to serialize in
  87107. * @returns the serialized object
  87108. */
  87109. serialize(currentSerializationObject?: any): any;
  87110. /**
  87111. * Returns a new TransformNode object parsed from the source provided.
  87112. * @param parsedTransformNode is the source.
  87113. * @param scene the scne the object belongs to
  87114. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87115. * @returns a new TransformNode object parsed from the source provided.
  87116. */
  87117. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87118. /**
  87119. * Get all child-transformNodes of this node
  87120. * @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
  87121. * @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
  87122. * @returns an array of TransformNode
  87123. */
  87124. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87125. /**
  87126. * Releases resources associated with this transform node.
  87127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87129. */
  87130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87131. /**
  87132. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87133. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87134. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87135. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87136. * @returns the current mesh
  87137. */
  87138. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87139. private _syncAbsoluteScalingAndRotation;
  87140. }
  87141. }
  87142. declare module BABYLON {
  87143. /**
  87144. * Class used to override all child animations of a given target
  87145. */
  87146. export class AnimationPropertiesOverride {
  87147. /**
  87148. * Gets or sets a value indicating if animation blending must be used
  87149. */
  87150. enableBlending: boolean;
  87151. /**
  87152. * Gets or sets the blending speed to use when enableBlending is true
  87153. */
  87154. blendingSpeed: number;
  87155. /**
  87156. * Gets or sets the default loop mode to use
  87157. */
  87158. loopMode: number;
  87159. }
  87160. }
  87161. declare module BABYLON {
  87162. /**
  87163. * Class used to store bone information
  87164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87165. */
  87166. export class Bone extends Node {
  87167. /**
  87168. * defines the bone name
  87169. */
  87170. name: string;
  87171. private static _tmpVecs;
  87172. private static _tmpQuat;
  87173. private static _tmpMats;
  87174. /**
  87175. * Gets the list of child bones
  87176. */
  87177. children: Bone[];
  87178. /** Gets the animations associated with this bone */
  87179. animations: Animation[];
  87180. /**
  87181. * Gets or sets bone length
  87182. */
  87183. length: number;
  87184. /**
  87185. * @hidden Internal only
  87186. * Set this value to map this bone to a different index in the transform matrices
  87187. * Set this value to -1 to exclude the bone from the transform matrices
  87188. */
  87189. _index: Nullable<number>;
  87190. private _skeleton;
  87191. private _localMatrix;
  87192. private _restPose;
  87193. private _baseMatrix;
  87194. private _absoluteTransform;
  87195. private _invertedAbsoluteTransform;
  87196. private _parent;
  87197. private _scalingDeterminant;
  87198. private _worldTransform;
  87199. private _localScaling;
  87200. private _localRotation;
  87201. private _localPosition;
  87202. private _needToDecompose;
  87203. private _needToCompose;
  87204. /** @hidden */
  87205. _linkedTransformNode: Nullable<TransformNode>;
  87206. /** @hidden */
  87207. _waitingTransformNodeId: Nullable<string>;
  87208. /** @hidden */
  87209. get _matrix(): Matrix;
  87210. /** @hidden */
  87211. set _matrix(value: Matrix);
  87212. /**
  87213. * Create a new bone
  87214. * @param name defines the bone name
  87215. * @param skeleton defines the parent skeleton
  87216. * @param parentBone defines the parent (can be null if the bone is the root)
  87217. * @param localMatrix defines the local matrix
  87218. * @param restPose defines the rest pose matrix
  87219. * @param baseMatrix defines the base matrix
  87220. * @param index defines index of the bone in the hiearchy
  87221. */
  87222. constructor(
  87223. /**
  87224. * defines the bone name
  87225. */
  87226. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87227. /**
  87228. * Gets the current object class name.
  87229. * @return the class name
  87230. */
  87231. getClassName(): string;
  87232. /**
  87233. * Gets the parent skeleton
  87234. * @returns a skeleton
  87235. */
  87236. getSkeleton(): Skeleton;
  87237. /**
  87238. * Gets parent bone
  87239. * @returns a bone or null if the bone is the root of the bone hierarchy
  87240. */
  87241. getParent(): Nullable<Bone>;
  87242. /**
  87243. * Returns an array containing the root bones
  87244. * @returns an array containing the root bones
  87245. */
  87246. getChildren(): Array<Bone>;
  87247. /**
  87248. * Gets the node index in matrix array generated for rendering
  87249. * @returns the node index
  87250. */
  87251. getIndex(): number;
  87252. /**
  87253. * Sets the parent bone
  87254. * @param parent defines the parent (can be null if the bone is the root)
  87255. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87256. */
  87257. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87258. /**
  87259. * Gets the local matrix
  87260. * @returns a matrix
  87261. */
  87262. getLocalMatrix(): Matrix;
  87263. /**
  87264. * Gets the base matrix (initial matrix which remains unchanged)
  87265. * @returns a matrix
  87266. */
  87267. getBaseMatrix(): Matrix;
  87268. /**
  87269. * Gets the rest pose matrix
  87270. * @returns a matrix
  87271. */
  87272. getRestPose(): Matrix;
  87273. /**
  87274. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87275. */
  87276. getWorldMatrix(): Matrix;
  87277. /**
  87278. * Sets the local matrix to rest pose matrix
  87279. */
  87280. returnToRest(): void;
  87281. /**
  87282. * Gets the inverse of the absolute transform matrix.
  87283. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87284. * @returns a matrix
  87285. */
  87286. getInvertedAbsoluteTransform(): Matrix;
  87287. /**
  87288. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87289. * @returns a matrix
  87290. */
  87291. getAbsoluteTransform(): Matrix;
  87292. /**
  87293. * Links with the given transform node.
  87294. * The local matrix of this bone is copied from the transform node every frame.
  87295. * @param transformNode defines the transform node to link to
  87296. */
  87297. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87298. /**
  87299. * Gets the node used to drive the bone's transformation
  87300. * @returns a transform node or null
  87301. */
  87302. getTransformNode(): Nullable<TransformNode>;
  87303. /** Gets or sets current position (in local space) */
  87304. get position(): Vector3;
  87305. set position(newPosition: Vector3);
  87306. /** Gets or sets current rotation (in local space) */
  87307. get rotation(): Vector3;
  87308. set rotation(newRotation: Vector3);
  87309. /** Gets or sets current rotation quaternion (in local space) */
  87310. get rotationQuaternion(): Quaternion;
  87311. set rotationQuaternion(newRotation: Quaternion);
  87312. /** Gets or sets current scaling (in local space) */
  87313. get scaling(): Vector3;
  87314. set scaling(newScaling: Vector3);
  87315. /**
  87316. * Gets the animation properties override
  87317. */
  87318. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87319. private _decompose;
  87320. private _compose;
  87321. /**
  87322. * Update the base and local matrices
  87323. * @param matrix defines the new base or local matrix
  87324. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87325. * @param updateLocalMatrix defines if the local matrix should be updated
  87326. */
  87327. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87328. /** @hidden */
  87329. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87330. /**
  87331. * Flag the bone as dirty (Forcing it to update everything)
  87332. */
  87333. markAsDirty(): void;
  87334. /** @hidden */
  87335. _markAsDirtyAndCompose(): void;
  87336. private _markAsDirtyAndDecompose;
  87337. /**
  87338. * Translate the bone in local or world space
  87339. * @param vec The amount to translate the bone
  87340. * @param space The space that the translation is in
  87341. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87342. */
  87343. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87344. /**
  87345. * Set the postion of the bone in local or world space
  87346. * @param position The position to set the bone
  87347. * @param space The space that the position is in
  87348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87349. */
  87350. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87351. /**
  87352. * Set the absolute position of the bone (world space)
  87353. * @param position The position to set the bone
  87354. * @param mesh The mesh that this bone is attached to
  87355. */
  87356. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87357. /**
  87358. * Scale the bone on the x, y and z axes (in local space)
  87359. * @param x The amount to scale the bone on the x axis
  87360. * @param y The amount to scale the bone on the y axis
  87361. * @param z The amount to scale the bone on the z axis
  87362. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87363. */
  87364. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87365. /**
  87366. * Set the bone scaling in local space
  87367. * @param scale defines the scaling vector
  87368. */
  87369. setScale(scale: Vector3): void;
  87370. /**
  87371. * Gets the current scaling in local space
  87372. * @returns the current scaling vector
  87373. */
  87374. getScale(): Vector3;
  87375. /**
  87376. * Gets the current scaling in local space and stores it in a target vector
  87377. * @param result defines the target vector
  87378. */
  87379. getScaleToRef(result: Vector3): void;
  87380. /**
  87381. * Set the yaw, pitch, and roll of the bone in local or world space
  87382. * @param yaw The rotation of the bone on the y axis
  87383. * @param pitch The rotation of the bone on the x axis
  87384. * @param roll The rotation of the bone on the z axis
  87385. * @param space The space that the axes of rotation are in
  87386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87387. */
  87388. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87389. /**
  87390. * Add a rotation to the bone on an axis in local or world space
  87391. * @param axis The axis to rotate the bone on
  87392. * @param amount The amount to rotate the bone
  87393. * @param space The space that the axis is in
  87394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87395. */
  87396. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87397. /**
  87398. * Set the rotation of the bone to a particular axis angle in local or world space
  87399. * @param axis The axis to rotate the bone on
  87400. * @param angle The angle that the bone should be rotated to
  87401. * @param space The space that the axis is in
  87402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87403. */
  87404. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87405. /**
  87406. * Set the euler rotation of the bone in local of world space
  87407. * @param rotation The euler rotation that the bone should be set to
  87408. * @param space The space that the rotation is in
  87409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87410. */
  87411. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87412. /**
  87413. * Set the quaternion rotation of the bone in local of world space
  87414. * @param quat The quaternion rotation that the bone should be set to
  87415. * @param space The space that the rotation is in
  87416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87417. */
  87418. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87419. /**
  87420. * Set the rotation matrix of the bone in local of world space
  87421. * @param rotMat The rotation matrix that the bone should be set to
  87422. * @param space The space that the rotation is in
  87423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87424. */
  87425. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87426. private _rotateWithMatrix;
  87427. private _getNegativeRotationToRef;
  87428. /**
  87429. * Get the position of the bone in local or world space
  87430. * @param space The space that the returned position is in
  87431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87432. * @returns The position of the bone
  87433. */
  87434. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87435. /**
  87436. * Copy the position of the bone to a vector3 in local or world space
  87437. * @param space The space that the returned position is in
  87438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87439. * @param result The vector3 to copy the position to
  87440. */
  87441. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87442. /**
  87443. * Get the absolute position of the bone (world space)
  87444. * @param mesh The mesh that this bone is attached to
  87445. * @returns The absolute position of the bone
  87446. */
  87447. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87448. /**
  87449. * Copy the absolute position of the bone (world space) to the result param
  87450. * @param mesh The mesh that this bone is attached to
  87451. * @param result The vector3 to copy the absolute position to
  87452. */
  87453. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87454. /**
  87455. * Compute the absolute transforms of this bone and its children
  87456. */
  87457. computeAbsoluteTransforms(): void;
  87458. /**
  87459. * Get the world direction from an axis that is in the local space of the bone
  87460. * @param localAxis The local direction that is used to compute the world direction
  87461. * @param mesh The mesh that this bone is attached to
  87462. * @returns The world direction
  87463. */
  87464. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87465. /**
  87466. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87467. * @param localAxis The local direction that is used to compute the world direction
  87468. * @param mesh The mesh that this bone is attached to
  87469. * @param result The vector3 that the world direction will be copied to
  87470. */
  87471. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87472. /**
  87473. * Get the euler rotation of the bone in local or world space
  87474. * @param space The space that the rotation should be in
  87475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87476. * @returns The euler rotation
  87477. */
  87478. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87479. /**
  87480. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87481. * @param space The space that the rotation should be in
  87482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87483. * @param result The vector3 that the rotation should be copied to
  87484. */
  87485. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87486. /**
  87487. * Get the quaternion rotation of the bone in either local or world space
  87488. * @param space The space that the rotation should be in
  87489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87490. * @returns The quaternion rotation
  87491. */
  87492. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87493. /**
  87494. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87495. * @param space The space that the rotation should be in
  87496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87497. * @param result The quaternion that the rotation should be copied to
  87498. */
  87499. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87500. /**
  87501. * Get the rotation matrix of the bone in local or world space
  87502. * @param space The space that the rotation should be in
  87503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87504. * @returns The rotation matrix
  87505. */
  87506. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87507. /**
  87508. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87509. * @param space The space that the rotation should be in
  87510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87511. * @param result The quaternion that the rotation should be copied to
  87512. */
  87513. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87514. /**
  87515. * Get the world position of a point that is in the local space of the bone
  87516. * @param position The local position
  87517. * @param mesh The mesh that this bone is attached to
  87518. * @returns The world position
  87519. */
  87520. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87521. /**
  87522. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87523. * @param position The local position
  87524. * @param mesh The mesh that this bone is attached to
  87525. * @param result The vector3 that the world position should be copied to
  87526. */
  87527. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87528. /**
  87529. * Get the local position of a point that is in world space
  87530. * @param position The world position
  87531. * @param mesh The mesh that this bone is attached to
  87532. * @returns The local position
  87533. */
  87534. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87535. /**
  87536. * Get the local position of a point that is in world space and copy it to the result param
  87537. * @param position The world position
  87538. * @param mesh The mesh that this bone is attached to
  87539. * @param result The vector3 that the local position should be copied to
  87540. */
  87541. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87542. }
  87543. }
  87544. declare module BABYLON {
  87545. /**
  87546. * Defines a runtime animation
  87547. */
  87548. export class RuntimeAnimation {
  87549. private _events;
  87550. /**
  87551. * The current frame of the runtime animation
  87552. */
  87553. private _currentFrame;
  87554. /**
  87555. * The animation used by the runtime animation
  87556. */
  87557. private _animation;
  87558. /**
  87559. * The target of the runtime animation
  87560. */
  87561. private _target;
  87562. /**
  87563. * The initiating animatable
  87564. */
  87565. private _host;
  87566. /**
  87567. * The original value of the runtime animation
  87568. */
  87569. private _originalValue;
  87570. /**
  87571. * The original blend value of the runtime animation
  87572. */
  87573. private _originalBlendValue;
  87574. /**
  87575. * The offsets cache of the runtime animation
  87576. */
  87577. private _offsetsCache;
  87578. /**
  87579. * The high limits cache of the runtime animation
  87580. */
  87581. private _highLimitsCache;
  87582. /**
  87583. * Specifies if the runtime animation has been stopped
  87584. */
  87585. private _stopped;
  87586. /**
  87587. * The blending factor of the runtime animation
  87588. */
  87589. private _blendingFactor;
  87590. /**
  87591. * The BabylonJS scene
  87592. */
  87593. private _scene;
  87594. /**
  87595. * The current value of the runtime animation
  87596. */
  87597. private _currentValue;
  87598. /** @hidden */
  87599. _animationState: _IAnimationState;
  87600. /**
  87601. * The active target of the runtime animation
  87602. */
  87603. private _activeTargets;
  87604. private _currentActiveTarget;
  87605. private _directTarget;
  87606. /**
  87607. * The target path of the runtime animation
  87608. */
  87609. private _targetPath;
  87610. /**
  87611. * The weight of the runtime animation
  87612. */
  87613. private _weight;
  87614. /**
  87615. * The ratio offset of the runtime animation
  87616. */
  87617. private _ratioOffset;
  87618. /**
  87619. * The previous delay of the runtime animation
  87620. */
  87621. private _previousDelay;
  87622. /**
  87623. * The previous ratio of the runtime animation
  87624. */
  87625. private _previousRatio;
  87626. private _enableBlending;
  87627. private _keys;
  87628. private _minFrame;
  87629. private _maxFrame;
  87630. private _minValue;
  87631. private _maxValue;
  87632. private _targetIsArray;
  87633. /**
  87634. * Gets the current frame of the runtime animation
  87635. */
  87636. get currentFrame(): number;
  87637. /**
  87638. * Gets the weight of the runtime animation
  87639. */
  87640. get weight(): number;
  87641. /**
  87642. * Gets the current value of the runtime animation
  87643. */
  87644. get currentValue(): any;
  87645. /**
  87646. * Gets the target path of the runtime animation
  87647. */
  87648. get targetPath(): string;
  87649. /**
  87650. * Gets the actual target of the runtime animation
  87651. */
  87652. get target(): any;
  87653. /** @hidden */
  87654. _onLoop: () => void;
  87655. /**
  87656. * Create a new RuntimeAnimation object
  87657. * @param target defines the target of the animation
  87658. * @param animation defines the source animation object
  87659. * @param scene defines the hosting scene
  87660. * @param host defines the initiating Animatable
  87661. */
  87662. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87663. private _preparePath;
  87664. /**
  87665. * Gets the animation from the runtime animation
  87666. */
  87667. get animation(): Animation;
  87668. /**
  87669. * Resets the runtime animation to the beginning
  87670. * @param restoreOriginal defines whether to restore the target property to the original value
  87671. */
  87672. reset(restoreOriginal?: boolean): void;
  87673. /**
  87674. * Specifies if the runtime animation is stopped
  87675. * @returns Boolean specifying if the runtime animation is stopped
  87676. */
  87677. isStopped(): boolean;
  87678. /**
  87679. * Disposes of the runtime animation
  87680. */
  87681. dispose(): void;
  87682. /**
  87683. * Apply the interpolated value to the target
  87684. * @param currentValue defines the value computed by the animation
  87685. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87686. */
  87687. setValue(currentValue: any, weight: number): void;
  87688. private _getOriginalValues;
  87689. private _setValue;
  87690. /**
  87691. * Gets the loop pmode of the runtime animation
  87692. * @returns Loop Mode
  87693. */
  87694. private _getCorrectLoopMode;
  87695. /**
  87696. * Move the current animation to a given frame
  87697. * @param frame defines the frame to move to
  87698. */
  87699. goToFrame(frame: number): void;
  87700. /**
  87701. * @hidden Internal use only
  87702. */
  87703. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87704. /**
  87705. * Execute the current animation
  87706. * @param delay defines the delay to add to the current frame
  87707. * @param from defines the lower bound of the animation range
  87708. * @param to defines the upper bound of the animation range
  87709. * @param loop defines if the current animation must loop
  87710. * @param speedRatio defines the current speed ratio
  87711. * @param weight defines the weight of the animation (default is -1 so no weight)
  87712. * @param onLoop optional callback called when animation loops
  87713. * @returns a boolean indicating if the animation is running
  87714. */
  87715. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87716. }
  87717. }
  87718. declare module BABYLON {
  87719. /**
  87720. * Class used to store an actual running animation
  87721. */
  87722. export class Animatable {
  87723. /** defines the target object */
  87724. target: any;
  87725. /** defines the starting frame number (default is 0) */
  87726. fromFrame: number;
  87727. /** defines the ending frame number (default is 100) */
  87728. toFrame: number;
  87729. /** defines if the animation must loop (default is false) */
  87730. loopAnimation: boolean;
  87731. /** defines a callback to call when animation ends if it is not looping */
  87732. onAnimationEnd?: (() => void) | null | undefined;
  87733. /** defines a callback to call when animation loops */
  87734. onAnimationLoop?: (() => void) | null | undefined;
  87735. private _localDelayOffset;
  87736. private _pausedDelay;
  87737. private _runtimeAnimations;
  87738. private _paused;
  87739. private _scene;
  87740. private _speedRatio;
  87741. private _weight;
  87742. private _syncRoot;
  87743. /**
  87744. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87745. * This will only apply for non looping animation (default is true)
  87746. */
  87747. disposeOnEnd: boolean;
  87748. /**
  87749. * Gets a boolean indicating if the animation has started
  87750. */
  87751. animationStarted: boolean;
  87752. /**
  87753. * Observer raised when the animation ends
  87754. */
  87755. onAnimationEndObservable: Observable<Animatable>;
  87756. /**
  87757. * Observer raised when the animation loops
  87758. */
  87759. onAnimationLoopObservable: Observable<Animatable>;
  87760. /**
  87761. * Gets the root Animatable used to synchronize and normalize animations
  87762. */
  87763. get syncRoot(): Nullable<Animatable>;
  87764. /**
  87765. * Gets the current frame of the first RuntimeAnimation
  87766. * Used to synchronize Animatables
  87767. */
  87768. get masterFrame(): number;
  87769. /**
  87770. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87771. */
  87772. get weight(): number;
  87773. set weight(value: number);
  87774. /**
  87775. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87776. */
  87777. get speedRatio(): number;
  87778. set speedRatio(value: number);
  87779. /**
  87780. * Creates a new Animatable
  87781. * @param scene defines the hosting scene
  87782. * @param target defines the target object
  87783. * @param fromFrame defines the starting frame number (default is 0)
  87784. * @param toFrame defines the ending frame number (default is 100)
  87785. * @param loopAnimation defines if the animation must loop (default is false)
  87786. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87787. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87788. * @param animations defines a group of animation to add to the new Animatable
  87789. * @param onAnimationLoop defines a callback to call when animation loops
  87790. */
  87791. constructor(scene: Scene,
  87792. /** defines the target object */
  87793. target: any,
  87794. /** defines the starting frame number (default is 0) */
  87795. fromFrame?: number,
  87796. /** defines the ending frame number (default is 100) */
  87797. toFrame?: number,
  87798. /** defines if the animation must loop (default is false) */
  87799. loopAnimation?: boolean, speedRatio?: number,
  87800. /** defines a callback to call when animation ends if it is not looping */
  87801. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87802. /** defines a callback to call when animation loops */
  87803. onAnimationLoop?: (() => void) | null | undefined);
  87804. /**
  87805. * Synchronize and normalize current Animatable with a source Animatable
  87806. * This is useful when using animation weights and when animations are not of the same length
  87807. * @param root defines the root Animatable to synchronize with
  87808. * @returns the current Animatable
  87809. */
  87810. syncWith(root: Animatable): Animatable;
  87811. /**
  87812. * Gets the list of runtime animations
  87813. * @returns an array of RuntimeAnimation
  87814. */
  87815. getAnimations(): RuntimeAnimation[];
  87816. /**
  87817. * Adds more animations to the current animatable
  87818. * @param target defines the target of the animations
  87819. * @param animations defines the new animations to add
  87820. */
  87821. appendAnimations(target: any, animations: Animation[]): void;
  87822. /**
  87823. * Gets the source animation for a specific property
  87824. * @param property defines the propertyu to look for
  87825. * @returns null or the source animation for the given property
  87826. */
  87827. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87828. /**
  87829. * Gets the runtime animation for a specific property
  87830. * @param property defines the propertyu to look for
  87831. * @returns null or the runtime animation for the given property
  87832. */
  87833. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87834. /**
  87835. * Resets the animatable to its original state
  87836. */
  87837. reset(): void;
  87838. /**
  87839. * Allows the animatable to blend with current running animations
  87840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87841. * @param blendingSpeed defines the blending speed to use
  87842. */
  87843. enableBlending(blendingSpeed: number): void;
  87844. /**
  87845. * Disable animation blending
  87846. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87847. */
  87848. disableBlending(): void;
  87849. /**
  87850. * Jump directly to a given frame
  87851. * @param frame defines the frame to jump to
  87852. */
  87853. goToFrame(frame: number): void;
  87854. /**
  87855. * Pause the animation
  87856. */
  87857. pause(): void;
  87858. /**
  87859. * Restart the animation
  87860. */
  87861. restart(): void;
  87862. private _raiseOnAnimationEnd;
  87863. /**
  87864. * Stop and delete the current animation
  87865. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87866. * @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)
  87867. */
  87868. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87869. /**
  87870. * Wait asynchronously for the animation to end
  87871. * @returns a promise which will be fullfilled when the animation ends
  87872. */
  87873. waitAsync(): Promise<Animatable>;
  87874. /** @hidden */
  87875. _animate(delay: number): boolean;
  87876. }
  87877. interface Scene {
  87878. /** @hidden */
  87879. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87880. /** @hidden */
  87881. _processLateAnimationBindingsForMatrices(holder: {
  87882. totalWeight: number;
  87883. animations: RuntimeAnimation[];
  87884. originalValue: Matrix;
  87885. }): any;
  87886. /** @hidden */
  87887. _processLateAnimationBindingsForQuaternions(holder: {
  87888. totalWeight: number;
  87889. animations: RuntimeAnimation[];
  87890. originalValue: Quaternion;
  87891. }, refQuaternion: Quaternion): Quaternion;
  87892. /** @hidden */
  87893. _processLateAnimationBindings(): void;
  87894. /**
  87895. * Will start the animation sequence of a given target
  87896. * @param target defines the target
  87897. * @param from defines from which frame should animation start
  87898. * @param to defines until which frame should animation run.
  87899. * @param weight defines the weight to apply to the animation (1.0 by default)
  87900. * @param loop defines if the animation loops
  87901. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87902. * @param onAnimationEnd defines the function to be executed when the animation ends
  87903. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87904. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87905. * @param onAnimationLoop defines the callback to call when an animation loops
  87906. * @returns the animatable object created for this animation
  87907. */
  87908. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87909. /**
  87910. * Will start the animation sequence of a given target
  87911. * @param target defines the target
  87912. * @param from defines from which frame should animation start
  87913. * @param to defines until which frame should animation run.
  87914. * @param loop defines if the animation loops
  87915. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87916. * @param onAnimationEnd defines the function to be executed when the animation ends
  87917. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87918. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87919. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87920. * @param onAnimationLoop defines the callback to call when an animation loops
  87921. * @returns the animatable object created for this animation
  87922. */
  87923. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87924. /**
  87925. * Will start the animation sequence of a given target and its hierarchy
  87926. * @param target defines the target
  87927. * @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.
  87928. * @param from defines from which frame should animation start
  87929. * @param to defines until which frame should animation run.
  87930. * @param loop defines if the animation loops
  87931. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87932. * @param onAnimationEnd defines the function to be executed when the animation ends
  87933. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87934. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87935. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87936. * @param onAnimationLoop defines the callback to call when an animation loops
  87937. * @returns the list of created animatables
  87938. */
  87939. 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[];
  87940. /**
  87941. * Begin a new animation on a given node
  87942. * @param target defines the target where the animation will take place
  87943. * @param animations defines the list of animations to start
  87944. * @param from defines the initial value
  87945. * @param to defines the final value
  87946. * @param loop defines if you want animation to loop (off by default)
  87947. * @param speedRatio defines the speed ratio to apply to all animations
  87948. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87949. * @param onAnimationLoop defines the callback to call when an animation loops
  87950. * @returns the list of created animatables
  87951. */
  87952. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  87953. /**
  87954. * Begin a new animation on a given node and its hierarchy
  87955. * @param target defines the root node where the animation will take place
  87956. * @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.
  87957. * @param animations defines the list of animations to start
  87958. * @param from defines the initial value
  87959. * @param to defines the final value
  87960. * @param loop defines if you want animation to loop (off by default)
  87961. * @param speedRatio defines the speed ratio to apply to all animations
  87962. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87963. * @param onAnimationLoop defines the callback to call when an animation loops
  87964. * @returns the list of animatables created for all nodes
  87965. */
  87966. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  87967. /**
  87968. * Gets the animatable associated with a specific target
  87969. * @param target defines the target of the animatable
  87970. * @returns the required animatable if found
  87971. */
  87972. getAnimatableByTarget(target: any): Nullable<Animatable>;
  87973. /**
  87974. * Gets all animatables associated with a given target
  87975. * @param target defines the target to look animatables for
  87976. * @returns an array of Animatables
  87977. */
  87978. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  87979. /**
  87980. * Stops and removes all animations that have been applied to the scene
  87981. */
  87982. stopAllAnimations(): void;
  87983. /**
  87984. * Gets the current delta time used by animation engine
  87985. */
  87986. deltaTime: number;
  87987. }
  87988. interface Bone {
  87989. /**
  87990. * Copy an animation range from another bone
  87991. * @param source defines the source bone
  87992. * @param rangeName defines the range name to copy
  87993. * @param frameOffset defines the frame offset
  87994. * @param rescaleAsRequired defines if rescaling must be applied if required
  87995. * @param skelDimensionsRatio defines the scaling ratio
  87996. * @returns true if operation was successful
  87997. */
  87998. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  87999. }
  88000. }
  88001. declare module BABYLON {
  88002. /**
  88003. * Class used to handle skinning animations
  88004. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88005. */
  88006. export class Skeleton implements IAnimatable {
  88007. /** defines the skeleton name */
  88008. name: string;
  88009. /** defines the skeleton Id */
  88010. id: string;
  88011. /**
  88012. * Defines the list of child bones
  88013. */
  88014. bones: Bone[];
  88015. /**
  88016. * Defines an estimate of the dimension of the skeleton at rest
  88017. */
  88018. dimensionsAtRest: Vector3;
  88019. /**
  88020. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88021. */
  88022. needInitialSkinMatrix: boolean;
  88023. /**
  88024. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88025. */
  88026. overrideMesh: Nullable<AbstractMesh>;
  88027. /**
  88028. * Gets the list of animations attached to this skeleton
  88029. */
  88030. animations: Array<Animation>;
  88031. private _scene;
  88032. private _isDirty;
  88033. private _transformMatrices;
  88034. private _transformMatrixTexture;
  88035. private _meshesWithPoseMatrix;
  88036. private _animatables;
  88037. private _identity;
  88038. private _synchronizedWithMesh;
  88039. private _ranges;
  88040. private _lastAbsoluteTransformsUpdateId;
  88041. private _canUseTextureForBones;
  88042. private _uniqueId;
  88043. /** @hidden */
  88044. _numBonesWithLinkedTransformNode: number;
  88045. /** @hidden */
  88046. _hasWaitingData: Nullable<boolean>;
  88047. /**
  88048. * Specifies if the skeleton should be serialized
  88049. */
  88050. doNotSerialize: boolean;
  88051. private _useTextureToStoreBoneMatrices;
  88052. /**
  88053. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88054. * Please note that this option is not available if the hardware does not support it
  88055. */
  88056. get useTextureToStoreBoneMatrices(): boolean;
  88057. set useTextureToStoreBoneMatrices(value: boolean);
  88058. private _animationPropertiesOverride;
  88059. /**
  88060. * Gets or sets the animation properties override
  88061. */
  88062. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88063. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88064. /**
  88065. * List of inspectable custom properties (used by the Inspector)
  88066. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88067. */
  88068. inspectableCustomProperties: IInspectable[];
  88069. /**
  88070. * An observable triggered before computing the skeleton's matrices
  88071. */
  88072. onBeforeComputeObservable: Observable<Skeleton>;
  88073. /**
  88074. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88075. */
  88076. get isUsingTextureForMatrices(): boolean;
  88077. /**
  88078. * Gets the unique ID of this skeleton
  88079. */
  88080. get uniqueId(): number;
  88081. /**
  88082. * Creates a new skeleton
  88083. * @param name defines the skeleton name
  88084. * @param id defines the skeleton Id
  88085. * @param scene defines the hosting scene
  88086. */
  88087. constructor(
  88088. /** defines the skeleton name */
  88089. name: string,
  88090. /** defines the skeleton Id */
  88091. id: string, scene: Scene);
  88092. /**
  88093. * Gets the current object class name.
  88094. * @return the class name
  88095. */
  88096. getClassName(): string;
  88097. /**
  88098. * Returns an array containing the root bones
  88099. * @returns an array containing the root bones
  88100. */
  88101. getChildren(): Array<Bone>;
  88102. /**
  88103. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88104. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88105. * @returns a Float32Array containing matrices data
  88106. */
  88107. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88108. /**
  88109. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88110. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88111. * @returns a raw texture containing the data
  88112. */
  88113. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88114. /**
  88115. * Gets the current hosting scene
  88116. * @returns a scene object
  88117. */
  88118. getScene(): Scene;
  88119. /**
  88120. * Gets a string representing the current skeleton data
  88121. * @param fullDetails defines a boolean indicating if we want a verbose version
  88122. * @returns a string representing the current skeleton data
  88123. */
  88124. toString(fullDetails?: boolean): string;
  88125. /**
  88126. * Get bone's index searching by name
  88127. * @param name defines bone's name to search for
  88128. * @return the indice of the bone. Returns -1 if not found
  88129. */
  88130. getBoneIndexByName(name: string): number;
  88131. /**
  88132. * Creater a new animation range
  88133. * @param name defines the name of the range
  88134. * @param from defines the start key
  88135. * @param to defines the end key
  88136. */
  88137. createAnimationRange(name: string, from: number, to: number): void;
  88138. /**
  88139. * Delete a specific animation range
  88140. * @param name defines the name of the range
  88141. * @param deleteFrames defines if frames must be removed as well
  88142. */
  88143. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88144. /**
  88145. * Gets a specific animation range
  88146. * @param name defines the name of the range to look for
  88147. * @returns the requested animation range or null if not found
  88148. */
  88149. getAnimationRange(name: string): Nullable<AnimationRange>;
  88150. /**
  88151. * Gets the list of all animation ranges defined on this skeleton
  88152. * @returns an array
  88153. */
  88154. getAnimationRanges(): Nullable<AnimationRange>[];
  88155. /**
  88156. * Copy animation range from a source skeleton.
  88157. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88158. * @param source defines the source skeleton
  88159. * @param name defines the name of the range to copy
  88160. * @param rescaleAsRequired defines if rescaling must be applied if required
  88161. * @returns true if operation was successful
  88162. */
  88163. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88164. /**
  88165. * Forces the skeleton to go to rest pose
  88166. */
  88167. returnToRest(): void;
  88168. private _getHighestAnimationFrame;
  88169. /**
  88170. * Begin a specific animation range
  88171. * @param name defines the name of the range to start
  88172. * @param loop defines if looping must be turned on (false by default)
  88173. * @param speedRatio defines the speed ratio to apply (1 by default)
  88174. * @param onAnimationEnd defines a callback which will be called when animation will end
  88175. * @returns a new animatable
  88176. */
  88177. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88178. /** @hidden */
  88179. _markAsDirty(): void;
  88180. /** @hidden */
  88181. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88182. /** @hidden */
  88183. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88184. private _computeTransformMatrices;
  88185. /**
  88186. * Build all resources required to render a skeleton
  88187. */
  88188. prepare(): void;
  88189. /**
  88190. * Gets the list of animatables currently running for this skeleton
  88191. * @returns an array of animatables
  88192. */
  88193. getAnimatables(): IAnimatable[];
  88194. /**
  88195. * Clone the current skeleton
  88196. * @param name defines the name of the new skeleton
  88197. * @param id defines the id of the new skeleton
  88198. * @returns the new skeleton
  88199. */
  88200. clone(name: string, id?: string): Skeleton;
  88201. /**
  88202. * Enable animation blending for this skeleton
  88203. * @param blendingSpeed defines the blending speed to apply
  88204. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88205. */
  88206. enableBlending(blendingSpeed?: number): void;
  88207. /**
  88208. * Releases all resources associated with the current skeleton
  88209. */
  88210. dispose(): void;
  88211. /**
  88212. * Serialize the skeleton in a JSON object
  88213. * @returns a JSON object
  88214. */
  88215. serialize(): any;
  88216. /**
  88217. * Creates a new skeleton from serialized data
  88218. * @param parsedSkeleton defines the serialized data
  88219. * @param scene defines the hosting scene
  88220. * @returns a new skeleton
  88221. */
  88222. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88223. /**
  88224. * Compute all node absolute transforms
  88225. * @param forceUpdate defines if computation must be done even if cache is up to date
  88226. */
  88227. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88228. /**
  88229. * Gets the root pose matrix
  88230. * @returns a matrix
  88231. */
  88232. getPoseMatrix(): Nullable<Matrix>;
  88233. /**
  88234. * Sorts bones per internal index
  88235. */
  88236. sortBones(): void;
  88237. private _sortBones;
  88238. }
  88239. }
  88240. declare module BABYLON {
  88241. /**
  88242. * Creates an instance based on a source mesh.
  88243. */
  88244. export class InstancedMesh extends AbstractMesh {
  88245. private _sourceMesh;
  88246. private _currentLOD;
  88247. /** @hidden */
  88248. _indexInSourceMeshInstanceArray: number;
  88249. constructor(name: string, source: Mesh);
  88250. /**
  88251. * Returns the string "InstancedMesh".
  88252. */
  88253. getClassName(): string;
  88254. /** Gets the list of lights affecting that mesh */
  88255. get lightSources(): Light[];
  88256. _resyncLightSources(): void;
  88257. _resyncLightSource(light: Light): void;
  88258. _removeLightSource(light: Light, dispose: boolean): void;
  88259. /**
  88260. * If the source mesh receives shadows
  88261. */
  88262. get receiveShadows(): boolean;
  88263. /**
  88264. * The material of the source mesh
  88265. */
  88266. get material(): Nullable<Material>;
  88267. /**
  88268. * Visibility of the source mesh
  88269. */
  88270. get visibility(): number;
  88271. /**
  88272. * Skeleton of the source mesh
  88273. */
  88274. get skeleton(): Nullable<Skeleton>;
  88275. /**
  88276. * Rendering ground id of the source mesh
  88277. */
  88278. get renderingGroupId(): number;
  88279. set renderingGroupId(value: number);
  88280. /**
  88281. * Returns the total number of vertices (integer).
  88282. */
  88283. getTotalVertices(): number;
  88284. /**
  88285. * Returns a positive integer : the total number of indices in this mesh geometry.
  88286. * @returns the numner of indices or zero if the mesh has no geometry.
  88287. */
  88288. getTotalIndices(): number;
  88289. /**
  88290. * The source mesh of the instance
  88291. */
  88292. get sourceMesh(): Mesh;
  88293. /**
  88294. * Is this node ready to be used/rendered
  88295. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88296. * @return {boolean} is it ready
  88297. */
  88298. isReady(completeCheck?: boolean): boolean;
  88299. /**
  88300. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88301. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88302. * @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.
  88303. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88304. */
  88305. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88306. /**
  88307. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88308. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88309. * The `data` are either a numeric array either a Float32Array.
  88310. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88311. * 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).
  88312. * Note that a new underlying VertexBuffer object is created each call.
  88313. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88314. *
  88315. * Possible `kind` values :
  88316. * - VertexBuffer.PositionKind
  88317. * - VertexBuffer.UVKind
  88318. * - VertexBuffer.UV2Kind
  88319. * - VertexBuffer.UV3Kind
  88320. * - VertexBuffer.UV4Kind
  88321. * - VertexBuffer.UV5Kind
  88322. * - VertexBuffer.UV6Kind
  88323. * - VertexBuffer.ColorKind
  88324. * - VertexBuffer.MatricesIndicesKind
  88325. * - VertexBuffer.MatricesIndicesExtraKind
  88326. * - VertexBuffer.MatricesWeightsKind
  88327. * - VertexBuffer.MatricesWeightsExtraKind
  88328. *
  88329. * Returns the Mesh.
  88330. */
  88331. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88332. /**
  88333. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88334. * If the mesh has no geometry, it is simply returned as it is.
  88335. * The `data` are either a numeric array either a Float32Array.
  88336. * No new underlying VertexBuffer object is created.
  88337. * 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.
  88338. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88339. *
  88340. * Possible `kind` values :
  88341. * - VertexBuffer.PositionKind
  88342. * - VertexBuffer.UVKind
  88343. * - VertexBuffer.UV2Kind
  88344. * - VertexBuffer.UV3Kind
  88345. * - VertexBuffer.UV4Kind
  88346. * - VertexBuffer.UV5Kind
  88347. * - VertexBuffer.UV6Kind
  88348. * - VertexBuffer.ColorKind
  88349. * - VertexBuffer.MatricesIndicesKind
  88350. * - VertexBuffer.MatricesIndicesExtraKind
  88351. * - VertexBuffer.MatricesWeightsKind
  88352. * - VertexBuffer.MatricesWeightsExtraKind
  88353. *
  88354. * Returns the Mesh.
  88355. */
  88356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88357. /**
  88358. * Sets the mesh indices.
  88359. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88360. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88361. * This method creates a new index buffer each call.
  88362. * Returns the Mesh.
  88363. */
  88364. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88365. /**
  88366. * Boolean : True if the mesh owns the requested kind of data.
  88367. */
  88368. isVerticesDataPresent(kind: string): boolean;
  88369. /**
  88370. * Returns an array of indices (IndicesArray).
  88371. */
  88372. getIndices(): Nullable<IndicesArray>;
  88373. get _positions(): Nullable<Vector3[]>;
  88374. /**
  88375. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88376. * This means the mesh underlying bounding box and sphere are recomputed.
  88377. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88378. * @returns the current mesh
  88379. */
  88380. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88381. /** @hidden */
  88382. _preActivate(): InstancedMesh;
  88383. /** @hidden */
  88384. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88385. /** @hidden */
  88386. _postActivate(): void;
  88387. getWorldMatrix(): Matrix;
  88388. get isAnInstance(): boolean;
  88389. /**
  88390. * Returns the current associated LOD AbstractMesh.
  88391. */
  88392. getLOD(camera: Camera): AbstractMesh;
  88393. /** @hidden */
  88394. _syncSubMeshes(): InstancedMesh;
  88395. /** @hidden */
  88396. _generatePointsArray(): boolean;
  88397. /**
  88398. * Creates a new InstancedMesh from the current mesh.
  88399. * - name (string) : the cloned mesh name
  88400. * - newParent (optional Node) : the optional Node to parent the clone to.
  88401. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88402. *
  88403. * Returns the clone.
  88404. */
  88405. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88406. /**
  88407. * Disposes the InstancedMesh.
  88408. * Returns nothing.
  88409. */
  88410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88411. }
  88412. interface Mesh {
  88413. /**
  88414. * Register a custom buffer that will be instanced
  88415. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88416. * @param kind defines the buffer kind
  88417. * @param stride defines the stride in floats
  88418. */
  88419. registerInstancedBuffer(kind: string, stride: number): void;
  88420. /** @hidden */
  88421. _userInstancedBuffersStorage: {
  88422. data: {
  88423. [key: string]: Float32Array;
  88424. };
  88425. sizes: {
  88426. [key: string]: number;
  88427. };
  88428. vertexBuffers: {
  88429. [key: string]: Nullable<VertexBuffer>;
  88430. };
  88431. strides: {
  88432. [key: string]: number;
  88433. };
  88434. };
  88435. }
  88436. interface AbstractMesh {
  88437. /**
  88438. * Object used to store instanced buffers defined by user
  88439. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88440. */
  88441. instancedBuffers: {
  88442. [key: string]: any;
  88443. };
  88444. }
  88445. }
  88446. declare module BABYLON {
  88447. /**
  88448. * Defines the options associated with the creation of a shader material.
  88449. */
  88450. export interface IShaderMaterialOptions {
  88451. /**
  88452. * Does the material work in alpha blend mode
  88453. */
  88454. needAlphaBlending: boolean;
  88455. /**
  88456. * Does the material work in alpha test mode
  88457. */
  88458. needAlphaTesting: boolean;
  88459. /**
  88460. * The list of attribute names used in the shader
  88461. */
  88462. attributes: string[];
  88463. /**
  88464. * The list of unifrom names used in the shader
  88465. */
  88466. uniforms: string[];
  88467. /**
  88468. * The list of UBO names used in the shader
  88469. */
  88470. uniformBuffers: string[];
  88471. /**
  88472. * The list of sampler names used in the shader
  88473. */
  88474. samplers: string[];
  88475. /**
  88476. * The list of defines used in the shader
  88477. */
  88478. defines: string[];
  88479. }
  88480. /**
  88481. * 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.
  88482. *
  88483. * This returned material effects how the mesh will look based on the code in the shaders.
  88484. *
  88485. * @see http://doc.babylonjs.com/how_to/shader_material
  88486. */
  88487. export class ShaderMaterial extends Material {
  88488. private _shaderPath;
  88489. private _options;
  88490. private _textures;
  88491. private _textureArrays;
  88492. private _floats;
  88493. private _ints;
  88494. private _floatsArrays;
  88495. private _colors3;
  88496. private _colors3Arrays;
  88497. private _colors4;
  88498. private _colors4Arrays;
  88499. private _vectors2;
  88500. private _vectors3;
  88501. private _vectors4;
  88502. private _matrices;
  88503. private _matrixArrays;
  88504. private _matrices3x3;
  88505. private _matrices2x2;
  88506. private _vectors2Arrays;
  88507. private _vectors3Arrays;
  88508. private _vectors4Arrays;
  88509. private _cachedWorldViewMatrix;
  88510. private _cachedWorldViewProjectionMatrix;
  88511. private _renderId;
  88512. private _multiview;
  88513. /**
  88514. * Instantiate a new shader material.
  88515. * 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.
  88516. * This returned material effects how the mesh will look based on the code in the shaders.
  88517. * @see http://doc.babylonjs.com/how_to/shader_material
  88518. * @param name Define the name of the material in the scene
  88519. * @param scene Define the scene the material belongs to
  88520. * @param shaderPath Defines the route to the shader code in one of three ways:
  88521. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88522. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88523. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88524. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88525. * @param options Define the options used to create the shader
  88526. */
  88527. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88528. /**
  88529. * Gets the shader path used to define the shader code
  88530. * It can be modified to trigger a new compilation
  88531. */
  88532. get shaderPath(): any;
  88533. /**
  88534. * Sets the shader path used to define the shader code
  88535. * It can be modified to trigger a new compilation
  88536. */
  88537. set shaderPath(shaderPath: any);
  88538. /**
  88539. * Gets the options used to compile the shader.
  88540. * They can be modified to trigger a new compilation
  88541. */
  88542. get options(): IShaderMaterialOptions;
  88543. /**
  88544. * Gets the current class name of the material e.g. "ShaderMaterial"
  88545. * Mainly use in serialization.
  88546. * @returns the class name
  88547. */
  88548. getClassName(): string;
  88549. /**
  88550. * Specifies if the material will require alpha blending
  88551. * @returns a boolean specifying if alpha blending is needed
  88552. */
  88553. needAlphaBlending(): boolean;
  88554. /**
  88555. * Specifies if this material should be rendered in alpha test mode
  88556. * @returns a boolean specifying if an alpha test is needed.
  88557. */
  88558. needAlphaTesting(): boolean;
  88559. private _checkUniform;
  88560. /**
  88561. * Set a texture in the shader.
  88562. * @param name Define the name of the uniform samplers as defined in the shader
  88563. * @param texture Define the texture to bind to this sampler
  88564. * @return the material itself allowing "fluent" like uniform updates
  88565. */
  88566. setTexture(name: string, texture: Texture): ShaderMaterial;
  88567. /**
  88568. * Set a texture array in the shader.
  88569. * @param name Define the name of the uniform sampler array as defined in the shader
  88570. * @param textures Define the list of textures to bind to this sampler
  88571. * @return the material itself allowing "fluent" like uniform updates
  88572. */
  88573. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88574. /**
  88575. * Set a float in the shader.
  88576. * @param name Define the name of the uniform as defined in the shader
  88577. * @param value Define the value to give to the uniform
  88578. * @return the material itself allowing "fluent" like uniform updates
  88579. */
  88580. setFloat(name: string, value: number): ShaderMaterial;
  88581. /**
  88582. * Set a int in the shader.
  88583. * @param name Define the name of the uniform as defined in the shader
  88584. * @param value Define the value to give to the uniform
  88585. * @return the material itself allowing "fluent" like uniform updates
  88586. */
  88587. setInt(name: string, value: number): ShaderMaterial;
  88588. /**
  88589. * Set an array of floats in the shader.
  88590. * @param name Define the name of the uniform as defined in the shader
  88591. * @param value Define the value to give to the uniform
  88592. * @return the material itself allowing "fluent" like uniform updates
  88593. */
  88594. setFloats(name: string, value: number[]): ShaderMaterial;
  88595. /**
  88596. * Set a vec3 in the shader from a Color3.
  88597. * @param name Define the name of the uniform as defined in the shader
  88598. * @param value Define the value to give to the uniform
  88599. * @return the material itself allowing "fluent" like uniform updates
  88600. */
  88601. setColor3(name: string, value: Color3): ShaderMaterial;
  88602. /**
  88603. * Set a vec3 array in the shader from a Color3 array.
  88604. * @param name Define the name of the uniform as defined in the shader
  88605. * @param value Define the value to give to the uniform
  88606. * @return the material itself allowing "fluent" like uniform updates
  88607. */
  88608. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88609. /**
  88610. * Set a vec4 in the shader from a Color4.
  88611. * @param name Define the name of the uniform as defined in the shader
  88612. * @param value Define the value to give to the uniform
  88613. * @return the material itself allowing "fluent" like uniform updates
  88614. */
  88615. setColor4(name: string, value: Color4): ShaderMaterial;
  88616. /**
  88617. * Set a vec4 array in the shader from a Color4 array.
  88618. * @param name Define the name of the uniform as defined in the shader
  88619. * @param value Define the value to give to the uniform
  88620. * @return the material itself allowing "fluent" like uniform updates
  88621. */
  88622. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88623. /**
  88624. * Set a vec2 in the shader from a Vector2.
  88625. * @param name Define the name of the uniform as defined in the shader
  88626. * @param value Define the value to give to the uniform
  88627. * @return the material itself allowing "fluent" like uniform updates
  88628. */
  88629. setVector2(name: string, value: Vector2): ShaderMaterial;
  88630. /**
  88631. * Set a vec3 in the shader from a Vector3.
  88632. * @param name Define the name of the uniform as defined in the shader
  88633. * @param value Define the value to give to the uniform
  88634. * @return the material itself allowing "fluent" like uniform updates
  88635. */
  88636. setVector3(name: string, value: Vector3): ShaderMaterial;
  88637. /**
  88638. * Set a vec4 in the shader from a Vector4.
  88639. * @param name Define the name of the uniform as defined in the shader
  88640. * @param value Define the value to give to the uniform
  88641. * @return the material itself allowing "fluent" like uniform updates
  88642. */
  88643. setVector4(name: string, value: Vector4): ShaderMaterial;
  88644. /**
  88645. * Set a mat4 in the shader from a Matrix.
  88646. * @param name Define the name of the uniform as defined in the shader
  88647. * @param value Define the value to give to the uniform
  88648. * @return the material itself allowing "fluent" like uniform updates
  88649. */
  88650. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88651. /**
  88652. * Set a float32Array in the shader from a matrix array.
  88653. * @param name Define the name of the uniform as defined in the shader
  88654. * @param value Define the value to give to the uniform
  88655. * @return the material itself allowing "fluent" like uniform updates
  88656. */
  88657. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88658. /**
  88659. * Set a mat3 in the shader from a Float32Array.
  88660. * @param name Define the name of the uniform as defined in the shader
  88661. * @param value Define the value to give to the uniform
  88662. * @return the material itself allowing "fluent" like uniform updates
  88663. */
  88664. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88665. /**
  88666. * Set a mat2 in the shader from a Float32Array.
  88667. * @param name Define the name of the uniform as defined in the shader
  88668. * @param value Define the value to give to the uniform
  88669. * @return the material itself allowing "fluent" like uniform updates
  88670. */
  88671. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88672. /**
  88673. * Set a vec2 array in the shader from a number array.
  88674. * @param name Define the name of the uniform as defined in the shader
  88675. * @param value Define the value to give to the uniform
  88676. * @return the material itself allowing "fluent" like uniform updates
  88677. */
  88678. setArray2(name: string, value: number[]): ShaderMaterial;
  88679. /**
  88680. * Set a vec3 array in the shader from a number array.
  88681. * @param name Define the name of the uniform as defined in the shader
  88682. * @param value Define the value to give to the uniform
  88683. * @return the material itself allowing "fluent" like uniform updates
  88684. */
  88685. setArray3(name: string, value: number[]): ShaderMaterial;
  88686. /**
  88687. * Set a vec4 array in the shader from a number array.
  88688. * @param name Define the name of the uniform as defined in the shader
  88689. * @param value Define the value to give to the uniform
  88690. * @return the material itself allowing "fluent" like uniform updates
  88691. */
  88692. setArray4(name: string, value: number[]): ShaderMaterial;
  88693. private _checkCache;
  88694. /**
  88695. * Specifies that the submesh is ready to be used
  88696. * @param mesh defines the mesh to check
  88697. * @param subMesh defines which submesh to check
  88698. * @param useInstances specifies that instances should be used
  88699. * @returns a boolean indicating that the submesh is ready or not
  88700. */
  88701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88702. /**
  88703. * Checks if the material is ready to render the requested mesh
  88704. * @param mesh Define the mesh to render
  88705. * @param useInstances Define whether or not the material is used with instances
  88706. * @returns true if ready, otherwise false
  88707. */
  88708. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88709. /**
  88710. * Binds the world matrix to the material
  88711. * @param world defines the world transformation matrix
  88712. */
  88713. bindOnlyWorldMatrix(world: Matrix): void;
  88714. /**
  88715. * Binds the material to the mesh
  88716. * @param world defines the world transformation matrix
  88717. * @param mesh defines the mesh to bind the material to
  88718. */
  88719. bind(world: Matrix, mesh?: Mesh): void;
  88720. /**
  88721. * Gets the active textures from the material
  88722. * @returns an array of textures
  88723. */
  88724. getActiveTextures(): BaseTexture[];
  88725. /**
  88726. * Specifies if the material uses a texture
  88727. * @param texture defines the texture to check against the material
  88728. * @returns a boolean specifying if the material uses the texture
  88729. */
  88730. hasTexture(texture: BaseTexture): boolean;
  88731. /**
  88732. * Makes a duplicate of the material, and gives it a new name
  88733. * @param name defines the new name for the duplicated material
  88734. * @returns the cloned material
  88735. */
  88736. clone(name: string): ShaderMaterial;
  88737. /**
  88738. * Disposes the material
  88739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88742. */
  88743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88744. /**
  88745. * Serializes this material in a JSON representation
  88746. * @returns the serialized material object
  88747. */
  88748. serialize(): any;
  88749. /**
  88750. * Creates a shader material from parsed shader material data
  88751. * @param source defines the JSON represnetation of the material
  88752. * @param scene defines the hosting scene
  88753. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88754. * @returns a new material
  88755. */
  88756. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88757. }
  88758. }
  88759. declare module BABYLON {
  88760. /** @hidden */
  88761. export var colorPixelShader: {
  88762. name: string;
  88763. shader: string;
  88764. };
  88765. }
  88766. declare module BABYLON {
  88767. /** @hidden */
  88768. export var colorVertexShader: {
  88769. name: string;
  88770. shader: string;
  88771. };
  88772. }
  88773. declare module BABYLON {
  88774. /**
  88775. * Line mesh
  88776. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88777. */
  88778. export class LinesMesh extends Mesh {
  88779. /**
  88780. * If vertex color should be applied to the mesh
  88781. */
  88782. readonly useVertexColor?: boolean | undefined;
  88783. /**
  88784. * If vertex alpha should be applied to the mesh
  88785. */
  88786. readonly useVertexAlpha?: boolean | undefined;
  88787. /**
  88788. * Color of the line (Default: White)
  88789. */
  88790. color: Color3;
  88791. /**
  88792. * Alpha of the line (Default: 1)
  88793. */
  88794. alpha: number;
  88795. /**
  88796. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88797. * This margin is expressed in world space coordinates, so its value may vary.
  88798. * Default value is 0.1
  88799. */
  88800. intersectionThreshold: number;
  88801. private _colorShader;
  88802. private color4;
  88803. /**
  88804. * Creates a new LinesMesh
  88805. * @param name defines the name
  88806. * @param scene defines the hosting scene
  88807. * @param parent defines the parent mesh if any
  88808. * @param source defines the optional source LinesMesh used to clone data from
  88809. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88810. * When false, achieved by calling a clone(), also passing False.
  88811. * This will make creation of children, recursive.
  88812. * @param useVertexColor defines if this LinesMesh supports vertex color
  88813. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88814. */
  88815. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88816. /**
  88817. * If vertex color should be applied to the mesh
  88818. */
  88819. useVertexColor?: boolean | undefined,
  88820. /**
  88821. * If vertex alpha should be applied to the mesh
  88822. */
  88823. useVertexAlpha?: boolean | undefined);
  88824. private _addClipPlaneDefine;
  88825. private _removeClipPlaneDefine;
  88826. isReady(): boolean;
  88827. /**
  88828. * Returns the string "LineMesh"
  88829. */
  88830. getClassName(): string;
  88831. /**
  88832. * @hidden
  88833. */
  88834. get material(): Material;
  88835. /**
  88836. * @hidden
  88837. */
  88838. set material(value: Material);
  88839. /**
  88840. * @hidden
  88841. */
  88842. get checkCollisions(): boolean;
  88843. /** @hidden */
  88844. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88845. /** @hidden */
  88846. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88847. /**
  88848. * Disposes of the line mesh
  88849. * @param doNotRecurse If children should be disposed
  88850. */
  88851. dispose(doNotRecurse?: boolean): void;
  88852. /**
  88853. * Returns a new LineMesh object cloned from the current one.
  88854. */
  88855. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88856. /**
  88857. * Creates a new InstancedLinesMesh object from the mesh model.
  88858. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88859. * @param name defines the name of the new instance
  88860. * @returns a new InstancedLinesMesh
  88861. */
  88862. createInstance(name: string): InstancedLinesMesh;
  88863. }
  88864. /**
  88865. * Creates an instance based on a source LinesMesh
  88866. */
  88867. export class InstancedLinesMesh extends InstancedMesh {
  88868. /**
  88869. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88870. * This margin is expressed in world space coordinates, so its value may vary.
  88871. * Initilized with the intersectionThreshold value of the source LinesMesh
  88872. */
  88873. intersectionThreshold: number;
  88874. constructor(name: string, source: LinesMesh);
  88875. /**
  88876. * Returns the string "InstancedLinesMesh".
  88877. */
  88878. getClassName(): string;
  88879. }
  88880. }
  88881. declare module BABYLON {
  88882. /** @hidden */
  88883. export var linePixelShader: {
  88884. name: string;
  88885. shader: string;
  88886. };
  88887. }
  88888. declare module BABYLON {
  88889. /** @hidden */
  88890. export var lineVertexShader: {
  88891. name: string;
  88892. shader: string;
  88893. };
  88894. }
  88895. declare module BABYLON {
  88896. interface AbstractMesh {
  88897. /**
  88898. * Gets the edgesRenderer associated with the mesh
  88899. */
  88900. edgesRenderer: Nullable<EdgesRenderer>;
  88901. }
  88902. interface LinesMesh {
  88903. /**
  88904. * Enables the edge rendering mode on the mesh.
  88905. * This mode makes the mesh edges visible
  88906. * @param epsilon defines the maximal distance between two angles to detect a face
  88907. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88908. * @returns the currentAbstractMesh
  88909. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88910. */
  88911. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88912. }
  88913. interface InstancedLinesMesh {
  88914. /**
  88915. * Enables the edge rendering mode on the mesh.
  88916. * This mode makes the mesh edges visible
  88917. * @param epsilon defines the maximal distance between two angles to detect a face
  88918. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88919. * @returns the current InstancedLinesMesh
  88920. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88921. */
  88922. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88923. }
  88924. /**
  88925. * Defines the minimum contract an Edges renderer should follow.
  88926. */
  88927. export interface IEdgesRenderer extends IDisposable {
  88928. /**
  88929. * Gets or sets a boolean indicating if the edgesRenderer is active
  88930. */
  88931. isEnabled: boolean;
  88932. /**
  88933. * Renders the edges of the attached mesh,
  88934. */
  88935. render(): void;
  88936. /**
  88937. * Checks wether or not the edges renderer is ready to render.
  88938. * @return true if ready, otherwise false.
  88939. */
  88940. isReady(): boolean;
  88941. }
  88942. /**
  88943. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88944. */
  88945. export class EdgesRenderer implements IEdgesRenderer {
  88946. /**
  88947. * Define the size of the edges with an orthographic camera
  88948. */
  88949. edgesWidthScalerForOrthographic: number;
  88950. /**
  88951. * Define the size of the edges with a perspective camera
  88952. */
  88953. edgesWidthScalerForPerspective: number;
  88954. protected _source: AbstractMesh;
  88955. protected _linesPositions: number[];
  88956. protected _linesNormals: number[];
  88957. protected _linesIndices: number[];
  88958. protected _epsilon: number;
  88959. protected _indicesCount: number;
  88960. protected _lineShader: ShaderMaterial;
  88961. protected _ib: DataBuffer;
  88962. protected _buffers: {
  88963. [key: string]: Nullable<VertexBuffer>;
  88964. };
  88965. protected _checkVerticesInsteadOfIndices: boolean;
  88966. private _meshRebuildObserver;
  88967. private _meshDisposeObserver;
  88968. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88969. isEnabled: boolean;
  88970. /**
  88971. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88972. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88973. * @param source Mesh used to create edges
  88974. * @param epsilon sum of angles in adjacency to check for edge
  88975. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88976. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88977. */
  88978. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88979. protected _prepareRessources(): void;
  88980. /** @hidden */
  88981. _rebuild(): void;
  88982. /**
  88983. * Releases the required resources for the edges renderer
  88984. */
  88985. dispose(): void;
  88986. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88987. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88988. /**
  88989. * Checks if the pair of p0 and p1 is en edge
  88990. * @param faceIndex
  88991. * @param edge
  88992. * @param faceNormals
  88993. * @param p0
  88994. * @param p1
  88995. * @private
  88996. */
  88997. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88998. /**
  88999. * push line into the position, normal and index buffer
  89000. * @protected
  89001. */
  89002. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89003. /**
  89004. * Generates lines edges from adjacencjes
  89005. * @private
  89006. */
  89007. _generateEdgesLines(): void;
  89008. /**
  89009. * Checks wether or not the edges renderer is ready to render.
  89010. * @return true if ready, otherwise false.
  89011. */
  89012. isReady(): boolean;
  89013. /**
  89014. * Renders the edges of the attached mesh,
  89015. */
  89016. render(): void;
  89017. }
  89018. /**
  89019. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89020. */
  89021. export class LineEdgesRenderer extends EdgesRenderer {
  89022. /**
  89023. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89024. * @param source LineMesh used to generate edges
  89025. * @param epsilon not important (specified angle for edge detection)
  89026. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89027. */
  89028. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89029. /**
  89030. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89031. */
  89032. _generateEdgesLines(): void;
  89033. }
  89034. }
  89035. declare module BABYLON {
  89036. /**
  89037. * This represents the object necessary to create a rendering group.
  89038. * This is exclusively used and created by the rendering manager.
  89039. * To modify the behavior, you use the available helpers in your scene or meshes.
  89040. * @hidden
  89041. */
  89042. export class RenderingGroup {
  89043. index: number;
  89044. private static _zeroVector;
  89045. private _scene;
  89046. private _opaqueSubMeshes;
  89047. private _transparentSubMeshes;
  89048. private _alphaTestSubMeshes;
  89049. private _depthOnlySubMeshes;
  89050. private _particleSystems;
  89051. private _spriteManagers;
  89052. private _opaqueSortCompareFn;
  89053. private _alphaTestSortCompareFn;
  89054. private _transparentSortCompareFn;
  89055. private _renderOpaque;
  89056. private _renderAlphaTest;
  89057. private _renderTransparent;
  89058. /** @hidden */
  89059. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89060. onBeforeTransparentRendering: () => void;
  89061. /**
  89062. * Set the opaque sort comparison function.
  89063. * If null the sub meshes will be render in the order they were created
  89064. */
  89065. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89066. /**
  89067. * Set the alpha test sort comparison function.
  89068. * If null the sub meshes will be render in the order they were created
  89069. */
  89070. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89071. /**
  89072. * Set the transparent sort comparison function.
  89073. * If null the sub meshes will be render in the order they were created
  89074. */
  89075. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89076. /**
  89077. * Creates a new rendering group.
  89078. * @param index The rendering group index
  89079. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89080. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89081. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89082. */
  89083. 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>);
  89084. /**
  89085. * Render all the sub meshes contained in the group.
  89086. * @param customRenderFunction Used to override the default render behaviour of the group.
  89087. * @returns true if rendered some submeshes.
  89088. */
  89089. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89090. /**
  89091. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89092. * @param subMeshes The submeshes to render
  89093. */
  89094. private renderOpaqueSorted;
  89095. /**
  89096. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89097. * @param subMeshes The submeshes to render
  89098. */
  89099. private renderAlphaTestSorted;
  89100. /**
  89101. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89102. * @param subMeshes The submeshes to render
  89103. */
  89104. private renderTransparentSorted;
  89105. /**
  89106. * Renders the submeshes in a specified order.
  89107. * @param subMeshes The submeshes to sort before render
  89108. * @param sortCompareFn The comparison function use to sort
  89109. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89110. * @param transparent Specifies to activate blending if true
  89111. */
  89112. private static renderSorted;
  89113. /**
  89114. * Renders the submeshes in the order they were dispatched (no sort applied).
  89115. * @param subMeshes The submeshes to render
  89116. */
  89117. private static renderUnsorted;
  89118. /**
  89119. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89120. * are rendered back to front if in the same alpha index.
  89121. *
  89122. * @param a The first submesh
  89123. * @param b The second submesh
  89124. * @returns The result of the comparison
  89125. */
  89126. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89127. /**
  89128. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89129. * are rendered back to front.
  89130. *
  89131. * @param a The first submesh
  89132. * @param b The second submesh
  89133. * @returns The result of the comparison
  89134. */
  89135. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89136. /**
  89137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89138. * are rendered front to back (prevent overdraw).
  89139. *
  89140. * @param a The first submesh
  89141. * @param b The second submesh
  89142. * @returns The result of the comparison
  89143. */
  89144. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89145. /**
  89146. * Resets the different lists of submeshes to prepare a new frame.
  89147. */
  89148. prepare(): void;
  89149. dispose(): void;
  89150. /**
  89151. * Inserts the submesh in its correct queue depending on its material.
  89152. * @param subMesh The submesh to dispatch
  89153. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89154. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89155. */
  89156. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89157. dispatchSprites(spriteManager: ISpriteManager): void;
  89158. dispatchParticles(particleSystem: IParticleSystem): void;
  89159. private _renderParticles;
  89160. private _renderSprites;
  89161. }
  89162. }
  89163. declare module BABYLON {
  89164. /**
  89165. * Interface describing the different options available in the rendering manager
  89166. * regarding Auto Clear between groups.
  89167. */
  89168. export interface IRenderingManagerAutoClearSetup {
  89169. /**
  89170. * Defines whether or not autoclear is enable.
  89171. */
  89172. autoClear: boolean;
  89173. /**
  89174. * Defines whether or not to autoclear the depth buffer.
  89175. */
  89176. depth: boolean;
  89177. /**
  89178. * Defines whether or not to autoclear the stencil buffer.
  89179. */
  89180. stencil: boolean;
  89181. }
  89182. /**
  89183. * This class is used by the onRenderingGroupObservable
  89184. */
  89185. export class RenderingGroupInfo {
  89186. /**
  89187. * The Scene that being rendered
  89188. */
  89189. scene: Scene;
  89190. /**
  89191. * The camera currently used for the rendering pass
  89192. */
  89193. camera: Nullable<Camera>;
  89194. /**
  89195. * The ID of the renderingGroup being processed
  89196. */
  89197. renderingGroupId: number;
  89198. }
  89199. /**
  89200. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89201. * It is enable to manage the different groups as well as the different necessary sort functions.
  89202. * This should not be used directly aside of the few static configurations
  89203. */
  89204. export class RenderingManager {
  89205. /**
  89206. * The max id used for rendering groups (not included)
  89207. */
  89208. static MAX_RENDERINGGROUPS: number;
  89209. /**
  89210. * The min id used for rendering groups (included)
  89211. */
  89212. static MIN_RENDERINGGROUPS: number;
  89213. /**
  89214. * Used to globally prevent autoclearing scenes.
  89215. */
  89216. static AUTOCLEAR: boolean;
  89217. /**
  89218. * @hidden
  89219. */
  89220. _useSceneAutoClearSetup: boolean;
  89221. private _scene;
  89222. private _renderingGroups;
  89223. private _depthStencilBufferAlreadyCleaned;
  89224. private _autoClearDepthStencil;
  89225. private _customOpaqueSortCompareFn;
  89226. private _customAlphaTestSortCompareFn;
  89227. private _customTransparentSortCompareFn;
  89228. private _renderingGroupInfo;
  89229. /**
  89230. * Instantiates a new rendering group for a particular scene
  89231. * @param scene Defines the scene the groups belongs to
  89232. */
  89233. constructor(scene: Scene);
  89234. private _clearDepthStencilBuffer;
  89235. /**
  89236. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89237. * @hidden
  89238. */
  89239. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89240. /**
  89241. * Resets the different information of the group to prepare a new frame
  89242. * @hidden
  89243. */
  89244. reset(): void;
  89245. /**
  89246. * Dispose and release the group and its associated resources.
  89247. * @hidden
  89248. */
  89249. dispose(): void;
  89250. /**
  89251. * Clear the info related to rendering groups preventing retention points during dispose.
  89252. */
  89253. freeRenderingGroups(): void;
  89254. private _prepareRenderingGroup;
  89255. /**
  89256. * Add a sprite manager to the rendering manager in order to render it this frame.
  89257. * @param spriteManager Define the sprite manager to render
  89258. */
  89259. dispatchSprites(spriteManager: ISpriteManager): void;
  89260. /**
  89261. * Add a particle system to the rendering manager in order to render it this frame.
  89262. * @param particleSystem Define the particle system to render
  89263. */
  89264. dispatchParticles(particleSystem: IParticleSystem): void;
  89265. /**
  89266. * Add a submesh to the manager in order to render it this frame
  89267. * @param subMesh The submesh to dispatch
  89268. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89269. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89270. */
  89271. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89272. /**
  89273. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89274. * This allowed control for front to back rendering or reversly depending of the special needs.
  89275. *
  89276. * @param renderingGroupId The rendering group id corresponding to its index
  89277. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89278. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89279. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89280. */
  89281. 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;
  89282. /**
  89283. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89284. *
  89285. * @param renderingGroupId The rendering group id corresponding to its index
  89286. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89287. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89288. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89289. */
  89290. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89291. /**
  89292. * Gets the current auto clear configuration for one rendering group of the rendering
  89293. * manager.
  89294. * @param index the rendering group index to get the information for
  89295. * @returns The auto clear setup for the requested rendering group
  89296. */
  89297. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89298. }
  89299. }
  89300. declare module BABYLON {
  89301. /**
  89302. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89303. */
  89304. export interface ICustomShaderOptions {
  89305. /**
  89306. * Gets or sets the custom shader name to use
  89307. */
  89308. shaderName: string;
  89309. /**
  89310. * The list of attribute names used in the shader
  89311. */
  89312. attributes?: string[];
  89313. /**
  89314. * The list of unifrom names used in the shader
  89315. */
  89316. uniforms?: string[];
  89317. /**
  89318. * The list of sampler names used in the shader
  89319. */
  89320. samplers?: string[];
  89321. /**
  89322. * The list of defines used in the shader
  89323. */
  89324. defines?: string[];
  89325. }
  89326. /**
  89327. * Interface to implement to create a shadow generator compatible with BJS.
  89328. */
  89329. export interface IShadowGenerator {
  89330. /**
  89331. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89332. * @returns The render target texture if present otherwise, null
  89333. */
  89334. getShadowMap(): Nullable<RenderTargetTexture>;
  89335. /**
  89336. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89337. * @param subMesh The submesh we want to render in the shadow map
  89338. * @param useInstances Defines wether will draw in the map using instances
  89339. * @returns true if ready otherwise, false
  89340. */
  89341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89342. /**
  89343. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89344. * @param defines Defines of the material we want to update
  89345. * @param lightIndex Index of the light in the enabled light list of the material
  89346. */
  89347. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89348. /**
  89349. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89350. * defined in the generator but impacting the effect).
  89351. * It implies the unifroms available on the materials are the standard BJS ones.
  89352. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89353. * @param effect The effect we are binfing the information for
  89354. */
  89355. bindShadowLight(lightIndex: string, effect: Effect): void;
  89356. /**
  89357. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89358. * (eq to shadow prjection matrix * light transform matrix)
  89359. * @returns The transform matrix used to create the shadow map
  89360. */
  89361. getTransformMatrix(): Matrix;
  89362. /**
  89363. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89364. * Cube and 2D textures for instance.
  89365. */
  89366. recreateShadowMap(): void;
  89367. /**
  89368. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89369. * @param onCompiled Callback triggered at the and of the effects compilation
  89370. * @param options Sets of optional options forcing the compilation with different modes
  89371. */
  89372. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89373. useInstances: boolean;
  89374. }>): void;
  89375. /**
  89376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89377. * @param options Sets of optional options forcing the compilation with different modes
  89378. * @returns A promise that resolves when the compilation completes
  89379. */
  89380. forceCompilationAsync(options?: Partial<{
  89381. useInstances: boolean;
  89382. }>): Promise<void>;
  89383. /**
  89384. * Serializes the shadow generator setup to a json object.
  89385. * @returns The serialized JSON object
  89386. */
  89387. serialize(): any;
  89388. /**
  89389. * Disposes the Shadow map and related Textures and effects.
  89390. */
  89391. dispose(): void;
  89392. }
  89393. /**
  89394. * Default implementation IShadowGenerator.
  89395. * This is the main object responsible of generating shadows in the framework.
  89396. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89397. */
  89398. export class ShadowGenerator implements IShadowGenerator {
  89399. /**
  89400. * Name of the shadow generator class
  89401. */
  89402. static CLASSNAME: string;
  89403. /**
  89404. * Shadow generator mode None: no filtering applied.
  89405. */
  89406. static readonly FILTER_NONE: number;
  89407. /**
  89408. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89410. */
  89411. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89412. /**
  89413. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89414. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89415. */
  89416. static readonly FILTER_POISSONSAMPLING: number;
  89417. /**
  89418. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89419. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89420. */
  89421. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89422. /**
  89423. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89424. * edge artifacts on steep falloff.
  89425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89426. */
  89427. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89428. /**
  89429. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89430. * edge artifacts on steep falloff.
  89431. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89432. */
  89433. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89434. /**
  89435. * Shadow generator mode PCF: Percentage Closer Filtering
  89436. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89437. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89438. */
  89439. static readonly FILTER_PCF: number;
  89440. /**
  89441. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89442. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89443. * Contact Hardening
  89444. */
  89445. static readonly FILTER_PCSS: number;
  89446. /**
  89447. * Reserved for PCF and PCSS
  89448. * Highest Quality.
  89449. *
  89450. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89451. *
  89452. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89453. */
  89454. static readonly QUALITY_HIGH: number;
  89455. /**
  89456. * Reserved for PCF and PCSS
  89457. * Good tradeoff for quality/perf cross devices
  89458. *
  89459. * Execute PCF on a 3*3 kernel.
  89460. *
  89461. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89462. */
  89463. static readonly QUALITY_MEDIUM: number;
  89464. /**
  89465. * Reserved for PCF and PCSS
  89466. * The lowest quality but the fastest.
  89467. *
  89468. * Execute PCF on a 1*1 kernel.
  89469. *
  89470. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89471. */
  89472. static readonly QUALITY_LOW: number;
  89473. /** Gets or sets the custom shader name to use */
  89474. customShaderOptions: ICustomShaderOptions;
  89475. /**
  89476. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89477. */
  89478. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89479. /**
  89480. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89481. */
  89482. onAfterShadowMapRenderObservable: Observable<Effect>;
  89483. /**
  89484. * Observable triggered before a mesh is rendered in the shadow map.
  89485. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89486. */
  89487. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89488. /**
  89489. * Observable triggered after a mesh is rendered in the shadow map.
  89490. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89491. */
  89492. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89493. protected _bias: number;
  89494. /**
  89495. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89496. */
  89497. get bias(): number;
  89498. /**
  89499. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89500. */
  89501. set bias(bias: number);
  89502. protected _normalBias: number;
  89503. /**
  89504. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89505. */
  89506. get normalBias(): number;
  89507. /**
  89508. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89509. */
  89510. set normalBias(normalBias: number);
  89511. protected _blurBoxOffset: number;
  89512. /**
  89513. * Gets the blur box offset: offset applied during the blur pass.
  89514. * Only useful if useKernelBlur = false
  89515. */
  89516. get blurBoxOffset(): number;
  89517. /**
  89518. * Sets the blur box offset: offset applied during the blur pass.
  89519. * Only useful if useKernelBlur = false
  89520. */
  89521. set blurBoxOffset(value: number);
  89522. protected _blurScale: number;
  89523. /**
  89524. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89525. * 2 means half of the size.
  89526. */
  89527. get blurScale(): number;
  89528. /**
  89529. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89530. * 2 means half of the size.
  89531. */
  89532. set blurScale(value: number);
  89533. protected _blurKernel: number;
  89534. /**
  89535. * Gets the blur kernel: kernel size of the blur pass.
  89536. * Only useful if useKernelBlur = true
  89537. */
  89538. get blurKernel(): number;
  89539. /**
  89540. * Sets the blur kernel: kernel size of the blur pass.
  89541. * Only useful if useKernelBlur = true
  89542. */
  89543. set blurKernel(value: number);
  89544. protected _useKernelBlur: boolean;
  89545. /**
  89546. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89547. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89548. */
  89549. get useKernelBlur(): boolean;
  89550. /**
  89551. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89552. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89553. */
  89554. set useKernelBlur(value: boolean);
  89555. protected _depthScale: number;
  89556. /**
  89557. * Gets the depth scale used in ESM mode.
  89558. */
  89559. get depthScale(): number;
  89560. /**
  89561. * Sets the depth scale used in ESM mode.
  89562. * This can override the scale stored on the light.
  89563. */
  89564. set depthScale(value: number);
  89565. protected _validateFilter(filter: number): number;
  89566. protected _filter: number;
  89567. /**
  89568. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89569. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89570. */
  89571. get filter(): number;
  89572. /**
  89573. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89574. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89575. */
  89576. set filter(value: number);
  89577. /**
  89578. * Gets if the current filter is set to Poisson Sampling.
  89579. */
  89580. get usePoissonSampling(): boolean;
  89581. /**
  89582. * Sets the current filter to Poisson Sampling.
  89583. */
  89584. set usePoissonSampling(value: boolean);
  89585. /**
  89586. * Gets if the current filter is set to ESM.
  89587. */
  89588. get useExponentialShadowMap(): boolean;
  89589. /**
  89590. * Sets the current filter is to ESM.
  89591. */
  89592. set useExponentialShadowMap(value: boolean);
  89593. /**
  89594. * Gets if the current filter is set to filtered ESM.
  89595. */
  89596. get useBlurExponentialShadowMap(): boolean;
  89597. /**
  89598. * Gets if the current filter is set to filtered ESM.
  89599. */
  89600. set useBlurExponentialShadowMap(value: boolean);
  89601. /**
  89602. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89603. * exponential to prevent steep falloff artifacts).
  89604. */
  89605. get useCloseExponentialShadowMap(): boolean;
  89606. /**
  89607. * Sets the current filter to "close ESM" (using the inverse of the
  89608. * exponential to prevent steep falloff artifacts).
  89609. */
  89610. set useCloseExponentialShadowMap(value: boolean);
  89611. /**
  89612. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89613. * exponential to prevent steep falloff artifacts).
  89614. */
  89615. get useBlurCloseExponentialShadowMap(): boolean;
  89616. /**
  89617. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89618. * exponential to prevent steep falloff artifacts).
  89619. */
  89620. set useBlurCloseExponentialShadowMap(value: boolean);
  89621. /**
  89622. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89623. */
  89624. get usePercentageCloserFiltering(): boolean;
  89625. /**
  89626. * Sets the current filter to "PCF" (percentage closer filtering).
  89627. */
  89628. set usePercentageCloserFiltering(value: boolean);
  89629. protected _filteringQuality: number;
  89630. /**
  89631. * Gets the PCF or PCSS Quality.
  89632. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89633. */
  89634. get filteringQuality(): number;
  89635. /**
  89636. * Sets the PCF or PCSS Quality.
  89637. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89638. */
  89639. set filteringQuality(filteringQuality: number);
  89640. /**
  89641. * Gets if the current filter is set to "PCSS" (contact hardening).
  89642. */
  89643. get useContactHardeningShadow(): boolean;
  89644. /**
  89645. * Sets the current filter to "PCSS" (contact hardening).
  89646. */
  89647. set useContactHardeningShadow(value: boolean);
  89648. protected _contactHardeningLightSizeUVRatio: number;
  89649. /**
  89650. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89651. * Using a ratio helps keeping shape stability independently of the map size.
  89652. *
  89653. * It does not account for the light projection as it was having too much
  89654. * instability during the light setup or during light position changes.
  89655. *
  89656. * Only valid if useContactHardeningShadow is true.
  89657. */
  89658. get contactHardeningLightSizeUVRatio(): number;
  89659. /**
  89660. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89661. * Using a ratio helps keeping shape stability independently of the map size.
  89662. *
  89663. * It does not account for the light projection as it was having too much
  89664. * instability during the light setup or during light position changes.
  89665. *
  89666. * Only valid if useContactHardeningShadow is true.
  89667. */
  89668. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89669. protected _darkness: number;
  89670. /** Gets or sets the actual darkness of a shadow */
  89671. get darkness(): number;
  89672. set darkness(value: number);
  89673. /**
  89674. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89675. * 0 means strongest and 1 would means no shadow.
  89676. * @returns the darkness.
  89677. */
  89678. getDarkness(): number;
  89679. /**
  89680. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89681. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89682. * @returns the shadow generator allowing fluent coding.
  89683. */
  89684. setDarkness(darkness: number): ShadowGenerator;
  89685. protected _transparencyShadow: boolean;
  89686. /** Gets or sets the ability to have transparent shadow */
  89687. get transparencyShadow(): boolean;
  89688. set transparencyShadow(value: boolean);
  89689. /**
  89690. * Sets the ability to have transparent shadow (boolean).
  89691. * @param transparent True if transparent else False
  89692. * @returns the shadow generator allowing fluent coding
  89693. */
  89694. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89695. protected _shadowMap: Nullable<RenderTargetTexture>;
  89696. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89697. /**
  89698. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89699. * @returns The render target texture if present otherwise, null
  89700. */
  89701. getShadowMap(): Nullable<RenderTargetTexture>;
  89702. /**
  89703. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89704. * @returns The render target texture if the shadow map is present otherwise, null
  89705. */
  89706. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89707. /**
  89708. * Gets the class name of that object
  89709. * @returns "ShadowGenerator"
  89710. */
  89711. getClassName(): string;
  89712. /**
  89713. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89714. * @param mesh Mesh to add
  89715. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89716. * @returns the Shadow Generator itself
  89717. */
  89718. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89719. /**
  89720. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89721. * @param mesh Mesh to remove
  89722. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89723. * @returns the Shadow Generator itself
  89724. */
  89725. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89726. /**
  89727. * Controls the extent to which the shadows fade out at the edge of the frustum
  89728. */
  89729. frustumEdgeFalloff: number;
  89730. protected _light: IShadowLight;
  89731. /**
  89732. * Returns the associated light object.
  89733. * @returns the light generating the shadow
  89734. */
  89735. getLight(): IShadowLight;
  89736. /**
  89737. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89738. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89739. * It might on the other hand introduce peter panning.
  89740. */
  89741. forceBackFacesOnly: boolean;
  89742. protected _scene: Scene;
  89743. protected _lightDirection: Vector3;
  89744. protected _effect: Effect;
  89745. protected _viewMatrix: Matrix;
  89746. protected _projectionMatrix: Matrix;
  89747. protected _transformMatrix: Matrix;
  89748. protected _cachedPosition: Vector3;
  89749. protected _cachedDirection: Vector3;
  89750. protected _cachedDefines: string;
  89751. protected _currentRenderID: number;
  89752. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89753. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89754. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89755. protected _blurPostProcesses: PostProcess[];
  89756. protected _mapSize: number;
  89757. protected _currentFaceIndex: number;
  89758. protected _currentFaceIndexCache: number;
  89759. protected _textureType: number;
  89760. protected _defaultTextureMatrix: Matrix;
  89761. protected _storedUniqueId: Nullable<number>;
  89762. /** @hidden */
  89763. static _SceneComponentInitialization: (scene: Scene) => void;
  89764. /**
  89765. * Creates a ShadowGenerator object.
  89766. * A ShadowGenerator is the required tool to use the shadows.
  89767. * Each light casting shadows needs to use its own ShadowGenerator.
  89768. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89769. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89770. * @param light The light object generating the shadows.
  89771. * @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.
  89772. */
  89773. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89774. protected _initializeGenerator(): void;
  89775. protected _createTargetRenderTexture(): void;
  89776. protected _initializeShadowMap(): void;
  89777. protected _initializeBlurRTTAndPostProcesses(): void;
  89778. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89779. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89780. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89781. protected _applyFilterValues(): void;
  89782. /**
  89783. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89784. * @param onCompiled Callback triggered at the and of the effects compilation
  89785. * @param options Sets of optional options forcing the compilation with different modes
  89786. */
  89787. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89788. useInstances: boolean;
  89789. }>): void;
  89790. /**
  89791. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89792. * @param options Sets of optional options forcing the compilation with different modes
  89793. * @returns A promise that resolves when the compilation completes
  89794. */
  89795. forceCompilationAsync(options?: Partial<{
  89796. useInstances: boolean;
  89797. }>): Promise<void>;
  89798. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89799. /**
  89800. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89801. * @param subMesh The submesh we want to render in the shadow map
  89802. * @param useInstances Defines wether will draw in the map using instances
  89803. * @returns true if ready otherwise, false
  89804. */
  89805. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89806. /**
  89807. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89808. * @param defines Defines of the material we want to update
  89809. * @param lightIndex Index of the light in the enabled light list of the material
  89810. */
  89811. prepareDefines(defines: any, lightIndex: number): void;
  89812. /**
  89813. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89814. * defined in the generator but impacting the effect).
  89815. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89816. * @param effect The effect we are binfing the information for
  89817. */
  89818. bindShadowLight(lightIndex: string, effect: Effect): void;
  89819. /**
  89820. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89821. * (eq to shadow prjection matrix * light transform matrix)
  89822. * @returns The transform matrix used to create the shadow map
  89823. */
  89824. getTransformMatrix(): Matrix;
  89825. /**
  89826. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89827. * Cube and 2D textures for instance.
  89828. */
  89829. recreateShadowMap(): void;
  89830. protected _disposeBlurPostProcesses(): void;
  89831. protected _disposeRTTandPostProcesses(): void;
  89832. /**
  89833. * Disposes the ShadowGenerator.
  89834. * Returns nothing.
  89835. */
  89836. dispose(): void;
  89837. /**
  89838. * Serializes the shadow generator setup to a json object.
  89839. * @returns The serialized JSON object
  89840. */
  89841. serialize(): any;
  89842. /**
  89843. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89844. * @param parsedShadowGenerator The JSON object to parse
  89845. * @param scene The scene to create the shadow map for
  89846. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89847. * @returns The parsed shadow generator
  89848. */
  89849. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89850. }
  89851. }
  89852. declare module BABYLON {
  89853. /**
  89854. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89855. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89856. * 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.
  89857. */
  89858. export abstract class Light extends Node {
  89859. /**
  89860. * Falloff Default: light is falling off following the material specification:
  89861. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89862. */
  89863. static readonly FALLOFF_DEFAULT: number;
  89864. /**
  89865. * Falloff Physical: light is falling off following the inverse squared distance law.
  89866. */
  89867. static readonly FALLOFF_PHYSICAL: number;
  89868. /**
  89869. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89870. * to enhance interoperability with other engines.
  89871. */
  89872. static readonly FALLOFF_GLTF: number;
  89873. /**
  89874. * Falloff Standard: light is falling off like in the standard material
  89875. * to enhance interoperability with other materials.
  89876. */
  89877. static readonly FALLOFF_STANDARD: number;
  89878. /**
  89879. * If every light affecting the material is in this lightmapMode,
  89880. * material.lightmapTexture adds or multiplies
  89881. * (depends on material.useLightmapAsShadowmap)
  89882. * after every other light calculations.
  89883. */
  89884. static readonly LIGHTMAP_DEFAULT: number;
  89885. /**
  89886. * material.lightmapTexture as only diffuse lighting from this light
  89887. * adds only specular lighting from this light
  89888. * adds dynamic shadows
  89889. */
  89890. static readonly LIGHTMAP_SPECULAR: number;
  89891. /**
  89892. * material.lightmapTexture as only lighting
  89893. * no light calculation from this light
  89894. * only adds dynamic shadows from this light
  89895. */
  89896. static readonly LIGHTMAP_SHADOWSONLY: number;
  89897. /**
  89898. * Each light type uses the default quantity according to its type:
  89899. * point/spot lights use luminous intensity
  89900. * directional lights use illuminance
  89901. */
  89902. static readonly INTENSITYMODE_AUTOMATIC: number;
  89903. /**
  89904. * lumen (lm)
  89905. */
  89906. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89907. /**
  89908. * candela (lm/sr)
  89909. */
  89910. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89911. /**
  89912. * lux (lm/m^2)
  89913. */
  89914. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89915. /**
  89916. * nit (cd/m^2)
  89917. */
  89918. static readonly INTENSITYMODE_LUMINANCE: number;
  89919. /**
  89920. * Light type const id of the point light.
  89921. */
  89922. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89923. /**
  89924. * Light type const id of the directional light.
  89925. */
  89926. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89927. /**
  89928. * Light type const id of the spot light.
  89929. */
  89930. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89931. /**
  89932. * Light type const id of the hemispheric light.
  89933. */
  89934. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89935. /**
  89936. * Diffuse gives the basic color to an object.
  89937. */
  89938. diffuse: Color3;
  89939. /**
  89940. * Specular produces a highlight color on an object.
  89941. * Note: This is note affecting PBR materials.
  89942. */
  89943. specular: Color3;
  89944. /**
  89945. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89946. * falling off base on range or angle.
  89947. * This can be set to any values in Light.FALLOFF_x.
  89948. *
  89949. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89950. * other types of materials.
  89951. */
  89952. falloffType: number;
  89953. /**
  89954. * Strength of the light.
  89955. * Note: By default it is define in the framework own unit.
  89956. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89957. */
  89958. intensity: number;
  89959. private _range;
  89960. protected _inverseSquaredRange: number;
  89961. /**
  89962. * Defines how far from the source the light is impacting in scene units.
  89963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89964. */
  89965. get range(): number;
  89966. /**
  89967. * Defines how far from the source the light is impacting in scene units.
  89968. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89969. */
  89970. set range(value: number);
  89971. /**
  89972. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89973. * of light.
  89974. */
  89975. private _photometricScale;
  89976. private _intensityMode;
  89977. /**
  89978. * Gets the photometric scale used to interpret the intensity.
  89979. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89980. */
  89981. get intensityMode(): number;
  89982. /**
  89983. * Sets the photometric scale used to interpret the intensity.
  89984. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89985. */
  89986. set intensityMode(value: number);
  89987. private _radius;
  89988. /**
  89989. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89990. */
  89991. get radius(): number;
  89992. /**
  89993. * sets the light radius used by PBR Materials to simulate soft area lights.
  89994. */
  89995. set radius(value: number);
  89996. private _renderPriority;
  89997. /**
  89998. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89999. * exceeding the number allowed of the materials.
  90000. */
  90001. renderPriority: number;
  90002. private _shadowEnabled;
  90003. /**
  90004. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90005. * the current shadow generator.
  90006. */
  90007. get shadowEnabled(): boolean;
  90008. /**
  90009. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90010. * the current shadow generator.
  90011. */
  90012. set shadowEnabled(value: boolean);
  90013. private _includedOnlyMeshes;
  90014. /**
  90015. * Gets the only meshes impacted by this light.
  90016. */
  90017. get includedOnlyMeshes(): AbstractMesh[];
  90018. /**
  90019. * Sets the only meshes impacted by this light.
  90020. */
  90021. set includedOnlyMeshes(value: AbstractMesh[]);
  90022. private _excludedMeshes;
  90023. /**
  90024. * Gets the meshes not impacted by this light.
  90025. */
  90026. get excludedMeshes(): AbstractMesh[];
  90027. /**
  90028. * Sets the meshes not impacted by this light.
  90029. */
  90030. set excludedMeshes(value: AbstractMesh[]);
  90031. private _excludeWithLayerMask;
  90032. /**
  90033. * Gets the layer id use to find what meshes are not impacted by the light.
  90034. * Inactive if 0
  90035. */
  90036. get excludeWithLayerMask(): number;
  90037. /**
  90038. * Sets the layer id use to find what meshes are not impacted by the light.
  90039. * Inactive if 0
  90040. */
  90041. set excludeWithLayerMask(value: number);
  90042. private _includeOnlyWithLayerMask;
  90043. /**
  90044. * Gets the layer id use to find what meshes are impacted by the light.
  90045. * Inactive if 0
  90046. */
  90047. get includeOnlyWithLayerMask(): number;
  90048. /**
  90049. * Sets the layer id use to find what meshes are impacted by the light.
  90050. * Inactive if 0
  90051. */
  90052. set includeOnlyWithLayerMask(value: number);
  90053. private _lightmapMode;
  90054. /**
  90055. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90056. */
  90057. get lightmapMode(): number;
  90058. /**
  90059. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90060. */
  90061. set lightmapMode(value: number);
  90062. /**
  90063. * Shadow generator associted to the light.
  90064. * @hidden Internal use only.
  90065. */
  90066. _shadowGenerator: Nullable<IShadowGenerator>;
  90067. /**
  90068. * @hidden Internal use only.
  90069. */
  90070. _excludedMeshesIds: string[];
  90071. /**
  90072. * @hidden Internal use only.
  90073. */
  90074. _includedOnlyMeshesIds: string[];
  90075. /**
  90076. * The current light unifom buffer.
  90077. * @hidden Internal use only.
  90078. */
  90079. _uniformBuffer: UniformBuffer;
  90080. /** @hidden */
  90081. _renderId: number;
  90082. /**
  90083. * Creates a Light object in the scene.
  90084. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90085. * @param name The firendly name of the light
  90086. * @param scene The scene the light belongs too
  90087. */
  90088. constructor(name: string, scene: Scene);
  90089. protected abstract _buildUniformLayout(): void;
  90090. /**
  90091. * Sets the passed Effect "effect" with the Light information.
  90092. * @param effect The effect to update
  90093. * @param lightIndex The index of the light in the effect to update
  90094. * @returns The light
  90095. */
  90096. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90097. /**
  90098. * Sets the passed Effect "effect" with the Light textures.
  90099. * @param effect The effect to update
  90100. * @param lightIndex The index of the light in the effect to update
  90101. * @returns The light
  90102. */
  90103. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90104. /**
  90105. * Binds the lights information from the scene to the effect for the given mesh.
  90106. * @param lightIndex Light index
  90107. * @param scene The scene where the light belongs to
  90108. * @param effect The effect we are binding the data to
  90109. * @param useSpecular Defines if specular is supported
  90110. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90111. */
  90112. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90113. /**
  90114. * Sets the passed Effect "effect" with the Light information.
  90115. * @param effect The effect to update
  90116. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90117. * @returns The light
  90118. */
  90119. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90120. /**
  90121. * Returns the string "Light".
  90122. * @returns the class name
  90123. */
  90124. getClassName(): string;
  90125. /** @hidden */
  90126. readonly _isLight: boolean;
  90127. /**
  90128. * Converts the light information to a readable string for debug purpose.
  90129. * @param fullDetails Supports for multiple levels of logging within scene loading
  90130. * @returns the human readable light info
  90131. */
  90132. toString(fullDetails?: boolean): string;
  90133. /** @hidden */
  90134. protected _syncParentEnabledState(): void;
  90135. /**
  90136. * Set the enabled state of this node.
  90137. * @param value - the new enabled state
  90138. */
  90139. setEnabled(value: boolean): void;
  90140. /**
  90141. * Returns the Light associated shadow generator if any.
  90142. * @return the associated shadow generator.
  90143. */
  90144. getShadowGenerator(): Nullable<IShadowGenerator>;
  90145. /**
  90146. * Returns a Vector3, the absolute light position in the World.
  90147. * @returns the world space position of the light
  90148. */
  90149. getAbsolutePosition(): Vector3;
  90150. /**
  90151. * Specifies if the light will affect the passed mesh.
  90152. * @param mesh The mesh to test against the light
  90153. * @return true the mesh is affected otherwise, false.
  90154. */
  90155. canAffectMesh(mesh: AbstractMesh): boolean;
  90156. /**
  90157. * Sort function to order lights for rendering.
  90158. * @param a First Light object to compare to second.
  90159. * @param b Second Light object to compare first.
  90160. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90161. */
  90162. static CompareLightsPriority(a: Light, b: Light): number;
  90163. /**
  90164. * Releases resources associated with this node.
  90165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90167. */
  90168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90169. /**
  90170. * Returns the light type ID (integer).
  90171. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90172. */
  90173. getTypeID(): number;
  90174. /**
  90175. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90176. * @returns the scaled intensity in intensity mode unit
  90177. */
  90178. getScaledIntensity(): number;
  90179. /**
  90180. * Returns a new Light object, named "name", from the current one.
  90181. * @param name The name of the cloned light
  90182. * @returns the new created light
  90183. */
  90184. clone(name: string): Nullable<Light>;
  90185. /**
  90186. * Serializes the current light into a Serialization object.
  90187. * @returns the serialized object.
  90188. */
  90189. serialize(): any;
  90190. /**
  90191. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90192. * This new light is named "name" and added to the passed scene.
  90193. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90194. * @param name The friendly name of the light
  90195. * @param scene The scene the new light will belong to
  90196. * @returns the constructor function
  90197. */
  90198. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90199. /**
  90200. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90201. * @param parsedLight The JSON representation of the light
  90202. * @param scene The scene to create the parsed light in
  90203. * @returns the created light after parsing
  90204. */
  90205. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90206. private _hookArrayForExcluded;
  90207. private _hookArrayForIncludedOnly;
  90208. private _resyncMeshes;
  90209. /**
  90210. * Forces the meshes to update their light related information in their rendering used effects
  90211. * @hidden Internal Use Only
  90212. */
  90213. _markMeshesAsLightDirty(): void;
  90214. /**
  90215. * Recomputes the cached photometric scale if needed.
  90216. */
  90217. private _computePhotometricScale;
  90218. /**
  90219. * Returns the Photometric Scale according to the light type and intensity mode.
  90220. */
  90221. private _getPhotometricScale;
  90222. /**
  90223. * Reorder the light in the scene according to their defined priority.
  90224. * @hidden Internal Use Only
  90225. */
  90226. _reorderLightsInScene(): void;
  90227. /**
  90228. * Prepares the list of defines specific to the light type.
  90229. * @param defines the list of defines
  90230. * @param lightIndex defines the index of the light for the effect
  90231. */
  90232. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90233. }
  90234. }
  90235. declare module BABYLON {
  90236. /**
  90237. * Interface used to define Action
  90238. */
  90239. export interface IAction {
  90240. /**
  90241. * Trigger for the action
  90242. */
  90243. trigger: number;
  90244. /** Options of the trigger */
  90245. triggerOptions: any;
  90246. /**
  90247. * Gets the trigger parameters
  90248. * @returns the trigger parameters
  90249. */
  90250. getTriggerParameter(): any;
  90251. /**
  90252. * Internal only - executes current action event
  90253. * @hidden
  90254. */
  90255. _executeCurrent(evt?: ActionEvent): void;
  90256. /**
  90257. * Serialize placeholder for child classes
  90258. * @param parent of child
  90259. * @returns the serialized object
  90260. */
  90261. serialize(parent: any): any;
  90262. /**
  90263. * Internal only
  90264. * @hidden
  90265. */
  90266. _prepare(): void;
  90267. /**
  90268. * Internal only - manager for action
  90269. * @hidden
  90270. */
  90271. _actionManager: AbstractActionManager;
  90272. /**
  90273. * Adds action to chain of actions, may be a DoNothingAction
  90274. * @param action defines the next action to execute
  90275. * @returns The action passed in
  90276. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90277. */
  90278. then(action: IAction): IAction;
  90279. }
  90280. /**
  90281. * The action to be carried out following a trigger
  90282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90283. */
  90284. export class Action implements IAction {
  90285. /** the trigger, with or without parameters, for the action */
  90286. triggerOptions: any;
  90287. /**
  90288. * Trigger for the action
  90289. */
  90290. trigger: number;
  90291. /**
  90292. * Internal only - manager for action
  90293. * @hidden
  90294. */
  90295. _actionManager: ActionManager;
  90296. private _nextActiveAction;
  90297. private _child;
  90298. private _condition?;
  90299. private _triggerParameter;
  90300. /**
  90301. * An event triggered prior to action being executed.
  90302. */
  90303. onBeforeExecuteObservable: Observable<Action>;
  90304. /**
  90305. * Creates a new Action
  90306. * @param triggerOptions the trigger, with or without parameters, for the action
  90307. * @param condition an optional determinant of action
  90308. */
  90309. constructor(
  90310. /** the trigger, with or without parameters, for the action */
  90311. triggerOptions: any, condition?: Condition);
  90312. /**
  90313. * Internal only
  90314. * @hidden
  90315. */
  90316. _prepare(): void;
  90317. /**
  90318. * Gets the trigger parameters
  90319. * @returns the trigger parameters
  90320. */
  90321. getTriggerParameter(): any;
  90322. /**
  90323. * Internal only - executes current action event
  90324. * @hidden
  90325. */
  90326. _executeCurrent(evt?: ActionEvent): void;
  90327. /**
  90328. * Execute placeholder for child classes
  90329. * @param evt optional action event
  90330. */
  90331. execute(evt?: ActionEvent): void;
  90332. /**
  90333. * Skips to next active action
  90334. */
  90335. skipToNextActiveAction(): void;
  90336. /**
  90337. * Adds action to chain of actions, may be a DoNothingAction
  90338. * @param action defines the next action to execute
  90339. * @returns The action passed in
  90340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90341. */
  90342. then(action: Action): Action;
  90343. /**
  90344. * Internal only
  90345. * @hidden
  90346. */
  90347. _getProperty(propertyPath: string): string;
  90348. /**
  90349. * Internal only
  90350. * @hidden
  90351. */
  90352. _getEffectiveTarget(target: any, propertyPath: string): any;
  90353. /**
  90354. * Serialize placeholder for child classes
  90355. * @param parent of child
  90356. * @returns the serialized object
  90357. */
  90358. serialize(parent: any): any;
  90359. /**
  90360. * Internal only called by serialize
  90361. * @hidden
  90362. */
  90363. protected _serialize(serializedAction: any, parent?: any): any;
  90364. /**
  90365. * Internal only
  90366. * @hidden
  90367. */
  90368. static _SerializeValueAsString: (value: any) => string;
  90369. /**
  90370. * Internal only
  90371. * @hidden
  90372. */
  90373. static _GetTargetProperty: (target: Node | Scene) => {
  90374. name: string;
  90375. targetType: string;
  90376. value: string;
  90377. };
  90378. }
  90379. }
  90380. declare module BABYLON {
  90381. /**
  90382. * A Condition applied to an Action
  90383. */
  90384. export class Condition {
  90385. /**
  90386. * Internal only - manager for action
  90387. * @hidden
  90388. */
  90389. _actionManager: ActionManager;
  90390. /**
  90391. * Internal only
  90392. * @hidden
  90393. */
  90394. _evaluationId: number;
  90395. /**
  90396. * Internal only
  90397. * @hidden
  90398. */
  90399. _currentResult: boolean;
  90400. /**
  90401. * Creates a new Condition
  90402. * @param actionManager the manager of the action the condition is applied to
  90403. */
  90404. constructor(actionManager: ActionManager);
  90405. /**
  90406. * Check if the current condition is valid
  90407. * @returns a boolean
  90408. */
  90409. isValid(): boolean;
  90410. /**
  90411. * Internal only
  90412. * @hidden
  90413. */
  90414. _getProperty(propertyPath: string): string;
  90415. /**
  90416. * Internal only
  90417. * @hidden
  90418. */
  90419. _getEffectiveTarget(target: any, propertyPath: string): any;
  90420. /**
  90421. * Serialize placeholder for child classes
  90422. * @returns the serialized object
  90423. */
  90424. serialize(): any;
  90425. /**
  90426. * Internal only
  90427. * @hidden
  90428. */
  90429. protected _serialize(serializedCondition: any): any;
  90430. }
  90431. /**
  90432. * Defines specific conditional operators as extensions of Condition
  90433. */
  90434. export class ValueCondition extends Condition {
  90435. /** path to specify the property of the target the conditional operator uses */
  90436. propertyPath: string;
  90437. /** the value compared by the conditional operator against the current value of the property */
  90438. value: any;
  90439. /** the conditional operator, default ValueCondition.IsEqual */
  90440. operator: number;
  90441. /**
  90442. * Internal only
  90443. * @hidden
  90444. */
  90445. private static _IsEqual;
  90446. /**
  90447. * Internal only
  90448. * @hidden
  90449. */
  90450. private static _IsDifferent;
  90451. /**
  90452. * Internal only
  90453. * @hidden
  90454. */
  90455. private static _IsGreater;
  90456. /**
  90457. * Internal only
  90458. * @hidden
  90459. */
  90460. private static _IsLesser;
  90461. /**
  90462. * returns the number for IsEqual
  90463. */
  90464. static get IsEqual(): number;
  90465. /**
  90466. * Returns the number for IsDifferent
  90467. */
  90468. static get IsDifferent(): number;
  90469. /**
  90470. * Returns the number for IsGreater
  90471. */
  90472. static get IsGreater(): number;
  90473. /**
  90474. * Returns the number for IsLesser
  90475. */
  90476. static get IsLesser(): number;
  90477. /**
  90478. * Internal only The action manager for the condition
  90479. * @hidden
  90480. */
  90481. _actionManager: ActionManager;
  90482. /**
  90483. * Internal only
  90484. * @hidden
  90485. */
  90486. private _target;
  90487. /**
  90488. * Internal only
  90489. * @hidden
  90490. */
  90491. private _effectiveTarget;
  90492. /**
  90493. * Internal only
  90494. * @hidden
  90495. */
  90496. private _property;
  90497. /**
  90498. * Creates a new ValueCondition
  90499. * @param actionManager manager for the action the condition applies to
  90500. * @param target for the action
  90501. * @param propertyPath path to specify the property of the target the conditional operator uses
  90502. * @param value the value compared by the conditional operator against the current value of the property
  90503. * @param operator the conditional operator, default ValueCondition.IsEqual
  90504. */
  90505. constructor(actionManager: ActionManager, target: any,
  90506. /** path to specify the property of the target the conditional operator uses */
  90507. propertyPath: string,
  90508. /** the value compared by the conditional operator against the current value of the property */
  90509. value: any,
  90510. /** the conditional operator, default ValueCondition.IsEqual */
  90511. operator?: number);
  90512. /**
  90513. * Compares the given value with the property value for the specified conditional operator
  90514. * @returns the result of the comparison
  90515. */
  90516. isValid(): boolean;
  90517. /**
  90518. * Serialize the ValueCondition into a JSON compatible object
  90519. * @returns serialization object
  90520. */
  90521. serialize(): any;
  90522. /**
  90523. * Gets the name of the conditional operator for the ValueCondition
  90524. * @param operator the conditional operator
  90525. * @returns the name
  90526. */
  90527. static GetOperatorName(operator: number): string;
  90528. }
  90529. /**
  90530. * Defines a predicate condition as an extension of Condition
  90531. */
  90532. export class PredicateCondition extends Condition {
  90533. /** defines the predicate function used to validate the condition */
  90534. predicate: () => boolean;
  90535. /**
  90536. * Internal only - manager for action
  90537. * @hidden
  90538. */
  90539. _actionManager: ActionManager;
  90540. /**
  90541. * Creates a new PredicateCondition
  90542. * @param actionManager manager for the action the condition applies to
  90543. * @param predicate defines the predicate function used to validate the condition
  90544. */
  90545. constructor(actionManager: ActionManager,
  90546. /** defines the predicate function used to validate the condition */
  90547. predicate: () => boolean);
  90548. /**
  90549. * @returns the validity of the predicate condition
  90550. */
  90551. isValid(): boolean;
  90552. }
  90553. /**
  90554. * Defines a state condition as an extension of Condition
  90555. */
  90556. export class StateCondition extends Condition {
  90557. /** Value to compare with target state */
  90558. value: string;
  90559. /**
  90560. * Internal only - manager for action
  90561. * @hidden
  90562. */
  90563. _actionManager: ActionManager;
  90564. /**
  90565. * Internal only
  90566. * @hidden
  90567. */
  90568. private _target;
  90569. /**
  90570. * Creates a new StateCondition
  90571. * @param actionManager manager for the action the condition applies to
  90572. * @param target of the condition
  90573. * @param value to compare with target state
  90574. */
  90575. constructor(actionManager: ActionManager, target: any,
  90576. /** Value to compare with target state */
  90577. value: string);
  90578. /**
  90579. * Gets a boolean indicating if the current condition is met
  90580. * @returns the validity of the state
  90581. */
  90582. isValid(): boolean;
  90583. /**
  90584. * Serialize the StateCondition into a JSON compatible object
  90585. * @returns serialization object
  90586. */
  90587. serialize(): any;
  90588. }
  90589. }
  90590. declare module BABYLON {
  90591. /**
  90592. * This defines an action responsible to toggle a boolean once triggered.
  90593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90594. */
  90595. export class SwitchBooleanAction extends Action {
  90596. /**
  90597. * The path to the boolean property in the target object
  90598. */
  90599. propertyPath: string;
  90600. private _target;
  90601. private _effectiveTarget;
  90602. private _property;
  90603. /**
  90604. * Instantiate the action
  90605. * @param triggerOptions defines the trigger options
  90606. * @param target defines the object containing the boolean
  90607. * @param propertyPath defines the path to the boolean property in the target object
  90608. * @param condition defines the trigger related conditions
  90609. */
  90610. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90611. /** @hidden */
  90612. _prepare(): void;
  90613. /**
  90614. * Execute the action toggle the boolean value.
  90615. */
  90616. execute(): void;
  90617. /**
  90618. * Serializes the actions and its related information.
  90619. * @param parent defines the object to serialize in
  90620. * @returns the serialized object
  90621. */
  90622. serialize(parent: any): any;
  90623. }
  90624. /**
  90625. * This defines an action responsible to set a the state field of the target
  90626. * to a desired value once triggered.
  90627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90628. */
  90629. export class SetStateAction extends Action {
  90630. /**
  90631. * The value to store in the state field.
  90632. */
  90633. value: string;
  90634. private _target;
  90635. /**
  90636. * Instantiate the action
  90637. * @param triggerOptions defines the trigger options
  90638. * @param target defines the object containing the state property
  90639. * @param value defines the value to store in the state field
  90640. * @param condition defines the trigger related conditions
  90641. */
  90642. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90643. /**
  90644. * Execute the action and store the value on the target state property.
  90645. */
  90646. execute(): void;
  90647. /**
  90648. * Serializes the actions and its related information.
  90649. * @param parent defines the object to serialize in
  90650. * @returns the serialized object
  90651. */
  90652. serialize(parent: any): any;
  90653. }
  90654. /**
  90655. * This defines an action responsible to set a property of the target
  90656. * to a desired value once triggered.
  90657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90658. */
  90659. export class SetValueAction extends Action {
  90660. /**
  90661. * The path of the property to set in the target.
  90662. */
  90663. propertyPath: string;
  90664. /**
  90665. * The value to set in the property
  90666. */
  90667. value: any;
  90668. private _target;
  90669. private _effectiveTarget;
  90670. private _property;
  90671. /**
  90672. * Instantiate the action
  90673. * @param triggerOptions defines the trigger options
  90674. * @param target defines the object containing the property
  90675. * @param propertyPath defines the path of the property to set in the target
  90676. * @param value defines the value to set in the property
  90677. * @param condition defines the trigger related conditions
  90678. */
  90679. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90680. /** @hidden */
  90681. _prepare(): void;
  90682. /**
  90683. * Execute the action and set the targetted property to the desired value.
  90684. */
  90685. execute(): void;
  90686. /**
  90687. * Serializes the actions and its related information.
  90688. * @param parent defines the object to serialize in
  90689. * @returns the serialized object
  90690. */
  90691. serialize(parent: any): any;
  90692. }
  90693. /**
  90694. * This defines an action responsible to increment the target value
  90695. * to a desired value once triggered.
  90696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90697. */
  90698. export class IncrementValueAction extends Action {
  90699. /**
  90700. * The path of the property to increment in the target.
  90701. */
  90702. propertyPath: string;
  90703. /**
  90704. * The value we should increment the property by.
  90705. */
  90706. value: any;
  90707. private _target;
  90708. private _effectiveTarget;
  90709. private _property;
  90710. /**
  90711. * Instantiate the action
  90712. * @param triggerOptions defines the trigger options
  90713. * @param target defines the object containing the property
  90714. * @param propertyPath defines the path of the property to increment in the target
  90715. * @param value defines the value value we should increment the property by
  90716. * @param condition defines the trigger related conditions
  90717. */
  90718. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90719. /** @hidden */
  90720. _prepare(): void;
  90721. /**
  90722. * Execute the action and increment the target of the value amount.
  90723. */
  90724. execute(): void;
  90725. /**
  90726. * Serializes the actions and its related information.
  90727. * @param parent defines the object to serialize in
  90728. * @returns the serialized object
  90729. */
  90730. serialize(parent: any): any;
  90731. }
  90732. /**
  90733. * This defines an action responsible to start an animation once triggered.
  90734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90735. */
  90736. export class PlayAnimationAction extends Action {
  90737. /**
  90738. * Where the animation should start (animation frame)
  90739. */
  90740. from: number;
  90741. /**
  90742. * Where the animation should stop (animation frame)
  90743. */
  90744. to: number;
  90745. /**
  90746. * Define if the animation should loop or stop after the first play.
  90747. */
  90748. loop?: boolean;
  90749. private _target;
  90750. /**
  90751. * Instantiate the action
  90752. * @param triggerOptions defines the trigger options
  90753. * @param target defines the target animation or animation name
  90754. * @param from defines from where the animation should start (animation frame)
  90755. * @param end defines where the animation should stop (animation frame)
  90756. * @param loop defines if the animation should loop or stop after the first play
  90757. * @param condition defines the trigger related conditions
  90758. */
  90759. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90760. /** @hidden */
  90761. _prepare(): void;
  90762. /**
  90763. * Execute the action and play the animation.
  90764. */
  90765. execute(): void;
  90766. /**
  90767. * Serializes the actions and its related information.
  90768. * @param parent defines the object to serialize in
  90769. * @returns the serialized object
  90770. */
  90771. serialize(parent: any): any;
  90772. }
  90773. /**
  90774. * This defines an action responsible to stop an animation once triggered.
  90775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90776. */
  90777. export class StopAnimationAction extends Action {
  90778. private _target;
  90779. /**
  90780. * Instantiate the action
  90781. * @param triggerOptions defines the trigger options
  90782. * @param target defines the target animation or animation name
  90783. * @param condition defines the trigger related conditions
  90784. */
  90785. constructor(triggerOptions: any, target: any, condition?: Condition);
  90786. /** @hidden */
  90787. _prepare(): void;
  90788. /**
  90789. * Execute the action and stop the animation.
  90790. */
  90791. execute(): void;
  90792. /**
  90793. * Serializes the actions and its related information.
  90794. * @param parent defines the object to serialize in
  90795. * @returns the serialized object
  90796. */
  90797. serialize(parent: any): any;
  90798. }
  90799. /**
  90800. * This defines an action responsible that does nothing once triggered.
  90801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90802. */
  90803. export class DoNothingAction extends Action {
  90804. /**
  90805. * Instantiate the action
  90806. * @param triggerOptions defines the trigger options
  90807. * @param condition defines the trigger related conditions
  90808. */
  90809. constructor(triggerOptions?: any, condition?: Condition);
  90810. /**
  90811. * Execute the action and do nothing.
  90812. */
  90813. execute(): void;
  90814. /**
  90815. * Serializes the actions and its related information.
  90816. * @param parent defines the object to serialize in
  90817. * @returns the serialized object
  90818. */
  90819. serialize(parent: any): any;
  90820. }
  90821. /**
  90822. * This defines an action responsible to trigger several actions once triggered.
  90823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90824. */
  90825. export class CombineAction extends Action {
  90826. /**
  90827. * The list of aggregated animations to run.
  90828. */
  90829. children: Action[];
  90830. /**
  90831. * Instantiate the action
  90832. * @param triggerOptions defines the trigger options
  90833. * @param children defines the list of aggregated animations to run
  90834. * @param condition defines the trigger related conditions
  90835. */
  90836. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90837. /** @hidden */
  90838. _prepare(): void;
  90839. /**
  90840. * Execute the action and executes all the aggregated actions.
  90841. */
  90842. execute(evt: ActionEvent): void;
  90843. /**
  90844. * Serializes the actions and its related information.
  90845. * @param parent defines the object to serialize in
  90846. * @returns the serialized object
  90847. */
  90848. serialize(parent: any): any;
  90849. }
  90850. /**
  90851. * This defines an action responsible to run code (external event) once triggered.
  90852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90853. */
  90854. export class ExecuteCodeAction extends Action {
  90855. /**
  90856. * The callback function to run.
  90857. */
  90858. func: (evt: ActionEvent) => void;
  90859. /**
  90860. * Instantiate the action
  90861. * @param triggerOptions defines the trigger options
  90862. * @param func defines the callback function to run
  90863. * @param condition defines the trigger related conditions
  90864. */
  90865. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90866. /**
  90867. * Execute the action and run the attached code.
  90868. */
  90869. execute(evt: ActionEvent): void;
  90870. }
  90871. /**
  90872. * This defines an action responsible to set the parent property of the target once triggered.
  90873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90874. */
  90875. export class SetParentAction extends Action {
  90876. private _parent;
  90877. private _target;
  90878. /**
  90879. * Instantiate the action
  90880. * @param triggerOptions defines the trigger options
  90881. * @param target defines the target containing the parent property
  90882. * @param parent defines from where the animation should start (animation frame)
  90883. * @param condition defines the trigger related conditions
  90884. */
  90885. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90886. /** @hidden */
  90887. _prepare(): void;
  90888. /**
  90889. * Execute the action and set the parent property.
  90890. */
  90891. execute(): void;
  90892. /**
  90893. * Serializes the actions and its related information.
  90894. * @param parent defines the object to serialize in
  90895. * @returns the serialized object
  90896. */
  90897. serialize(parent: any): any;
  90898. }
  90899. }
  90900. declare module BABYLON {
  90901. /**
  90902. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90903. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90905. */
  90906. export class ActionManager extends AbstractActionManager {
  90907. /**
  90908. * Nothing
  90909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90910. */
  90911. static readonly NothingTrigger: number;
  90912. /**
  90913. * On pick
  90914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90915. */
  90916. static readonly OnPickTrigger: number;
  90917. /**
  90918. * On left pick
  90919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90920. */
  90921. static readonly OnLeftPickTrigger: number;
  90922. /**
  90923. * On right pick
  90924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90925. */
  90926. static readonly OnRightPickTrigger: number;
  90927. /**
  90928. * On center pick
  90929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90930. */
  90931. static readonly OnCenterPickTrigger: number;
  90932. /**
  90933. * On pick down
  90934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90935. */
  90936. static readonly OnPickDownTrigger: number;
  90937. /**
  90938. * On double pick
  90939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90940. */
  90941. static readonly OnDoublePickTrigger: number;
  90942. /**
  90943. * On pick up
  90944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90945. */
  90946. static readonly OnPickUpTrigger: number;
  90947. /**
  90948. * On pick out.
  90949. * This trigger will only be raised if you also declared a OnPickDown
  90950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90951. */
  90952. static readonly OnPickOutTrigger: number;
  90953. /**
  90954. * On long press
  90955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90956. */
  90957. static readonly OnLongPressTrigger: number;
  90958. /**
  90959. * On pointer over
  90960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90961. */
  90962. static readonly OnPointerOverTrigger: number;
  90963. /**
  90964. * On pointer out
  90965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90966. */
  90967. static readonly OnPointerOutTrigger: number;
  90968. /**
  90969. * On every frame
  90970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90971. */
  90972. static readonly OnEveryFrameTrigger: number;
  90973. /**
  90974. * On intersection enter
  90975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90976. */
  90977. static readonly OnIntersectionEnterTrigger: number;
  90978. /**
  90979. * On intersection exit
  90980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90981. */
  90982. static readonly OnIntersectionExitTrigger: number;
  90983. /**
  90984. * On key down
  90985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90986. */
  90987. static readonly OnKeyDownTrigger: number;
  90988. /**
  90989. * On key up
  90990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90991. */
  90992. static readonly OnKeyUpTrigger: number;
  90993. private _scene;
  90994. /**
  90995. * Creates a new action manager
  90996. * @param scene defines the hosting scene
  90997. */
  90998. constructor(scene: Scene);
  90999. /**
  91000. * Releases all associated resources
  91001. */
  91002. dispose(): void;
  91003. /**
  91004. * Gets hosting scene
  91005. * @returns the hosting scene
  91006. */
  91007. getScene(): Scene;
  91008. /**
  91009. * Does this action manager handles actions of any of the given triggers
  91010. * @param triggers defines the triggers to be tested
  91011. * @return a boolean indicating whether one (or more) of the triggers is handled
  91012. */
  91013. hasSpecificTriggers(triggers: number[]): boolean;
  91014. /**
  91015. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91016. * speed.
  91017. * @param triggerA defines the trigger to be tested
  91018. * @param triggerB defines the trigger to be tested
  91019. * @return a boolean indicating whether one (or more) of the triggers is handled
  91020. */
  91021. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91022. /**
  91023. * Does this action manager handles actions of a given trigger
  91024. * @param trigger defines the trigger to be tested
  91025. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91026. * @return whether the trigger is handled
  91027. */
  91028. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91029. /**
  91030. * Does this action manager has pointer triggers
  91031. */
  91032. get hasPointerTriggers(): boolean;
  91033. /**
  91034. * Does this action manager has pick triggers
  91035. */
  91036. get hasPickTriggers(): boolean;
  91037. /**
  91038. * Registers an action to this action manager
  91039. * @param action defines the action to be registered
  91040. * @return the action amended (prepared) after registration
  91041. */
  91042. registerAction(action: IAction): Nullable<IAction>;
  91043. /**
  91044. * Unregisters an action to this action manager
  91045. * @param action defines the action to be unregistered
  91046. * @return a boolean indicating whether the action has been unregistered
  91047. */
  91048. unregisterAction(action: IAction): Boolean;
  91049. /**
  91050. * Process a specific trigger
  91051. * @param trigger defines the trigger to process
  91052. * @param evt defines the event details to be processed
  91053. */
  91054. processTrigger(trigger: number, evt?: IActionEvent): void;
  91055. /** @hidden */
  91056. _getEffectiveTarget(target: any, propertyPath: string): any;
  91057. /** @hidden */
  91058. _getProperty(propertyPath: string): string;
  91059. /**
  91060. * Serialize this manager to a JSON object
  91061. * @param name defines the property name to store this manager
  91062. * @returns a JSON representation of this manager
  91063. */
  91064. serialize(name: string): any;
  91065. /**
  91066. * Creates a new ActionManager from a JSON data
  91067. * @param parsedActions defines the JSON data to read from
  91068. * @param object defines the hosting mesh
  91069. * @param scene defines the hosting scene
  91070. */
  91071. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91072. /**
  91073. * Get a trigger name by index
  91074. * @param trigger defines the trigger index
  91075. * @returns a trigger name
  91076. */
  91077. static GetTriggerName(trigger: number): string;
  91078. }
  91079. }
  91080. declare module BABYLON {
  91081. /**
  91082. * Class used to represent a sprite
  91083. * @see http://doc.babylonjs.com/babylon101/sprites
  91084. */
  91085. export class Sprite {
  91086. /** defines the name */
  91087. name: string;
  91088. /** Gets or sets the current world position */
  91089. position: Vector3;
  91090. /** Gets or sets the main color */
  91091. color: Color4;
  91092. /** Gets or sets the width */
  91093. width: number;
  91094. /** Gets or sets the height */
  91095. height: number;
  91096. /** Gets or sets rotation angle */
  91097. angle: number;
  91098. /** Gets or sets the cell index in the sprite sheet */
  91099. cellIndex: number;
  91100. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91101. cellRef: string;
  91102. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91103. invertU: number;
  91104. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91105. invertV: number;
  91106. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91107. disposeWhenFinishedAnimating: boolean;
  91108. /** Gets the list of attached animations */
  91109. animations: Animation[];
  91110. /** Gets or sets a boolean indicating if the sprite can be picked */
  91111. isPickable: boolean;
  91112. /**
  91113. * Gets or sets the associated action manager
  91114. */
  91115. actionManager: Nullable<ActionManager>;
  91116. private _animationStarted;
  91117. private _loopAnimation;
  91118. private _fromIndex;
  91119. private _toIndex;
  91120. private _delay;
  91121. private _direction;
  91122. private _manager;
  91123. private _time;
  91124. private _onAnimationEnd;
  91125. /**
  91126. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91127. */
  91128. isVisible: boolean;
  91129. /**
  91130. * Gets or sets the sprite size
  91131. */
  91132. get size(): number;
  91133. set size(value: number);
  91134. /**
  91135. * Creates a new Sprite
  91136. * @param name defines the name
  91137. * @param manager defines the manager
  91138. */
  91139. constructor(
  91140. /** defines the name */
  91141. name: string, manager: ISpriteManager);
  91142. /**
  91143. * Starts an animation
  91144. * @param from defines the initial key
  91145. * @param to defines the end key
  91146. * @param loop defines if the animation must loop
  91147. * @param delay defines the start delay (in ms)
  91148. * @param onAnimationEnd defines a callback to call when animation ends
  91149. */
  91150. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91151. /** Stops current animation (if any) */
  91152. stopAnimation(): void;
  91153. /** @hidden */
  91154. _animate(deltaTime: number): void;
  91155. /** Release associated resources */
  91156. dispose(): void;
  91157. }
  91158. }
  91159. declare module BABYLON {
  91160. /**
  91161. * Information about the result of picking within a scene
  91162. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91163. */
  91164. export class PickingInfo {
  91165. /** @hidden */
  91166. _pickingUnavailable: boolean;
  91167. /**
  91168. * If the pick collided with an object
  91169. */
  91170. hit: boolean;
  91171. /**
  91172. * Distance away where the pick collided
  91173. */
  91174. distance: number;
  91175. /**
  91176. * The location of pick collision
  91177. */
  91178. pickedPoint: Nullable<Vector3>;
  91179. /**
  91180. * The mesh corresponding the the pick collision
  91181. */
  91182. pickedMesh: Nullable<AbstractMesh>;
  91183. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91184. bu: number;
  91185. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91186. bv: number;
  91187. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91188. faceId: number;
  91189. /** Id of the the submesh that was picked */
  91190. subMeshId: number;
  91191. /** If a sprite was picked, this will be the sprite the pick collided with */
  91192. pickedSprite: Nullable<Sprite>;
  91193. /**
  91194. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91195. */
  91196. originMesh: Nullable<AbstractMesh>;
  91197. /**
  91198. * The ray that was used to perform the picking.
  91199. */
  91200. ray: Nullable<Ray>;
  91201. /**
  91202. * Gets the normal correspodning to the face the pick collided with
  91203. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91204. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91205. * @returns The normal correspodning to the face the pick collided with
  91206. */
  91207. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91208. /**
  91209. * Gets the texture coordinates of where the pick occured
  91210. * @returns the vector containing the coordnates of the texture
  91211. */
  91212. getTextureCoordinates(): Nullable<Vector2>;
  91213. }
  91214. }
  91215. declare module BABYLON {
  91216. /**
  91217. * Gather the list of pointer event types as constants.
  91218. */
  91219. export class PointerEventTypes {
  91220. /**
  91221. * 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.
  91222. */
  91223. static readonly POINTERDOWN: number;
  91224. /**
  91225. * The pointerup event is fired when a pointer is no longer active.
  91226. */
  91227. static readonly POINTERUP: number;
  91228. /**
  91229. * The pointermove event is fired when a pointer changes coordinates.
  91230. */
  91231. static readonly POINTERMOVE: number;
  91232. /**
  91233. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91234. */
  91235. static readonly POINTERWHEEL: number;
  91236. /**
  91237. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91238. */
  91239. static readonly POINTERPICK: number;
  91240. /**
  91241. * The pointertap event is fired when a the object has been touched and released without drag.
  91242. */
  91243. static readonly POINTERTAP: number;
  91244. /**
  91245. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91246. */
  91247. static readonly POINTERDOUBLETAP: number;
  91248. }
  91249. /**
  91250. * Base class of pointer info types.
  91251. */
  91252. export class PointerInfoBase {
  91253. /**
  91254. * Defines the type of event (PointerEventTypes)
  91255. */
  91256. type: number;
  91257. /**
  91258. * Defines the related dom event
  91259. */
  91260. event: PointerEvent | MouseWheelEvent;
  91261. /**
  91262. * Instantiates the base class of pointers info.
  91263. * @param type Defines the type of event (PointerEventTypes)
  91264. * @param event Defines the related dom event
  91265. */
  91266. constructor(
  91267. /**
  91268. * Defines the type of event (PointerEventTypes)
  91269. */
  91270. type: number,
  91271. /**
  91272. * Defines the related dom event
  91273. */
  91274. event: PointerEvent | MouseWheelEvent);
  91275. }
  91276. /**
  91277. * This class is used to store pointer related info for the onPrePointerObservable event.
  91278. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91279. */
  91280. export class PointerInfoPre extends PointerInfoBase {
  91281. /**
  91282. * Ray from a pointer if availible (eg. 6dof controller)
  91283. */
  91284. ray: Nullable<Ray>;
  91285. /**
  91286. * Defines the local position of the pointer on the canvas.
  91287. */
  91288. localPosition: Vector2;
  91289. /**
  91290. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91291. */
  91292. skipOnPointerObservable: boolean;
  91293. /**
  91294. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91295. * @param type Defines the type of event (PointerEventTypes)
  91296. * @param event Defines the related dom event
  91297. * @param localX Defines the local x coordinates of the pointer when the event occured
  91298. * @param localY Defines the local y coordinates of the pointer when the event occured
  91299. */
  91300. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91301. }
  91302. /**
  91303. * This type contains all the data related to a pointer event in Babylon.js.
  91304. * 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.
  91305. */
  91306. export class PointerInfo extends PointerInfoBase {
  91307. /**
  91308. * Defines the picking info associated to the info (if any)\
  91309. */
  91310. pickInfo: Nullable<PickingInfo>;
  91311. /**
  91312. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91313. * @param type Defines the type of event (PointerEventTypes)
  91314. * @param event Defines the related dom event
  91315. * @param pickInfo Defines the picking info associated to the info (if any)\
  91316. */
  91317. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91318. /**
  91319. * Defines the picking info associated to the info (if any)\
  91320. */
  91321. pickInfo: Nullable<PickingInfo>);
  91322. }
  91323. /**
  91324. * Data relating to a touch event on the screen.
  91325. */
  91326. export interface PointerTouch {
  91327. /**
  91328. * X coordinate of touch.
  91329. */
  91330. x: number;
  91331. /**
  91332. * Y coordinate of touch.
  91333. */
  91334. y: number;
  91335. /**
  91336. * Id of touch. Unique for each finger.
  91337. */
  91338. pointerId: number;
  91339. /**
  91340. * Event type passed from DOM.
  91341. */
  91342. type: any;
  91343. }
  91344. }
  91345. declare module BABYLON {
  91346. /**
  91347. * Manage the mouse inputs to control the movement of a free camera.
  91348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91349. */
  91350. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91351. /**
  91352. * Define if touch is enabled in the mouse input
  91353. */
  91354. touchEnabled: boolean;
  91355. /**
  91356. * Defines the camera the input is attached to.
  91357. */
  91358. camera: FreeCamera;
  91359. /**
  91360. * Defines the buttons associated with the input to handle camera move.
  91361. */
  91362. buttons: number[];
  91363. /**
  91364. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91365. */
  91366. angularSensibility: number;
  91367. private _pointerInput;
  91368. private _onMouseMove;
  91369. private _observer;
  91370. private previousPosition;
  91371. /**
  91372. * Observable for when a pointer move event occurs containing the move offset
  91373. */
  91374. onPointerMovedObservable: Observable<{
  91375. offsetX: number;
  91376. offsetY: number;
  91377. }>;
  91378. /**
  91379. * @hidden
  91380. * If the camera should be rotated automatically based on pointer movement
  91381. */
  91382. _allowCameraRotation: boolean;
  91383. /**
  91384. * Manage the mouse inputs to control the movement of a free camera.
  91385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91386. * @param touchEnabled Defines if touch is enabled or not
  91387. */
  91388. constructor(
  91389. /**
  91390. * Define if touch is enabled in the mouse input
  91391. */
  91392. touchEnabled?: boolean);
  91393. /**
  91394. * Attach the input controls to a specific dom element to get the input from.
  91395. * @param element Defines the element the controls should be listened from
  91396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91397. */
  91398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91399. /**
  91400. * Called on JS contextmenu event.
  91401. * Override this method to provide functionality.
  91402. */
  91403. protected onContextMenu(evt: PointerEvent): void;
  91404. /**
  91405. * Detach the current controls from the specified dom element.
  91406. * @param element Defines the element to stop listening the inputs from
  91407. */
  91408. detachControl(element: Nullable<HTMLElement>): void;
  91409. /**
  91410. * Gets the class name of the current intput.
  91411. * @returns the class name
  91412. */
  91413. getClassName(): string;
  91414. /**
  91415. * Get the friendly name associated with the input class.
  91416. * @returns the input friendly name
  91417. */
  91418. getSimpleName(): string;
  91419. }
  91420. }
  91421. declare module BABYLON {
  91422. /**
  91423. * Manage the touch inputs to control the movement of a free camera.
  91424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91425. */
  91426. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91427. /**
  91428. * Defines the camera the input is attached to.
  91429. */
  91430. camera: FreeCamera;
  91431. /**
  91432. * Defines the touch sensibility for rotation.
  91433. * The higher the faster.
  91434. */
  91435. touchAngularSensibility: number;
  91436. /**
  91437. * Defines the touch sensibility for move.
  91438. * The higher the faster.
  91439. */
  91440. touchMoveSensibility: number;
  91441. private _offsetX;
  91442. private _offsetY;
  91443. private _pointerPressed;
  91444. private _pointerInput;
  91445. private _observer;
  91446. private _onLostFocus;
  91447. /**
  91448. * Attach the input controls to a specific dom element to get the input from.
  91449. * @param element Defines the element the controls should be listened from
  91450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91451. */
  91452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91453. /**
  91454. * Detach the current controls from the specified dom element.
  91455. * @param element Defines the element to stop listening the inputs from
  91456. */
  91457. detachControl(element: Nullable<HTMLElement>): void;
  91458. /**
  91459. * Update the current camera state depending on the inputs that have been used this frame.
  91460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91461. */
  91462. checkInputs(): void;
  91463. /**
  91464. * Gets the class name of the current intput.
  91465. * @returns the class name
  91466. */
  91467. getClassName(): string;
  91468. /**
  91469. * Get the friendly name associated with the input class.
  91470. * @returns the input friendly name
  91471. */
  91472. getSimpleName(): string;
  91473. }
  91474. }
  91475. declare module BABYLON {
  91476. /**
  91477. * Default Inputs manager for the FreeCamera.
  91478. * It groups all the default supported inputs for ease of use.
  91479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91480. */
  91481. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91482. /**
  91483. * @hidden
  91484. */
  91485. _mouseInput: Nullable<FreeCameraMouseInput>;
  91486. /**
  91487. * Instantiates a new FreeCameraInputsManager.
  91488. * @param camera Defines the camera the inputs belong to
  91489. */
  91490. constructor(camera: FreeCamera);
  91491. /**
  91492. * Add keyboard input support to the input manager.
  91493. * @returns the current input manager
  91494. */
  91495. addKeyboard(): FreeCameraInputsManager;
  91496. /**
  91497. * Add mouse input support to the input manager.
  91498. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91499. * @returns the current input manager
  91500. */
  91501. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91502. /**
  91503. * Removes the mouse input support from the manager
  91504. * @returns the current input manager
  91505. */
  91506. removeMouse(): FreeCameraInputsManager;
  91507. /**
  91508. * Add touch input support to the input manager.
  91509. * @returns the current input manager
  91510. */
  91511. addTouch(): FreeCameraInputsManager;
  91512. /**
  91513. * Remove all attached input methods from a camera
  91514. */
  91515. clear(): void;
  91516. }
  91517. }
  91518. declare module BABYLON {
  91519. /**
  91520. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91521. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91522. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91523. */
  91524. export class FreeCamera extends TargetCamera {
  91525. /**
  91526. * Define the collision ellipsoid of the camera.
  91527. * This is helpful to simulate a camera body like the player body around the camera
  91528. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91529. */
  91530. ellipsoid: Vector3;
  91531. /**
  91532. * Define an offset for the position of the ellipsoid around the camera.
  91533. * This can be helpful to determine the center of the body near the gravity center of the body
  91534. * instead of its head.
  91535. */
  91536. ellipsoidOffset: Vector3;
  91537. /**
  91538. * Enable or disable collisions of the camera with the rest of the scene objects.
  91539. */
  91540. checkCollisions: boolean;
  91541. /**
  91542. * Enable or disable gravity on the camera.
  91543. */
  91544. applyGravity: boolean;
  91545. /**
  91546. * Define the input manager associated to the camera.
  91547. */
  91548. inputs: FreeCameraInputsManager;
  91549. /**
  91550. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91551. * Higher values reduce sensitivity.
  91552. */
  91553. get angularSensibility(): number;
  91554. /**
  91555. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91556. * Higher values reduce sensitivity.
  91557. */
  91558. set angularSensibility(value: number);
  91559. /**
  91560. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91561. */
  91562. get keysUp(): number[];
  91563. set keysUp(value: number[]);
  91564. /**
  91565. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91566. */
  91567. get keysDown(): number[];
  91568. set keysDown(value: number[]);
  91569. /**
  91570. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91571. */
  91572. get keysLeft(): number[];
  91573. set keysLeft(value: number[]);
  91574. /**
  91575. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91576. */
  91577. get keysRight(): number[];
  91578. set keysRight(value: number[]);
  91579. /**
  91580. * Event raised when the camera collide with a mesh in the scene.
  91581. */
  91582. onCollide: (collidedMesh: AbstractMesh) => void;
  91583. private _collider;
  91584. private _needMoveForGravity;
  91585. private _oldPosition;
  91586. private _diffPosition;
  91587. private _newPosition;
  91588. /** @hidden */
  91589. _localDirection: Vector3;
  91590. /** @hidden */
  91591. _transformedDirection: Vector3;
  91592. /**
  91593. * Instantiates a Free Camera.
  91594. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91595. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91596. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91597. * @param name Define the name of the camera in the scene
  91598. * @param position Define the start position of the camera in the scene
  91599. * @param scene Define the scene the camera belongs to
  91600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91601. */
  91602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91603. /**
  91604. * Attached controls to the current camera.
  91605. * @param element Defines the element the controls should be listened from
  91606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91607. */
  91608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91609. /**
  91610. * Detach the current controls from the camera.
  91611. * The camera will stop reacting to inputs.
  91612. * @param element Defines the element to stop listening the inputs from
  91613. */
  91614. detachControl(element: HTMLElement): void;
  91615. private _collisionMask;
  91616. /**
  91617. * Define a collision mask to limit the list of object the camera can collide with
  91618. */
  91619. get collisionMask(): number;
  91620. set collisionMask(mask: number);
  91621. /** @hidden */
  91622. _collideWithWorld(displacement: Vector3): void;
  91623. private _onCollisionPositionChange;
  91624. /** @hidden */
  91625. _checkInputs(): void;
  91626. /** @hidden */
  91627. _decideIfNeedsToMove(): boolean;
  91628. /** @hidden */
  91629. _updatePosition(): void;
  91630. /**
  91631. * Destroy the camera and release the current resources hold by it.
  91632. */
  91633. dispose(): void;
  91634. /**
  91635. * Gets the current object class name.
  91636. * @return the class name
  91637. */
  91638. getClassName(): string;
  91639. }
  91640. }
  91641. declare module BABYLON {
  91642. /**
  91643. * Represents a gamepad control stick position
  91644. */
  91645. export class StickValues {
  91646. /**
  91647. * The x component of the control stick
  91648. */
  91649. x: number;
  91650. /**
  91651. * The y component of the control stick
  91652. */
  91653. y: number;
  91654. /**
  91655. * Initializes the gamepad x and y control stick values
  91656. * @param x The x component of the gamepad control stick value
  91657. * @param y The y component of the gamepad control stick value
  91658. */
  91659. constructor(
  91660. /**
  91661. * The x component of the control stick
  91662. */
  91663. x: number,
  91664. /**
  91665. * The y component of the control stick
  91666. */
  91667. y: number);
  91668. }
  91669. /**
  91670. * An interface which manages callbacks for gamepad button changes
  91671. */
  91672. export interface GamepadButtonChanges {
  91673. /**
  91674. * Called when a gamepad has been changed
  91675. */
  91676. changed: boolean;
  91677. /**
  91678. * Called when a gamepad press event has been triggered
  91679. */
  91680. pressChanged: boolean;
  91681. /**
  91682. * Called when a touch event has been triggered
  91683. */
  91684. touchChanged: boolean;
  91685. /**
  91686. * Called when a value has changed
  91687. */
  91688. valueChanged: boolean;
  91689. }
  91690. /**
  91691. * Represents a gamepad
  91692. */
  91693. export class Gamepad {
  91694. /**
  91695. * The id of the gamepad
  91696. */
  91697. id: string;
  91698. /**
  91699. * The index of the gamepad
  91700. */
  91701. index: number;
  91702. /**
  91703. * The browser gamepad
  91704. */
  91705. browserGamepad: any;
  91706. /**
  91707. * Specifies what type of gamepad this represents
  91708. */
  91709. type: number;
  91710. private _leftStick;
  91711. private _rightStick;
  91712. /** @hidden */
  91713. _isConnected: boolean;
  91714. private _leftStickAxisX;
  91715. private _leftStickAxisY;
  91716. private _rightStickAxisX;
  91717. private _rightStickAxisY;
  91718. /**
  91719. * Triggered when the left control stick has been changed
  91720. */
  91721. private _onleftstickchanged;
  91722. /**
  91723. * Triggered when the right control stick has been changed
  91724. */
  91725. private _onrightstickchanged;
  91726. /**
  91727. * Represents a gamepad controller
  91728. */
  91729. static GAMEPAD: number;
  91730. /**
  91731. * Represents a generic controller
  91732. */
  91733. static GENERIC: number;
  91734. /**
  91735. * Represents an XBox controller
  91736. */
  91737. static XBOX: number;
  91738. /**
  91739. * Represents a pose-enabled controller
  91740. */
  91741. static POSE_ENABLED: number;
  91742. /**
  91743. * Represents an Dual Shock controller
  91744. */
  91745. static DUALSHOCK: number;
  91746. /**
  91747. * Specifies whether the left control stick should be Y-inverted
  91748. */
  91749. protected _invertLeftStickY: boolean;
  91750. /**
  91751. * Specifies if the gamepad has been connected
  91752. */
  91753. get isConnected(): boolean;
  91754. /**
  91755. * Initializes the gamepad
  91756. * @param id The id of the gamepad
  91757. * @param index The index of the gamepad
  91758. * @param browserGamepad The browser gamepad
  91759. * @param leftStickX The x component of the left joystick
  91760. * @param leftStickY The y component of the left joystick
  91761. * @param rightStickX The x component of the right joystick
  91762. * @param rightStickY The y component of the right joystick
  91763. */
  91764. constructor(
  91765. /**
  91766. * The id of the gamepad
  91767. */
  91768. id: string,
  91769. /**
  91770. * The index of the gamepad
  91771. */
  91772. index: number,
  91773. /**
  91774. * The browser gamepad
  91775. */
  91776. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91777. /**
  91778. * Callback triggered when the left joystick has changed
  91779. * @param callback
  91780. */
  91781. onleftstickchanged(callback: (values: StickValues) => void): void;
  91782. /**
  91783. * Callback triggered when the right joystick has changed
  91784. * @param callback
  91785. */
  91786. onrightstickchanged(callback: (values: StickValues) => void): void;
  91787. /**
  91788. * Gets the left joystick
  91789. */
  91790. get leftStick(): StickValues;
  91791. /**
  91792. * Sets the left joystick values
  91793. */
  91794. set leftStick(newValues: StickValues);
  91795. /**
  91796. * Gets the right joystick
  91797. */
  91798. get rightStick(): StickValues;
  91799. /**
  91800. * Sets the right joystick value
  91801. */
  91802. set rightStick(newValues: StickValues);
  91803. /**
  91804. * Updates the gamepad joystick positions
  91805. */
  91806. update(): void;
  91807. /**
  91808. * Disposes the gamepad
  91809. */
  91810. dispose(): void;
  91811. }
  91812. /**
  91813. * Represents a generic gamepad
  91814. */
  91815. export class GenericPad extends Gamepad {
  91816. private _buttons;
  91817. private _onbuttondown;
  91818. private _onbuttonup;
  91819. /**
  91820. * Observable triggered when a button has been pressed
  91821. */
  91822. onButtonDownObservable: Observable<number>;
  91823. /**
  91824. * Observable triggered when a button has been released
  91825. */
  91826. onButtonUpObservable: Observable<number>;
  91827. /**
  91828. * Callback triggered when a button has been pressed
  91829. * @param callback Called when a button has been pressed
  91830. */
  91831. onbuttondown(callback: (buttonPressed: number) => void): void;
  91832. /**
  91833. * Callback triggered when a button has been released
  91834. * @param callback Called when a button has been released
  91835. */
  91836. onbuttonup(callback: (buttonReleased: number) => void): void;
  91837. /**
  91838. * Initializes the generic gamepad
  91839. * @param id The id of the generic gamepad
  91840. * @param index The index of the generic gamepad
  91841. * @param browserGamepad The browser gamepad
  91842. */
  91843. constructor(id: string, index: number, browserGamepad: any);
  91844. private _setButtonValue;
  91845. /**
  91846. * Updates the generic gamepad
  91847. */
  91848. update(): void;
  91849. /**
  91850. * Disposes the generic gamepad
  91851. */
  91852. dispose(): void;
  91853. }
  91854. }
  91855. declare module BABYLON {
  91856. /**
  91857. * Defines the types of pose enabled controllers that are supported
  91858. */
  91859. export enum PoseEnabledControllerType {
  91860. /**
  91861. * HTC Vive
  91862. */
  91863. VIVE = 0,
  91864. /**
  91865. * Oculus Rift
  91866. */
  91867. OCULUS = 1,
  91868. /**
  91869. * Windows mixed reality
  91870. */
  91871. WINDOWS = 2,
  91872. /**
  91873. * Samsung gear VR
  91874. */
  91875. GEAR_VR = 3,
  91876. /**
  91877. * Google Daydream
  91878. */
  91879. DAYDREAM = 4,
  91880. /**
  91881. * Generic
  91882. */
  91883. GENERIC = 5
  91884. }
  91885. /**
  91886. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91887. */
  91888. export interface MutableGamepadButton {
  91889. /**
  91890. * Value of the button/trigger
  91891. */
  91892. value: number;
  91893. /**
  91894. * If the button/trigger is currently touched
  91895. */
  91896. touched: boolean;
  91897. /**
  91898. * If the button/trigger is currently pressed
  91899. */
  91900. pressed: boolean;
  91901. }
  91902. /**
  91903. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91904. * @hidden
  91905. */
  91906. export interface ExtendedGamepadButton extends GamepadButton {
  91907. /**
  91908. * If the button/trigger is currently pressed
  91909. */
  91910. readonly pressed: boolean;
  91911. /**
  91912. * If the button/trigger is currently touched
  91913. */
  91914. readonly touched: boolean;
  91915. /**
  91916. * Value of the button/trigger
  91917. */
  91918. readonly value: number;
  91919. }
  91920. /** @hidden */
  91921. export interface _GamePadFactory {
  91922. /**
  91923. * Returns whether or not the current gamepad can be created for this type of controller.
  91924. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91925. * @returns true if it can be created, otherwise false
  91926. */
  91927. canCreate(gamepadInfo: any): boolean;
  91928. /**
  91929. * Creates a new instance of the Gamepad.
  91930. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91931. * @returns the new gamepad instance
  91932. */
  91933. create(gamepadInfo: any): Gamepad;
  91934. }
  91935. /**
  91936. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91937. */
  91938. export class PoseEnabledControllerHelper {
  91939. /** @hidden */
  91940. static _ControllerFactories: _GamePadFactory[];
  91941. /** @hidden */
  91942. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91943. /**
  91944. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91945. * @param vrGamepad the gamepad to initialized
  91946. * @returns a vr controller of the type the gamepad identified as
  91947. */
  91948. static InitiateController(vrGamepad: any): Gamepad;
  91949. }
  91950. /**
  91951. * Defines the PoseEnabledController object that contains state of a vr capable controller
  91952. */
  91953. export class PoseEnabledController extends Gamepad implements PoseControlled {
  91954. /**
  91955. * If the controller is used in a webXR session
  91956. */
  91957. isXR: boolean;
  91958. private _deviceRoomPosition;
  91959. private _deviceRoomRotationQuaternion;
  91960. /**
  91961. * The device position in babylon space
  91962. */
  91963. devicePosition: Vector3;
  91964. /**
  91965. * The device rotation in babylon space
  91966. */
  91967. deviceRotationQuaternion: Quaternion;
  91968. /**
  91969. * The scale factor of the device in babylon space
  91970. */
  91971. deviceScaleFactor: number;
  91972. /**
  91973. * (Likely devicePosition should be used instead) The device position in its room space
  91974. */
  91975. position: Vector3;
  91976. /**
  91977. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  91978. */
  91979. rotationQuaternion: Quaternion;
  91980. /**
  91981. * The type of controller (Eg. Windows mixed reality)
  91982. */
  91983. controllerType: PoseEnabledControllerType;
  91984. protected _calculatedPosition: Vector3;
  91985. private _calculatedRotation;
  91986. /**
  91987. * The raw pose from the device
  91988. */
  91989. rawPose: DevicePose;
  91990. private _trackPosition;
  91991. private _maxRotationDistFromHeadset;
  91992. private _draggedRoomRotation;
  91993. /**
  91994. * @hidden
  91995. */
  91996. _disableTrackPosition(fixedPosition: Vector3): void;
  91997. /**
  91998. * Internal, the mesh attached to the controller
  91999. * @hidden
  92000. */
  92001. _mesh: Nullable<AbstractMesh>;
  92002. private _poseControlledCamera;
  92003. private _leftHandSystemQuaternion;
  92004. /**
  92005. * Internal, matrix used to convert room space to babylon space
  92006. * @hidden
  92007. */
  92008. _deviceToWorld: Matrix;
  92009. /**
  92010. * Node to be used when casting a ray from the controller
  92011. * @hidden
  92012. */
  92013. _pointingPoseNode: Nullable<TransformNode>;
  92014. /**
  92015. * Name of the child mesh that can be used to cast a ray from the controller
  92016. */
  92017. static readonly POINTING_POSE: string;
  92018. /**
  92019. * Creates a new PoseEnabledController from a gamepad
  92020. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92021. */
  92022. constructor(browserGamepad: any);
  92023. private _workingMatrix;
  92024. /**
  92025. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92026. */
  92027. update(): void;
  92028. /**
  92029. * Updates only the pose device and mesh without doing any button event checking
  92030. */
  92031. protected _updatePoseAndMesh(): void;
  92032. /**
  92033. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92034. * @param poseData raw pose fromthe device
  92035. */
  92036. updateFromDevice(poseData: DevicePose): void;
  92037. /**
  92038. * @hidden
  92039. */
  92040. _meshAttachedObservable: Observable<AbstractMesh>;
  92041. /**
  92042. * Attaches a mesh to the controller
  92043. * @param mesh the mesh to be attached
  92044. */
  92045. attachToMesh(mesh: AbstractMesh): void;
  92046. /**
  92047. * Attaches the controllers mesh to a camera
  92048. * @param camera the camera the mesh should be attached to
  92049. */
  92050. attachToPoseControlledCamera(camera: TargetCamera): void;
  92051. /**
  92052. * Disposes of the controller
  92053. */
  92054. dispose(): void;
  92055. /**
  92056. * The mesh that is attached to the controller
  92057. */
  92058. get mesh(): Nullable<AbstractMesh>;
  92059. /**
  92060. * Gets the ray of the controller in the direction the controller is pointing
  92061. * @param length the length the resulting ray should be
  92062. * @returns a ray in the direction the controller is pointing
  92063. */
  92064. getForwardRay(length?: number): Ray;
  92065. }
  92066. }
  92067. declare module BABYLON {
  92068. /**
  92069. * Defines the WebVRController object that represents controllers tracked in 3D space
  92070. */
  92071. export abstract class WebVRController extends PoseEnabledController {
  92072. /**
  92073. * Internal, the default controller model for the controller
  92074. */
  92075. protected _defaultModel: Nullable<AbstractMesh>;
  92076. /**
  92077. * Fired when the trigger state has changed
  92078. */
  92079. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92080. /**
  92081. * Fired when the main button state has changed
  92082. */
  92083. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92084. /**
  92085. * Fired when the secondary button state has changed
  92086. */
  92087. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92088. /**
  92089. * Fired when the pad state has changed
  92090. */
  92091. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92092. /**
  92093. * Fired when controllers stick values have changed
  92094. */
  92095. onPadValuesChangedObservable: Observable<StickValues>;
  92096. /**
  92097. * Array of button availible on the controller
  92098. */
  92099. protected _buttons: Array<MutableGamepadButton>;
  92100. private _onButtonStateChange;
  92101. /**
  92102. * Fired when a controller button's state has changed
  92103. * @param callback the callback containing the button that was modified
  92104. */
  92105. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92106. /**
  92107. * X and Y axis corresponding to the controllers joystick
  92108. */
  92109. pad: StickValues;
  92110. /**
  92111. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92112. */
  92113. hand: string;
  92114. /**
  92115. * The default controller model for the controller
  92116. */
  92117. get defaultModel(): Nullable<AbstractMesh>;
  92118. /**
  92119. * Creates a new WebVRController from a gamepad
  92120. * @param vrGamepad the gamepad that the WebVRController should be created from
  92121. */
  92122. constructor(vrGamepad: any);
  92123. /**
  92124. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92125. */
  92126. update(): void;
  92127. /**
  92128. * Function to be called when a button is modified
  92129. */
  92130. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92131. /**
  92132. * Loads a mesh and attaches it to the controller
  92133. * @param scene the scene the mesh should be added to
  92134. * @param meshLoaded callback for when the mesh has been loaded
  92135. */
  92136. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92137. private _setButtonValue;
  92138. private _changes;
  92139. private _checkChanges;
  92140. /**
  92141. * Disposes of th webVRCOntroller
  92142. */
  92143. dispose(): void;
  92144. }
  92145. }
  92146. declare module BABYLON {
  92147. /**
  92148. * The HemisphericLight simulates the ambient environment light,
  92149. * so the passed direction is the light reflection direction, not the incoming direction.
  92150. */
  92151. export class HemisphericLight extends Light {
  92152. /**
  92153. * The groundColor is the light in the opposite direction to the one specified during creation.
  92154. * 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.
  92155. */
  92156. groundColor: Color3;
  92157. /**
  92158. * The light reflection direction, not the incoming direction.
  92159. */
  92160. direction: Vector3;
  92161. /**
  92162. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92163. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92164. * The HemisphericLight can't cast shadows.
  92165. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92166. * @param name The friendly name of the light
  92167. * @param direction The direction of the light reflection
  92168. * @param scene The scene the light belongs to
  92169. */
  92170. constructor(name: string, direction: Vector3, scene: Scene);
  92171. protected _buildUniformLayout(): void;
  92172. /**
  92173. * Returns the string "HemisphericLight".
  92174. * @return The class name
  92175. */
  92176. getClassName(): string;
  92177. /**
  92178. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92179. * Returns the updated direction.
  92180. * @param target The target the direction should point to
  92181. * @return The computed direction
  92182. */
  92183. setDirectionToTarget(target: Vector3): Vector3;
  92184. /**
  92185. * Returns the shadow generator associated to the light.
  92186. * @returns Always null for hemispheric lights because it does not support shadows.
  92187. */
  92188. getShadowGenerator(): Nullable<IShadowGenerator>;
  92189. /**
  92190. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92191. * @param effect The effect to update
  92192. * @param lightIndex The index of the light in the effect to update
  92193. * @returns The hemispheric light
  92194. */
  92195. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92196. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92197. /**
  92198. * Computes the world matrix of the node
  92199. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92200. * @param useWasUpdatedFlag defines a reserved property
  92201. * @returns the world matrix
  92202. */
  92203. computeWorldMatrix(): Matrix;
  92204. /**
  92205. * Returns the integer 3.
  92206. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92207. */
  92208. getTypeID(): number;
  92209. /**
  92210. * Prepares the list of defines specific to the light type.
  92211. * @param defines the list of defines
  92212. * @param lightIndex defines the index of the light for the effect
  92213. */
  92214. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92215. }
  92216. }
  92217. declare module BABYLON {
  92218. /** @hidden */
  92219. export var vrMultiviewToSingleviewPixelShader: {
  92220. name: string;
  92221. shader: string;
  92222. };
  92223. }
  92224. declare module BABYLON {
  92225. /**
  92226. * Renders to multiple views with a single draw call
  92227. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92228. */
  92229. export class MultiviewRenderTarget extends RenderTargetTexture {
  92230. /**
  92231. * Creates a multiview render target
  92232. * @param scene scene used with the render target
  92233. * @param size the size of the render target (used for each view)
  92234. */
  92235. constructor(scene: Scene, size?: number | {
  92236. width: number;
  92237. height: number;
  92238. } | {
  92239. ratio: number;
  92240. });
  92241. /**
  92242. * @hidden
  92243. * @param faceIndex the face index, if its a cube texture
  92244. */
  92245. _bindFrameBuffer(faceIndex?: number): void;
  92246. /**
  92247. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92248. * @returns the view count
  92249. */
  92250. getViewCount(): number;
  92251. }
  92252. }
  92253. declare module BABYLON {
  92254. /**
  92255. * Represents a camera frustum
  92256. */
  92257. export class Frustum {
  92258. /**
  92259. * Gets the planes representing the frustum
  92260. * @param transform matrix to be applied to the returned planes
  92261. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92262. */
  92263. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92264. /**
  92265. * Gets the near frustum plane transformed by the transform matrix
  92266. * @param transform transformation matrix to be applied to the resulting frustum plane
  92267. * @param frustumPlane the resuling frustum plane
  92268. */
  92269. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92270. /**
  92271. * Gets the far frustum plane transformed by the transform matrix
  92272. * @param transform transformation matrix to be applied to the resulting frustum plane
  92273. * @param frustumPlane the resuling frustum plane
  92274. */
  92275. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92276. /**
  92277. * Gets the left frustum plane transformed by the transform matrix
  92278. * @param transform transformation matrix to be applied to the resulting frustum plane
  92279. * @param frustumPlane the resuling frustum plane
  92280. */
  92281. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92282. /**
  92283. * Gets the right frustum plane transformed by the transform matrix
  92284. * @param transform transformation matrix to be applied to the resulting frustum plane
  92285. * @param frustumPlane the resuling frustum plane
  92286. */
  92287. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92288. /**
  92289. * Gets the top frustum plane transformed by the transform matrix
  92290. * @param transform transformation matrix to be applied to the resulting frustum plane
  92291. * @param frustumPlane the resuling frustum plane
  92292. */
  92293. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92294. /**
  92295. * Gets the bottom frustum plane transformed by the transform matrix
  92296. * @param transform transformation matrix to be applied to the resulting frustum plane
  92297. * @param frustumPlane the resuling frustum plane
  92298. */
  92299. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92300. /**
  92301. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92302. * @param transform transformation matrix to be applied to the resulting frustum planes
  92303. * @param frustumPlanes the resuling frustum planes
  92304. */
  92305. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92306. }
  92307. }
  92308. declare module BABYLON {
  92309. interface Engine {
  92310. /**
  92311. * Creates a new multiview render target
  92312. * @param width defines the width of the texture
  92313. * @param height defines the height of the texture
  92314. * @returns the created multiview texture
  92315. */
  92316. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92317. /**
  92318. * Binds a multiview framebuffer to be drawn to
  92319. * @param multiviewTexture texture to bind
  92320. */
  92321. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92322. }
  92323. interface Camera {
  92324. /**
  92325. * @hidden
  92326. * 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)
  92327. */
  92328. _useMultiviewToSingleView: boolean;
  92329. /**
  92330. * @hidden
  92331. * 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)
  92332. */
  92333. _multiviewTexture: Nullable<RenderTargetTexture>;
  92334. /**
  92335. * @hidden
  92336. * ensures the multiview texture of the camera exists and has the specified width/height
  92337. * @param width height to set on the multiview texture
  92338. * @param height width to set on the multiview texture
  92339. */
  92340. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92341. }
  92342. interface Scene {
  92343. /** @hidden */
  92344. _transformMatrixR: Matrix;
  92345. /** @hidden */
  92346. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92347. /** @hidden */
  92348. _createMultiviewUbo(): void;
  92349. /** @hidden */
  92350. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92351. /** @hidden */
  92352. _renderMultiviewToSingleView(camera: Camera): void;
  92353. }
  92354. }
  92355. declare module BABYLON {
  92356. /**
  92357. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92358. * This will not be used for webXR as it supports displaying texture arrays directly
  92359. */
  92360. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92361. /**
  92362. * Initializes a VRMultiviewToSingleview
  92363. * @param name name of the post process
  92364. * @param camera camera to be applied to
  92365. * @param scaleFactor scaling factor to the size of the output texture
  92366. */
  92367. constructor(name: string, camera: Camera, scaleFactor: number);
  92368. }
  92369. }
  92370. declare module BABYLON {
  92371. /**
  92372. * Interface used to define additional presentation attributes
  92373. */
  92374. export interface IVRPresentationAttributes {
  92375. /**
  92376. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92377. */
  92378. highRefreshRate: boolean;
  92379. /**
  92380. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92381. */
  92382. foveationLevel: number;
  92383. }
  92384. interface Engine {
  92385. /** @hidden */
  92386. _vrDisplay: any;
  92387. /** @hidden */
  92388. _vrSupported: boolean;
  92389. /** @hidden */
  92390. _oldSize: Size;
  92391. /** @hidden */
  92392. _oldHardwareScaleFactor: number;
  92393. /** @hidden */
  92394. _vrExclusivePointerMode: boolean;
  92395. /** @hidden */
  92396. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92397. /** @hidden */
  92398. _onVRDisplayPointerRestricted: () => void;
  92399. /** @hidden */
  92400. _onVRDisplayPointerUnrestricted: () => void;
  92401. /** @hidden */
  92402. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92403. /** @hidden */
  92404. _onVrDisplayDisconnect: Nullable<() => void>;
  92405. /** @hidden */
  92406. _onVrDisplayPresentChange: Nullable<() => void>;
  92407. /**
  92408. * Observable signaled when VR display mode changes
  92409. */
  92410. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92411. /**
  92412. * Observable signaled when VR request present is complete
  92413. */
  92414. onVRRequestPresentComplete: Observable<boolean>;
  92415. /**
  92416. * Observable signaled when VR request present starts
  92417. */
  92418. onVRRequestPresentStart: Observable<Engine>;
  92419. /**
  92420. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92421. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92422. */
  92423. isInVRExclusivePointerMode: boolean;
  92424. /**
  92425. * Gets a boolean indicating if a webVR device was detected
  92426. * @returns true if a webVR device was detected
  92427. */
  92428. isVRDevicePresent(): boolean;
  92429. /**
  92430. * Gets the current webVR device
  92431. * @returns the current webVR device (or null)
  92432. */
  92433. getVRDevice(): any;
  92434. /**
  92435. * Initializes a webVR display and starts listening to display change events
  92436. * The onVRDisplayChangedObservable will be notified upon these changes
  92437. * @returns A promise containing a VRDisplay and if vr is supported
  92438. */
  92439. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92440. /** @hidden */
  92441. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92442. /**
  92443. * Gets or sets the presentation attributes used to configure VR rendering
  92444. */
  92445. vrPresentationAttributes?: IVRPresentationAttributes;
  92446. /**
  92447. * Call this function to switch to webVR mode
  92448. * Will do nothing if webVR is not supported or if there is no webVR device
  92449. * @param options the webvr options provided to the camera. mainly used for multiview
  92450. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92451. */
  92452. enableVR(options: WebVROptions): void;
  92453. /** @hidden */
  92454. _onVRFullScreenTriggered(): void;
  92455. }
  92456. }
  92457. declare module BABYLON {
  92458. /**
  92459. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92460. * IMPORTANT!! The data is right-hand data.
  92461. * @export
  92462. * @interface DevicePose
  92463. */
  92464. export interface DevicePose {
  92465. /**
  92466. * The position of the device, values in array are [x,y,z].
  92467. */
  92468. readonly position: Nullable<Float32Array>;
  92469. /**
  92470. * The linearVelocity of the device, values in array are [x,y,z].
  92471. */
  92472. readonly linearVelocity: Nullable<Float32Array>;
  92473. /**
  92474. * The linearAcceleration of the device, values in array are [x,y,z].
  92475. */
  92476. readonly linearAcceleration: Nullable<Float32Array>;
  92477. /**
  92478. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92479. */
  92480. readonly orientation: Nullable<Float32Array>;
  92481. /**
  92482. * The angularVelocity of the device, values in array are [x,y,z].
  92483. */
  92484. readonly angularVelocity: Nullable<Float32Array>;
  92485. /**
  92486. * The angularAcceleration of the device, values in array are [x,y,z].
  92487. */
  92488. readonly angularAcceleration: Nullable<Float32Array>;
  92489. }
  92490. /**
  92491. * Interface representing a pose controlled object in Babylon.
  92492. * A pose controlled object has both regular pose values as well as pose values
  92493. * from an external device such as a VR head mounted display
  92494. */
  92495. export interface PoseControlled {
  92496. /**
  92497. * The position of the object in babylon space.
  92498. */
  92499. position: Vector3;
  92500. /**
  92501. * The rotation quaternion of the object in babylon space.
  92502. */
  92503. rotationQuaternion: Quaternion;
  92504. /**
  92505. * The position of the device in babylon space.
  92506. */
  92507. devicePosition?: Vector3;
  92508. /**
  92509. * The rotation quaternion of the device in babylon space.
  92510. */
  92511. deviceRotationQuaternion: Quaternion;
  92512. /**
  92513. * The raw pose coming from the device.
  92514. */
  92515. rawPose: Nullable<DevicePose>;
  92516. /**
  92517. * The scale of the device to be used when translating from device space to babylon space.
  92518. */
  92519. deviceScaleFactor: number;
  92520. /**
  92521. * Updates the poseControlled values based on the input device pose.
  92522. * @param poseData the pose data to update the object with
  92523. */
  92524. updateFromDevice(poseData: DevicePose): void;
  92525. }
  92526. /**
  92527. * Set of options to customize the webVRCamera
  92528. */
  92529. export interface WebVROptions {
  92530. /**
  92531. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92532. */
  92533. trackPosition?: boolean;
  92534. /**
  92535. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92536. */
  92537. positionScale?: number;
  92538. /**
  92539. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92540. */
  92541. displayName?: string;
  92542. /**
  92543. * Should the native controller meshes be initialized. (default: true)
  92544. */
  92545. controllerMeshes?: boolean;
  92546. /**
  92547. * Creating a default HemiLight only on controllers. (default: true)
  92548. */
  92549. defaultLightingOnControllers?: boolean;
  92550. /**
  92551. * If you don't want to use the default VR button of the helper. (default: false)
  92552. */
  92553. useCustomVRButton?: boolean;
  92554. /**
  92555. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92556. */
  92557. customVRButton?: HTMLButtonElement;
  92558. /**
  92559. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92560. */
  92561. rayLength?: number;
  92562. /**
  92563. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92564. */
  92565. defaultHeight?: number;
  92566. /**
  92567. * If multiview should be used if availible (default: false)
  92568. */
  92569. useMultiview?: boolean;
  92570. }
  92571. /**
  92572. * This represents a WebVR camera.
  92573. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92574. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92575. */
  92576. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92577. private webVROptions;
  92578. /**
  92579. * @hidden
  92580. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92581. */
  92582. _vrDevice: any;
  92583. /**
  92584. * The rawPose of the vrDevice.
  92585. */
  92586. rawPose: Nullable<DevicePose>;
  92587. private _onVREnabled;
  92588. private _specsVersion;
  92589. private _attached;
  92590. private _frameData;
  92591. protected _descendants: Array<Node>;
  92592. private _deviceRoomPosition;
  92593. /** @hidden */
  92594. _deviceRoomRotationQuaternion: Quaternion;
  92595. private _standingMatrix;
  92596. /**
  92597. * Represents device position in babylon space.
  92598. */
  92599. devicePosition: Vector3;
  92600. /**
  92601. * Represents device rotation in babylon space.
  92602. */
  92603. deviceRotationQuaternion: Quaternion;
  92604. /**
  92605. * The scale of the device to be used when translating from device space to babylon space.
  92606. */
  92607. deviceScaleFactor: number;
  92608. private _deviceToWorld;
  92609. private _worldToDevice;
  92610. /**
  92611. * References to the webVR controllers for the vrDevice.
  92612. */
  92613. controllers: Array<WebVRController>;
  92614. /**
  92615. * Emits an event when a controller is attached.
  92616. */
  92617. onControllersAttachedObservable: Observable<WebVRController[]>;
  92618. /**
  92619. * Emits an event when a controller's mesh has been loaded;
  92620. */
  92621. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92622. /**
  92623. * Emits an event when the HMD's pose has been updated.
  92624. */
  92625. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92626. private _poseSet;
  92627. /**
  92628. * If the rig cameras be used as parent instead of this camera.
  92629. */
  92630. rigParenting: boolean;
  92631. private _lightOnControllers;
  92632. private _defaultHeight?;
  92633. /**
  92634. * Instantiates a WebVRFreeCamera.
  92635. * @param name The name of the WebVRFreeCamera
  92636. * @param position The starting anchor position for the camera
  92637. * @param scene The scene the camera belongs to
  92638. * @param webVROptions a set of customizable options for the webVRCamera
  92639. */
  92640. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92641. /**
  92642. * Gets the device distance from the ground in meters.
  92643. * @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.
  92644. */
  92645. deviceDistanceToRoomGround(): number;
  92646. /**
  92647. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92648. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92649. */
  92650. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92651. /**
  92652. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92653. * @returns A promise with a boolean set to if the standing matrix is supported.
  92654. */
  92655. useStandingMatrixAsync(): Promise<boolean>;
  92656. /**
  92657. * Disposes the camera
  92658. */
  92659. dispose(): void;
  92660. /**
  92661. * Gets a vrController by name.
  92662. * @param name The name of the controller to retreive
  92663. * @returns the controller matching the name specified or null if not found
  92664. */
  92665. getControllerByName(name: string): Nullable<WebVRController>;
  92666. private _leftController;
  92667. /**
  92668. * The controller corresponding to the users left hand.
  92669. */
  92670. get leftController(): Nullable<WebVRController>;
  92671. private _rightController;
  92672. /**
  92673. * The controller corresponding to the users right hand.
  92674. */
  92675. get rightController(): Nullable<WebVRController>;
  92676. /**
  92677. * Casts a ray forward from the vrCamera's gaze.
  92678. * @param length Length of the ray (default: 100)
  92679. * @returns the ray corresponding to the gaze
  92680. */
  92681. getForwardRay(length?: number): Ray;
  92682. /**
  92683. * @hidden
  92684. * Updates the camera based on device's frame data
  92685. */
  92686. _checkInputs(): void;
  92687. /**
  92688. * Updates the poseControlled values based on the input device pose.
  92689. * @param poseData Pose coming from the device
  92690. */
  92691. updateFromDevice(poseData: DevicePose): void;
  92692. private _htmlElementAttached;
  92693. private _detachIfAttached;
  92694. /**
  92695. * WebVR's attach control will start broadcasting frames to the device.
  92696. * Note that in certain browsers (chrome for example) this function must be called
  92697. * within a user-interaction callback. Example:
  92698. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92699. *
  92700. * @param element html element to attach the vrDevice to
  92701. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92702. */
  92703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92704. /**
  92705. * Detaches the camera from the html element and disables VR
  92706. *
  92707. * @param element html element to detach from
  92708. */
  92709. detachControl(element: HTMLElement): void;
  92710. /**
  92711. * @returns the name of this class
  92712. */
  92713. getClassName(): string;
  92714. /**
  92715. * Calls resetPose on the vrDisplay
  92716. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92717. */
  92718. resetToCurrentRotation(): void;
  92719. /**
  92720. * @hidden
  92721. * Updates the rig cameras (left and right eye)
  92722. */
  92723. _updateRigCameras(): void;
  92724. private _workingVector;
  92725. private _oneVector;
  92726. private _workingMatrix;
  92727. private updateCacheCalled;
  92728. private _correctPositionIfNotTrackPosition;
  92729. /**
  92730. * @hidden
  92731. * Updates the cached values of the camera
  92732. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92733. */
  92734. _updateCache(ignoreParentClass?: boolean): void;
  92735. /**
  92736. * @hidden
  92737. * Get current device position in babylon world
  92738. */
  92739. _computeDevicePosition(): void;
  92740. /**
  92741. * Updates the current device position and rotation in the babylon world
  92742. */
  92743. update(): void;
  92744. /**
  92745. * @hidden
  92746. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92747. * @returns an identity matrix
  92748. */
  92749. _getViewMatrix(): Matrix;
  92750. private _tmpMatrix;
  92751. /**
  92752. * This function is called by the two RIG cameras.
  92753. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92754. * @hidden
  92755. */
  92756. _getWebVRViewMatrix(): Matrix;
  92757. /** @hidden */
  92758. _getWebVRProjectionMatrix(): Matrix;
  92759. private _onGamepadConnectedObserver;
  92760. private _onGamepadDisconnectedObserver;
  92761. private _updateCacheWhenTrackingDisabledObserver;
  92762. /**
  92763. * Initializes the controllers and their meshes
  92764. */
  92765. initControllers(): void;
  92766. }
  92767. }
  92768. declare module BABYLON {
  92769. /**
  92770. * Size options for a post process
  92771. */
  92772. export type PostProcessOptions = {
  92773. width: number;
  92774. height: number;
  92775. };
  92776. /**
  92777. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92778. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92779. */
  92780. export class PostProcess {
  92781. /** Name of the PostProcess. */
  92782. name: string;
  92783. /**
  92784. * Gets or sets the unique id of the post process
  92785. */
  92786. uniqueId: number;
  92787. /**
  92788. * Width of the texture to apply the post process on
  92789. */
  92790. width: number;
  92791. /**
  92792. * Height of the texture to apply the post process on
  92793. */
  92794. height: number;
  92795. /**
  92796. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92797. * @hidden
  92798. */
  92799. _outputTexture: Nullable<InternalTexture>;
  92800. /**
  92801. * Sampling mode used by the shader
  92802. * See https://doc.babylonjs.com/classes/3.1/texture
  92803. */
  92804. renderTargetSamplingMode: number;
  92805. /**
  92806. * Clear color to use when screen clearing
  92807. */
  92808. clearColor: Color4;
  92809. /**
  92810. * If the buffer needs to be cleared before applying the post process. (default: true)
  92811. * Should be set to false if shader will overwrite all previous pixels.
  92812. */
  92813. autoClear: boolean;
  92814. /**
  92815. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92816. */
  92817. alphaMode: number;
  92818. /**
  92819. * Sets the setAlphaBlendConstants of the babylon engine
  92820. */
  92821. alphaConstants: Color4;
  92822. /**
  92823. * Animations to be used for the post processing
  92824. */
  92825. animations: Animation[];
  92826. /**
  92827. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92828. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92829. */
  92830. enablePixelPerfectMode: boolean;
  92831. /**
  92832. * Force the postprocess to be applied without taking in account viewport
  92833. */
  92834. forceFullscreenViewport: boolean;
  92835. /**
  92836. * List of inspectable custom properties (used by the Inspector)
  92837. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92838. */
  92839. inspectableCustomProperties: IInspectable[];
  92840. /**
  92841. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92842. *
  92843. * | Value | Type | Description |
  92844. * | ----- | ----------------------------------- | ----------- |
  92845. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92846. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92847. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92848. *
  92849. */
  92850. scaleMode: number;
  92851. /**
  92852. * Force textures to be a power of two (default: false)
  92853. */
  92854. alwaysForcePOT: boolean;
  92855. private _samples;
  92856. /**
  92857. * Number of sample textures (default: 1)
  92858. */
  92859. get samples(): number;
  92860. set samples(n: number);
  92861. /**
  92862. * Modify the scale of the post process to be the same as the viewport (default: false)
  92863. */
  92864. adaptScaleToCurrentViewport: boolean;
  92865. private _camera;
  92866. private _scene;
  92867. private _engine;
  92868. private _options;
  92869. private _reusable;
  92870. private _textureType;
  92871. private _textureFormat;
  92872. /**
  92873. * Smart array of input and output textures for the post process.
  92874. * @hidden
  92875. */
  92876. _textures: SmartArray<InternalTexture>;
  92877. /**
  92878. * The index in _textures that corresponds to the output texture.
  92879. * @hidden
  92880. */
  92881. _currentRenderTextureInd: number;
  92882. private _effect;
  92883. private _samplers;
  92884. private _fragmentUrl;
  92885. private _vertexUrl;
  92886. private _parameters;
  92887. private _scaleRatio;
  92888. protected _indexParameters: any;
  92889. private _shareOutputWithPostProcess;
  92890. private _texelSize;
  92891. private _forcedOutputTexture;
  92892. /**
  92893. * Returns the fragment url or shader name used in the post process.
  92894. * @returns the fragment url or name in the shader store.
  92895. */
  92896. getEffectName(): string;
  92897. /**
  92898. * An event triggered when the postprocess is activated.
  92899. */
  92900. onActivateObservable: Observable<Camera>;
  92901. private _onActivateObserver;
  92902. /**
  92903. * A function that is added to the onActivateObservable
  92904. */
  92905. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92906. /**
  92907. * An event triggered when the postprocess changes its size.
  92908. */
  92909. onSizeChangedObservable: Observable<PostProcess>;
  92910. private _onSizeChangedObserver;
  92911. /**
  92912. * A function that is added to the onSizeChangedObservable
  92913. */
  92914. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92915. /**
  92916. * An event triggered when the postprocess applies its effect.
  92917. */
  92918. onApplyObservable: Observable<Effect>;
  92919. private _onApplyObserver;
  92920. /**
  92921. * A function that is added to the onApplyObservable
  92922. */
  92923. set onApply(callback: (effect: Effect) => void);
  92924. /**
  92925. * An event triggered before rendering the postprocess
  92926. */
  92927. onBeforeRenderObservable: Observable<Effect>;
  92928. private _onBeforeRenderObserver;
  92929. /**
  92930. * A function that is added to the onBeforeRenderObservable
  92931. */
  92932. set onBeforeRender(callback: (effect: Effect) => void);
  92933. /**
  92934. * An event triggered after rendering the postprocess
  92935. */
  92936. onAfterRenderObservable: Observable<Effect>;
  92937. private _onAfterRenderObserver;
  92938. /**
  92939. * A function that is added to the onAfterRenderObservable
  92940. */
  92941. set onAfterRender(callback: (efect: Effect) => void);
  92942. /**
  92943. * 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
  92944. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92945. */
  92946. get inputTexture(): InternalTexture;
  92947. set inputTexture(value: InternalTexture);
  92948. /**
  92949. * Gets the camera which post process is applied to.
  92950. * @returns The camera the post process is applied to.
  92951. */
  92952. getCamera(): Camera;
  92953. /**
  92954. * Gets the texel size of the postprocess.
  92955. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  92956. */
  92957. get texelSize(): Vector2;
  92958. /**
  92959. * Creates a new instance PostProcess
  92960. * @param name The name of the PostProcess.
  92961. * @param fragmentUrl The url of the fragment shader to be used.
  92962. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  92963. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  92964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  92965. * @param camera The camera to apply the render pass to.
  92966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92967. * @param engine The engine which the post process will be applied. (default: current engine)
  92968. * @param reusable If the post process can be reused on the same frame. (default: false)
  92969. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  92970. * @param textureType Type of textures used when performing the post process. (default: 0)
  92971. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  92972. * @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
  92973. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  92974. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  92975. */
  92976. constructor(
  92977. /** Name of the PostProcess. */
  92978. 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);
  92979. /**
  92980. * Gets a string idenfifying the name of the class
  92981. * @returns "PostProcess" string
  92982. */
  92983. getClassName(): string;
  92984. /**
  92985. * Gets the engine which this post process belongs to.
  92986. * @returns The engine the post process was enabled with.
  92987. */
  92988. getEngine(): Engine;
  92989. /**
  92990. * The effect that is created when initializing the post process.
  92991. * @returns The created effect corresponding the the postprocess.
  92992. */
  92993. getEffect(): Effect;
  92994. /**
  92995. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  92996. * @param postProcess The post process to share the output with.
  92997. * @returns This post process.
  92998. */
  92999. shareOutputWith(postProcess: PostProcess): PostProcess;
  93000. /**
  93001. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93002. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93003. */
  93004. useOwnOutput(): void;
  93005. /**
  93006. * Updates the effect with the current post process compile time values and recompiles the shader.
  93007. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93008. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93009. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93010. * @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
  93011. * @param onCompiled Called when the shader has been compiled.
  93012. * @param onError Called if there is an error when compiling a shader.
  93013. */
  93014. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93015. /**
  93016. * The post process is reusable if it can be used multiple times within one frame.
  93017. * @returns If the post process is reusable
  93018. */
  93019. isReusable(): boolean;
  93020. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93021. markTextureDirty(): void;
  93022. /**
  93023. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93024. * 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.
  93025. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93026. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93027. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93028. * @returns The target texture that was bound to be written to.
  93029. */
  93030. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93031. /**
  93032. * If the post process is supported.
  93033. */
  93034. get isSupported(): boolean;
  93035. /**
  93036. * The aspect ratio of the output texture.
  93037. */
  93038. get aspectRatio(): number;
  93039. /**
  93040. * Get a value indicating if the post-process is ready to be used
  93041. * @returns true if the post-process is ready (shader is compiled)
  93042. */
  93043. isReady(): boolean;
  93044. /**
  93045. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93046. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93047. */
  93048. apply(): Nullable<Effect>;
  93049. private _disposeTextures;
  93050. /**
  93051. * Disposes the post process.
  93052. * @param camera The camera to dispose the post process on.
  93053. */
  93054. dispose(camera?: Camera): void;
  93055. }
  93056. }
  93057. declare module BABYLON {
  93058. /** @hidden */
  93059. export var kernelBlurVaryingDeclaration: {
  93060. name: string;
  93061. shader: string;
  93062. };
  93063. }
  93064. declare module BABYLON {
  93065. /** @hidden */
  93066. export var kernelBlurFragment: {
  93067. name: string;
  93068. shader: string;
  93069. };
  93070. }
  93071. declare module BABYLON {
  93072. /** @hidden */
  93073. export var kernelBlurFragment2: {
  93074. name: string;
  93075. shader: string;
  93076. };
  93077. }
  93078. declare module BABYLON {
  93079. /** @hidden */
  93080. export var kernelBlurPixelShader: {
  93081. name: string;
  93082. shader: string;
  93083. };
  93084. }
  93085. declare module BABYLON {
  93086. /** @hidden */
  93087. export var kernelBlurVertex: {
  93088. name: string;
  93089. shader: string;
  93090. };
  93091. }
  93092. declare module BABYLON {
  93093. /** @hidden */
  93094. export var kernelBlurVertexShader: {
  93095. name: string;
  93096. shader: string;
  93097. };
  93098. }
  93099. declare module BABYLON {
  93100. /**
  93101. * The Blur Post Process which blurs an image based on a kernel and direction.
  93102. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93103. */
  93104. export class BlurPostProcess extends PostProcess {
  93105. /** The direction in which to blur the image. */
  93106. direction: Vector2;
  93107. private blockCompilation;
  93108. protected _kernel: number;
  93109. protected _idealKernel: number;
  93110. protected _packedFloat: boolean;
  93111. private _staticDefines;
  93112. /**
  93113. * Sets the length in pixels of the blur sample region
  93114. */
  93115. set kernel(v: number);
  93116. /**
  93117. * Gets the length in pixels of the blur sample region
  93118. */
  93119. get kernel(): number;
  93120. /**
  93121. * Sets wether or not the blur needs to unpack/repack floats
  93122. */
  93123. set packedFloat(v: boolean);
  93124. /**
  93125. * Gets wether or not the blur is unpacking/repacking floats
  93126. */
  93127. get packedFloat(): boolean;
  93128. /**
  93129. * Creates a new instance BlurPostProcess
  93130. * @param name The name of the effect.
  93131. * @param direction The direction in which to blur the image.
  93132. * @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.
  93133. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93134. * @param camera The camera to apply the render pass to.
  93135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93136. * @param engine The engine which the post process will be applied. (default: current engine)
  93137. * @param reusable If the post process can be reused on the same frame. (default: false)
  93138. * @param textureType Type of textures used when performing the post process. (default: 0)
  93139. * @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)
  93140. */
  93141. constructor(name: string,
  93142. /** The direction in which to blur the image. */
  93143. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93144. /**
  93145. * Updates the effect with the current post process compile time values and recompiles the shader.
  93146. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93147. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93148. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93149. * @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
  93150. * @param onCompiled Called when the shader has been compiled.
  93151. * @param onError Called if there is an error when compiling a shader.
  93152. */
  93153. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93154. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93155. /**
  93156. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93157. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93158. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93159. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93160. * The gaps between physical kernels are compensated for in the weighting of the samples
  93161. * @param idealKernel Ideal blur kernel.
  93162. * @return Nearest best kernel.
  93163. */
  93164. protected _nearestBestKernel(idealKernel: number): number;
  93165. /**
  93166. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93167. * @param x The point on the Gaussian distribution to sample.
  93168. * @return the value of the Gaussian function at x.
  93169. */
  93170. protected _gaussianWeight(x: number): number;
  93171. /**
  93172. * Generates a string that can be used as a floating point number in GLSL.
  93173. * @param x Value to print.
  93174. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93175. * @return GLSL float string.
  93176. */
  93177. protected _glslFloat(x: number, decimalFigures?: number): string;
  93178. }
  93179. }
  93180. declare module BABYLON {
  93181. /**
  93182. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93183. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93184. * You can then easily use it as a reflectionTexture on a flat surface.
  93185. * In case the surface is not a plane, please consider relying on reflection probes.
  93186. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93187. */
  93188. export class MirrorTexture extends RenderTargetTexture {
  93189. private scene;
  93190. /**
  93191. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93192. * 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.
  93193. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93194. */
  93195. mirrorPlane: Plane;
  93196. /**
  93197. * Define the blur ratio used to blur the reflection if needed.
  93198. */
  93199. set blurRatio(value: number);
  93200. get blurRatio(): number;
  93201. /**
  93202. * Define the adaptive blur kernel used to blur the reflection if needed.
  93203. * This will autocompute the closest best match for the `blurKernel`
  93204. */
  93205. set adaptiveBlurKernel(value: number);
  93206. /**
  93207. * Define the blur kernel used to blur the reflection if needed.
  93208. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93209. */
  93210. set blurKernel(value: number);
  93211. /**
  93212. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93213. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93214. */
  93215. set blurKernelX(value: number);
  93216. get blurKernelX(): number;
  93217. /**
  93218. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93219. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93220. */
  93221. set blurKernelY(value: number);
  93222. get blurKernelY(): number;
  93223. private _autoComputeBlurKernel;
  93224. protected _onRatioRescale(): void;
  93225. private _updateGammaSpace;
  93226. private _imageProcessingConfigChangeObserver;
  93227. private _transformMatrix;
  93228. private _mirrorMatrix;
  93229. private _savedViewMatrix;
  93230. private _blurX;
  93231. private _blurY;
  93232. private _adaptiveBlurKernel;
  93233. private _blurKernelX;
  93234. private _blurKernelY;
  93235. private _blurRatio;
  93236. /**
  93237. * Instantiates a Mirror Texture.
  93238. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93239. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93240. * You can then easily use it as a reflectionTexture on a flat surface.
  93241. * In case the surface is not a plane, please consider relying on reflection probes.
  93242. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93243. * @param name
  93244. * @param size
  93245. * @param scene
  93246. * @param generateMipMaps
  93247. * @param type
  93248. * @param samplingMode
  93249. * @param generateDepthBuffer
  93250. */
  93251. constructor(name: string, size: number | {
  93252. width: number;
  93253. height: number;
  93254. } | {
  93255. ratio: number;
  93256. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93257. private _preparePostProcesses;
  93258. /**
  93259. * Clone the mirror texture.
  93260. * @returns the cloned texture
  93261. */
  93262. clone(): MirrorTexture;
  93263. /**
  93264. * Serialize the texture to a JSON representation you could use in Parse later on
  93265. * @returns the serialized JSON representation
  93266. */
  93267. serialize(): any;
  93268. /**
  93269. * Dispose the texture and release its associated resources.
  93270. */
  93271. dispose(): void;
  93272. }
  93273. }
  93274. declare module BABYLON {
  93275. /**
  93276. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93277. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93278. */
  93279. export class Texture extends BaseTexture {
  93280. /**
  93281. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93282. */
  93283. static SerializeBuffers: boolean;
  93284. /** @hidden */
  93285. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93286. /** @hidden */
  93287. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93288. /** @hidden */
  93289. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93290. /** nearest is mag = nearest and min = nearest and mip = linear */
  93291. static readonly NEAREST_SAMPLINGMODE: number;
  93292. /** nearest is mag = nearest and min = nearest and mip = linear */
  93293. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93294. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93295. static readonly BILINEAR_SAMPLINGMODE: number;
  93296. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93297. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93298. /** Trilinear is mag = linear and min = linear and mip = linear */
  93299. static readonly TRILINEAR_SAMPLINGMODE: number;
  93300. /** Trilinear is mag = linear and min = linear and mip = linear */
  93301. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93302. /** mag = nearest and min = nearest and mip = nearest */
  93303. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93304. /** mag = nearest and min = linear and mip = nearest */
  93305. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93306. /** mag = nearest and min = linear and mip = linear */
  93307. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93308. /** mag = nearest and min = linear and mip = none */
  93309. static readonly NEAREST_LINEAR: number;
  93310. /** mag = nearest and min = nearest and mip = none */
  93311. static readonly NEAREST_NEAREST: number;
  93312. /** mag = linear and min = nearest and mip = nearest */
  93313. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93314. /** mag = linear and min = nearest and mip = linear */
  93315. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93316. /** mag = linear and min = linear and mip = none */
  93317. static readonly LINEAR_LINEAR: number;
  93318. /** mag = linear and min = nearest and mip = none */
  93319. static readonly LINEAR_NEAREST: number;
  93320. /** Explicit coordinates mode */
  93321. static readonly EXPLICIT_MODE: number;
  93322. /** Spherical coordinates mode */
  93323. static readonly SPHERICAL_MODE: number;
  93324. /** Planar coordinates mode */
  93325. static readonly PLANAR_MODE: number;
  93326. /** Cubic coordinates mode */
  93327. static readonly CUBIC_MODE: number;
  93328. /** Projection coordinates mode */
  93329. static readonly PROJECTION_MODE: number;
  93330. /** Inverse Cubic coordinates mode */
  93331. static readonly SKYBOX_MODE: number;
  93332. /** Inverse Cubic coordinates mode */
  93333. static readonly INVCUBIC_MODE: number;
  93334. /** Equirectangular coordinates mode */
  93335. static readonly EQUIRECTANGULAR_MODE: number;
  93336. /** Equirectangular Fixed coordinates mode */
  93337. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93338. /** Equirectangular Fixed Mirrored coordinates mode */
  93339. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93340. /** Texture is not repeating outside of 0..1 UVs */
  93341. static readonly CLAMP_ADDRESSMODE: number;
  93342. /** Texture is repeating outside of 0..1 UVs */
  93343. static readonly WRAP_ADDRESSMODE: number;
  93344. /** Texture is repeating and mirrored */
  93345. static readonly MIRROR_ADDRESSMODE: number;
  93346. /**
  93347. * 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
  93348. */
  93349. static UseSerializedUrlIfAny: boolean;
  93350. /**
  93351. * Define the url of the texture.
  93352. */
  93353. url: Nullable<string>;
  93354. /**
  93355. * Define an offset on the texture to offset the u coordinates of the UVs
  93356. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93357. */
  93358. uOffset: number;
  93359. /**
  93360. * Define an offset on the texture to offset the v coordinates of the UVs
  93361. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93362. */
  93363. vOffset: number;
  93364. /**
  93365. * Define an offset on the texture to scale the u coordinates of the UVs
  93366. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93367. */
  93368. uScale: number;
  93369. /**
  93370. * Define an offset on the texture to scale the v coordinates of the UVs
  93371. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93372. */
  93373. vScale: number;
  93374. /**
  93375. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93376. * @see http://doc.babylonjs.com/how_to/more_materials
  93377. */
  93378. uAng: number;
  93379. /**
  93380. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93381. * @see http://doc.babylonjs.com/how_to/more_materials
  93382. */
  93383. vAng: number;
  93384. /**
  93385. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93386. * @see http://doc.babylonjs.com/how_to/more_materials
  93387. */
  93388. wAng: number;
  93389. /**
  93390. * Defines the center of rotation (U)
  93391. */
  93392. uRotationCenter: number;
  93393. /**
  93394. * Defines the center of rotation (V)
  93395. */
  93396. vRotationCenter: number;
  93397. /**
  93398. * Defines the center of rotation (W)
  93399. */
  93400. wRotationCenter: number;
  93401. /**
  93402. * Are mip maps generated for this texture or not.
  93403. */
  93404. get noMipmap(): boolean;
  93405. /**
  93406. * List of inspectable custom properties (used by the Inspector)
  93407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93408. */
  93409. inspectableCustomProperties: Nullable<IInspectable[]>;
  93410. private _noMipmap;
  93411. /** @hidden */
  93412. _invertY: boolean;
  93413. private _rowGenerationMatrix;
  93414. private _cachedTextureMatrix;
  93415. private _projectionModeMatrix;
  93416. private _t0;
  93417. private _t1;
  93418. private _t2;
  93419. private _cachedUOffset;
  93420. private _cachedVOffset;
  93421. private _cachedUScale;
  93422. private _cachedVScale;
  93423. private _cachedUAng;
  93424. private _cachedVAng;
  93425. private _cachedWAng;
  93426. private _cachedProjectionMatrixId;
  93427. private _cachedCoordinatesMode;
  93428. /** @hidden */
  93429. protected _initialSamplingMode: number;
  93430. /** @hidden */
  93431. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93432. private _deleteBuffer;
  93433. protected _format: Nullable<number>;
  93434. private _delayedOnLoad;
  93435. private _delayedOnError;
  93436. private _mimeType?;
  93437. /**
  93438. * Observable triggered once the texture has been loaded.
  93439. */
  93440. onLoadObservable: Observable<Texture>;
  93441. protected _isBlocking: boolean;
  93442. /**
  93443. * Is the texture preventing material to render while loading.
  93444. * If false, a default texture will be used instead of the loading one during the preparation step.
  93445. */
  93446. set isBlocking(value: boolean);
  93447. get isBlocking(): boolean;
  93448. /**
  93449. * Get the current sampling mode associated with the texture.
  93450. */
  93451. get samplingMode(): number;
  93452. /**
  93453. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93454. */
  93455. get invertY(): boolean;
  93456. /**
  93457. * Instantiates a new texture.
  93458. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93459. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93460. * @param url defines the url of the picture to load as a texture
  93461. * @param scene defines the scene or engine the texture will belong to
  93462. * @param noMipmap defines if the texture will require mip maps or not
  93463. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93464. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93465. * @param onLoad defines a callback triggered when the texture has been loaded
  93466. * @param onError defines a callback triggered when an error occurred during the loading session
  93467. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93468. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93469. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93470. * @param mimeType defines an optional mime type information
  93471. */
  93472. 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);
  93473. /**
  93474. * Update the url (and optional buffer) of this texture if url was null during construction.
  93475. * @param url the url of the texture
  93476. * @param buffer the buffer of the texture (defaults to null)
  93477. * @param onLoad callback called when the texture is loaded (defaults to null)
  93478. */
  93479. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93480. /**
  93481. * Finish the loading sequence of a texture flagged as delayed load.
  93482. * @hidden
  93483. */
  93484. delayLoad(): void;
  93485. private _prepareRowForTextureGeneration;
  93486. /**
  93487. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93488. * @returns the transform matrix of the texture.
  93489. */
  93490. getTextureMatrix(uBase?: number): Matrix;
  93491. /**
  93492. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93493. * @returns The reflection texture transform
  93494. */
  93495. getReflectionTextureMatrix(): Matrix;
  93496. /**
  93497. * Clones the texture.
  93498. * @returns the cloned texture
  93499. */
  93500. clone(): Texture;
  93501. /**
  93502. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93503. * @returns The JSON representation of the texture
  93504. */
  93505. serialize(): any;
  93506. /**
  93507. * Get the current class name of the texture useful for serialization or dynamic coding.
  93508. * @returns "Texture"
  93509. */
  93510. getClassName(): string;
  93511. /**
  93512. * Dispose the texture and release its associated resources.
  93513. */
  93514. dispose(): void;
  93515. /**
  93516. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93517. * @param parsedTexture Define the JSON representation of the texture
  93518. * @param scene Define the scene the parsed texture should be instantiated in
  93519. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93520. * @returns The parsed texture if successful
  93521. */
  93522. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93523. /**
  93524. * Creates a texture from its base 64 representation.
  93525. * @param data Define the base64 payload without the data: prefix
  93526. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93527. * @param scene Define the scene the texture should belong to
  93528. * @param noMipmap Forces the texture to not create mip map information if true
  93529. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93530. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93531. * @param onLoad define a callback triggered when the texture has been loaded
  93532. * @param onError define a callback triggered when an error occurred during the loading session
  93533. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93534. * @returns the created texture
  93535. */
  93536. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93537. /**
  93538. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93539. * @param data Define the base64 payload without the data: prefix
  93540. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93541. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93542. * @param scene Define the scene the texture should belong to
  93543. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93544. * @param noMipmap Forces the texture to not create mip map information if true
  93545. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93546. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93547. * @param onLoad define a callback triggered when the texture has been loaded
  93548. * @param onError define a callback triggered when an error occurred during the loading session
  93549. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93550. * @returns the created texture
  93551. */
  93552. 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;
  93553. }
  93554. }
  93555. declare module BABYLON {
  93556. /**
  93557. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93558. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93559. */
  93560. export class PostProcessManager {
  93561. private _scene;
  93562. private _indexBuffer;
  93563. private _vertexBuffers;
  93564. /**
  93565. * Creates a new instance PostProcess
  93566. * @param scene The scene that the post process is associated with.
  93567. */
  93568. constructor(scene: Scene);
  93569. private _prepareBuffers;
  93570. private _buildIndexBuffer;
  93571. /**
  93572. * Rebuilds the vertex buffers of the manager.
  93573. * @hidden
  93574. */
  93575. _rebuild(): void;
  93576. /**
  93577. * Prepares a frame to be run through a post process.
  93578. * @param sourceTexture The input texture to the post procesess. (default: null)
  93579. * @param postProcesses An array of post processes to be run. (default: null)
  93580. * @returns True if the post processes were able to be run.
  93581. * @hidden
  93582. */
  93583. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93584. /**
  93585. * Manually render a set of post processes to a texture.
  93586. * @param postProcesses An array of post processes to be run.
  93587. * @param targetTexture The target texture to render to.
  93588. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93589. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93590. * @param lodLevel defines which lod of the texture to render to
  93591. */
  93592. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93593. /**
  93594. * Finalize the result of the output of the postprocesses.
  93595. * @param doNotPresent If true the result will not be displayed to the screen.
  93596. * @param targetTexture The target texture to render to.
  93597. * @param faceIndex The index of the face to bind the target texture to.
  93598. * @param postProcesses The array of post processes to render.
  93599. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93600. * @hidden
  93601. */
  93602. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93603. /**
  93604. * Disposes of the post process manager.
  93605. */
  93606. dispose(): void;
  93607. }
  93608. }
  93609. declare module BABYLON {
  93610. /**
  93611. * This Helps creating a texture that will be created from a camera in your scene.
  93612. * It is basically a dynamic texture that could be used to create special effects for instance.
  93613. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93614. */
  93615. export class RenderTargetTexture extends Texture {
  93616. isCube: boolean;
  93617. /**
  93618. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93619. */
  93620. static readonly REFRESHRATE_RENDER_ONCE: number;
  93621. /**
  93622. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93623. */
  93624. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93625. /**
  93626. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93627. * the central point of your effect and can save a lot of performances.
  93628. */
  93629. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93630. /**
  93631. * Use this predicate to dynamically define the list of mesh you want to render.
  93632. * If set, the renderList property will be overwritten.
  93633. */
  93634. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93635. private _renderList;
  93636. /**
  93637. * Use this list to define the list of mesh you want to render.
  93638. */
  93639. get renderList(): Nullable<Array<AbstractMesh>>;
  93640. set renderList(value: Nullable<Array<AbstractMesh>>);
  93641. /**
  93642. * Use this function to overload the renderList array at rendering time.
  93643. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93644. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93645. * the cube (if the RTT is a cube, else layerOrFace=0).
  93646. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93647. */
  93648. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93649. private _hookArray;
  93650. /**
  93651. * Define if particles should be rendered in your texture.
  93652. */
  93653. renderParticles: boolean;
  93654. /**
  93655. * Define if sprites should be rendered in your texture.
  93656. */
  93657. renderSprites: boolean;
  93658. /**
  93659. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93660. */
  93661. coordinatesMode: number;
  93662. /**
  93663. * Define the camera used to render the texture.
  93664. */
  93665. activeCamera: Nullable<Camera>;
  93666. /**
  93667. * Override the render function of the texture with your own one.
  93668. */
  93669. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93670. /**
  93671. * Define if camera post processes should be use while rendering the texture.
  93672. */
  93673. useCameraPostProcesses: boolean;
  93674. /**
  93675. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93676. */
  93677. ignoreCameraViewport: boolean;
  93678. private _postProcessManager;
  93679. private _postProcesses;
  93680. private _resizeObserver;
  93681. /**
  93682. * An event triggered when the texture is unbind.
  93683. */
  93684. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93685. /**
  93686. * An event triggered when the texture is unbind.
  93687. */
  93688. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93689. private _onAfterUnbindObserver;
  93690. /**
  93691. * Set a after unbind callback in the texture.
  93692. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93693. */
  93694. set onAfterUnbind(callback: () => void);
  93695. /**
  93696. * An event triggered before rendering the texture
  93697. */
  93698. onBeforeRenderObservable: Observable<number>;
  93699. private _onBeforeRenderObserver;
  93700. /**
  93701. * Set a before render callback in the texture.
  93702. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93703. */
  93704. set onBeforeRender(callback: (faceIndex: number) => void);
  93705. /**
  93706. * An event triggered after rendering the texture
  93707. */
  93708. onAfterRenderObservable: Observable<number>;
  93709. private _onAfterRenderObserver;
  93710. /**
  93711. * Set a after render callback in the texture.
  93712. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93713. */
  93714. set onAfterRender(callback: (faceIndex: number) => void);
  93715. /**
  93716. * An event triggered after the texture clear
  93717. */
  93718. onClearObservable: Observable<Engine>;
  93719. private _onClearObserver;
  93720. /**
  93721. * Set a clear callback in the texture.
  93722. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93723. */
  93724. set onClear(callback: (Engine: Engine) => void);
  93725. /**
  93726. * An event triggered when the texture is resized.
  93727. */
  93728. onResizeObservable: Observable<RenderTargetTexture>;
  93729. /**
  93730. * Define the clear color of the Render Target if it should be different from the scene.
  93731. */
  93732. clearColor: Color4;
  93733. protected _size: number | {
  93734. width: number;
  93735. height: number;
  93736. layers?: number;
  93737. };
  93738. protected _initialSizeParameter: number | {
  93739. width: number;
  93740. height: number;
  93741. } | {
  93742. ratio: number;
  93743. };
  93744. protected _sizeRatio: Nullable<number>;
  93745. /** @hidden */
  93746. _generateMipMaps: boolean;
  93747. protected _renderingManager: RenderingManager;
  93748. /** @hidden */
  93749. _waitingRenderList: string[];
  93750. protected _doNotChangeAspectRatio: boolean;
  93751. protected _currentRefreshId: number;
  93752. protected _refreshRate: number;
  93753. protected _textureMatrix: Matrix;
  93754. protected _samples: number;
  93755. protected _renderTargetOptions: RenderTargetCreationOptions;
  93756. /**
  93757. * Gets render target creation options that were used.
  93758. */
  93759. get renderTargetOptions(): RenderTargetCreationOptions;
  93760. protected _engine: Engine;
  93761. protected _onRatioRescale(): void;
  93762. /**
  93763. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93764. * It must define where the camera used to render the texture is set
  93765. */
  93766. boundingBoxPosition: Vector3;
  93767. private _boundingBoxSize;
  93768. /**
  93769. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93770. * When defined, the cubemap will switch to local mode
  93771. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93772. * @example https://www.babylonjs-playground.com/#RNASML
  93773. */
  93774. set boundingBoxSize(value: Vector3);
  93775. get boundingBoxSize(): Vector3;
  93776. /**
  93777. * In case the RTT has been created with a depth texture, get the associated
  93778. * depth texture.
  93779. * Otherwise, return null.
  93780. */
  93781. get depthStencilTexture(): Nullable<InternalTexture>;
  93782. /**
  93783. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93784. * or used a shadow, depth texture...
  93785. * @param name The friendly name of the texture
  93786. * @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)
  93787. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93788. * @param generateMipMaps True if mip maps need to be generated after render.
  93789. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93790. * @param type The type of the buffer in the RTT (int, half float, float...)
  93791. * @param isCube True if a cube texture needs to be created
  93792. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93793. * @param generateDepthBuffer True to generate a depth buffer
  93794. * @param generateStencilBuffer True to generate a stencil buffer
  93795. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93796. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93797. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93798. */
  93799. constructor(name: string, size: number | {
  93800. width: number;
  93801. height: number;
  93802. layers?: number;
  93803. } | {
  93804. ratio: number;
  93805. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93806. /**
  93807. * Creates a depth stencil texture.
  93808. * This is only available in WebGL 2 or with the depth texture extension available.
  93809. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93810. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93811. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93812. */
  93813. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93814. private _processSizeParameter;
  93815. /**
  93816. * Define the number of samples to use in case of MSAA.
  93817. * It defaults to one meaning no MSAA has been enabled.
  93818. */
  93819. get samples(): number;
  93820. set samples(value: number);
  93821. /**
  93822. * Resets the refresh counter of the texture and start bak from scratch.
  93823. * Could be useful to regenerate the texture if it is setup to render only once.
  93824. */
  93825. resetRefreshCounter(): void;
  93826. /**
  93827. * Define the refresh rate of the texture or the rendering frequency.
  93828. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93829. */
  93830. get refreshRate(): number;
  93831. set refreshRate(value: number);
  93832. /**
  93833. * Adds a post process to the render target rendering passes.
  93834. * @param postProcess define the post process to add
  93835. */
  93836. addPostProcess(postProcess: PostProcess): void;
  93837. /**
  93838. * Clear all the post processes attached to the render target
  93839. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93840. */
  93841. clearPostProcesses(dispose?: boolean): void;
  93842. /**
  93843. * Remove one of the post process from the list of attached post processes to the texture
  93844. * @param postProcess define the post process to remove from the list
  93845. */
  93846. removePostProcess(postProcess: PostProcess): void;
  93847. /** @hidden */
  93848. _shouldRender(): boolean;
  93849. /**
  93850. * Gets the actual render size of the texture.
  93851. * @returns the width of the render size
  93852. */
  93853. getRenderSize(): number;
  93854. /**
  93855. * Gets the actual render width of the texture.
  93856. * @returns the width of the render size
  93857. */
  93858. getRenderWidth(): number;
  93859. /**
  93860. * Gets the actual render height of the texture.
  93861. * @returns the height of the render size
  93862. */
  93863. getRenderHeight(): number;
  93864. /**
  93865. * Gets the actual number of layers of the texture.
  93866. * @returns the number of layers
  93867. */
  93868. getRenderLayers(): number;
  93869. /**
  93870. * Get if the texture can be rescaled or not.
  93871. */
  93872. get canRescale(): boolean;
  93873. /**
  93874. * Resize the texture using a ratio.
  93875. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93876. */
  93877. scale(ratio: number): void;
  93878. /**
  93879. * Get the texture reflection matrix used to rotate/transform the reflection.
  93880. * @returns the reflection matrix
  93881. */
  93882. getReflectionTextureMatrix(): Matrix;
  93883. /**
  93884. * Resize the texture to a new desired size.
  93885. * Be carrefull as it will recreate all the data in the new texture.
  93886. * @param size Define the new size. It can be:
  93887. * - a number for squared texture,
  93888. * - an object containing { width: number, height: number }
  93889. * - or an object containing a ratio { ratio: number }
  93890. */
  93891. resize(size: number | {
  93892. width: number;
  93893. height: number;
  93894. } | {
  93895. ratio: number;
  93896. }): void;
  93897. private _defaultRenderListPrepared;
  93898. /**
  93899. * Renders all the objects from the render list into the texture.
  93900. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93901. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93902. */
  93903. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93904. private _bestReflectionRenderTargetDimension;
  93905. private _prepareRenderingManager;
  93906. /**
  93907. * @hidden
  93908. * @param faceIndex face index to bind to if this is a cubetexture
  93909. * @param layer defines the index of the texture to bind in the array
  93910. */
  93911. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93912. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93913. private renderToTarget;
  93914. /**
  93915. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93916. * This allowed control for front to back rendering or reversly depending of the special needs.
  93917. *
  93918. * @param renderingGroupId The rendering group id corresponding to its index
  93919. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93920. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93921. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93922. */
  93923. 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;
  93924. /**
  93925. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93926. *
  93927. * @param renderingGroupId The rendering group id corresponding to its index
  93928. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93929. */
  93930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93931. /**
  93932. * Clones the texture.
  93933. * @returns the cloned texture
  93934. */
  93935. clone(): RenderTargetTexture;
  93936. /**
  93937. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93938. * @returns The JSON representation of the texture
  93939. */
  93940. serialize(): any;
  93941. /**
  93942. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93943. */
  93944. disposeFramebufferObjects(): void;
  93945. /**
  93946. * Dispose the texture and release its associated resources.
  93947. */
  93948. dispose(): void;
  93949. /** @hidden */
  93950. _rebuild(): void;
  93951. /**
  93952. * Clear the info related to rendering groups preventing retention point in material dispose.
  93953. */
  93954. freeRenderingGroups(): void;
  93955. /**
  93956. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93957. * @returns the view count
  93958. */
  93959. getViewCount(): number;
  93960. }
  93961. }
  93962. declare module BABYLON {
  93963. /**
  93964. * Options for compiling materials.
  93965. */
  93966. export interface IMaterialCompilationOptions {
  93967. /**
  93968. * Defines whether clip planes are enabled.
  93969. */
  93970. clipPlane: boolean;
  93971. /**
  93972. * Defines whether instances are enabled.
  93973. */
  93974. useInstances: boolean;
  93975. }
  93976. /**
  93977. * Base class for the main features of a material in Babylon.js
  93978. */
  93979. export class Material implements IAnimatable {
  93980. /**
  93981. * Returns the triangle fill mode
  93982. */
  93983. static readonly TriangleFillMode: number;
  93984. /**
  93985. * Returns the wireframe mode
  93986. */
  93987. static readonly WireFrameFillMode: number;
  93988. /**
  93989. * Returns the point fill mode
  93990. */
  93991. static readonly PointFillMode: number;
  93992. /**
  93993. * Returns the point list draw mode
  93994. */
  93995. static readonly PointListDrawMode: number;
  93996. /**
  93997. * Returns the line list draw mode
  93998. */
  93999. static readonly LineListDrawMode: number;
  94000. /**
  94001. * Returns the line loop draw mode
  94002. */
  94003. static readonly LineLoopDrawMode: number;
  94004. /**
  94005. * Returns the line strip draw mode
  94006. */
  94007. static readonly LineStripDrawMode: number;
  94008. /**
  94009. * Returns the triangle strip draw mode
  94010. */
  94011. static readonly TriangleStripDrawMode: number;
  94012. /**
  94013. * Returns the triangle fan draw mode
  94014. */
  94015. static readonly TriangleFanDrawMode: number;
  94016. /**
  94017. * Stores the clock-wise side orientation
  94018. */
  94019. static readonly ClockWiseSideOrientation: number;
  94020. /**
  94021. * Stores the counter clock-wise side orientation
  94022. */
  94023. static readonly CounterClockWiseSideOrientation: number;
  94024. /**
  94025. * The dirty texture flag value
  94026. */
  94027. static readonly TextureDirtyFlag: number;
  94028. /**
  94029. * The dirty light flag value
  94030. */
  94031. static readonly LightDirtyFlag: number;
  94032. /**
  94033. * The dirty fresnel flag value
  94034. */
  94035. static readonly FresnelDirtyFlag: number;
  94036. /**
  94037. * The dirty attribute flag value
  94038. */
  94039. static readonly AttributesDirtyFlag: number;
  94040. /**
  94041. * The dirty misc flag value
  94042. */
  94043. static readonly MiscDirtyFlag: number;
  94044. /**
  94045. * The all dirty flag value
  94046. */
  94047. static readonly AllDirtyFlag: number;
  94048. /**
  94049. * The ID of the material
  94050. */
  94051. id: string;
  94052. /**
  94053. * Gets or sets the unique id of the material
  94054. */
  94055. uniqueId: number;
  94056. /**
  94057. * The name of the material
  94058. */
  94059. name: string;
  94060. /**
  94061. * Gets or sets user defined metadata
  94062. */
  94063. metadata: any;
  94064. /**
  94065. * For internal use only. Please do not use.
  94066. */
  94067. reservedDataStore: any;
  94068. /**
  94069. * Specifies if the ready state should be checked on each call
  94070. */
  94071. checkReadyOnEveryCall: boolean;
  94072. /**
  94073. * Specifies if the ready state should be checked once
  94074. */
  94075. checkReadyOnlyOnce: boolean;
  94076. /**
  94077. * The state of the material
  94078. */
  94079. state: string;
  94080. /**
  94081. * The alpha value of the material
  94082. */
  94083. protected _alpha: number;
  94084. /**
  94085. * List of inspectable custom properties (used by the Inspector)
  94086. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94087. */
  94088. inspectableCustomProperties: IInspectable[];
  94089. /**
  94090. * Sets the alpha value of the material
  94091. */
  94092. set alpha(value: number);
  94093. /**
  94094. * Gets the alpha value of the material
  94095. */
  94096. get alpha(): number;
  94097. /**
  94098. * Specifies if back face culling is enabled
  94099. */
  94100. protected _backFaceCulling: boolean;
  94101. /**
  94102. * Sets the back-face culling state
  94103. */
  94104. set backFaceCulling(value: boolean);
  94105. /**
  94106. * Gets the back-face culling state
  94107. */
  94108. get backFaceCulling(): boolean;
  94109. /**
  94110. * Stores the value for side orientation
  94111. */
  94112. sideOrientation: number;
  94113. /**
  94114. * Callback triggered when the material is compiled
  94115. */
  94116. onCompiled: Nullable<(effect: Effect) => void>;
  94117. /**
  94118. * Callback triggered when an error occurs
  94119. */
  94120. onError: Nullable<(effect: Effect, errors: string) => void>;
  94121. /**
  94122. * Callback triggered to get the render target textures
  94123. */
  94124. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94125. /**
  94126. * Gets a boolean indicating that current material needs to register RTT
  94127. */
  94128. get hasRenderTargetTextures(): boolean;
  94129. /**
  94130. * Specifies if the material should be serialized
  94131. */
  94132. doNotSerialize: boolean;
  94133. /**
  94134. * @hidden
  94135. */
  94136. _storeEffectOnSubMeshes: boolean;
  94137. /**
  94138. * Stores the animations for the material
  94139. */
  94140. animations: Nullable<Array<Animation>>;
  94141. /**
  94142. * An event triggered when the material is disposed
  94143. */
  94144. onDisposeObservable: Observable<Material>;
  94145. /**
  94146. * An observer which watches for dispose events
  94147. */
  94148. private _onDisposeObserver;
  94149. private _onUnBindObservable;
  94150. /**
  94151. * Called during a dispose event
  94152. */
  94153. set onDispose(callback: () => void);
  94154. private _onBindObservable;
  94155. /**
  94156. * An event triggered when the material is bound
  94157. */
  94158. get onBindObservable(): Observable<AbstractMesh>;
  94159. /**
  94160. * An observer which watches for bind events
  94161. */
  94162. private _onBindObserver;
  94163. /**
  94164. * Called during a bind event
  94165. */
  94166. set onBind(callback: (Mesh: AbstractMesh) => void);
  94167. /**
  94168. * An event triggered when the material is unbound
  94169. */
  94170. get onUnBindObservable(): Observable<Material>;
  94171. /**
  94172. * Stores the value of the alpha mode
  94173. */
  94174. private _alphaMode;
  94175. /**
  94176. * Sets the value of the alpha mode.
  94177. *
  94178. * | Value | Type | Description |
  94179. * | --- | --- | --- |
  94180. * | 0 | ALPHA_DISABLE | |
  94181. * | 1 | ALPHA_ADD | |
  94182. * | 2 | ALPHA_COMBINE | |
  94183. * | 3 | ALPHA_SUBTRACT | |
  94184. * | 4 | ALPHA_MULTIPLY | |
  94185. * | 5 | ALPHA_MAXIMIZED | |
  94186. * | 6 | ALPHA_ONEONE | |
  94187. * | 7 | ALPHA_PREMULTIPLIED | |
  94188. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94189. * | 9 | ALPHA_INTERPOLATE | |
  94190. * | 10 | ALPHA_SCREENMODE | |
  94191. *
  94192. */
  94193. set alphaMode(value: number);
  94194. /**
  94195. * Gets the value of the alpha mode
  94196. */
  94197. get alphaMode(): number;
  94198. /**
  94199. * Stores the state of the need depth pre-pass value
  94200. */
  94201. private _needDepthPrePass;
  94202. /**
  94203. * Sets the need depth pre-pass value
  94204. */
  94205. set needDepthPrePass(value: boolean);
  94206. /**
  94207. * Gets the depth pre-pass value
  94208. */
  94209. get needDepthPrePass(): boolean;
  94210. /**
  94211. * Specifies if depth writing should be disabled
  94212. */
  94213. disableDepthWrite: boolean;
  94214. /**
  94215. * Specifies if depth writing should be forced
  94216. */
  94217. forceDepthWrite: boolean;
  94218. /**
  94219. * Specifies the depth function that should be used. 0 means the default engine function
  94220. */
  94221. depthFunction: number;
  94222. /**
  94223. * Specifies if there should be a separate pass for culling
  94224. */
  94225. separateCullingPass: boolean;
  94226. /**
  94227. * Stores the state specifing if fog should be enabled
  94228. */
  94229. private _fogEnabled;
  94230. /**
  94231. * Sets the state for enabling fog
  94232. */
  94233. set fogEnabled(value: boolean);
  94234. /**
  94235. * Gets the value of the fog enabled state
  94236. */
  94237. get fogEnabled(): boolean;
  94238. /**
  94239. * Stores the size of points
  94240. */
  94241. pointSize: number;
  94242. /**
  94243. * Stores the z offset value
  94244. */
  94245. zOffset: number;
  94246. /**
  94247. * Gets a value specifying if wireframe mode is enabled
  94248. */
  94249. get wireframe(): boolean;
  94250. /**
  94251. * Sets the state of wireframe mode
  94252. */
  94253. set wireframe(value: boolean);
  94254. /**
  94255. * Gets the value specifying if point clouds are enabled
  94256. */
  94257. get pointsCloud(): boolean;
  94258. /**
  94259. * Sets the state of point cloud mode
  94260. */
  94261. set pointsCloud(value: boolean);
  94262. /**
  94263. * Gets the material fill mode
  94264. */
  94265. get fillMode(): number;
  94266. /**
  94267. * Sets the material fill mode
  94268. */
  94269. set fillMode(value: number);
  94270. /**
  94271. * @hidden
  94272. * Stores the effects for the material
  94273. */
  94274. _effect: Nullable<Effect>;
  94275. /**
  94276. * Specifies if uniform buffers should be used
  94277. */
  94278. private _useUBO;
  94279. /**
  94280. * Stores a reference to the scene
  94281. */
  94282. private _scene;
  94283. /**
  94284. * Stores the fill mode state
  94285. */
  94286. private _fillMode;
  94287. /**
  94288. * Specifies if the depth write state should be cached
  94289. */
  94290. private _cachedDepthWriteState;
  94291. /**
  94292. * Specifies if the depth function state should be cached
  94293. */
  94294. private _cachedDepthFunctionState;
  94295. /**
  94296. * Stores the uniform buffer
  94297. */
  94298. protected _uniformBuffer: UniformBuffer;
  94299. /** @hidden */
  94300. _indexInSceneMaterialArray: number;
  94301. /** @hidden */
  94302. meshMap: Nullable<{
  94303. [id: string]: AbstractMesh | undefined;
  94304. }>;
  94305. /**
  94306. * Creates a material instance
  94307. * @param name defines the name of the material
  94308. * @param scene defines the scene to reference
  94309. * @param doNotAdd specifies if the material should be added to the scene
  94310. */
  94311. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94312. /**
  94313. * Returns a string representation of the current material
  94314. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94315. * @returns a string with material information
  94316. */
  94317. toString(fullDetails?: boolean): string;
  94318. /**
  94319. * Gets the class name of the material
  94320. * @returns a string with the class name of the material
  94321. */
  94322. getClassName(): string;
  94323. /**
  94324. * Specifies if updates for the material been locked
  94325. */
  94326. get isFrozen(): boolean;
  94327. /**
  94328. * Locks updates for the material
  94329. */
  94330. freeze(): void;
  94331. /**
  94332. * Unlocks updates for the material
  94333. */
  94334. unfreeze(): void;
  94335. /**
  94336. * Specifies if the material is ready to be used
  94337. * @param mesh defines the mesh to check
  94338. * @param useInstances specifies if instances should be used
  94339. * @returns a boolean indicating if the material is ready to be used
  94340. */
  94341. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94342. /**
  94343. * Specifies that the submesh is ready to be used
  94344. * @param mesh defines the mesh to check
  94345. * @param subMesh defines which submesh to check
  94346. * @param useInstances specifies that instances should be used
  94347. * @returns a boolean indicating that the submesh is ready or not
  94348. */
  94349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94350. /**
  94351. * Returns the material effect
  94352. * @returns the effect associated with the material
  94353. */
  94354. getEffect(): Nullable<Effect>;
  94355. /**
  94356. * Returns the current scene
  94357. * @returns a Scene
  94358. */
  94359. getScene(): Scene;
  94360. /**
  94361. * Specifies if the material will require alpha blending
  94362. * @returns a boolean specifying if alpha blending is needed
  94363. */
  94364. needAlphaBlending(): boolean;
  94365. /**
  94366. * Specifies if the mesh will require alpha blending
  94367. * @param mesh defines the mesh to check
  94368. * @returns a boolean specifying if alpha blending is needed for the mesh
  94369. */
  94370. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94371. /**
  94372. * Specifies if this material should be rendered in alpha test mode
  94373. * @returns a boolean specifying if an alpha test is needed.
  94374. */
  94375. needAlphaTesting(): boolean;
  94376. /**
  94377. * Gets the texture used for the alpha test
  94378. * @returns the texture to use for alpha testing
  94379. */
  94380. getAlphaTestTexture(): Nullable<BaseTexture>;
  94381. /**
  94382. * Marks the material to indicate that it needs to be re-calculated
  94383. */
  94384. markDirty(): void;
  94385. /** @hidden */
  94386. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94387. /**
  94388. * Binds the material to the mesh
  94389. * @param world defines the world transformation matrix
  94390. * @param mesh defines the mesh to bind the material to
  94391. */
  94392. bind(world: Matrix, mesh?: Mesh): void;
  94393. /**
  94394. * Binds the submesh to the material
  94395. * @param world defines the world transformation matrix
  94396. * @param mesh defines the mesh containing the submesh
  94397. * @param subMesh defines the submesh to bind the material to
  94398. */
  94399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94400. /**
  94401. * Binds the world matrix to the material
  94402. * @param world defines the world transformation matrix
  94403. */
  94404. bindOnlyWorldMatrix(world: Matrix): void;
  94405. /**
  94406. * Binds the scene's uniform buffer to the effect.
  94407. * @param effect defines the effect to bind to the scene uniform buffer
  94408. * @param sceneUbo defines the uniform buffer storing scene data
  94409. */
  94410. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94411. /**
  94412. * Binds the view matrix to the effect
  94413. * @param effect defines the effect to bind the view matrix to
  94414. */
  94415. bindView(effect: Effect): void;
  94416. /**
  94417. * Binds the view projection matrix to the effect
  94418. * @param effect defines the effect to bind the view projection matrix to
  94419. */
  94420. bindViewProjection(effect: Effect): void;
  94421. /**
  94422. * Specifies if material alpha testing should be turned on for the mesh
  94423. * @param mesh defines the mesh to check
  94424. */
  94425. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94426. /**
  94427. * Processes to execute after binding the material to a mesh
  94428. * @param mesh defines the rendered mesh
  94429. */
  94430. protected _afterBind(mesh?: Mesh): void;
  94431. /**
  94432. * Unbinds the material from the mesh
  94433. */
  94434. unbind(): void;
  94435. /**
  94436. * Gets the active textures from the material
  94437. * @returns an array of textures
  94438. */
  94439. getActiveTextures(): BaseTexture[];
  94440. /**
  94441. * Specifies if the material uses a texture
  94442. * @param texture defines the texture to check against the material
  94443. * @returns a boolean specifying if the material uses the texture
  94444. */
  94445. hasTexture(texture: BaseTexture): boolean;
  94446. /**
  94447. * Makes a duplicate of the material, and gives it a new name
  94448. * @param name defines the new name for the duplicated material
  94449. * @returns the cloned material
  94450. */
  94451. clone(name: string): Nullable<Material>;
  94452. /**
  94453. * Gets the meshes bound to the material
  94454. * @returns an array of meshes bound to the material
  94455. */
  94456. getBindedMeshes(): AbstractMesh[];
  94457. /**
  94458. * Force shader compilation
  94459. * @param mesh defines the mesh associated with this material
  94460. * @param onCompiled defines a function to execute once the material is compiled
  94461. * @param options defines the options to configure the compilation
  94462. * @param onError defines a function to execute if the material fails compiling
  94463. */
  94464. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94465. /**
  94466. * Force shader compilation
  94467. * @param mesh defines the mesh that will use this material
  94468. * @param options defines additional options for compiling the shaders
  94469. * @returns a promise that resolves when the compilation completes
  94470. */
  94471. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94472. private static readonly _AllDirtyCallBack;
  94473. private static readonly _ImageProcessingDirtyCallBack;
  94474. private static readonly _TextureDirtyCallBack;
  94475. private static readonly _FresnelDirtyCallBack;
  94476. private static readonly _MiscDirtyCallBack;
  94477. private static readonly _LightsDirtyCallBack;
  94478. private static readonly _AttributeDirtyCallBack;
  94479. private static _FresnelAndMiscDirtyCallBack;
  94480. private static _TextureAndMiscDirtyCallBack;
  94481. private static readonly _DirtyCallbackArray;
  94482. private static readonly _RunDirtyCallBacks;
  94483. /**
  94484. * Marks a define in the material to indicate that it needs to be re-computed
  94485. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94486. */
  94487. markAsDirty(flag: number): void;
  94488. /**
  94489. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94490. * @param func defines a function which checks material defines against the submeshes
  94491. */
  94492. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94493. /**
  94494. * Indicates that we need to re-calculated for all submeshes
  94495. */
  94496. protected _markAllSubMeshesAsAllDirty(): void;
  94497. /**
  94498. * Indicates that image processing needs to be re-calculated for all submeshes
  94499. */
  94500. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94501. /**
  94502. * Indicates that textures need to be re-calculated for all submeshes
  94503. */
  94504. protected _markAllSubMeshesAsTexturesDirty(): void;
  94505. /**
  94506. * Indicates that fresnel needs to be re-calculated for all submeshes
  94507. */
  94508. protected _markAllSubMeshesAsFresnelDirty(): void;
  94509. /**
  94510. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94511. */
  94512. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94513. /**
  94514. * Indicates that lights need to be re-calculated for all submeshes
  94515. */
  94516. protected _markAllSubMeshesAsLightsDirty(): void;
  94517. /**
  94518. * Indicates that attributes need to be re-calculated for all submeshes
  94519. */
  94520. protected _markAllSubMeshesAsAttributesDirty(): void;
  94521. /**
  94522. * Indicates that misc needs to be re-calculated for all submeshes
  94523. */
  94524. protected _markAllSubMeshesAsMiscDirty(): void;
  94525. /**
  94526. * Indicates that textures and misc need to be re-calculated for all submeshes
  94527. */
  94528. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94529. /**
  94530. * Disposes the material
  94531. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94532. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94533. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94534. */
  94535. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94536. /** @hidden */
  94537. private releaseVertexArrayObject;
  94538. /**
  94539. * Serializes this material
  94540. * @returns the serialized material object
  94541. */
  94542. serialize(): any;
  94543. /**
  94544. * Creates a material from parsed material data
  94545. * @param parsedMaterial defines parsed material data
  94546. * @param scene defines the hosting scene
  94547. * @param rootUrl defines the root URL to use to load textures
  94548. * @returns a new material
  94549. */
  94550. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94551. }
  94552. }
  94553. declare module BABYLON {
  94554. /**
  94555. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94556. * separate meshes. This can be use to improve performances.
  94557. * @see http://doc.babylonjs.com/how_to/multi_materials
  94558. */
  94559. export class MultiMaterial extends Material {
  94560. private _subMaterials;
  94561. /**
  94562. * Gets or Sets the list of Materials used within the multi material.
  94563. * They need to be ordered according to the submeshes order in the associated mesh
  94564. */
  94565. get subMaterials(): Nullable<Material>[];
  94566. set subMaterials(value: Nullable<Material>[]);
  94567. /**
  94568. * Function used to align with Node.getChildren()
  94569. * @returns the list of Materials used within the multi material
  94570. */
  94571. getChildren(): Nullable<Material>[];
  94572. /**
  94573. * Instantiates a new Multi Material
  94574. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94575. * separate meshes. This can be use to improve performances.
  94576. * @see http://doc.babylonjs.com/how_to/multi_materials
  94577. * @param name Define the name in the scene
  94578. * @param scene Define the scene the material belongs to
  94579. */
  94580. constructor(name: string, scene: Scene);
  94581. private _hookArray;
  94582. /**
  94583. * Get one of the submaterial by its index in the submaterials array
  94584. * @param index The index to look the sub material at
  94585. * @returns The Material if the index has been defined
  94586. */
  94587. getSubMaterial(index: number): Nullable<Material>;
  94588. /**
  94589. * Get the list of active textures for the whole sub materials list.
  94590. * @returns All the textures that will be used during the rendering
  94591. */
  94592. getActiveTextures(): BaseTexture[];
  94593. /**
  94594. * Gets the current class name of the material e.g. "MultiMaterial"
  94595. * Mainly use in serialization.
  94596. * @returns the class name
  94597. */
  94598. getClassName(): string;
  94599. /**
  94600. * Checks if the material is ready to render the requested sub mesh
  94601. * @param mesh Define the mesh the submesh belongs to
  94602. * @param subMesh Define the sub mesh to look readyness for
  94603. * @param useInstances Define whether or not the material is used with instances
  94604. * @returns true if ready, otherwise false
  94605. */
  94606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94607. /**
  94608. * Clones the current material and its related sub materials
  94609. * @param name Define the name of the newly cloned material
  94610. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94611. * @returns the cloned material
  94612. */
  94613. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94614. /**
  94615. * Serializes the materials into a JSON representation.
  94616. * @returns the JSON representation
  94617. */
  94618. serialize(): any;
  94619. /**
  94620. * Dispose the material and release its associated resources
  94621. * @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)
  94622. * @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)
  94623. * @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)
  94624. */
  94625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94626. /**
  94627. * Creates a MultiMaterial from parsed MultiMaterial data.
  94628. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94629. * @param scene defines the hosting scene
  94630. * @returns a new MultiMaterial
  94631. */
  94632. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94633. }
  94634. }
  94635. declare module BABYLON {
  94636. /**
  94637. * Base class for submeshes
  94638. */
  94639. export class BaseSubMesh {
  94640. /** @hidden */
  94641. _materialDefines: Nullable<MaterialDefines>;
  94642. /** @hidden */
  94643. _materialEffect: Nullable<Effect>;
  94644. /**
  94645. * Gets material defines used by the effect associated to the sub mesh
  94646. */
  94647. get materialDefines(): Nullable<MaterialDefines>;
  94648. /**
  94649. * Sets material defines used by the effect associated to the sub mesh
  94650. */
  94651. set materialDefines(defines: Nullable<MaterialDefines>);
  94652. /**
  94653. * Gets associated effect
  94654. */
  94655. get effect(): Nullable<Effect>;
  94656. /**
  94657. * Sets associated effect (effect used to render this submesh)
  94658. * @param effect defines the effect to associate with
  94659. * @param defines defines the set of defines used to compile this effect
  94660. */
  94661. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94662. }
  94663. /**
  94664. * Defines a subdivision inside a mesh
  94665. */
  94666. export class SubMesh extends BaseSubMesh implements ICullable {
  94667. /** the material index to use */
  94668. materialIndex: number;
  94669. /** vertex index start */
  94670. verticesStart: number;
  94671. /** vertices count */
  94672. verticesCount: number;
  94673. /** index start */
  94674. indexStart: number;
  94675. /** indices count */
  94676. indexCount: number;
  94677. /** @hidden */
  94678. _linesIndexCount: number;
  94679. private _mesh;
  94680. private _renderingMesh;
  94681. private _boundingInfo;
  94682. private _linesIndexBuffer;
  94683. /** @hidden */
  94684. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94685. /** @hidden */
  94686. _trianglePlanes: Plane[];
  94687. /** @hidden */
  94688. _lastColliderTransformMatrix: Nullable<Matrix>;
  94689. /** @hidden */
  94690. _renderId: number;
  94691. /** @hidden */
  94692. _alphaIndex: number;
  94693. /** @hidden */
  94694. _distanceToCamera: number;
  94695. /** @hidden */
  94696. _id: number;
  94697. private _currentMaterial;
  94698. /**
  94699. * Add a new submesh to a mesh
  94700. * @param materialIndex defines the material index to use
  94701. * @param verticesStart defines vertex index start
  94702. * @param verticesCount defines vertices count
  94703. * @param indexStart defines index start
  94704. * @param indexCount defines indices count
  94705. * @param mesh defines the parent mesh
  94706. * @param renderingMesh defines an optional rendering mesh
  94707. * @param createBoundingBox defines if bounding box should be created for this submesh
  94708. * @returns the new submesh
  94709. */
  94710. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94711. /**
  94712. * Creates a new submesh
  94713. * @param materialIndex defines the material index to use
  94714. * @param verticesStart defines vertex index start
  94715. * @param verticesCount defines vertices count
  94716. * @param indexStart defines index start
  94717. * @param indexCount defines indices count
  94718. * @param mesh defines the parent mesh
  94719. * @param renderingMesh defines an optional rendering mesh
  94720. * @param createBoundingBox defines if bounding box should be created for this submesh
  94721. */
  94722. constructor(
  94723. /** the material index to use */
  94724. materialIndex: number,
  94725. /** vertex index start */
  94726. verticesStart: number,
  94727. /** vertices count */
  94728. verticesCount: number,
  94729. /** index start */
  94730. indexStart: number,
  94731. /** indices count */
  94732. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94733. /**
  94734. * Returns true if this submesh covers the entire parent mesh
  94735. * @ignorenaming
  94736. */
  94737. get IsGlobal(): boolean;
  94738. /**
  94739. * Returns the submesh BoudingInfo object
  94740. * @returns current bounding info (or mesh's one if the submesh is global)
  94741. */
  94742. getBoundingInfo(): BoundingInfo;
  94743. /**
  94744. * Sets the submesh BoundingInfo
  94745. * @param boundingInfo defines the new bounding info to use
  94746. * @returns the SubMesh
  94747. */
  94748. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94749. /**
  94750. * Returns the mesh of the current submesh
  94751. * @return the parent mesh
  94752. */
  94753. getMesh(): AbstractMesh;
  94754. /**
  94755. * Returns the rendering mesh of the submesh
  94756. * @returns the rendering mesh (could be different from parent mesh)
  94757. */
  94758. getRenderingMesh(): Mesh;
  94759. /**
  94760. * Returns the submesh material
  94761. * @returns null or the current material
  94762. */
  94763. getMaterial(): Nullable<Material>;
  94764. /**
  94765. * Sets a new updated BoundingInfo object to the submesh
  94766. * @param data defines an optional position array to use to determine the bounding info
  94767. * @returns the SubMesh
  94768. */
  94769. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94770. /** @hidden */
  94771. _checkCollision(collider: Collider): boolean;
  94772. /**
  94773. * Updates the submesh BoundingInfo
  94774. * @param world defines the world matrix to use to update the bounding info
  94775. * @returns the submesh
  94776. */
  94777. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94778. /**
  94779. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94780. * @param frustumPlanes defines the frustum planes
  94781. * @returns true if the submesh is intersecting with the frustum
  94782. */
  94783. isInFrustum(frustumPlanes: Plane[]): boolean;
  94784. /**
  94785. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94786. * @param frustumPlanes defines the frustum planes
  94787. * @returns true if the submesh is inside the frustum
  94788. */
  94789. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94790. /**
  94791. * Renders the submesh
  94792. * @param enableAlphaMode defines if alpha needs to be used
  94793. * @returns the submesh
  94794. */
  94795. render(enableAlphaMode: boolean): SubMesh;
  94796. /**
  94797. * @hidden
  94798. */
  94799. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94800. /**
  94801. * Checks if the submesh intersects with a ray
  94802. * @param ray defines the ray to test
  94803. * @returns true is the passed ray intersects the submesh bounding box
  94804. */
  94805. canIntersects(ray: Ray): boolean;
  94806. /**
  94807. * Intersects current submesh with a ray
  94808. * @param ray defines the ray to test
  94809. * @param positions defines mesh's positions array
  94810. * @param indices defines mesh's indices array
  94811. * @param fastCheck defines if only bounding info should be used
  94812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94813. * @returns intersection info or null if no intersection
  94814. */
  94815. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94816. /** @hidden */
  94817. private _intersectLines;
  94818. /** @hidden */
  94819. private _intersectUnIndexedLines;
  94820. /** @hidden */
  94821. private _intersectTriangles;
  94822. /** @hidden */
  94823. private _intersectUnIndexedTriangles;
  94824. /** @hidden */
  94825. _rebuild(): void;
  94826. /**
  94827. * Creates a new submesh from the passed mesh
  94828. * @param newMesh defines the new hosting mesh
  94829. * @param newRenderingMesh defines an optional rendering mesh
  94830. * @returns the new submesh
  94831. */
  94832. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94833. /**
  94834. * Release associated resources
  94835. */
  94836. dispose(): void;
  94837. /**
  94838. * Gets the class name
  94839. * @returns the string "SubMesh".
  94840. */
  94841. getClassName(): string;
  94842. /**
  94843. * Creates a new submesh from indices data
  94844. * @param materialIndex the index of the main mesh material
  94845. * @param startIndex the index where to start the copy in the mesh indices array
  94846. * @param indexCount the number of indices to copy then from the startIndex
  94847. * @param mesh the main mesh to create the submesh from
  94848. * @param renderingMesh the optional rendering mesh
  94849. * @returns a new submesh
  94850. */
  94851. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94852. }
  94853. }
  94854. declare module BABYLON {
  94855. /**
  94856. * Class used to represent data loading progression
  94857. */
  94858. export class SceneLoaderFlags {
  94859. private static _ForceFullSceneLoadingForIncremental;
  94860. private static _ShowLoadingScreen;
  94861. private static _CleanBoneMatrixWeights;
  94862. private static _loggingLevel;
  94863. /**
  94864. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94865. */
  94866. static get ForceFullSceneLoadingForIncremental(): boolean;
  94867. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94868. /**
  94869. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94870. */
  94871. static get ShowLoadingScreen(): boolean;
  94872. static set ShowLoadingScreen(value: boolean);
  94873. /**
  94874. * Defines the current logging level (while loading the scene)
  94875. * @ignorenaming
  94876. */
  94877. static get loggingLevel(): number;
  94878. static set loggingLevel(value: number);
  94879. /**
  94880. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94881. */
  94882. static get CleanBoneMatrixWeights(): boolean;
  94883. static set CleanBoneMatrixWeights(value: boolean);
  94884. }
  94885. }
  94886. declare module BABYLON {
  94887. /**
  94888. * Class used to store geometry data (vertex buffers + index buffer)
  94889. */
  94890. export class Geometry implements IGetSetVerticesData {
  94891. /**
  94892. * Gets or sets the ID of the geometry
  94893. */
  94894. id: string;
  94895. /**
  94896. * Gets or sets the unique ID of the geometry
  94897. */
  94898. uniqueId: number;
  94899. /**
  94900. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94901. */
  94902. delayLoadState: number;
  94903. /**
  94904. * Gets the file containing the data to load when running in delay load state
  94905. */
  94906. delayLoadingFile: Nullable<string>;
  94907. /**
  94908. * Callback called when the geometry is updated
  94909. */
  94910. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94911. private _scene;
  94912. private _engine;
  94913. private _meshes;
  94914. private _totalVertices;
  94915. /** @hidden */
  94916. _indices: IndicesArray;
  94917. /** @hidden */
  94918. _vertexBuffers: {
  94919. [key: string]: VertexBuffer;
  94920. };
  94921. private _isDisposed;
  94922. private _extend;
  94923. private _boundingBias;
  94924. /** @hidden */
  94925. _delayInfo: Array<string>;
  94926. private _indexBuffer;
  94927. private _indexBufferIsUpdatable;
  94928. /** @hidden */
  94929. _boundingInfo: Nullable<BoundingInfo>;
  94930. /** @hidden */
  94931. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94932. /** @hidden */
  94933. _softwareSkinningFrameId: number;
  94934. private _vertexArrayObjects;
  94935. private _updatable;
  94936. /** @hidden */
  94937. _positions: Nullable<Vector3[]>;
  94938. /**
  94939. * 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
  94940. */
  94941. get boundingBias(): Vector2;
  94942. /**
  94943. * 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
  94944. */
  94945. set boundingBias(value: Vector2);
  94946. /**
  94947. * Static function used to attach a new empty geometry to a mesh
  94948. * @param mesh defines the mesh to attach the geometry to
  94949. * @returns the new Geometry
  94950. */
  94951. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94952. /**
  94953. * Creates a new geometry
  94954. * @param id defines the unique ID
  94955. * @param scene defines the hosting scene
  94956. * @param vertexData defines the VertexData used to get geometry data
  94957. * @param updatable defines if geometry must be updatable (false by default)
  94958. * @param mesh defines the mesh that will be associated with the geometry
  94959. */
  94960. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94961. /**
  94962. * Gets the current extend of the geometry
  94963. */
  94964. get extend(): {
  94965. minimum: Vector3;
  94966. maximum: Vector3;
  94967. };
  94968. /**
  94969. * Gets the hosting scene
  94970. * @returns the hosting Scene
  94971. */
  94972. getScene(): Scene;
  94973. /**
  94974. * Gets the hosting engine
  94975. * @returns the hosting Engine
  94976. */
  94977. getEngine(): Engine;
  94978. /**
  94979. * Defines if the geometry is ready to use
  94980. * @returns true if the geometry is ready to be used
  94981. */
  94982. isReady(): boolean;
  94983. /**
  94984. * Gets a value indicating that the geometry should not be serialized
  94985. */
  94986. get doNotSerialize(): boolean;
  94987. /** @hidden */
  94988. _rebuild(): void;
  94989. /**
  94990. * Affects all geometry data in one call
  94991. * @param vertexData defines the geometry data
  94992. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94993. */
  94994. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94995. /**
  94996. * Set specific vertex data
  94997. * @param kind defines the data kind (Position, normal, etc...)
  94998. * @param data defines the vertex data to use
  94999. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95000. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95001. */
  95002. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95003. /**
  95004. * Removes a specific vertex data
  95005. * @param kind defines the data kind (Position, normal, etc...)
  95006. */
  95007. removeVerticesData(kind: string): void;
  95008. /**
  95009. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95010. * @param buffer defines the vertex buffer to use
  95011. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95012. */
  95013. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95014. /**
  95015. * Update a specific vertex buffer
  95016. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95017. * It will do nothing if the buffer is not updatable
  95018. * @param kind defines the data kind (Position, normal, etc...)
  95019. * @param data defines the data to use
  95020. * @param offset defines the offset in the target buffer where to store the data
  95021. * @param useBytes set to true if the offset is in bytes
  95022. */
  95023. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95024. /**
  95025. * Update a specific vertex buffer
  95026. * This function will create a new buffer if the current one is not updatable
  95027. * @param kind defines the data kind (Position, normal, etc...)
  95028. * @param data defines the data to use
  95029. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95030. */
  95031. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95032. private _updateBoundingInfo;
  95033. /** @hidden */
  95034. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95035. /**
  95036. * Gets total number of vertices
  95037. * @returns the total number of vertices
  95038. */
  95039. getTotalVertices(): number;
  95040. /**
  95041. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95042. * @param kind defines the data kind (Position, normal, etc...)
  95043. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95044. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95045. * @returns a float array containing vertex data
  95046. */
  95047. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95048. /**
  95049. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95050. * @param kind defines the data kind (Position, normal, etc...)
  95051. * @returns true if the vertex buffer with the specified kind is updatable
  95052. */
  95053. isVertexBufferUpdatable(kind: string): boolean;
  95054. /**
  95055. * Gets a specific vertex buffer
  95056. * @param kind defines the data kind (Position, normal, etc...)
  95057. * @returns a VertexBuffer
  95058. */
  95059. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95060. /**
  95061. * Returns all vertex buffers
  95062. * @return an object holding all vertex buffers indexed by kind
  95063. */
  95064. getVertexBuffers(): Nullable<{
  95065. [key: string]: VertexBuffer;
  95066. }>;
  95067. /**
  95068. * Gets a boolean indicating if specific vertex buffer is present
  95069. * @param kind defines the data kind (Position, normal, etc...)
  95070. * @returns true if data is present
  95071. */
  95072. isVerticesDataPresent(kind: string): boolean;
  95073. /**
  95074. * Gets a list of all attached data kinds (Position, normal, etc...)
  95075. * @returns a list of string containing all kinds
  95076. */
  95077. getVerticesDataKinds(): string[];
  95078. /**
  95079. * Update index buffer
  95080. * @param indices defines the indices to store in the index buffer
  95081. * @param offset defines the offset in the target buffer where to store the data
  95082. * @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)
  95083. */
  95084. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95085. /**
  95086. * Creates a new index buffer
  95087. * @param indices defines the indices to store in the index buffer
  95088. * @param totalVertices defines the total number of vertices (could be null)
  95089. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95090. */
  95091. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95092. /**
  95093. * Return the total number of indices
  95094. * @returns the total number of indices
  95095. */
  95096. getTotalIndices(): number;
  95097. /**
  95098. * Gets the index buffer array
  95099. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95100. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95101. * @returns the index buffer array
  95102. */
  95103. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95104. /**
  95105. * Gets the index buffer
  95106. * @return the index buffer
  95107. */
  95108. getIndexBuffer(): Nullable<DataBuffer>;
  95109. /** @hidden */
  95110. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95111. /**
  95112. * Release the associated resources for a specific mesh
  95113. * @param mesh defines the source mesh
  95114. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95115. */
  95116. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95117. /**
  95118. * Apply current geometry to a given mesh
  95119. * @param mesh defines the mesh to apply geometry to
  95120. */
  95121. applyToMesh(mesh: Mesh): void;
  95122. private _updateExtend;
  95123. private _applyToMesh;
  95124. private notifyUpdate;
  95125. /**
  95126. * Load the geometry if it was flagged as delay loaded
  95127. * @param scene defines the hosting scene
  95128. * @param onLoaded defines a callback called when the geometry is loaded
  95129. */
  95130. load(scene: Scene, onLoaded?: () => void): void;
  95131. private _queueLoad;
  95132. /**
  95133. * Invert the geometry to move from a right handed system to a left handed one.
  95134. */
  95135. toLeftHanded(): void;
  95136. /** @hidden */
  95137. _resetPointsArrayCache(): void;
  95138. /** @hidden */
  95139. _generatePointsArray(): boolean;
  95140. /**
  95141. * Gets a value indicating if the geometry is disposed
  95142. * @returns true if the geometry was disposed
  95143. */
  95144. isDisposed(): boolean;
  95145. private _disposeVertexArrayObjects;
  95146. /**
  95147. * Free all associated resources
  95148. */
  95149. dispose(): void;
  95150. /**
  95151. * Clone the current geometry into a new geometry
  95152. * @param id defines the unique ID of the new geometry
  95153. * @returns a new geometry object
  95154. */
  95155. copy(id: string): Geometry;
  95156. /**
  95157. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95158. * @return a JSON representation of the current geometry data (without the vertices data)
  95159. */
  95160. serialize(): any;
  95161. private toNumberArray;
  95162. /**
  95163. * Serialize all vertices data into a JSON oject
  95164. * @returns a JSON representation of the current geometry data
  95165. */
  95166. serializeVerticeData(): any;
  95167. /**
  95168. * Extracts a clone of a mesh geometry
  95169. * @param mesh defines the source mesh
  95170. * @param id defines the unique ID of the new geometry object
  95171. * @returns the new geometry object
  95172. */
  95173. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95174. /**
  95175. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95176. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95177. * Be aware Math.random() could cause collisions, but:
  95178. * "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"
  95179. * @returns a string containing a new GUID
  95180. */
  95181. static RandomId(): string;
  95182. /** @hidden */
  95183. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95184. private static _CleanMatricesWeights;
  95185. /**
  95186. * Create a new geometry from persisted data (Using .babylon file format)
  95187. * @param parsedVertexData defines the persisted data
  95188. * @param scene defines the hosting scene
  95189. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95190. * @returns the new geometry object
  95191. */
  95192. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95193. }
  95194. }
  95195. declare module BABYLON {
  95196. /**
  95197. * Define an interface for all classes that will get and set the data on vertices
  95198. */
  95199. export interface IGetSetVerticesData {
  95200. /**
  95201. * Gets a boolean indicating if specific vertex data is present
  95202. * @param kind defines the vertex data kind to use
  95203. * @returns true is data kind is present
  95204. */
  95205. isVerticesDataPresent(kind: string): boolean;
  95206. /**
  95207. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95208. * @param kind defines the data kind (Position, normal, etc...)
  95209. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95210. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95211. * @returns a float array containing vertex data
  95212. */
  95213. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95214. /**
  95215. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95216. * @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.
  95217. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95218. * @returns the indices array or an empty array if the mesh has no geometry
  95219. */
  95220. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95221. /**
  95222. * Set specific vertex data
  95223. * @param kind defines the data kind (Position, normal, etc...)
  95224. * @param data defines the vertex data to use
  95225. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95226. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95227. */
  95228. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95229. /**
  95230. * Update a specific associated vertex buffer
  95231. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95232. * - VertexBuffer.PositionKind
  95233. * - VertexBuffer.UVKind
  95234. * - VertexBuffer.UV2Kind
  95235. * - VertexBuffer.UV3Kind
  95236. * - VertexBuffer.UV4Kind
  95237. * - VertexBuffer.UV5Kind
  95238. * - VertexBuffer.UV6Kind
  95239. * - VertexBuffer.ColorKind
  95240. * - VertexBuffer.MatricesIndicesKind
  95241. * - VertexBuffer.MatricesIndicesExtraKind
  95242. * - VertexBuffer.MatricesWeightsKind
  95243. * - VertexBuffer.MatricesWeightsExtraKind
  95244. * @param data defines the data source
  95245. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95246. * @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)
  95247. */
  95248. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95249. /**
  95250. * Creates a new index buffer
  95251. * @param indices defines the indices to store in the index buffer
  95252. * @param totalVertices defines the total number of vertices (could be null)
  95253. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95254. */
  95255. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95256. }
  95257. /**
  95258. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95259. */
  95260. export class VertexData {
  95261. /**
  95262. * Mesh side orientation : usually the external or front surface
  95263. */
  95264. static readonly FRONTSIDE: number;
  95265. /**
  95266. * Mesh side orientation : usually the internal or back surface
  95267. */
  95268. static readonly BACKSIDE: number;
  95269. /**
  95270. * Mesh side orientation : both internal and external or front and back surfaces
  95271. */
  95272. static readonly DOUBLESIDE: number;
  95273. /**
  95274. * Mesh side orientation : by default, `FRONTSIDE`
  95275. */
  95276. static readonly DEFAULTSIDE: number;
  95277. /**
  95278. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95279. */
  95280. positions: Nullable<FloatArray>;
  95281. /**
  95282. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95283. */
  95284. normals: Nullable<FloatArray>;
  95285. /**
  95286. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95287. */
  95288. tangents: Nullable<FloatArray>;
  95289. /**
  95290. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95291. */
  95292. uvs: Nullable<FloatArray>;
  95293. /**
  95294. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95295. */
  95296. uvs2: Nullable<FloatArray>;
  95297. /**
  95298. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95299. */
  95300. uvs3: Nullable<FloatArray>;
  95301. /**
  95302. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95303. */
  95304. uvs4: Nullable<FloatArray>;
  95305. /**
  95306. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95307. */
  95308. uvs5: Nullable<FloatArray>;
  95309. /**
  95310. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95311. */
  95312. uvs6: Nullable<FloatArray>;
  95313. /**
  95314. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95315. */
  95316. colors: Nullable<FloatArray>;
  95317. /**
  95318. * 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).
  95319. */
  95320. matricesIndices: Nullable<FloatArray>;
  95321. /**
  95322. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95323. */
  95324. matricesWeights: Nullable<FloatArray>;
  95325. /**
  95326. * An array extending the number of possible indices
  95327. */
  95328. matricesIndicesExtra: Nullable<FloatArray>;
  95329. /**
  95330. * An array extending the number of possible weights when the number of indices is extended
  95331. */
  95332. matricesWeightsExtra: Nullable<FloatArray>;
  95333. /**
  95334. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95335. */
  95336. indices: Nullable<IndicesArray>;
  95337. /**
  95338. * Uses the passed data array to set the set the values for the specified kind of data
  95339. * @param data a linear array of floating numbers
  95340. * @param kind the type of data that is being set, eg positions, colors etc
  95341. */
  95342. set(data: FloatArray, kind: string): void;
  95343. /**
  95344. * Associates the vertexData to the passed Mesh.
  95345. * Sets it as updatable or not (default `false`)
  95346. * @param mesh the mesh the vertexData is applied to
  95347. * @param updatable when used and having the value true allows new data to update the vertexData
  95348. * @returns the VertexData
  95349. */
  95350. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95351. /**
  95352. * Associates the vertexData to the passed Geometry.
  95353. * Sets it as updatable or not (default `false`)
  95354. * @param geometry the geometry the vertexData is applied to
  95355. * @param updatable when used and having the value true allows new data to update the vertexData
  95356. * @returns VertexData
  95357. */
  95358. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95359. /**
  95360. * Updates the associated mesh
  95361. * @param mesh the mesh to be updated
  95362. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95363. * @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
  95364. * @returns VertexData
  95365. */
  95366. updateMesh(mesh: Mesh): VertexData;
  95367. /**
  95368. * Updates the associated geometry
  95369. * @param geometry the geometry to be updated
  95370. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95371. * @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
  95372. * @returns VertexData.
  95373. */
  95374. updateGeometry(geometry: Geometry): VertexData;
  95375. private _applyTo;
  95376. private _update;
  95377. /**
  95378. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95379. * @param matrix the transforming matrix
  95380. * @returns the VertexData
  95381. */
  95382. transform(matrix: Matrix): VertexData;
  95383. /**
  95384. * Merges the passed VertexData into the current one
  95385. * @param other the VertexData to be merged into the current one
  95386. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95387. * @returns the modified VertexData
  95388. */
  95389. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95390. private _mergeElement;
  95391. private _validate;
  95392. /**
  95393. * Serializes the VertexData
  95394. * @returns a serialized object
  95395. */
  95396. serialize(): any;
  95397. /**
  95398. * Extracts the vertexData from a mesh
  95399. * @param mesh the mesh from which to extract the VertexData
  95400. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95401. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95402. * @returns the object VertexData associated to the passed mesh
  95403. */
  95404. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95405. /**
  95406. * Extracts the vertexData from the geometry
  95407. * @param geometry the geometry from which to extract the VertexData
  95408. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95409. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95410. * @returns the object VertexData associated to the passed mesh
  95411. */
  95412. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95413. private static _ExtractFrom;
  95414. /**
  95415. * Creates the VertexData for a Ribbon
  95416. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95417. * * pathArray array of paths, each of which an array of successive Vector3
  95418. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95419. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95420. * * 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
  95421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95422. * * 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)
  95423. * * 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)
  95424. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95425. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95426. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95427. * @returns the VertexData of the ribbon
  95428. */
  95429. static CreateRibbon(options: {
  95430. pathArray: Vector3[][];
  95431. closeArray?: boolean;
  95432. closePath?: boolean;
  95433. offset?: number;
  95434. sideOrientation?: number;
  95435. frontUVs?: Vector4;
  95436. backUVs?: Vector4;
  95437. invertUV?: boolean;
  95438. uvs?: Vector2[];
  95439. colors?: Color4[];
  95440. }): VertexData;
  95441. /**
  95442. * Creates the VertexData for a box
  95443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95444. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95445. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95446. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95447. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95448. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95449. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95451. * * 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)
  95452. * * 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)
  95453. * @returns the VertexData of the box
  95454. */
  95455. static CreateBox(options: {
  95456. size?: number;
  95457. width?: number;
  95458. height?: number;
  95459. depth?: number;
  95460. faceUV?: Vector4[];
  95461. faceColors?: Color4[];
  95462. sideOrientation?: number;
  95463. frontUVs?: Vector4;
  95464. backUVs?: Vector4;
  95465. }): VertexData;
  95466. /**
  95467. * Creates the VertexData for a tiled box
  95468. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95469. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95470. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95471. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95473. * @returns the VertexData of the box
  95474. */
  95475. static CreateTiledBox(options: {
  95476. pattern?: number;
  95477. width?: number;
  95478. height?: number;
  95479. depth?: number;
  95480. tileSize?: number;
  95481. tileWidth?: number;
  95482. tileHeight?: number;
  95483. alignHorizontal?: number;
  95484. alignVertical?: number;
  95485. faceUV?: Vector4[];
  95486. faceColors?: Color4[];
  95487. sideOrientation?: number;
  95488. }): VertexData;
  95489. /**
  95490. * Creates the VertexData for a tiled plane
  95491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95492. * * pattern a limited pattern arrangement depending on the number
  95493. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95494. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95495. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95497. * * 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)
  95498. * * 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)
  95499. * @returns the VertexData of the tiled plane
  95500. */
  95501. static CreateTiledPlane(options: {
  95502. pattern?: number;
  95503. tileSize?: number;
  95504. tileWidth?: number;
  95505. tileHeight?: number;
  95506. size?: number;
  95507. width?: number;
  95508. height?: number;
  95509. alignHorizontal?: number;
  95510. alignVertical?: number;
  95511. sideOrientation?: number;
  95512. frontUVs?: Vector4;
  95513. backUVs?: Vector4;
  95514. }): VertexData;
  95515. /**
  95516. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95517. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95518. * * segments sets the number of horizontal strips optional, default 32
  95519. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95520. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95521. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95522. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95523. * * 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
  95524. * * 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
  95525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95526. * * 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)
  95527. * * 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)
  95528. * @returns the VertexData of the ellipsoid
  95529. */
  95530. static CreateSphere(options: {
  95531. segments?: number;
  95532. diameter?: number;
  95533. diameterX?: number;
  95534. diameterY?: number;
  95535. diameterZ?: number;
  95536. arc?: number;
  95537. slice?: number;
  95538. sideOrientation?: number;
  95539. frontUVs?: Vector4;
  95540. backUVs?: Vector4;
  95541. }): VertexData;
  95542. /**
  95543. * Creates the VertexData for a cylinder, cone or prism
  95544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95545. * * height sets the height (y direction) of the cylinder, optional, default 2
  95546. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95547. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95548. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95549. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95550. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95551. * * 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
  95552. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95553. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95554. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95555. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95557. * * 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)
  95558. * * 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)
  95559. * @returns the VertexData of the cylinder, cone or prism
  95560. */
  95561. static CreateCylinder(options: {
  95562. height?: number;
  95563. diameterTop?: number;
  95564. diameterBottom?: number;
  95565. diameter?: number;
  95566. tessellation?: number;
  95567. subdivisions?: number;
  95568. arc?: number;
  95569. faceColors?: Color4[];
  95570. faceUV?: Vector4[];
  95571. hasRings?: boolean;
  95572. enclose?: boolean;
  95573. sideOrientation?: number;
  95574. frontUVs?: Vector4;
  95575. backUVs?: Vector4;
  95576. }): VertexData;
  95577. /**
  95578. * Creates the VertexData for a torus
  95579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95580. * * diameter the diameter of the torus, optional default 1
  95581. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95584. * * 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)
  95585. * * 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)
  95586. * @returns the VertexData of the torus
  95587. */
  95588. static CreateTorus(options: {
  95589. diameter?: number;
  95590. thickness?: number;
  95591. tessellation?: number;
  95592. sideOrientation?: number;
  95593. frontUVs?: Vector4;
  95594. backUVs?: Vector4;
  95595. }): VertexData;
  95596. /**
  95597. * Creates the VertexData of the LineSystem
  95598. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95599. * - lines an array of lines, each line being an array of successive Vector3
  95600. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95601. * @returns the VertexData of the LineSystem
  95602. */
  95603. static CreateLineSystem(options: {
  95604. lines: Vector3[][];
  95605. colors?: Nullable<Color4[][]>;
  95606. }): VertexData;
  95607. /**
  95608. * Create the VertexData for a DashedLines
  95609. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95610. * - points an array successive Vector3
  95611. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95612. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95613. * - dashNb the intended total number of dashes, optional, default 200
  95614. * @returns the VertexData for the DashedLines
  95615. */
  95616. static CreateDashedLines(options: {
  95617. points: Vector3[];
  95618. dashSize?: number;
  95619. gapSize?: number;
  95620. dashNb?: number;
  95621. }): VertexData;
  95622. /**
  95623. * Creates the VertexData for a Ground
  95624. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95625. * - width the width (x direction) of the ground, optional, default 1
  95626. * - height the height (z direction) of the ground, optional, default 1
  95627. * - subdivisions the number of subdivisions per side, optional, default 1
  95628. * @returns the VertexData of the Ground
  95629. */
  95630. static CreateGround(options: {
  95631. width?: number;
  95632. height?: number;
  95633. subdivisions?: number;
  95634. subdivisionsX?: number;
  95635. subdivisionsY?: number;
  95636. }): VertexData;
  95637. /**
  95638. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95639. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95640. * * xmin the ground minimum X coordinate, optional, default -1
  95641. * * zmin the ground minimum Z coordinate, optional, default -1
  95642. * * xmax the ground maximum X coordinate, optional, default 1
  95643. * * zmax the ground maximum Z coordinate, optional, default 1
  95644. * * 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}
  95645. * * 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}
  95646. * @returns the VertexData of the TiledGround
  95647. */
  95648. static CreateTiledGround(options: {
  95649. xmin: number;
  95650. zmin: number;
  95651. xmax: number;
  95652. zmax: number;
  95653. subdivisions?: {
  95654. w: number;
  95655. h: number;
  95656. };
  95657. precision?: {
  95658. w: number;
  95659. h: number;
  95660. };
  95661. }): VertexData;
  95662. /**
  95663. * Creates the VertexData of the Ground designed from a heightmap
  95664. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95665. * * width the width (x direction) of the ground
  95666. * * height the height (z direction) of the ground
  95667. * * subdivisions the number of subdivisions per side
  95668. * * minHeight the minimum altitude on the ground, optional, default 0
  95669. * * maxHeight the maximum altitude on the ground, optional default 1
  95670. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95671. * * buffer the array holding the image color data
  95672. * * bufferWidth the width of image
  95673. * * bufferHeight the height of image
  95674. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95675. * @returns the VertexData of the Ground designed from a heightmap
  95676. */
  95677. static CreateGroundFromHeightMap(options: {
  95678. width: number;
  95679. height: number;
  95680. subdivisions: number;
  95681. minHeight: number;
  95682. maxHeight: number;
  95683. colorFilter: Color3;
  95684. buffer: Uint8Array;
  95685. bufferWidth: number;
  95686. bufferHeight: number;
  95687. alphaFilter: number;
  95688. }): VertexData;
  95689. /**
  95690. * Creates the VertexData for a Plane
  95691. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95692. * * size sets the width and height of the plane to the value of size, optional default 1
  95693. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95694. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95696. * * 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)
  95697. * * 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)
  95698. * @returns the VertexData of the box
  95699. */
  95700. static CreatePlane(options: {
  95701. size?: number;
  95702. width?: number;
  95703. height?: number;
  95704. sideOrientation?: number;
  95705. frontUVs?: Vector4;
  95706. backUVs?: Vector4;
  95707. }): VertexData;
  95708. /**
  95709. * Creates the VertexData of the Disc or regular Polygon
  95710. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95711. * * radius the radius of the disc, optional default 0.5
  95712. * * tessellation the number of polygon sides, optional, default 64
  95713. * * 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
  95714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95715. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  95716. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  95717. * @returns the VertexData of the box
  95718. */
  95719. static CreateDisc(options: {
  95720. radius?: number;
  95721. tessellation?: number;
  95722. arc?: number;
  95723. sideOrientation?: number;
  95724. frontUVs?: Vector4;
  95725. backUVs?: Vector4;
  95726. }): VertexData;
  95727. /**
  95728. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95729. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95730. * @param polygon a mesh built from polygonTriangulation.build()
  95731. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95732. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95733. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95734. * @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)
  95735. * @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)
  95736. * @returns the VertexData of the Polygon
  95737. */
  95738. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95739. /**
  95740. * Creates the VertexData of the IcoSphere
  95741. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95742. * * radius the radius of the IcoSphere, optional default 1
  95743. * * radiusX allows stretching in the x direction, optional, default radius
  95744. * * radiusY allows stretching in the y direction, optional, default radius
  95745. * * radiusZ allows stretching in the z direction, optional, default radius
  95746. * * flat when true creates a flat shaded mesh, optional, default true
  95747. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95749. * * 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)
  95750. * * 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)
  95751. * @returns the VertexData of the IcoSphere
  95752. */
  95753. static CreateIcoSphere(options: {
  95754. radius?: number;
  95755. radiusX?: number;
  95756. radiusY?: number;
  95757. radiusZ?: number;
  95758. flat?: boolean;
  95759. subdivisions?: number;
  95760. sideOrientation?: number;
  95761. frontUVs?: Vector4;
  95762. backUVs?: Vector4;
  95763. }): VertexData;
  95764. /**
  95765. * Creates the VertexData for a Polyhedron
  95766. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95767. * * type provided types are:
  95768. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95769. * * 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)
  95770. * * size the size of the IcoSphere, optional default 1
  95771. * * sizeX allows stretching in the x direction, optional, default size
  95772. * * sizeY allows stretching in the y direction, optional, default size
  95773. * * sizeZ allows stretching in the z direction, optional, default size
  95774. * * 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
  95775. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95776. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95777. * * flat when true creates a flat shaded mesh, optional, default true
  95778. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95780. * * 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)
  95781. * * 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)
  95782. * @returns the VertexData of the Polyhedron
  95783. */
  95784. static CreatePolyhedron(options: {
  95785. type?: number;
  95786. size?: number;
  95787. sizeX?: number;
  95788. sizeY?: number;
  95789. sizeZ?: number;
  95790. custom?: any;
  95791. faceUV?: Vector4[];
  95792. faceColors?: Color4[];
  95793. flat?: boolean;
  95794. sideOrientation?: number;
  95795. frontUVs?: Vector4;
  95796. backUVs?: Vector4;
  95797. }): VertexData;
  95798. /**
  95799. * Creates the VertexData for a TorusKnot
  95800. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95801. * * radius the radius of the torus knot, optional, default 2
  95802. * * tube the thickness of the tube, optional, default 0.5
  95803. * * radialSegments the number of sides on each tube segments, optional, default 32
  95804. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95805. * * p the number of windings around the z axis, optional, default 2
  95806. * * q the number of windings around the x axis, optional, default 3
  95807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95808. * * 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)
  95809. * * 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)
  95810. * @returns the VertexData of the Torus Knot
  95811. */
  95812. static CreateTorusKnot(options: {
  95813. radius?: number;
  95814. tube?: number;
  95815. radialSegments?: number;
  95816. tubularSegments?: number;
  95817. p?: number;
  95818. q?: number;
  95819. sideOrientation?: number;
  95820. frontUVs?: Vector4;
  95821. backUVs?: Vector4;
  95822. }): VertexData;
  95823. /**
  95824. * Compute normals for given positions and indices
  95825. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95826. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95827. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95828. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95829. * * facetNormals : optional array of facet normals (vector3)
  95830. * * facetPositions : optional array of facet positions (vector3)
  95831. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95832. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95833. * * bInfo : optional bounding info, required for facetPartitioning computation
  95834. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95835. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95836. * * useRightHandedSystem: optional boolean to for right handed system computation
  95837. * * depthSort : optional boolean to enable the facet depth sort computation
  95838. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95839. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95840. */
  95841. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95842. facetNormals?: any;
  95843. facetPositions?: any;
  95844. facetPartitioning?: any;
  95845. ratio?: number;
  95846. bInfo?: any;
  95847. bbSize?: Vector3;
  95848. subDiv?: any;
  95849. useRightHandedSystem?: boolean;
  95850. depthSort?: boolean;
  95851. distanceTo?: Vector3;
  95852. depthSortedFacets?: any;
  95853. }): void;
  95854. /** @hidden */
  95855. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95856. /**
  95857. * Applies VertexData created from the imported parameters to the geometry
  95858. * @param parsedVertexData the parsed data from an imported file
  95859. * @param geometry the geometry to apply the VertexData to
  95860. */
  95861. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95862. }
  95863. }
  95864. declare module BABYLON {
  95865. /**
  95866. * Defines a target to use with MorphTargetManager
  95867. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95868. */
  95869. export class MorphTarget implements IAnimatable {
  95870. /** defines the name of the target */
  95871. name: string;
  95872. /**
  95873. * Gets or sets the list of animations
  95874. */
  95875. animations: Animation[];
  95876. private _scene;
  95877. private _positions;
  95878. private _normals;
  95879. private _tangents;
  95880. private _uvs;
  95881. private _influence;
  95882. private _uniqueId;
  95883. /**
  95884. * Observable raised when the influence changes
  95885. */
  95886. onInfluenceChanged: Observable<boolean>;
  95887. /** @hidden */
  95888. _onDataLayoutChanged: Observable<void>;
  95889. /**
  95890. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95891. */
  95892. get influence(): number;
  95893. set influence(influence: number);
  95894. /**
  95895. * Gets or sets the id of the morph Target
  95896. */
  95897. id: string;
  95898. private _animationPropertiesOverride;
  95899. /**
  95900. * Gets or sets the animation properties override
  95901. */
  95902. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95903. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95904. /**
  95905. * Creates a new MorphTarget
  95906. * @param name defines the name of the target
  95907. * @param influence defines the influence to use
  95908. * @param scene defines the scene the morphtarget belongs to
  95909. */
  95910. constructor(
  95911. /** defines the name of the target */
  95912. name: string, influence?: number, scene?: Nullable<Scene>);
  95913. /**
  95914. * Gets the unique ID of this manager
  95915. */
  95916. get uniqueId(): number;
  95917. /**
  95918. * Gets a boolean defining if the target contains position data
  95919. */
  95920. get hasPositions(): boolean;
  95921. /**
  95922. * Gets a boolean defining if the target contains normal data
  95923. */
  95924. get hasNormals(): boolean;
  95925. /**
  95926. * Gets a boolean defining if the target contains tangent data
  95927. */
  95928. get hasTangents(): boolean;
  95929. /**
  95930. * Gets a boolean defining if the target contains texture coordinates data
  95931. */
  95932. get hasUVs(): boolean;
  95933. /**
  95934. * Affects position data to this target
  95935. * @param data defines the position data to use
  95936. */
  95937. setPositions(data: Nullable<FloatArray>): void;
  95938. /**
  95939. * Gets the position data stored in this target
  95940. * @returns a FloatArray containing the position data (or null if not present)
  95941. */
  95942. getPositions(): Nullable<FloatArray>;
  95943. /**
  95944. * Affects normal data to this target
  95945. * @param data defines the normal data to use
  95946. */
  95947. setNormals(data: Nullable<FloatArray>): void;
  95948. /**
  95949. * Gets the normal data stored in this target
  95950. * @returns a FloatArray containing the normal data (or null if not present)
  95951. */
  95952. getNormals(): Nullable<FloatArray>;
  95953. /**
  95954. * Affects tangent data to this target
  95955. * @param data defines the tangent data to use
  95956. */
  95957. setTangents(data: Nullable<FloatArray>): void;
  95958. /**
  95959. * Gets the tangent data stored in this target
  95960. * @returns a FloatArray containing the tangent data (or null if not present)
  95961. */
  95962. getTangents(): Nullable<FloatArray>;
  95963. /**
  95964. * Affects texture coordinates data to this target
  95965. * @param data defines the texture coordinates data to use
  95966. */
  95967. setUVs(data: Nullable<FloatArray>): void;
  95968. /**
  95969. * Gets the texture coordinates data stored in this target
  95970. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95971. */
  95972. getUVs(): Nullable<FloatArray>;
  95973. /**
  95974. * Clone the current target
  95975. * @returns a new MorphTarget
  95976. */
  95977. clone(): MorphTarget;
  95978. /**
  95979. * Serializes the current target into a Serialization object
  95980. * @returns the serialized object
  95981. */
  95982. serialize(): any;
  95983. /**
  95984. * Returns the string "MorphTarget"
  95985. * @returns "MorphTarget"
  95986. */
  95987. getClassName(): string;
  95988. /**
  95989. * Creates a new target from serialized data
  95990. * @param serializationObject defines the serialized data to use
  95991. * @returns a new MorphTarget
  95992. */
  95993. static Parse(serializationObject: any): MorphTarget;
  95994. /**
  95995. * Creates a MorphTarget from mesh data
  95996. * @param mesh defines the source mesh
  95997. * @param name defines the name to use for the new target
  95998. * @param influence defines the influence to attach to the target
  95999. * @returns a new MorphTarget
  96000. */
  96001. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96002. }
  96003. }
  96004. declare module BABYLON {
  96005. /**
  96006. * This class is used to deform meshes using morphing between different targets
  96007. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96008. */
  96009. export class MorphTargetManager {
  96010. private _targets;
  96011. private _targetInfluenceChangedObservers;
  96012. private _targetDataLayoutChangedObservers;
  96013. private _activeTargets;
  96014. private _scene;
  96015. private _influences;
  96016. private _supportsNormals;
  96017. private _supportsTangents;
  96018. private _supportsUVs;
  96019. private _vertexCount;
  96020. private _uniqueId;
  96021. private _tempInfluences;
  96022. /**
  96023. * Gets or sets a boolean indicating if normals must be morphed
  96024. */
  96025. enableNormalMorphing: boolean;
  96026. /**
  96027. * Gets or sets a boolean indicating if tangents must be morphed
  96028. */
  96029. enableTangentMorphing: boolean;
  96030. /**
  96031. * Gets or sets a boolean indicating if UV must be morphed
  96032. */
  96033. enableUVMorphing: boolean;
  96034. /**
  96035. * Creates a new MorphTargetManager
  96036. * @param scene defines the current scene
  96037. */
  96038. constructor(scene?: Nullable<Scene>);
  96039. /**
  96040. * Gets the unique ID of this manager
  96041. */
  96042. get uniqueId(): number;
  96043. /**
  96044. * Gets the number of vertices handled by this manager
  96045. */
  96046. get vertexCount(): number;
  96047. /**
  96048. * Gets a boolean indicating if this manager supports morphing of normals
  96049. */
  96050. get supportsNormals(): boolean;
  96051. /**
  96052. * Gets a boolean indicating if this manager supports morphing of tangents
  96053. */
  96054. get supportsTangents(): boolean;
  96055. /**
  96056. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96057. */
  96058. get supportsUVs(): boolean;
  96059. /**
  96060. * Gets the number of targets stored in this manager
  96061. */
  96062. get numTargets(): number;
  96063. /**
  96064. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96065. */
  96066. get numInfluencers(): number;
  96067. /**
  96068. * Gets the list of influences (one per target)
  96069. */
  96070. get influences(): Float32Array;
  96071. /**
  96072. * Gets the active target at specified index. An active target is a target with an influence > 0
  96073. * @param index defines the index to check
  96074. * @returns the requested target
  96075. */
  96076. getActiveTarget(index: number): MorphTarget;
  96077. /**
  96078. * Gets the target at specified index
  96079. * @param index defines the index to check
  96080. * @returns the requested target
  96081. */
  96082. getTarget(index: number): MorphTarget;
  96083. /**
  96084. * Add a new target to this manager
  96085. * @param target defines the target to add
  96086. */
  96087. addTarget(target: MorphTarget): void;
  96088. /**
  96089. * Removes a target from the manager
  96090. * @param target defines the target to remove
  96091. */
  96092. removeTarget(target: MorphTarget): void;
  96093. /**
  96094. * Clone the current manager
  96095. * @returns a new MorphTargetManager
  96096. */
  96097. clone(): MorphTargetManager;
  96098. /**
  96099. * Serializes the current manager into a Serialization object
  96100. * @returns the serialized object
  96101. */
  96102. serialize(): any;
  96103. private _syncActiveTargets;
  96104. /**
  96105. * Syncrhonize the targets with all the meshes using this morph target manager
  96106. */
  96107. synchronize(): void;
  96108. /**
  96109. * Creates a new MorphTargetManager from serialized data
  96110. * @param serializationObject defines the serialized data
  96111. * @param scene defines the hosting scene
  96112. * @returns the new MorphTargetManager
  96113. */
  96114. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96115. }
  96116. }
  96117. declare module BABYLON {
  96118. /**
  96119. * Class used to represent a specific level of detail of a mesh
  96120. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96121. */
  96122. export class MeshLODLevel {
  96123. /** Defines the distance where this level should start being displayed */
  96124. distance: number;
  96125. /** Defines the mesh to use to render this level */
  96126. mesh: Nullable<Mesh>;
  96127. /**
  96128. * Creates a new LOD level
  96129. * @param distance defines the distance where this level should star being displayed
  96130. * @param mesh defines the mesh to use to render this level
  96131. */
  96132. constructor(
  96133. /** Defines the distance where this level should start being displayed */
  96134. distance: number,
  96135. /** Defines the mesh to use to render this level */
  96136. mesh: Nullable<Mesh>);
  96137. }
  96138. }
  96139. declare module BABYLON {
  96140. /**
  96141. * Mesh representing the gorund
  96142. */
  96143. export class GroundMesh extends Mesh {
  96144. /** If octree should be generated */
  96145. generateOctree: boolean;
  96146. private _heightQuads;
  96147. /** @hidden */
  96148. _subdivisionsX: number;
  96149. /** @hidden */
  96150. _subdivisionsY: number;
  96151. /** @hidden */
  96152. _width: number;
  96153. /** @hidden */
  96154. _height: number;
  96155. /** @hidden */
  96156. _minX: number;
  96157. /** @hidden */
  96158. _maxX: number;
  96159. /** @hidden */
  96160. _minZ: number;
  96161. /** @hidden */
  96162. _maxZ: number;
  96163. constructor(name: string, scene: Scene);
  96164. /**
  96165. * "GroundMesh"
  96166. * @returns "GroundMesh"
  96167. */
  96168. getClassName(): string;
  96169. /**
  96170. * The minimum of x and y subdivisions
  96171. */
  96172. get subdivisions(): number;
  96173. /**
  96174. * X subdivisions
  96175. */
  96176. get subdivisionsX(): number;
  96177. /**
  96178. * Y subdivisions
  96179. */
  96180. get subdivisionsY(): number;
  96181. /**
  96182. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96183. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96184. * @param chunksCount the number of subdivisions for x and y
  96185. * @param octreeBlocksSize (Default: 32)
  96186. */
  96187. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96188. /**
  96189. * Returns a height (y) value in the Worl system :
  96190. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96191. * @param x x coordinate
  96192. * @param z z coordinate
  96193. * @returns the ground y position if (x, z) are outside the ground surface.
  96194. */
  96195. getHeightAtCoordinates(x: number, z: number): number;
  96196. /**
  96197. * Returns a normalized vector (Vector3) orthogonal to the ground
  96198. * at the ground coordinates (x, z) expressed in the World system.
  96199. * @param x x coordinate
  96200. * @param z z coordinate
  96201. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96202. */
  96203. getNormalAtCoordinates(x: number, z: number): Vector3;
  96204. /**
  96205. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96206. * at the ground coordinates (x, z) expressed in the World system.
  96207. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96208. * @param x x coordinate
  96209. * @param z z coordinate
  96210. * @param ref vector to store the result
  96211. * @returns the GroundMesh.
  96212. */
  96213. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96214. /**
  96215. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96216. * if the ground has been updated.
  96217. * This can be used in the render loop.
  96218. * @returns the GroundMesh.
  96219. */
  96220. updateCoordinateHeights(): GroundMesh;
  96221. private _getFacetAt;
  96222. private _initHeightQuads;
  96223. private _computeHeightQuads;
  96224. /**
  96225. * Serializes this ground mesh
  96226. * @param serializationObject object to write serialization to
  96227. */
  96228. serialize(serializationObject: any): void;
  96229. /**
  96230. * Parses a serialized ground mesh
  96231. * @param parsedMesh the serialized mesh
  96232. * @param scene the scene to create the ground mesh in
  96233. * @returns the created ground mesh
  96234. */
  96235. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96236. }
  96237. }
  96238. declare module BABYLON {
  96239. /**
  96240. * Interface for Physics-Joint data
  96241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96242. */
  96243. export interface PhysicsJointData {
  96244. /**
  96245. * The main pivot of the joint
  96246. */
  96247. mainPivot?: Vector3;
  96248. /**
  96249. * The connected pivot of the joint
  96250. */
  96251. connectedPivot?: Vector3;
  96252. /**
  96253. * The main axis of the joint
  96254. */
  96255. mainAxis?: Vector3;
  96256. /**
  96257. * The connected axis of the joint
  96258. */
  96259. connectedAxis?: Vector3;
  96260. /**
  96261. * The collision of the joint
  96262. */
  96263. collision?: boolean;
  96264. /**
  96265. * Native Oimo/Cannon/Energy data
  96266. */
  96267. nativeParams?: any;
  96268. }
  96269. /**
  96270. * This is a holder class for the physics joint created by the physics plugin
  96271. * It holds a set of functions to control the underlying joint
  96272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96273. */
  96274. export class PhysicsJoint {
  96275. /**
  96276. * The type of the physics joint
  96277. */
  96278. type: number;
  96279. /**
  96280. * The data for the physics joint
  96281. */
  96282. jointData: PhysicsJointData;
  96283. private _physicsJoint;
  96284. protected _physicsPlugin: IPhysicsEnginePlugin;
  96285. /**
  96286. * Initializes the physics joint
  96287. * @param type The type of the physics joint
  96288. * @param jointData The data for the physics joint
  96289. */
  96290. constructor(
  96291. /**
  96292. * The type of the physics joint
  96293. */
  96294. type: number,
  96295. /**
  96296. * The data for the physics joint
  96297. */
  96298. jointData: PhysicsJointData);
  96299. /**
  96300. * Gets the physics joint
  96301. */
  96302. get physicsJoint(): any;
  96303. /**
  96304. * Sets the physics joint
  96305. */
  96306. set physicsJoint(newJoint: any);
  96307. /**
  96308. * Sets the physics plugin
  96309. */
  96310. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96311. /**
  96312. * Execute a function that is physics-plugin specific.
  96313. * @param {Function} func the function that will be executed.
  96314. * It accepts two parameters: the physics world and the physics joint
  96315. */
  96316. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96317. /**
  96318. * Distance-Joint type
  96319. */
  96320. static DistanceJoint: number;
  96321. /**
  96322. * Hinge-Joint type
  96323. */
  96324. static HingeJoint: number;
  96325. /**
  96326. * Ball-and-Socket joint type
  96327. */
  96328. static BallAndSocketJoint: number;
  96329. /**
  96330. * Wheel-Joint type
  96331. */
  96332. static WheelJoint: number;
  96333. /**
  96334. * Slider-Joint type
  96335. */
  96336. static SliderJoint: number;
  96337. /**
  96338. * Prismatic-Joint type
  96339. */
  96340. static PrismaticJoint: number;
  96341. /**
  96342. * Universal-Joint type
  96343. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96344. */
  96345. static UniversalJoint: number;
  96346. /**
  96347. * Hinge-Joint 2 type
  96348. */
  96349. static Hinge2Joint: number;
  96350. /**
  96351. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96352. */
  96353. static PointToPointJoint: number;
  96354. /**
  96355. * Spring-Joint type
  96356. */
  96357. static SpringJoint: number;
  96358. /**
  96359. * Lock-Joint type
  96360. */
  96361. static LockJoint: number;
  96362. }
  96363. /**
  96364. * A class representing a physics distance joint
  96365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96366. */
  96367. export class DistanceJoint extends PhysicsJoint {
  96368. /**
  96369. *
  96370. * @param jointData The data for the Distance-Joint
  96371. */
  96372. constructor(jointData: DistanceJointData);
  96373. /**
  96374. * Update the predefined distance.
  96375. * @param maxDistance The maximum preferred distance
  96376. * @param minDistance The minimum preferred distance
  96377. */
  96378. updateDistance(maxDistance: number, minDistance?: number): void;
  96379. }
  96380. /**
  96381. * Represents a Motor-Enabled Joint
  96382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96383. */
  96384. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96385. /**
  96386. * Initializes the Motor-Enabled Joint
  96387. * @param type The type of the joint
  96388. * @param jointData The physica joint data for the joint
  96389. */
  96390. constructor(type: number, jointData: PhysicsJointData);
  96391. /**
  96392. * Set the motor values.
  96393. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96394. * @param force the force to apply
  96395. * @param maxForce max force for this motor.
  96396. */
  96397. setMotor(force?: number, maxForce?: number): void;
  96398. /**
  96399. * Set the motor's limits.
  96400. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96401. * @param upperLimit The upper limit of the motor
  96402. * @param lowerLimit The lower limit of the motor
  96403. */
  96404. setLimit(upperLimit: number, lowerLimit?: number): void;
  96405. }
  96406. /**
  96407. * This class represents a single physics Hinge-Joint
  96408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96409. */
  96410. export class HingeJoint extends MotorEnabledJoint {
  96411. /**
  96412. * Initializes the Hinge-Joint
  96413. * @param jointData The joint data for the Hinge-Joint
  96414. */
  96415. constructor(jointData: PhysicsJointData);
  96416. /**
  96417. * Set the motor values.
  96418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96419. * @param {number} force the force to apply
  96420. * @param {number} maxForce max force for this motor.
  96421. */
  96422. setMotor(force?: number, maxForce?: number): void;
  96423. /**
  96424. * Set the motor's limits.
  96425. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96426. * @param upperLimit The upper limit of the motor
  96427. * @param lowerLimit The lower limit of the motor
  96428. */
  96429. setLimit(upperLimit: number, lowerLimit?: number): void;
  96430. }
  96431. /**
  96432. * This class represents a dual hinge physics joint (same as wheel joint)
  96433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96434. */
  96435. export class Hinge2Joint extends MotorEnabledJoint {
  96436. /**
  96437. * Initializes the Hinge2-Joint
  96438. * @param jointData The joint data for the Hinge2-Joint
  96439. */
  96440. constructor(jointData: PhysicsJointData);
  96441. /**
  96442. * Set the motor values.
  96443. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96444. * @param {number} targetSpeed the speed the motor is to reach
  96445. * @param {number} maxForce max force for this motor.
  96446. * @param {motorIndex} the motor's index, 0 or 1.
  96447. */
  96448. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96449. /**
  96450. * Set the motor limits.
  96451. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96452. * @param {number} upperLimit the upper limit
  96453. * @param {number} lowerLimit lower limit
  96454. * @param {motorIndex} the motor's index, 0 or 1.
  96455. */
  96456. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96457. }
  96458. /**
  96459. * Interface for a motor enabled joint
  96460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96461. */
  96462. export interface IMotorEnabledJoint {
  96463. /**
  96464. * Physics joint
  96465. */
  96466. physicsJoint: any;
  96467. /**
  96468. * Sets the motor of the motor-enabled joint
  96469. * @param force The force of the motor
  96470. * @param maxForce The maximum force of the motor
  96471. * @param motorIndex The index of the motor
  96472. */
  96473. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96474. /**
  96475. * Sets the limit of the motor
  96476. * @param upperLimit The upper limit of the motor
  96477. * @param lowerLimit The lower limit of the motor
  96478. * @param motorIndex The index of the motor
  96479. */
  96480. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96481. }
  96482. /**
  96483. * Joint data for a Distance-Joint
  96484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96485. */
  96486. export interface DistanceJointData extends PhysicsJointData {
  96487. /**
  96488. * Max distance the 2 joint objects can be apart
  96489. */
  96490. maxDistance: number;
  96491. }
  96492. /**
  96493. * Joint data from a spring joint
  96494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96495. */
  96496. export interface SpringJointData extends PhysicsJointData {
  96497. /**
  96498. * Length of the spring
  96499. */
  96500. length: number;
  96501. /**
  96502. * Stiffness of the spring
  96503. */
  96504. stiffness: number;
  96505. /**
  96506. * Damping of the spring
  96507. */
  96508. damping: number;
  96509. /** this callback will be called when applying the force to the impostors. */
  96510. forceApplicationCallback: () => void;
  96511. }
  96512. }
  96513. declare module BABYLON {
  96514. /**
  96515. * Holds the data for the raycast result
  96516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96517. */
  96518. export class PhysicsRaycastResult {
  96519. private _hasHit;
  96520. private _hitDistance;
  96521. private _hitNormalWorld;
  96522. private _hitPointWorld;
  96523. private _rayFromWorld;
  96524. private _rayToWorld;
  96525. /**
  96526. * Gets if there was a hit
  96527. */
  96528. get hasHit(): boolean;
  96529. /**
  96530. * Gets the distance from the hit
  96531. */
  96532. get hitDistance(): number;
  96533. /**
  96534. * Gets the hit normal/direction in the world
  96535. */
  96536. get hitNormalWorld(): Vector3;
  96537. /**
  96538. * Gets the hit point in the world
  96539. */
  96540. get hitPointWorld(): Vector3;
  96541. /**
  96542. * Gets the ray "start point" of the ray in the world
  96543. */
  96544. get rayFromWorld(): Vector3;
  96545. /**
  96546. * Gets the ray "end point" of the ray in the world
  96547. */
  96548. get rayToWorld(): Vector3;
  96549. /**
  96550. * Sets the hit data (normal & point in world space)
  96551. * @param hitNormalWorld defines the normal in world space
  96552. * @param hitPointWorld defines the point in world space
  96553. */
  96554. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96555. /**
  96556. * Sets the distance from the start point to the hit point
  96557. * @param distance
  96558. */
  96559. setHitDistance(distance: number): void;
  96560. /**
  96561. * Calculates the distance manually
  96562. */
  96563. calculateHitDistance(): void;
  96564. /**
  96565. * Resets all the values to default
  96566. * @param from The from point on world space
  96567. * @param to The to point on world space
  96568. */
  96569. reset(from?: Vector3, to?: Vector3): void;
  96570. }
  96571. /**
  96572. * Interface for the size containing width and height
  96573. */
  96574. interface IXYZ {
  96575. /**
  96576. * X
  96577. */
  96578. x: number;
  96579. /**
  96580. * Y
  96581. */
  96582. y: number;
  96583. /**
  96584. * Z
  96585. */
  96586. z: number;
  96587. }
  96588. }
  96589. declare module BABYLON {
  96590. /**
  96591. * Interface used to describe a physics joint
  96592. */
  96593. export interface PhysicsImpostorJoint {
  96594. /** Defines the main impostor to which the joint is linked */
  96595. mainImpostor: PhysicsImpostor;
  96596. /** Defines the impostor that is connected to the main impostor using this joint */
  96597. connectedImpostor: PhysicsImpostor;
  96598. /** Defines the joint itself */
  96599. joint: PhysicsJoint;
  96600. }
  96601. /** @hidden */
  96602. export interface IPhysicsEnginePlugin {
  96603. world: any;
  96604. name: string;
  96605. setGravity(gravity: Vector3): void;
  96606. setTimeStep(timeStep: number): void;
  96607. getTimeStep(): number;
  96608. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96609. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96610. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96612. removePhysicsBody(impostor: PhysicsImpostor): void;
  96613. generateJoint(joint: PhysicsImpostorJoint): void;
  96614. removeJoint(joint: PhysicsImpostorJoint): void;
  96615. isSupported(): boolean;
  96616. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96617. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96618. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96619. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96620. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96621. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96622. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96623. getBodyMass(impostor: PhysicsImpostor): number;
  96624. getBodyFriction(impostor: PhysicsImpostor): number;
  96625. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96626. getBodyRestitution(impostor: PhysicsImpostor): number;
  96627. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96628. getBodyPressure?(impostor: PhysicsImpostor): number;
  96629. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96630. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96631. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96632. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96633. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96634. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96635. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96636. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96637. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96638. sleepBody(impostor: PhysicsImpostor): void;
  96639. wakeUpBody(impostor: PhysicsImpostor): void;
  96640. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96641. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96642. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96643. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96644. getRadius(impostor: PhysicsImpostor): number;
  96645. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96647. dispose(): void;
  96648. }
  96649. /**
  96650. * Interface used to define a physics engine
  96651. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96652. */
  96653. export interface IPhysicsEngine {
  96654. /**
  96655. * Gets the gravity vector used by the simulation
  96656. */
  96657. gravity: Vector3;
  96658. /**
  96659. * Sets the gravity vector used by the simulation
  96660. * @param gravity defines the gravity vector to use
  96661. */
  96662. setGravity(gravity: Vector3): void;
  96663. /**
  96664. * Set the time step of the physics engine.
  96665. * Default is 1/60.
  96666. * To slow it down, enter 1/600 for example.
  96667. * To speed it up, 1/30
  96668. * @param newTimeStep the new timestep to apply to this world.
  96669. */
  96670. setTimeStep(newTimeStep: number): void;
  96671. /**
  96672. * Get the time step of the physics engine.
  96673. * @returns the current time step
  96674. */
  96675. getTimeStep(): number;
  96676. /**
  96677. * Set the sub time step of the physics engine.
  96678. * Default is 0 meaning there is no sub steps
  96679. * To increase physics resolution precision, set a small value (like 1 ms)
  96680. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96681. */
  96682. setSubTimeStep(subTimeStep: number): void;
  96683. /**
  96684. * Get the sub time step of the physics engine.
  96685. * @returns the current sub time step
  96686. */
  96687. getSubTimeStep(): number;
  96688. /**
  96689. * Release all resources
  96690. */
  96691. dispose(): void;
  96692. /**
  96693. * Gets the name of the current physics plugin
  96694. * @returns the name of the plugin
  96695. */
  96696. getPhysicsPluginName(): string;
  96697. /**
  96698. * Adding a new impostor for the impostor tracking.
  96699. * This will be done by the impostor itself.
  96700. * @param impostor the impostor to add
  96701. */
  96702. addImpostor(impostor: PhysicsImpostor): void;
  96703. /**
  96704. * Remove an impostor from the engine.
  96705. * This impostor and its mesh will not longer be updated by the physics engine.
  96706. * @param impostor the impostor to remove
  96707. */
  96708. removeImpostor(impostor: PhysicsImpostor): void;
  96709. /**
  96710. * Add a joint to the physics engine
  96711. * @param mainImpostor defines the main impostor to which the joint is added.
  96712. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96713. * @param joint defines the joint that will connect both impostors.
  96714. */
  96715. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96716. /**
  96717. * Removes a joint from the simulation
  96718. * @param mainImpostor defines the impostor used with the joint
  96719. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96720. * @param joint defines the joint to remove
  96721. */
  96722. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96723. /**
  96724. * Gets the current plugin used to run the simulation
  96725. * @returns current plugin
  96726. */
  96727. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96728. /**
  96729. * Gets the list of physic impostors
  96730. * @returns an array of PhysicsImpostor
  96731. */
  96732. getImpostors(): Array<PhysicsImpostor>;
  96733. /**
  96734. * Gets the impostor for a physics enabled object
  96735. * @param object defines the object impersonated by the impostor
  96736. * @returns the PhysicsImpostor or null if not found
  96737. */
  96738. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96739. /**
  96740. * Gets the impostor for a physics body object
  96741. * @param body defines physics body used by the impostor
  96742. * @returns the PhysicsImpostor or null if not found
  96743. */
  96744. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96745. /**
  96746. * Does a raycast in the physics world
  96747. * @param from when should the ray start?
  96748. * @param to when should the ray end?
  96749. * @returns PhysicsRaycastResult
  96750. */
  96751. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96752. /**
  96753. * Called by the scene. No need to call it.
  96754. * @param delta defines the timespam between frames
  96755. */
  96756. _step(delta: number): void;
  96757. }
  96758. }
  96759. declare module BABYLON {
  96760. /**
  96761. * The interface for the physics imposter parameters
  96762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96763. */
  96764. export interface PhysicsImpostorParameters {
  96765. /**
  96766. * The mass of the physics imposter
  96767. */
  96768. mass: number;
  96769. /**
  96770. * The friction of the physics imposter
  96771. */
  96772. friction?: number;
  96773. /**
  96774. * The coefficient of restitution of the physics imposter
  96775. */
  96776. restitution?: number;
  96777. /**
  96778. * The native options of the physics imposter
  96779. */
  96780. nativeOptions?: any;
  96781. /**
  96782. * Specifies if the parent should be ignored
  96783. */
  96784. ignoreParent?: boolean;
  96785. /**
  96786. * Specifies if bi-directional transformations should be disabled
  96787. */
  96788. disableBidirectionalTransformation?: boolean;
  96789. /**
  96790. * The pressure inside the physics imposter, soft object only
  96791. */
  96792. pressure?: number;
  96793. /**
  96794. * The stiffness the physics imposter, soft object only
  96795. */
  96796. stiffness?: number;
  96797. /**
  96798. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96799. */
  96800. velocityIterations?: number;
  96801. /**
  96802. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96803. */
  96804. positionIterations?: number;
  96805. /**
  96806. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96807. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96808. * Add to fix multiple points
  96809. */
  96810. fixedPoints?: number;
  96811. /**
  96812. * The collision margin around a soft object
  96813. */
  96814. margin?: number;
  96815. /**
  96816. * The collision margin around a soft object
  96817. */
  96818. damping?: number;
  96819. /**
  96820. * The path for a rope based on an extrusion
  96821. */
  96822. path?: any;
  96823. /**
  96824. * The shape of an extrusion used for a rope based on an extrusion
  96825. */
  96826. shape?: any;
  96827. }
  96828. /**
  96829. * Interface for a physics-enabled object
  96830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96831. */
  96832. export interface IPhysicsEnabledObject {
  96833. /**
  96834. * The position of the physics-enabled object
  96835. */
  96836. position: Vector3;
  96837. /**
  96838. * The rotation of the physics-enabled object
  96839. */
  96840. rotationQuaternion: Nullable<Quaternion>;
  96841. /**
  96842. * The scale of the physics-enabled object
  96843. */
  96844. scaling: Vector3;
  96845. /**
  96846. * The rotation of the physics-enabled object
  96847. */
  96848. rotation?: Vector3;
  96849. /**
  96850. * The parent of the physics-enabled object
  96851. */
  96852. parent?: any;
  96853. /**
  96854. * The bounding info of the physics-enabled object
  96855. * @returns The bounding info of the physics-enabled object
  96856. */
  96857. getBoundingInfo(): BoundingInfo;
  96858. /**
  96859. * Computes the world matrix
  96860. * @param force Specifies if the world matrix should be computed by force
  96861. * @returns A world matrix
  96862. */
  96863. computeWorldMatrix(force: boolean): Matrix;
  96864. /**
  96865. * Gets the world matrix
  96866. * @returns A world matrix
  96867. */
  96868. getWorldMatrix?(): Matrix;
  96869. /**
  96870. * Gets the child meshes
  96871. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96872. * @returns An array of abstract meshes
  96873. */
  96874. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96875. /**
  96876. * Gets the vertex data
  96877. * @param kind The type of vertex data
  96878. * @returns A nullable array of numbers, or a float32 array
  96879. */
  96880. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96881. /**
  96882. * Gets the indices from the mesh
  96883. * @returns A nullable array of index arrays
  96884. */
  96885. getIndices?(): Nullable<IndicesArray>;
  96886. /**
  96887. * Gets the scene from the mesh
  96888. * @returns the indices array or null
  96889. */
  96890. getScene?(): Scene;
  96891. /**
  96892. * Gets the absolute position from the mesh
  96893. * @returns the absolute position
  96894. */
  96895. getAbsolutePosition(): Vector3;
  96896. /**
  96897. * Gets the absolute pivot point from the mesh
  96898. * @returns the absolute pivot point
  96899. */
  96900. getAbsolutePivotPoint(): Vector3;
  96901. /**
  96902. * Rotates the mesh
  96903. * @param axis The axis of rotation
  96904. * @param amount The amount of rotation
  96905. * @param space The space of the rotation
  96906. * @returns The rotation transform node
  96907. */
  96908. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96909. /**
  96910. * Translates the mesh
  96911. * @param axis The axis of translation
  96912. * @param distance The distance of translation
  96913. * @param space The space of the translation
  96914. * @returns The transform node
  96915. */
  96916. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96917. /**
  96918. * Sets the absolute position of the mesh
  96919. * @param absolutePosition The absolute position of the mesh
  96920. * @returns The transform node
  96921. */
  96922. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96923. /**
  96924. * Gets the class name of the mesh
  96925. * @returns The class name
  96926. */
  96927. getClassName(): string;
  96928. }
  96929. /**
  96930. * Represents a physics imposter
  96931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96932. */
  96933. export class PhysicsImpostor {
  96934. /**
  96935. * The physics-enabled object used as the physics imposter
  96936. */
  96937. object: IPhysicsEnabledObject;
  96938. /**
  96939. * The type of the physics imposter
  96940. */
  96941. type: number;
  96942. private _options;
  96943. private _scene?;
  96944. /**
  96945. * The default object size of the imposter
  96946. */
  96947. static DEFAULT_OBJECT_SIZE: Vector3;
  96948. /**
  96949. * The identity quaternion of the imposter
  96950. */
  96951. static IDENTITY_QUATERNION: Quaternion;
  96952. /** @hidden */
  96953. _pluginData: any;
  96954. private _physicsEngine;
  96955. private _physicsBody;
  96956. private _bodyUpdateRequired;
  96957. private _onBeforePhysicsStepCallbacks;
  96958. private _onAfterPhysicsStepCallbacks;
  96959. /** @hidden */
  96960. _onPhysicsCollideCallbacks: Array<{
  96961. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96962. otherImpostors: Array<PhysicsImpostor>;
  96963. }>;
  96964. private _deltaPosition;
  96965. private _deltaRotation;
  96966. private _deltaRotationConjugated;
  96967. /** @hidden */
  96968. _isFromLine: boolean;
  96969. private _parent;
  96970. private _isDisposed;
  96971. private static _tmpVecs;
  96972. private static _tmpQuat;
  96973. /**
  96974. * Specifies if the physics imposter is disposed
  96975. */
  96976. get isDisposed(): boolean;
  96977. /**
  96978. * Gets the mass of the physics imposter
  96979. */
  96980. get mass(): number;
  96981. set mass(value: number);
  96982. /**
  96983. * Gets the coefficient of friction
  96984. */
  96985. get friction(): number;
  96986. /**
  96987. * Sets the coefficient of friction
  96988. */
  96989. set friction(value: number);
  96990. /**
  96991. * Gets the coefficient of restitution
  96992. */
  96993. get restitution(): number;
  96994. /**
  96995. * Sets the coefficient of restitution
  96996. */
  96997. set restitution(value: number);
  96998. /**
  96999. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97000. */
  97001. get pressure(): number;
  97002. /**
  97003. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97004. */
  97005. set pressure(value: number);
  97006. /**
  97007. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97008. */
  97009. get stiffness(): number;
  97010. /**
  97011. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97012. */
  97013. set stiffness(value: number);
  97014. /**
  97015. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97016. */
  97017. get velocityIterations(): number;
  97018. /**
  97019. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97020. */
  97021. set velocityIterations(value: number);
  97022. /**
  97023. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97024. */
  97025. get positionIterations(): number;
  97026. /**
  97027. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97028. */
  97029. set positionIterations(value: number);
  97030. /**
  97031. * The unique id of the physics imposter
  97032. * set by the physics engine when adding this impostor to the array
  97033. */
  97034. uniqueId: number;
  97035. /**
  97036. * @hidden
  97037. */
  97038. soft: boolean;
  97039. /**
  97040. * @hidden
  97041. */
  97042. segments: number;
  97043. private _joints;
  97044. /**
  97045. * Initializes the physics imposter
  97046. * @param object The physics-enabled object used as the physics imposter
  97047. * @param type The type of the physics imposter
  97048. * @param _options The options for the physics imposter
  97049. * @param _scene The Babylon scene
  97050. */
  97051. constructor(
  97052. /**
  97053. * The physics-enabled object used as the physics imposter
  97054. */
  97055. object: IPhysicsEnabledObject,
  97056. /**
  97057. * The type of the physics imposter
  97058. */
  97059. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97060. /**
  97061. * This function will completly initialize this impostor.
  97062. * It will create a new body - but only if this mesh has no parent.
  97063. * If it has, this impostor will not be used other than to define the impostor
  97064. * of the child mesh.
  97065. * @hidden
  97066. */
  97067. _init(): void;
  97068. private _getPhysicsParent;
  97069. /**
  97070. * Should a new body be generated.
  97071. * @returns boolean specifying if body initialization is required
  97072. */
  97073. isBodyInitRequired(): boolean;
  97074. /**
  97075. * Sets the updated scaling
  97076. * @param updated Specifies if the scaling is updated
  97077. */
  97078. setScalingUpdated(): void;
  97079. /**
  97080. * Force a regeneration of this or the parent's impostor's body.
  97081. * Use under cautious - This will remove all joints already implemented.
  97082. */
  97083. forceUpdate(): void;
  97084. /**
  97085. * Gets the body that holds this impostor. Either its own, or its parent.
  97086. */
  97087. get physicsBody(): any;
  97088. /**
  97089. * Get the parent of the physics imposter
  97090. * @returns Physics imposter or null
  97091. */
  97092. get parent(): Nullable<PhysicsImpostor>;
  97093. /**
  97094. * Sets the parent of the physics imposter
  97095. */
  97096. set parent(value: Nullable<PhysicsImpostor>);
  97097. /**
  97098. * Set the physics body. Used mainly by the physics engine/plugin
  97099. */
  97100. set physicsBody(physicsBody: any);
  97101. /**
  97102. * Resets the update flags
  97103. */
  97104. resetUpdateFlags(): void;
  97105. /**
  97106. * Gets the object extend size
  97107. * @returns the object extend size
  97108. */
  97109. getObjectExtendSize(): Vector3;
  97110. /**
  97111. * Gets the object center
  97112. * @returns The object center
  97113. */
  97114. getObjectCenter(): Vector3;
  97115. /**
  97116. * Get a specific parameter from the options parameters
  97117. * @param paramName The object parameter name
  97118. * @returns The object parameter
  97119. */
  97120. getParam(paramName: string): any;
  97121. /**
  97122. * Sets a specific parameter in the options given to the physics plugin
  97123. * @param paramName The parameter name
  97124. * @param value The value of the parameter
  97125. */
  97126. setParam(paramName: string, value: number): void;
  97127. /**
  97128. * Specifically change the body's mass option. Won't recreate the physics body object
  97129. * @param mass The mass of the physics imposter
  97130. */
  97131. setMass(mass: number): void;
  97132. /**
  97133. * Gets the linear velocity
  97134. * @returns linear velocity or null
  97135. */
  97136. getLinearVelocity(): Nullable<Vector3>;
  97137. /**
  97138. * Sets the linear velocity
  97139. * @param velocity linear velocity or null
  97140. */
  97141. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97142. /**
  97143. * Gets the angular velocity
  97144. * @returns angular velocity or null
  97145. */
  97146. getAngularVelocity(): Nullable<Vector3>;
  97147. /**
  97148. * Sets the angular velocity
  97149. * @param velocity The velocity or null
  97150. */
  97151. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97152. /**
  97153. * Execute a function with the physics plugin native code
  97154. * Provide a function the will have two variables - the world object and the physics body object
  97155. * @param func The function to execute with the physics plugin native code
  97156. */
  97157. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97158. /**
  97159. * Register a function that will be executed before the physics world is stepping forward
  97160. * @param func The function to execute before the physics world is stepped forward
  97161. */
  97162. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97163. /**
  97164. * Unregister a function that will be executed before the physics world is stepping forward
  97165. * @param func The function to execute before the physics world is stepped forward
  97166. */
  97167. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97168. /**
  97169. * Register a function that will be executed after the physics step
  97170. * @param func The function to execute after physics step
  97171. */
  97172. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97173. /**
  97174. * Unregisters a function that will be executed after the physics step
  97175. * @param func The function to execute after physics step
  97176. */
  97177. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97178. /**
  97179. * register a function that will be executed when this impostor collides against a different body
  97180. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97181. * @param func Callback that is executed on collision
  97182. */
  97183. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97184. /**
  97185. * Unregisters the physics imposter on contact
  97186. * @param collideAgainst The physics object to collide against
  97187. * @param func Callback to execute on collision
  97188. */
  97189. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97190. private _tmpQuat;
  97191. private _tmpQuat2;
  97192. /**
  97193. * Get the parent rotation
  97194. * @returns The parent rotation
  97195. */
  97196. getParentsRotation(): Quaternion;
  97197. /**
  97198. * this function is executed by the physics engine.
  97199. */
  97200. beforeStep: () => void;
  97201. /**
  97202. * this function is executed by the physics engine
  97203. */
  97204. afterStep: () => void;
  97205. /**
  97206. * Legacy collision detection event support
  97207. */
  97208. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97209. /**
  97210. * event and body object due to cannon's event-based architecture.
  97211. */
  97212. onCollide: (e: {
  97213. body: any;
  97214. }) => void;
  97215. /**
  97216. * Apply a force
  97217. * @param force The force to apply
  97218. * @param contactPoint The contact point for the force
  97219. * @returns The physics imposter
  97220. */
  97221. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97222. /**
  97223. * Apply an impulse
  97224. * @param force The impulse force
  97225. * @param contactPoint The contact point for the impulse force
  97226. * @returns The physics imposter
  97227. */
  97228. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97229. /**
  97230. * A help function to create a joint
  97231. * @param otherImpostor A physics imposter used to create a joint
  97232. * @param jointType The type of joint
  97233. * @param jointData The data for the joint
  97234. * @returns The physics imposter
  97235. */
  97236. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97237. /**
  97238. * Add a joint to this impostor with a different impostor
  97239. * @param otherImpostor A physics imposter used to add a joint
  97240. * @param joint The joint to add
  97241. * @returns The physics imposter
  97242. */
  97243. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97244. /**
  97245. * Add an anchor to a cloth impostor
  97246. * @param otherImpostor rigid impostor to anchor to
  97247. * @param width ratio across width from 0 to 1
  97248. * @param height ratio up height from 0 to 1
  97249. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97250. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97251. * @returns impostor the soft imposter
  97252. */
  97253. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97254. /**
  97255. * Add a hook to a rope impostor
  97256. * @param otherImpostor rigid impostor to anchor to
  97257. * @param length ratio across rope from 0 to 1
  97258. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97259. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97260. * @returns impostor the rope imposter
  97261. */
  97262. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97263. /**
  97264. * Will keep this body still, in a sleep mode.
  97265. * @returns the physics imposter
  97266. */
  97267. sleep(): PhysicsImpostor;
  97268. /**
  97269. * Wake the body up.
  97270. * @returns The physics imposter
  97271. */
  97272. wakeUp(): PhysicsImpostor;
  97273. /**
  97274. * Clones the physics imposter
  97275. * @param newObject The physics imposter clones to this physics-enabled object
  97276. * @returns A nullable physics imposter
  97277. */
  97278. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97279. /**
  97280. * Disposes the physics imposter
  97281. */
  97282. dispose(): void;
  97283. /**
  97284. * Sets the delta position
  97285. * @param position The delta position amount
  97286. */
  97287. setDeltaPosition(position: Vector3): void;
  97288. /**
  97289. * Sets the delta rotation
  97290. * @param rotation The delta rotation amount
  97291. */
  97292. setDeltaRotation(rotation: Quaternion): void;
  97293. /**
  97294. * Gets the box size of the physics imposter and stores the result in the input parameter
  97295. * @param result Stores the box size
  97296. * @returns The physics imposter
  97297. */
  97298. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97299. /**
  97300. * Gets the radius of the physics imposter
  97301. * @returns Radius of the physics imposter
  97302. */
  97303. getRadius(): number;
  97304. /**
  97305. * Sync a bone with this impostor
  97306. * @param bone The bone to sync to the impostor.
  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. */
  97312. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97313. /**
  97314. * Sync impostor to a bone
  97315. * @param bone The bone that the impostor will be synced to.
  97316. * @param boneMesh The mesh that the bone is influencing.
  97317. * @param jointPivot The pivot of the joint / bone in local space.
  97318. * @param distToJoint Optional distance from the impostor to the joint.
  97319. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97320. * @param boneAxis Optional vector3 axis the bone is aligned with
  97321. */
  97322. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97323. /**
  97324. * No-Imposter type
  97325. */
  97326. static NoImpostor: number;
  97327. /**
  97328. * Sphere-Imposter type
  97329. */
  97330. static SphereImpostor: number;
  97331. /**
  97332. * Box-Imposter type
  97333. */
  97334. static BoxImpostor: number;
  97335. /**
  97336. * Plane-Imposter type
  97337. */
  97338. static PlaneImpostor: number;
  97339. /**
  97340. * Mesh-imposter type
  97341. */
  97342. static MeshImpostor: number;
  97343. /**
  97344. * Capsule-Impostor type (Ammo.js plugin only)
  97345. */
  97346. static CapsuleImpostor: number;
  97347. /**
  97348. * Cylinder-Imposter type
  97349. */
  97350. static CylinderImpostor: number;
  97351. /**
  97352. * Particle-Imposter type
  97353. */
  97354. static ParticleImpostor: number;
  97355. /**
  97356. * Heightmap-Imposter type
  97357. */
  97358. static HeightmapImpostor: number;
  97359. /**
  97360. * ConvexHull-Impostor type (Ammo.js plugin only)
  97361. */
  97362. static ConvexHullImpostor: number;
  97363. /**
  97364. * Custom-Imposter type (Ammo.js plugin only)
  97365. */
  97366. static CustomImpostor: number;
  97367. /**
  97368. * Rope-Imposter type
  97369. */
  97370. static RopeImpostor: number;
  97371. /**
  97372. * Cloth-Imposter type
  97373. */
  97374. static ClothImpostor: number;
  97375. /**
  97376. * Softbody-Imposter type
  97377. */
  97378. static SoftbodyImpostor: number;
  97379. }
  97380. }
  97381. declare module BABYLON {
  97382. /**
  97383. * @hidden
  97384. **/
  97385. export class _CreationDataStorage {
  97386. closePath?: boolean;
  97387. closeArray?: boolean;
  97388. idx: number[];
  97389. dashSize: number;
  97390. gapSize: number;
  97391. path3D: Path3D;
  97392. pathArray: Vector3[][];
  97393. arc: number;
  97394. radius: number;
  97395. cap: number;
  97396. tessellation: number;
  97397. }
  97398. /**
  97399. * @hidden
  97400. **/
  97401. class _InstanceDataStorage {
  97402. visibleInstances: any;
  97403. batchCache: _InstancesBatch;
  97404. instancesBufferSize: number;
  97405. instancesBuffer: Nullable<Buffer>;
  97406. instancesData: Float32Array;
  97407. overridenInstanceCount: number;
  97408. isFrozen: boolean;
  97409. previousBatch: Nullable<_InstancesBatch>;
  97410. hardwareInstancedRendering: boolean;
  97411. sideOrientation: number;
  97412. manualUpdate: boolean;
  97413. }
  97414. /**
  97415. * @hidden
  97416. **/
  97417. export class _InstancesBatch {
  97418. mustReturn: boolean;
  97419. visibleInstances: Nullable<InstancedMesh[]>[];
  97420. renderSelf: boolean[];
  97421. hardwareInstancedRendering: boolean[];
  97422. }
  97423. /**
  97424. * Class used to represent renderable models
  97425. */
  97426. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97427. /**
  97428. * Mesh side orientation : usually the external or front surface
  97429. */
  97430. static readonly FRONTSIDE: number;
  97431. /**
  97432. * Mesh side orientation : usually the internal or back surface
  97433. */
  97434. static readonly BACKSIDE: number;
  97435. /**
  97436. * Mesh side orientation : both internal and external or front and back surfaces
  97437. */
  97438. static readonly DOUBLESIDE: number;
  97439. /**
  97440. * Mesh side orientation : by default, `FRONTSIDE`
  97441. */
  97442. static readonly DEFAULTSIDE: number;
  97443. /**
  97444. * Mesh cap setting : no cap
  97445. */
  97446. static readonly NO_CAP: number;
  97447. /**
  97448. * Mesh cap setting : one cap at the beginning of the mesh
  97449. */
  97450. static readonly CAP_START: number;
  97451. /**
  97452. * Mesh cap setting : one cap at the end of the mesh
  97453. */
  97454. static readonly CAP_END: number;
  97455. /**
  97456. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97457. */
  97458. static readonly CAP_ALL: number;
  97459. /**
  97460. * Mesh pattern setting : no flip or rotate
  97461. */
  97462. static readonly NO_FLIP: number;
  97463. /**
  97464. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97465. */
  97466. static readonly FLIP_TILE: number;
  97467. /**
  97468. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97469. */
  97470. static readonly ROTATE_TILE: number;
  97471. /**
  97472. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97473. */
  97474. static readonly FLIP_ROW: number;
  97475. /**
  97476. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97477. */
  97478. static readonly ROTATE_ROW: number;
  97479. /**
  97480. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97481. */
  97482. static readonly FLIP_N_ROTATE_TILE: number;
  97483. /**
  97484. * Mesh pattern setting : rotate pattern and rotate
  97485. */
  97486. static readonly FLIP_N_ROTATE_ROW: number;
  97487. /**
  97488. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97489. */
  97490. static readonly CENTER: number;
  97491. /**
  97492. * Mesh tile positioning : part tiles on left
  97493. */
  97494. static readonly LEFT: number;
  97495. /**
  97496. * Mesh tile positioning : part tiles on right
  97497. */
  97498. static readonly RIGHT: number;
  97499. /**
  97500. * Mesh tile positioning : part tiles on top
  97501. */
  97502. static readonly TOP: number;
  97503. /**
  97504. * Mesh tile positioning : part tiles on bottom
  97505. */
  97506. static readonly BOTTOM: number;
  97507. /**
  97508. * Gets the default side orientation.
  97509. * @param orientation the orientation to value to attempt to get
  97510. * @returns the default orientation
  97511. * @hidden
  97512. */
  97513. static _GetDefaultSideOrientation(orientation?: number): number;
  97514. private _internalMeshDataInfo;
  97515. /**
  97516. * An event triggered before rendering the mesh
  97517. */
  97518. get onBeforeRenderObservable(): Observable<Mesh>;
  97519. /**
  97520. * An event triggered before binding the mesh
  97521. */
  97522. get onBeforeBindObservable(): Observable<Mesh>;
  97523. /**
  97524. * An event triggered after rendering the mesh
  97525. */
  97526. get onAfterRenderObservable(): Observable<Mesh>;
  97527. /**
  97528. * An event triggered before drawing the mesh
  97529. */
  97530. get onBeforeDrawObservable(): Observable<Mesh>;
  97531. private _onBeforeDrawObserver;
  97532. /**
  97533. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97534. */
  97535. set onBeforeDraw(callback: () => void);
  97536. get hasInstances(): boolean;
  97537. /**
  97538. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97539. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97540. */
  97541. delayLoadState: number;
  97542. /**
  97543. * Gets the list of instances created from this mesh
  97544. * it is not supposed to be modified manually.
  97545. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97546. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97547. */
  97548. instances: InstancedMesh[];
  97549. /**
  97550. * Gets the file containing delay loading data for this mesh
  97551. */
  97552. delayLoadingFile: string;
  97553. /** @hidden */
  97554. _binaryInfo: any;
  97555. /**
  97556. * User defined function used to change how LOD level selection is done
  97557. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97558. */
  97559. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97560. /**
  97561. * Gets or sets the morph target manager
  97562. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97563. */
  97564. get morphTargetManager(): Nullable<MorphTargetManager>;
  97565. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97566. /** @hidden */
  97567. _creationDataStorage: Nullable<_CreationDataStorage>;
  97568. /** @hidden */
  97569. _geometry: Nullable<Geometry>;
  97570. /** @hidden */
  97571. _delayInfo: Array<string>;
  97572. /** @hidden */
  97573. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97574. /** @hidden */
  97575. _instanceDataStorage: _InstanceDataStorage;
  97576. private _effectiveMaterial;
  97577. /** @hidden */
  97578. _shouldGenerateFlatShading: boolean;
  97579. /** @hidden */
  97580. _originalBuilderSideOrientation: number;
  97581. /**
  97582. * Use this property to change the original side orientation defined at construction time
  97583. */
  97584. overrideMaterialSideOrientation: Nullable<number>;
  97585. /**
  97586. * Gets the source mesh (the one used to clone this one from)
  97587. */
  97588. get source(): Nullable<Mesh>;
  97589. /**
  97590. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97591. */
  97592. get isUnIndexed(): boolean;
  97593. set isUnIndexed(value: boolean);
  97594. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97595. get worldMatrixInstancedBuffer(): Float32Array;
  97596. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97597. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97598. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97599. /**
  97600. * @constructor
  97601. * @param name The value used by scene.getMeshByName() to do a lookup.
  97602. * @param scene The scene to add this mesh to.
  97603. * @param parent The parent of this mesh, if it has one
  97604. * @param source An optional Mesh from which geometry is shared, cloned.
  97605. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97606. * When false, achieved by calling a clone(), also passing False.
  97607. * This will make creation of children, recursive.
  97608. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97609. */
  97610. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97611. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97612. doNotInstantiate: boolean;
  97613. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97614. /**
  97615. * Gets the class name
  97616. * @returns the string "Mesh".
  97617. */
  97618. getClassName(): string;
  97619. /** @hidden */
  97620. get _isMesh(): boolean;
  97621. /**
  97622. * Returns a description of this mesh
  97623. * @param fullDetails define if full details about this mesh must be used
  97624. * @returns a descriptive string representing this mesh
  97625. */
  97626. toString(fullDetails?: boolean): string;
  97627. /** @hidden */
  97628. _unBindEffect(): void;
  97629. /**
  97630. * Gets a boolean indicating if this mesh has LOD
  97631. */
  97632. get hasLODLevels(): boolean;
  97633. /**
  97634. * Gets the list of MeshLODLevel associated with the current mesh
  97635. * @returns an array of MeshLODLevel
  97636. */
  97637. getLODLevels(): MeshLODLevel[];
  97638. private _sortLODLevels;
  97639. /**
  97640. * Add a mesh as LOD level triggered at the given distance.
  97641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97642. * @param distance The distance from the center of the object to show this level
  97643. * @param mesh The mesh to be added as LOD level (can be null)
  97644. * @return This mesh (for chaining)
  97645. */
  97646. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97647. /**
  97648. * Returns the LOD level mesh at the passed distance or null if not found.
  97649. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97650. * @param distance The distance from the center of the object to show this level
  97651. * @returns a Mesh or `null`
  97652. */
  97653. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97654. /**
  97655. * Remove a mesh from the LOD array
  97656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97657. * @param mesh defines the mesh to be removed
  97658. * @return This mesh (for chaining)
  97659. */
  97660. removeLODLevel(mesh: Mesh): Mesh;
  97661. /**
  97662. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97663. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97664. * @param camera defines the camera to use to compute distance
  97665. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97666. * @return This mesh (for chaining)
  97667. */
  97668. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97669. /**
  97670. * Gets the mesh internal Geometry object
  97671. */
  97672. get geometry(): Nullable<Geometry>;
  97673. /**
  97674. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97675. * @returns the total number of vertices
  97676. */
  97677. getTotalVertices(): number;
  97678. /**
  97679. * Returns the content of an associated vertex buffer
  97680. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97681. * - VertexBuffer.PositionKind
  97682. * - VertexBuffer.UVKind
  97683. * - VertexBuffer.UV2Kind
  97684. * - VertexBuffer.UV3Kind
  97685. * - VertexBuffer.UV4Kind
  97686. * - VertexBuffer.UV5Kind
  97687. * - VertexBuffer.UV6Kind
  97688. * - VertexBuffer.ColorKind
  97689. * - VertexBuffer.MatricesIndicesKind
  97690. * - VertexBuffer.MatricesIndicesExtraKind
  97691. * - VertexBuffer.MatricesWeightsKind
  97692. * - VertexBuffer.MatricesWeightsExtraKind
  97693. * @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
  97694. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97695. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97696. */
  97697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97698. /**
  97699. * Returns the mesh VertexBuffer object from the requested `kind`
  97700. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97701. * - VertexBuffer.PositionKind
  97702. * - VertexBuffer.NormalKind
  97703. * - VertexBuffer.UVKind
  97704. * - VertexBuffer.UV2Kind
  97705. * - VertexBuffer.UV3Kind
  97706. * - VertexBuffer.UV4Kind
  97707. * - VertexBuffer.UV5Kind
  97708. * - VertexBuffer.UV6Kind
  97709. * - VertexBuffer.ColorKind
  97710. * - VertexBuffer.MatricesIndicesKind
  97711. * - VertexBuffer.MatricesIndicesExtraKind
  97712. * - VertexBuffer.MatricesWeightsKind
  97713. * - VertexBuffer.MatricesWeightsExtraKind
  97714. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97715. */
  97716. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97717. /**
  97718. * Tests if a specific vertex buffer is associated with this mesh
  97719. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97720. * - VertexBuffer.PositionKind
  97721. * - VertexBuffer.NormalKind
  97722. * - VertexBuffer.UVKind
  97723. * - VertexBuffer.UV2Kind
  97724. * - VertexBuffer.UV3Kind
  97725. * - VertexBuffer.UV4Kind
  97726. * - VertexBuffer.UV5Kind
  97727. * - VertexBuffer.UV6Kind
  97728. * - VertexBuffer.ColorKind
  97729. * - VertexBuffer.MatricesIndicesKind
  97730. * - VertexBuffer.MatricesIndicesExtraKind
  97731. * - VertexBuffer.MatricesWeightsKind
  97732. * - VertexBuffer.MatricesWeightsExtraKind
  97733. * @returns a boolean
  97734. */
  97735. isVerticesDataPresent(kind: string): boolean;
  97736. /**
  97737. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97738. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97739. * - VertexBuffer.PositionKind
  97740. * - VertexBuffer.UVKind
  97741. * - VertexBuffer.UV2Kind
  97742. * - VertexBuffer.UV3Kind
  97743. * - VertexBuffer.UV4Kind
  97744. * - VertexBuffer.UV5Kind
  97745. * - VertexBuffer.UV6Kind
  97746. * - VertexBuffer.ColorKind
  97747. * - VertexBuffer.MatricesIndicesKind
  97748. * - VertexBuffer.MatricesIndicesExtraKind
  97749. * - VertexBuffer.MatricesWeightsKind
  97750. * - VertexBuffer.MatricesWeightsExtraKind
  97751. * @returns a boolean
  97752. */
  97753. isVertexBufferUpdatable(kind: string): boolean;
  97754. /**
  97755. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97756. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97757. * - VertexBuffer.PositionKind
  97758. * - VertexBuffer.NormalKind
  97759. * - VertexBuffer.UVKind
  97760. * - VertexBuffer.UV2Kind
  97761. * - VertexBuffer.UV3Kind
  97762. * - VertexBuffer.UV4Kind
  97763. * - VertexBuffer.UV5Kind
  97764. * - VertexBuffer.UV6Kind
  97765. * - VertexBuffer.ColorKind
  97766. * - VertexBuffer.MatricesIndicesKind
  97767. * - VertexBuffer.MatricesIndicesExtraKind
  97768. * - VertexBuffer.MatricesWeightsKind
  97769. * - VertexBuffer.MatricesWeightsExtraKind
  97770. * @returns an array of strings
  97771. */
  97772. getVerticesDataKinds(): string[];
  97773. /**
  97774. * Returns a positive integer : the total number of indices in this mesh geometry.
  97775. * @returns the numner of indices or zero if the mesh has no geometry.
  97776. */
  97777. getTotalIndices(): number;
  97778. /**
  97779. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97780. * @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.
  97781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97782. * @returns the indices array or an empty array if the mesh has no geometry
  97783. */
  97784. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97785. get isBlocked(): boolean;
  97786. /**
  97787. * Determine if the current mesh is ready to be rendered
  97788. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97789. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97790. * @returns true if all associated assets are ready (material, textures, shaders)
  97791. */
  97792. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97793. /**
  97794. * 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.
  97795. */
  97796. get areNormalsFrozen(): boolean;
  97797. /**
  97798. * 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.
  97799. * @returns the current mesh
  97800. */
  97801. freezeNormals(): Mesh;
  97802. /**
  97803. * 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
  97804. * @returns the current mesh
  97805. */
  97806. unfreezeNormals(): Mesh;
  97807. /**
  97808. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97809. */
  97810. set overridenInstanceCount(count: number);
  97811. /** @hidden */
  97812. _preActivate(): Mesh;
  97813. /** @hidden */
  97814. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97815. /** @hidden */
  97816. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97817. /**
  97818. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97819. * This means the mesh underlying bounding box and sphere are recomputed.
  97820. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97821. * @returns the current mesh
  97822. */
  97823. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97824. /** @hidden */
  97825. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97826. /**
  97827. * This function will subdivide the mesh into multiple submeshes
  97828. * @param count defines the expected number of submeshes
  97829. */
  97830. subdivide(count: number): void;
  97831. /**
  97832. * Copy a FloatArray into a specific associated vertex buffer
  97833. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97834. * - VertexBuffer.PositionKind
  97835. * - VertexBuffer.UVKind
  97836. * - VertexBuffer.UV2Kind
  97837. * - VertexBuffer.UV3Kind
  97838. * - VertexBuffer.UV4Kind
  97839. * - VertexBuffer.UV5Kind
  97840. * - VertexBuffer.UV6Kind
  97841. * - VertexBuffer.ColorKind
  97842. * - VertexBuffer.MatricesIndicesKind
  97843. * - VertexBuffer.MatricesIndicesExtraKind
  97844. * - VertexBuffer.MatricesWeightsKind
  97845. * - VertexBuffer.MatricesWeightsExtraKind
  97846. * @param data defines the data source
  97847. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97848. * @param stride defines the data stride size (can be null)
  97849. * @returns the current mesh
  97850. */
  97851. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97852. /**
  97853. * Delete a vertex buffer associated with this mesh
  97854. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97855. * - VertexBuffer.PositionKind
  97856. * - VertexBuffer.UVKind
  97857. * - VertexBuffer.UV2Kind
  97858. * - VertexBuffer.UV3Kind
  97859. * - VertexBuffer.UV4Kind
  97860. * - VertexBuffer.UV5Kind
  97861. * - VertexBuffer.UV6Kind
  97862. * - VertexBuffer.ColorKind
  97863. * - VertexBuffer.MatricesIndicesKind
  97864. * - VertexBuffer.MatricesIndicesExtraKind
  97865. * - VertexBuffer.MatricesWeightsKind
  97866. * - VertexBuffer.MatricesWeightsExtraKind
  97867. */
  97868. removeVerticesData(kind: string): void;
  97869. /**
  97870. * Flags an associated vertex buffer as updatable
  97871. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97872. * - VertexBuffer.PositionKind
  97873. * - VertexBuffer.UVKind
  97874. * - VertexBuffer.UV2Kind
  97875. * - VertexBuffer.UV3Kind
  97876. * - VertexBuffer.UV4Kind
  97877. * - VertexBuffer.UV5Kind
  97878. * - VertexBuffer.UV6Kind
  97879. * - VertexBuffer.ColorKind
  97880. * - VertexBuffer.MatricesIndicesKind
  97881. * - VertexBuffer.MatricesIndicesExtraKind
  97882. * - VertexBuffer.MatricesWeightsKind
  97883. * - VertexBuffer.MatricesWeightsExtraKind
  97884. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97885. */
  97886. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97887. /**
  97888. * Sets the mesh global Vertex Buffer
  97889. * @param buffer defines the buffer to use
  97890. * @returns the current mesh
  97891. */
  97892. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97893. /**
  97894. * Update a specific associated vertex buffer
  97895. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97896. * - VertexBuffer.PositionKind
  97897. * - VertexBuffer.UVKind
  97898. * - VertexBuffer.UV2Kind
  97899. * - VertexBuffer.UV3Kind
  97900. * - VertexBuffer.UV4Kind
  97901. * - VertexBuffer.UV5Kind
  97902. * - VertexBuffer.UV6Kind
  97903. * - VertexBuffer.ColorKind
  97904. * - VertexBuffer.MatricesIndicesKind
  97905. * - VertexBuffer.MatricesIndicesExtraKind
  97906. * - VertexBuffer.MatricesWeightsKind
  97907. * - VertexBuffer.MatricesWeightsExtraKind
  97908. * @param data defines the data source
  97909. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97910. * @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)
  97911. * @returns the current mesh
  97912. */
  97913. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97914. /**
  97915. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97916. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97917. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97918. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97919. * @returns the current mesh
  97920. */
  97921. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97922. /**
  97923. * Creates a un-shared specific occurence of the geometry for the mesh.
  97924. * @returns the current mesh
  97925. */
  97926. makeGeometryUnique(): Mesh;
  97927. /**
  97928. * Set the index buffer of this mesh
  97929. * @param indices defines the source data
  97930. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97931. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97932. * @returns the current mesh
  97933. */
  97934. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97935. /**
  97936. * Update the current index buffer
  97937. * @param indices defines the source data
  97938. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97939. * @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)
  97940. * @returns the current mesh
  97941. */
  97942. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97943. /**
  97944. * Invert the geometry to move from a right handed system to a left handed one.
  97945. * @returns the current mesh
  97946. */
  97947. toLeftHanded(): Mesh;
  97948. /** @hidden */
  97949. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97950. /** @hidden */
  97951. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97952. /**
  97953. * Registers for this mesh a javascript function called just before the rendering process
  97954. * @param func defines the function to call before rendering this mesh
  97955. * @returns the current mesh
  97956. */
  97957. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97958. /**
  97959. * Disposes a previously registered javascript function called before the rendering
  97960. * @param func defines the function to remove
  97961. * @returns the current mesh
  97962. */
  97963. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97964. /**
  97965. * Registers for this mesh a javascript function called just after the rendering is complete
  97966. * @param func defines the function to call after rendering this mesh
  97967. * @returns the current mesh
  97968. */
  97969. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97970. /**
  97971. * Disposes a previously registered javascript function called after the rendering.
  97972. * @param func defines the function to remove
  97973. * @returns the current mesh
  97974. */
  97975. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97976. /** @hidden */
  97977. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97978. /** @hidden */
  97979. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97980. /** @hidden */
  97981. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97982. /** @hidden */
  97983. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97984. /** @hidden */
  97985. _rebuild(): void;
  97986. /** @hidden */
  97987. _freeze(): void;
  97988. /** @hidden */
  97989. _unFreeze(): void;
  97990. /**
  97991. * 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
  97992. * @param subMesh defines the subMesh to render
  97993. * @param enableAlphaMode defines if alpha mode can be changed
  97994. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97995. * @returns the current mesh
  97996. */
  97997. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97998. private _onBeforeDraw;
  97999. /**
  98000. * Renormalize the mesh and patch it up if there are no weights
  98001. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98002. * However in the case of zero weights then we set just a single influence to 1.
  98003. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98004. */
  98005. cleanMatrixWeights(): void;
  98006. private normalizeSkinFourWeights;
  98007. private normalizeSkinWeightsAndExtra;
  98008. /**
  98009. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98010. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98011. * the user know there was an issue with importing the mesh
  98012. * @returns a validation object with skinned, valid and report string
  98013. */
  98014. validateSkinning(): {
  98015. skinned: boolean;
  98016. valid: boolean;
  98017. report: string;
  98018. };
  98019. /** @hidden */
  98020. _checkDelayState(): Mesh;
  98021. private _queueLoad;
  98022. /**
  98023. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98024. * A mesh is in the frustum if its bounding box intersects the frustum
  98025. * @param frustumPlanes defines the frustum to test
  98026. * @returns true if the mesh is in the frustum planes
  98027. */
  98028. isInFrustum(frustumPlanes: Plane[]): boolean;
  98029. /**
  98030. * Sets the mesh material by the material or multiMaterial `id` property
  98031. * @param id is a string identifying the material or the multiMaterial
  98032. * @returns the current mesh
  98033. */
  98034. setMaterialByID(id: string): Mesh;
  98035. /**
  98036. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98037. * @returns an array of IAnimatable
  98038. */
  98039. getAnimatables(): IAnimatable[];
  98040. /**
  98041. * Modifies the mesh geometry according to the passed transformation matrix.
  98042. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98043. * The mesh normals are modified using the same transformation.
  98044. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98045. * @param transform defines the transform matrix to use
  98046. * @see http://doc.babylonjs.com/resources/baking_transformations
  98047. * @returns the current mesh
  98048. */
  98049. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98050. /**
  98051. * Modifies the mesh geometry according to its own current World Matrix.
  98052. * The mesh World Matrix is then reset.
  98053. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98054. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98055. * @see http://doc.babylonjs.com/resources/baking_transformations
  98056. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98057. * @returns the current mesh
  98058. */
  98059. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98060. /** @hidden */
  98061. get _positions(): Nullable<Vector3[]>;
  98062. /** @hidden */
  98063. _resetPointsArrayCache(): Mesh;
  98064. /** @hidden */
  98065. _generatePointsArray(): boolean;
  98066. /**
  98067. * Returns a new Mesh object generated from the current mesh properties.
  98068. * This method must not get confused with createInstance()
  98069. * @param name is a string, the name given to the new mesh
  98070. * @param newParent can be any Node object (default `null`)
  98071. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98072. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98073. * @returns a new mesh
  98074. */
  98075. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98076. /**
  98077. * Releases resources associated with this mesh.
  98078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98080. */
  98081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98082. /** @hidden */
  98083. _disposeInstanceSpecificData(): void;
  98084. /**
  98085. * Modifies the mesh geometry according to a displacement map.
  98086. * 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.
  98087. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98088. * @param url is a string, the URL from the image file is to be downloaded.
  98089. * @param minHeight is the lower limit of the displacement.
  98090. * @param maxHeight is the upper limit of the displacement.
  98091. * @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.
  98092. * @param uvOffset is an optional vector2 used to offset UV.
  98093. * @param uvScale is an optional vector2 used to scale UV.
  98094. * @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.
  98095. * @returns the Mesh.
  98096. */
  98097. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98098. /**
  98099. * Modifies the mesh geometry according to a displacementMap buffer.
  98100. * 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.
  98101. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98102. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98103. * @param heightMapWidth is the width of the buffer image.
  98104. * @param heightMapHeight is the height of the buffer image.
  98105. * @param minHeight is the lower limit of the displacement.
  98106. * @param maxHeight is the upper limit of the displacement.
  98107. * @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.
  98108. * @param uvOffset is an optional vector2 used to offset UV.
  98109. * @param uvScale is an optional vector2 used to scale UV.
  98110. * @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.
  98111. * @returns the Mesh.
  98112. */
  98113. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98114. /**
  98115. * Modify the mesh to get a flat shading rendering.
  98116. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98117. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98118. * @returns current mesh
  98119. */
  98120. convertToFlatShadedMesh(): Mesh;
  98121. /**
  98122. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98123. * In other words, more vertices, no more indices and a single bigger VBO.
  98124. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98125. * @returns current mesh
  98126. */
  98127. convertToUnIndexedMesh(): Mesh;
  98128. /**
  98129. * Inverses facet orientations.
  98130. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98131. * @param flipNormals will also inverts the normals
  98132. * @returns current mesh
  98133. */
  98134. flipFaces(flipNormals?: boolean): Mesh;
  98135. /**
  98136. * Increase the number of facets and hence vertices in a mesh
  98137. * Vertex normals are interpolated from existing vertex normals
  98138. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98139. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98140. */
  98141. increaseVertices(numberPerEdge: number): void;
  98142. /**
  98143. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98144. * This will undo any application of covertToFlatShadedMesh
  98145. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98146. */
  98147. forceSharedVertices(): void;
  98148. /** @hidden */
  98149. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98150. /** @hidden */
  98151. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98152. /**
  98153. * Creates a new InstancedMesh object from the mesh model.
  98154. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98155. * @param name defines the name of the new instance
  98156. * @returns a new InstancedMesh
  98157. */
  98158. createInstance(name: string): InstancedMesh;
  98159. /**
  98160. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98161. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98162. * @returns the current mesh
  98163. */
  98164. synchronizeInstances(): Mesh;
  98165. /**
  98166. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98167. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98168. * This should be used together with the simplification to avoid disappearing triangles.
  98169. * @param successCallback an optional success callback to be called after the optimization finished.
  98170. * @returns the current mesh
  98171. */
  98172. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98173. /**
  98174. * Serialize current mesh
  98175. * @param serializationObject defines the object which will receive the serialization data
  98176. */
  98177. serialize(serializationObject: any): void;
  98178. /** @hidden */
  98179. _syncGeometryWithMorphTargetManager(): void;
  98180. /** @hidden */
  98181. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98182. /**
  98183. * Returns a new Mesh object parsed from the source provided.
  98184. * @param parsedMesh is the source
  98185. * @param scene defines the hosting scene
  98186. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98187. * @returns a new Mesh
  98188. */
  98189. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98190. /**
  98191. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98192. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98193. * @param name defines the name of the mesh to create
  98194. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98195. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98196. * @param closePath creates a seam between the first and the last points of each path of the path array
  98197. * @param offset is taken in account only if the `pathArray` is containing a single path
  98198. * @param scene defines the hosting scene
  98199. * @param updatable defines if the mesh must be flagged as updatable
  98200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98201. * @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)
  98202. * @returns a new Mesh
  98203. */
  98204. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98205. /**
  98206. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98207. * @param name defines the name of the mesh to create
  98208. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98209. * @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
  98210. * @param scene defines the hosting scene
  98211. * @param updatable defines if the mesh must be flagged as updatable
  98212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98213. * @returns a new Mesh
  98214. */
  98215. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98216. /**
  98217. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98218. * @param name defines the name of the mesh to create
  98219. * @param size sets the size (float) of each box side (default 1)
  98220. * @param scene defines the hosting scene
  98221. * @param updatable defines if the mesh must be flagged as updatable
  98222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98223. * @returns a new Mesh
  98224. */
  98225. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98226. /**
  98227. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98228. * @param name defines the name of the mesh to create
  98229. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98230. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98231. * @param scene defines the hosting scene
  98232. * @param updatable defines if the mesh must be flagged as updatable
  98233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98234. * @returns a new Mesh
  98235. */
  98236. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98237. /**
  98238. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98241. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98242. * @param scene defines the hosting scene
  98243. * @returns a new Mesh
  98244. */
  98245. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98246. /**
  98247. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98248. * @param name defines the name of the mesh to create
  98249. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98250. * @param diameterTop set the top cap diameter (floats, default 1)
  98251. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98252. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98253. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98254. * @param scene defines the hosting scene
  98255. * @param updatable defines if the mesh must be flagged as updatable
  98256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98257. * @returns a new Mesh
  98258. */
  98259. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98260. /**
  98261. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98262. * @param name defines the name of the mesh to create
  98263. * @param diameter sets the diameter size (float) of the torus (default 1)
  98264. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98265. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98266. * @param scene defines the hosting scene
  98267. * @param updatable defines if the mesh must be flagged as updatable
  98268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98269. * @returns a new Mesh
  98270. */
  98271. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98272. /**
  98273. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98274. * @param name defines the name of the mesh to create
  98275. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98276. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98277. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98278. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98279. * @param p the number of windings on X axis (positive integers, default 2)
  98280. * @param q the number of windings on Y axis (positive integers, default 3)
  98281. * @param scene defines the hosting scene
  98282. * @param updatable defines if the mesh must be flagged as updatable
  98283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98284. * @returns a new Mesh
  98285. */
  98286. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98287. /**
  98288. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98289. * @param name defines the name of the mesh to create
  98290. * @param points is an array successive Vector3
  98291. * @param scene defines the hosting scene
  98292. * @param updatable defines if the mesh must be flagged as updatable
  98293. * @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).
  98294. * @returns a new Mesh
  98295. */
  98296. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98297. /**
  98298. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98299. * @param name defines the name of the mesh to create
  98300. * @param points is an array successive Vector3
  98301. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98302. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98303. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98304. * @param scene defines the hosting scene
  98305. * @param updatable defines if the mesh must be flagged as updatable
  98306. * @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)
  98307. * @returns a new Mesh
  98308. */
  98309. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98310. /**
  98311. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98312. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98313. * 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.
  98314. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98315. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98316. * Remember you can only change the shape positions, not their number when updating a polygon.
  98317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98318. * @param name defines the name of the mesh to create
  98319. * @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
  98320. * @param scene defines the hosting scene
  98321. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98322. * @param updatable defines if the mesh must be flagged as updatable
  98323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98324. * @param earcutInjection can be used to inject your own earcut reference
  98325. * @returns a new Mesh
  98326. */
  98327. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98328. /**
  98329. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98330. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98331. * @param name defines the name of the mesh to create
  98332. * @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
  98333. * @param depth defines the height of extrusion
  98334. * @param scene defines the hosting scene
  98335. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98336. * @param updatable defines if the mesh must be flagged as updatable
  98337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98338. * @param earcutInjection can be used to inject your own earcut reference
  98339. * @returns a new Mesh
  98340. */
  98341. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98342. /**
  98343. * Creates an extruded shape mesh.
  98344. * 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
  98345. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98346. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98347. * @param name defines the name of the mesh to create
  98348. * @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
  98349. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98350. * @param scale is the value to scale the shape
  98351. * @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
  98352. * @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
  98353. * @param scene defines the hosting scene
  98354. * @param updatable defines if the mesh must be flagged as updatable
  98355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98356. * @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)
  98357. * @returns a new Mesh
  98358. */
  98359. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98360. /**
  98361. * Creates an custom extruded shape mesh.
  98362. * The custom extrusion is a parametric shape.
  98363. * It has no predefined shape. Its final shape will depend on the input parameters.
  98364. * Please consider using the same method from the MeshBuilder class instead
  98365. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98366. * @param name defines the name of the mesh to create
  98367. * @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
  98368. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98369. * @param scaleFunction is a custom Javascript function called on each path point
  98370. * @param rotationFunction is a custom Javascript function called on each path point
  98371. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98372. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98373. * @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
  98374. * @param scene defines the hosting scene
  98375. * @param updatable defines if the mesh must be flagged as updatable
  98376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98377. * @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)
  98378. * @returns a new Mesh
  98379. */
  98380. 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;
  98381. /**
  98382. * Creates lathe mesh.
  98383. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98384. * Please consider using the same method from the MeshBuilder class instead
  98385. * @param name defines the name of the mesh to create
  98386. * @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
  98387. * @param radius is the radius value of the lathe
  98388. * @param tessellation is the side number of the lathe.
  98389. * @param scene defines the hosting scene
  98390. * @param updatable defines if the mesh must be flagged as updatable
  98391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98392. * @returns a new Mesh
  98393. */
  98394. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98395. /**
  98396. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98397. * @param name defines the name of the mesh to create
  98398. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98399. * @param scene defines the hosting scene
  98400. * @param updatable defines if the mesh must be flagged as updatable
  98401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98402. * @returns a new Mesh
  98403. */
  98404. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98405. /**
  98406. * Creates a ground mesh.
  98407. * Please consider using the same method from the MeshBuilder class instead
  98408. * @param name defines the name of the mesh to create
  98409. * @param width set the width of the ground
  98410. * @param height set the height of the ground
  98411. * @param subdivisions sets the number of subdivisions per side
  98412. * @param scene defines the hosting scene
  98413. * @param updatable defines if the mesh must be flagged as updatable
  98414. * @returns a new Mesh
  98415. */
  98416. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98417. /**
  98418. * Creates a tiled ground mesh.
  98419. * Please consider using the same method from the MeshBuilder class instead
  98420. * @param name defines the name of the mesh to create
  98421. * @param xmin set the ground minimum X coordinate
  98422. * @param zmin set the ground minimum Y coordinate
  98423. * @param xmax set the ground maximum X coordinate
  98424. * @param zmax set the ground maximum Z coordinate
  98425. * @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
  98426. * @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
  98427. * @param scene defines the hosting scene
  98428. * @param updatable defines if the mesh must be flagged as updatable
  98429. * @returns a new Mesh
  98430. */
  98431. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98432. w: number;
  98433. h: number;
  98434. }, precision: {
  98435. w: number;
  98436. h: number;
  98437. }, scene: Scene, updatable?: boolean): Mesh;
  98438. /**
  98439. * Creates a ground mesh from a height map.
  98440. * Please consider using the same method from the MeshBuilder class instead
  98441. * @see http://doc.babylonjs.com/babylon101/height_map
  98442. * @param name defines the name of the mesh to create
  98443. * @param url sets the URL of the height map image resource
  98444. * @param width set the ground width size
  98445. * @param height set the ground height size
  98446. * @param subdivisions sets the number of subdivision per side
  98447. * @param minHeight is the minimum altitude on the ground
  98448. * @param maxHeight is the maximum altitude on the ground
  98449. * @param scene defines the hosting scene
  98450. * @param updatable defines if the mesh must be flagged as updatable
  98451. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98452. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98453. * @returns a new Mesh
  98454. */
  98455. 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;
  98456. /**
  98457. * Creates a tube mesh.
  98458. * The tube is a parametric shape.
  98459. * It has no predefined shape. Its final shape will depend on the input parameters.
  98460. * Please consider using the same method from the MeshBuilder class instead
  98461. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98462. * @param name defines the name of the mesh to create
  98463. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98464. * @param radius sets the tube radius size
  98465. * @param tessellation is the number of sides on the tubular surface
  98466. * @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
  98467. * @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
  98468. * @param scene defines the hosting scene
  98469. * @param updatable defines if the mesh must be flagged as updatable
  98470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98471. * @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)
  98472. * @returns a new Mesh
  98473. */
  98474. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98475. (i: number, distance: number): number;
  98476. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98477. /**
  98478. * Creates a polyhedron mesh.
  98479. * Please consider using the same method from the MeshBuilder class instead.
  98480. * * 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
  98481. * * The parameter `size` (positive float, default 1) sets the polygon size
  98482. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98483. * * 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`
  98484. * * 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
  98485. * * 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)`)
  98486. * * 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
  98487. * * 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
  98488. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98489. * * If you create a double-sided mesh, you can choose what parts of 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
  98490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98491. * @param name defines the name of the mesh to create
  98492. * @param options defines the options used to create the mesh
  98493. * @param scene defines the hosting scene
  98494. * @returns a new Mesh
  98495. */
  98496. static CreatePolyhedron(name: string, options: {
  98497. type?: number;
  98498. size?: number;
  98499. sizeX?: number;
  98500. sizeY?: number;
  98501. sizeZ?: number;
  98502. custom?: any;
  98503. faceUV?: Vector4[];
  98504. faceColors?: Color4[];
  98505. updatable?: boolean;
  98506. sideOrientation?: number;
  98507. }, scene: Scene): Mesh;
  98508. /**
  98509. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98510. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98511. * * 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`)
  98512. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98513. * * 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
  98514. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98515. * * If you create a double-sided mesh, you can choose what parts of 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
  98516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98517. * @param name defines the name of the mesh
  98518. * @param options defines the options used to create the mesh
  98519. * @param scene defines the hosting scene
  98520. * @returns a new Mesh
  98521. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98522. */
  98523. static CreateIcoSphere(name: string, options: {
  98524. radius?: number;
  98525. flat?: boolean;
  98526. subdivisions?: number;
  98527. sideOrientation?: number;
  98528. updatable?: boolean;
  98529. }, scene: Scene): Mesh;
  98530. /**
  98531. * Creates a decal mesh.
  98532. * Please consider using the same method from the MeshBuilder class instead.
  98533. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98534. * @param name defines the name of the mesh
  98535. * @param sourceMesh defines the mesh receiving the decal
  98536. * @param position sets the position of the decal in world coordinates
  98537. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98538. * @param size sets the decal scaling
  98539. * @param angle sets the angle to rotate the decal
  98540. * @returns a new Mesh
  98541. */
  98542. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98543. /**
  98544. * Prepare internal position array for software CPU skinning
  98545. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98546. */
  98547. setPositionsForCPUSkinning(): Float32Array;
  98548. /**
  98549. * Prepare internal normal array for software CPU skinning
  98550. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98551. */
  98552. setNormalsForCPUSkinning(): Float32Array;
  98553. /**
  98554. * Updates the vertex buffer by applying transformation from the bones
  98555. * @param skeleton defines the skeleton to apply to current mesh
  98556. * @returns the current mesh
  98557. */
  98558. applySkeleton(skeleton: Skeleton): Mesh;
  98559. /**
  98560. * 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
  98561. * @param meshes defines the list of meshes to scan
  98562. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98563. */
  98564. static MinMax(meshes: AbstractMesh[]): {
  98565. min: Vector3;
  98566. max: Vector3;
  98567. };
  98568. /**
  98569. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98570. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98571. * @returns a vector3
  98572. */
  98573. static Center(meshesOrMinMaxVector: {
  98574. min: Vector3;
  98575. max: Vector3;
  98576. } | AbstractMesh[]): Vector3;
  98577. /**
  98578. * Merge the array of meshes into a single mesh for performance reasons.
  98579. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98580. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98581. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98582. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98583. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98584. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98585. * @returns a new mesh
  98586. */
  98587. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98588. /** @hidden */
  98589. addInstance(instance: InstancedMesh): void;
  98590. /** @hidden */
  98591. removeInstance(instance: InstancedMesh): void;
  98592. }
  98593. }
  98594. declare module BABYLON {
  98595. /**
  98596. * This is the base class of all the camera used in the application.
  98597. * @see http://doc.babylonjs.com/features/cameras
  98598. */
  98599. export class Camera extends Node {
  98600. /** @hidden */
  98601. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98602. /**
  98603. * This is the default projection mode used by the cameras.
  98604. * It helps recreating a feeling of perspective and better appreciate depth.
  98605. * This is the best way to simulate real life cameras.
  98606. */
  98607. static readonly PERSPECTIVE_CAMERA: number;
  98608. /**
  98609. * This helps creating camera with an orthographic mode.
  98610. * 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.
  98611. */
  98612. static readonly ORTHOGRAPHIC_CAMERA: number;
  98613. /**
  98614. * This is the default FOV mode for perspective cameras.
  98615. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98616. */
  98617. static readonly FOVMODE_VERTICAL_FIXED: number;
  98618. /**
  98619. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98620. */
  98621. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98622. /**
  98623. * This specifies ther is no need for a camera rig.
  98624. * Basically only one eye is rendered corresponding to the camera.
  98625. */
  98626. static readonly RIG_MODE_NONE: number;
  98627. /**
  98628. * Simulates a camera Rig with one blue eye and one red eye.
  98629. * This can be use with 3d blue and red glasses.
  98630. */
  98631. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98632. /**
  98633. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98634. */
  98635. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98636. /**
  98637. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98638. */
  98639. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98640. /**
  98641. * Defines that both eyes of the camera will be rendered over under each other.
  98642. */
  98643. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98644. /**
  98645. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98646. */
  98647. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98648. /**
  98649. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98650. */
  98651. static readonly RIG_MODE_VR: number;
  98652. /**
  98653. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98654. */
  98655. static readonly RIG_MODE_WEBVR: number;
  98656. /**
  98657. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98658. */
  98659. static readonly RIG_MODE_CUSTOM: number;
  98660. /**
  98661. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98662. */
  98663. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98664. /**
  98665. * Define the input manager associated with the camera.
  98666. */
  98667. inputs: CameraInputsManager<Camera>;
  98668. /** @hidden */
  98669. _position: Vector3;
  98670. /**
  98671. * Define the current local position of the camera in the scene
  98672. */
  98673. get position(): Vector3;
  98674. set position(newPosition: Vector3);
  98675. /**
  98676. * The vector the camera should consider as up.
  98677. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98678. */
  98679. upVector: Vector3;
  98680. /**
  98681. * Define the current limit on the left side for an orthographic camera
  98682. * In scene unit
  98683. */
  98684. orthoLeft: Nullable<number>;
  98685. /**
  98686. * Define the current limit on the right side for an orthographic camera
  98687. * In scene unit
  98688. */
  98689. orthoRight: Nullable<number>;
  98690. /**
  98691. * Define the current limit on the bottom side for an orthographic camera
  98692. * In scene unit
  98693. */
  98694. orthoBottom: Nullable<number>;
  98695. /**
  98696. * Define the current limit on the top side for an orthographic camera
  98697. * In scene unit
  98698. */
  98699. orthoTop: Nullable<number>;
  98700. /**
  98701. * Field Of View is set in Radians. (default is 0.8)
  98702. */
  98703. fov: number;
  98704. /**
  98705. * Define the minimum distance the camera can see from.
  98706. * This is important to note that the depth buffer are not infinite and the closer it starts
  98707. * the more your scene might encounter depth fighting issue.
  98708. */
  98709. minZ: number;
  98710. /**
  98711. * Define the maximum distance the camera can see to.
  98712. * This is important to note that the depth buffer are not infinite and the further it end
  98713. * the more your scene might encounter depth fighting issue.
  98714. */
  98715. maxZ: number;
  98716. /**
  98717. * Define the default inertia of the camera.
  98718. * This helps giving a smooth feeling to the camera movement.
  98719. */
  98720. inertia: number;
  98721. /**
  98722. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98723. */
  98724. mode: number;
  98725. /**
  98726. * Define whether the camera is intermediate.
  98727. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98728. */
  98729. isIntermediate: boolean;
  98730. /**
  98731. * Define the viewport of the camera.
  98732. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98733. */
  98734. viewport: Viewport;
  98735. /**
  98736. * Restricts the camera to viewing objects with the same layerMask.
  98737. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98738. */
  98739. layerMask: number;
  98740. /**
  98741. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98742. */
  98743. fovMode: number;
  98744. /**
  98745. * Rig mode of the camera.
  98746. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98747. * This is normally controlled byt the camera themselves as internal use.
  98748. */
  98749. cameraRigMode: number;
  98750. /**
  98751. * Defines the distance between both "eyes" in case of a RIG
  98752. */
  98753. interaxialDistance: number;
  98754. /**
  98755. * Defines if stereoscopic rendering is done side by side or over under.
  98756. */
  98757. isStereoscopicSideBySide: boolean;
  98758. /**
  98759. * 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
  98760. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98761. * else in the scene. (Eg. security camera)
  98762. *
  98763. * 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)
  98764. */
  98765. customRenderTargets: RenderTargetTexture[];
  98766. /**
  98767. * When set, the camera will render to this render target instead of the default canvas
  98768. *
  98769. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98770. */
  98771. outputRenderTarget: Nullable<RenderTargetTexture>;
  98772. /**
  98773. * Observable triggered when the camera view matrix has changed.
  98774. */
  98775. onViewMatrixChangedObservable: Observable<Camera>;
  98776. /**
  98777. * Observable triggered when the camera Projection matrix has changed.
  98778. */
  98779. onProjectionMatrixChangedObservable: Observable<Camera>;
  98780. /**
  98781. * Observable triggered when the inputs have been processed.
  98782. */
  98783. onAfterCheckInputsObservable: Observable<Camera>;
  98784. /**
  98785. * Observable triggered when reset has been called and applied to the camera.
  98786. */
  98787. onRestoreStateObservable: Observable<Camera>;
  98788. /**
  98789. * Is this camera a part of a rig system?
  98790. */
  98791. isRigCamera: boolean;
  98792. /**
  98793. * If isRigCamera set to true this will be set with the parent camera.
  98794. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98795. */
  98796. rigParent?: Camera;
  98797. /** @hidden */
  98798. _cameraRigParams: any;
  98799. /** @hidden */
  98800. _rigCameras: Camera[];
  98801. /** @hidden */
  98802. _rigPostProcess: Nullable<PostProcess>;
  98803. protected _webvrViewMatrix: Matrix;
  98804. /** @hidden */
  98805. _skipRendering: boolean;
  98806. /** @hidden */
  98807. _projectionMatrix: Matrix;
  98808. /** @hidden */
  98809. _postProcesses: Nullable<PostProcess>[];
  98810. /** @hidden */
  98811. _activeMeshes: SmartArray<AbstractMesh>;
  98812. protected _globalPosition: Vector3;
  98813. /** @hidden */
  98814. _computedViewMatrix: Matrix;
  98815. private _doNotComputeProjectionMatrix;
  98816. private _transformMatrix;
  98817. private _frustumPlanes;
  98818. private _refreshFrustumPlanes;
  98819. private _storedFov;
  98820. private _stateStored;
  98821. /**
  98822. * Instantiates a new camera object.
  98823. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98824. * @see http://doc.babylonjs.com/features/cameras
  98825. * @param name Defines the name of the camera in the scene
  98826. * @param position Defines the position of the camera
  98827. * @param scene Defines the scene the camera belongs too
  98828. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98829. */
  98830. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98831. /**
  98832. * Store current camera state (fov, position, etc..)
  98833. * @returns the camera
  98834. */
  98835. storeState(): Camera;
  98836. /**
  98837. * Restores the camera state values if it has been stored. You must call storeState() first
  98838. */
  98839. protected _restoreStateValues(): boolean;
  98840. /**
  98841. * Restored camera state. You must call storeState() first.
  98842. * @returns true if restored and false otherwise
  98843. */
  98844. restoreState(): boolean;
  98845. /**
  98846. * Gets the class name of the camera.
  98847. * @returns the class name
  98848. */
  98849. getClassName(): string;
  98850. /** @hidden */
  98851. readonly _isCamera: boolean;
  98852. /**
  98853. * Gets a string representation of the camera useful for debug purpose.
  98854. * @param fullDetails Defines that a more verboe level of logging is required
  98855. * @returns the string representation
  98856. */
  98857. toString(fullDetails?: boolean): string;
  98858. /**
  98859. * Gets the current world space position of the camera.
  98860. */
  98861. get globalPosition(): Vector3;
  98862. /**
  98863. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98864. * @returns the active meshe list
  98865. */
  98866. getActiveMeshes(): SmartArray<AbstractMesh>;
  98867. /**
  98868. * Check whether a mesh is part of the current active mesh list of the camera
  98869. * @param mesh Defines the mesh to check
  98870. * @returns true if active, false otherwise
  98871. */
  98872. isActiveMesh(mesh: Mesh): boolean;
  98873. /**
  98874. * Is this camera ready to be used/rendered
  98875. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98876. * @return true if the camera is ready
  98877. */
  98878. isReady(completeCheck?: boolean): boolean;
  98879. /** @hidden */
  98880. _initCache(): void;
  98881. /** @hidden */
  98882. _updateCache(ignoreParentClass?: boolean): void;
  98883. /** @hidden */
  98884. _isSynchronized(): boolean;
  98885. /** @hidden */
  98886. _isSynchronizedViewMatrix(): boolean;
  98887. /** @hidden */
  98888. _isSynchronizedProjectionMatrix(): boolean;
  98889. /**
  98890. * Attach the input controls to a specific dom element to get the input from.
  98891. * @param element Defines the element the controls should be listened from
  98892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98893. */
  98894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98895. /**
  98896. * Detach the current controls from the specified dom element.
  98897. * @param element Defines the element to stop listening the inputs from
  98898. */
  98899. detachControl(element: HTMLElement): void;
  98900. /**
  98901. * Update the camera state according to the different inputs gathered during the frame.
  98902. */
  98903. update(): void;
  98904. /** @hidden */
  98905. _checkInputs(): void;
  98906. /** @hidden */
  98907. get rigCameras(): Camera[];
  98908. /**
  98909. * Gets the post process used by the rig cameras
  98910. */
  98911. get rigPostProcess(): Nullable<PostProcess>;
  98912. /**
  98913. * Internal, gets the first post proces.
  98914. * @returns the first post process to be run on this camera.
  98915. */
  98916. _getFirstPostProcess(): Nullable<PostProcess>;
  98917. private _cascadePostProcessesToRigCams;
  98918. /**
  98919. * Attach a post process to the camera.
  98920. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98921. * @param postProcess The post process to attach to the camera
  98922. * @param insertAt The position of the post process in case several of them are in use in the scene
  98923. * @returns the position the post process has been inserted at
  98924. */
  98925. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98926. /**
  98927. * Detach a post process to the camera.
  98928. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98929. * @param postProcess The post process to detach from the camera
  98930. */
  98931. detachPostProcess(postProcess: PostProcess): void;
  98932. /**
  98933. * Gets the current world matrix of the camera
  98934. */
  98935. getWorldMatrix(): Matrix;
  98936. /** @hidden */
  98937. _getViewMatrix(): Matrix;
  98938. /**
  98939. * Gets the current view matrix of the camera.
  98940. * @param force forces the camera to recompute the matrix without looking at the cached state
  98941. * @returns the view matrix
  98942. */
  98943. getViewMatrix(force?: boolean): Matrix;
  98944. /**
  98945. * Freeze the projection matrix.
  98946. * It will prevent the cache check of the camera projection compute and can speed up perf
  98947. * if no parameter of the camera are meant to change
  98948. * @param projection Defines manually a projection if necessary
  98949. */
  98950. freezeProjectionMatrix(projection?: Matrix): void;
  98951. /**
  98952. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98953. */
  98954. unfreezeProjectionMatrix(): void;
  98955. /**
  98956. * Gets the current projection matrix of the camera.
  98957. * @param force forces the camera to recompute the matrix without looking at the cached state
  98958. * @returns the projection matrix
  98959. */
  98960. getProjectionMatrix(force?: boolean): Matrix;
  98961. /**
  98962. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98963. * @returns a Matrix
  98964. */
  98965. getTransformationMatrix(): Matrix;
  98966. private _updateFrustumPlanes;
  98967. /**
  98968. * Checks if a cullable object (mesh...) is in the camera frustum
  98969. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98970. * @param target The object to check
  98971. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98972. * @returns true if the object is in frustum otherwise false
  98973. */
  98974. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98975. /**
  98976. * Checks if a cullable object (mesh...) is in the camera frustum
  98977. * Unlike isInFrustum this cheks the full bounding box
  98978. * @param target The object to check
  98979. * @returns true if the object is in frustum otherwise false
  98980. */
  98981. isCompletelyInFrustum(target: ICullable): boolean;
  98982. /**
  98983. * Gets a ray in the forward direction from the camera.
  98984. * @param length Defines the length of the ray to create
  98985. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98986. * @param origin Defines the start point of the ray which defaults to the camera position
  98987. * @returns the forward ray
  98988. */
  98989. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98990. /**
  98991. * Releases resources associated with this node.
  98992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98994. */
  98995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98996. /** @hidden */
  98997. _isLeftCamera: boolean;
  98998. /**
  98999. * Gets the left camera of a rig setup in case of Rigged Camera
  99000. */
  99001. get isLeftCamera(): boolean;
  99002. /** @hidden */
  99003. _isRightCamera: boolean;
  99004. /**
  99005. * Gets the right camera of a rig setup in case of Rigged Camera
  99006. */
  99007. get isRightCamera(): boolean;
  99008. /**
  99009. * Gets the left camera of a rig setup in case of Rigged Camera
  99010. */
  99011. get leftCamera(): Nullable<FreeCamera>;
  99012. /**
  99013. * Gets the right camera of a rig setup in case of Rigged Camera
  99014. */
  99015. get rightCamera(): Nullable<FreeCamera>;
  99016. /**
  99017. * Gets the left camera target of a rig setup in case of Rigged Camera
  99018. * @returns the target position
  99019. */
  99020. getLeftTarget(): Nullable<Vector3>;
  99021. /**
  99022. * Gets the right camera target of a rig setup in case of Rigged Camera
  99023. * @returns the target position
  99024. */
  99025. getRightTarget(): Nullable<Vector3>;
  99026. /**
  99027. * @hidden
  99028. */
  99029. setCameraRigMode(mode: number, rigParams: any): void;
  99030. /** @hidden */
  99031. static _setStereoscopicRigMode(camera: Camera): void;
  99032. /** @hidden */
  99033. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99034. /** @hidden */
  99035. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99036. /** @hidden */
  99037. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99038. /** @hidden */
  99039. _getVRProjectionMatrix(): Matrix;
  99040. protected _updateCameraRotationMatrix(): void;
  99041. protected _updateWebVRCameraRotationMatrix(): void;
  99042. /**
  99043. * This function MUST be overwritten by the different WebVR cameras available.
  99044. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99045. * @hidden
  99046. */
  99047. _getWebVRProjectionMatrix(): Matrix;
  99048. /**
  99049. * This function MUST be overwritten by the different WebVR cameras available.
  99050. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99051. * @hidden
  99052. */
  99053. _getWebVRViewMatrix(): Matrix;
  99054. /** @hidden */
  99055. setCameraRigParameter(name: string, value: any): void;
  99056. /**
  99057. * needs to be overridden by children so sub has required properties to be copied
  99058. * @hidden
  99059. */
  99060. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99061. /**
  99062. * May need to be overridden by children
  99063. * @hidden
  99064. */
  99065. _updateRigCameras(): void;
  99066. /** @hidden */
  99067. _setupInputs(): void;
  99068. /**
  99069. * Serialiaze the camera setup to a json represention
  99070. * @returns the JSON representation
  99071. */
  99072. serialize(): any;
  99073. /**
  99074. * Clones the current camera.
  99075. * @param name The cloned camera name
  99076. * @returns the cloned camera
  99077. */
  99078. clone(name: string): Camera;
  99079. /**
  99080. * Gets the direction of the camera relative to a given local axis.
  99081. * @param localAxis Defines the reference axis to provide a relative direction.
  99082. * @return the direction
  99083. */
  99084. getDirection(localAxis: Vector3): Vector3;
  99085. /**
  99086. * Returns the current camera absolute rotation
  99087. */
  99088. get absoluteRotation(): Quaternion;
  99089. /**
  99090. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99091. * @param localAxis Defines the reference axis to provide a relative direction.
  99092. * @param result Defines the vector to store the result in
  99093. */
  99094. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99095. /**
  99096. * Gets a camera constructor for a given camera type
  99097. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99098. * @param name The name of the camera the result will be able to instantiate
  99099. * @param scene The scene the result will construct the camera in
  99100. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99101. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99102. * @returns a factory method to construc the camera
  99103. */
  99104. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99105. /**
  99106. * Compute the world matrix of the camera.
  99107. * @returns the camera world matrix
  99108. */
  99109. computeWorldMatrix(): Matrix;
  99110. /**
  99111. * Parse a JSON and creates the camera from the parsed information
  99112. * @param parsedCamera The JSON to parse
  99113. * @param scene The scene to instantiate the camera in
  99114. * @returns the newly constructed camera
  99115. */
  99116. static Parse(parsedCamera: any, scene: Scene): Camera;
  99117. }
  99118. }
  99119. declare module BABYLON {
  99120. /**
  99121. * Class containing static functions to help procedurally build meshes
  99122. */
  99123. export class DiscBuilder {
  99124. /**
  99125. * Creates a plane polygonal mesh. By default, this is a disc
  99126. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99127. * * 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
  99128. * * 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
  99129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99132. * @param name defines the name of the mesh
  99133. * @param options defines the options used to create the mesh
  99134. * @param scene defines the hosting scene
  99135. * @returns the plane polygonal mesh
  99136. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99137. */
  99138. static CreateDisc(name: string, options: {
  99139. radius?: number;
  99140. tessellation?: number;
  99141. arc?: number;
  99142. updatable?: boolean;
  99143. sideOrientation?: number;
  99144. frontUVs?: Vector4;
  99145. backUVs?: Vector4;
  99146. }, scene?: Nullable<Scene>): Mesh;
  99147. }
  99148. }
  99149. declare module BABYLON {
  99150. /**
  99151. * This represents all the required information to add a fresnel effect on a material:
  99152. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99153. */
  99154. export class FresnelParameters {
  99155. private _isEnabled;
  99156. /**
  99157. * Define if the fresnel effect is enable or not.
  99158. */
  99159. get isEnabled(): boolean;
  99160. set isEnabled(value: boolean);
  99161. /**
  99162. * Define the color used on edges (grazing angle)
  99163. */
  99164. leftColor: Color3;
  99165. /**
  99166. * Define the color used on center
  99167. */
  99168. rightColor: Color3;
  99169. /**
  99170. * Define bias applied to computed fresnel term
  99171. */
  99172. bias: number;
  99173. /**
  99174. * Defined the power exponent applied to fresnel term
  99175. */
  99176. power: number;
  99177. /**
  99178. * Clones the current fresnel and its valuues
  99179. * @returns a clone fresnel configuration
  99180. */
  99181. clone(): FresnelParameters;
  99182. /**
  99183. * Serializes the current fresnel parameters to a JSON representation.
  99184. * @return the JSON serialization
  99185. */
  99186. serialize(): any;
  99187. /**
  99188. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99189. * @param parsedFresnelParameters Define the JSON representation
  99190. * @returns the parsed parameters
  99191. */
  99192. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99193. }
  99194. }
  99195. declare module BABYLON {
  99196. /**
  99197. * Base class of materials working in push mode in babylon JS
  99198. * @hidden
  99199. */
  99200. export class PushMaterial extends Material {
  99201. protected _activeEffect: Effect;
  99202. protected _normalMatrix: Matrix;
  99203. /**
  99204. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99205. * This means that the material can keep using a previous shader while a new one is being compiled.
  99206. * This is mostly used when shader parallel compilation is supported (true by default)
  99207. */
  99208. allowShaderHotSwapping: boolean;
  99209. constructor(name: string, scene: Scene);
  99210. getEffect(): Effect;
  99211. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99212. /**
  99213. * Binds the given world matrix to the active effect
  99214. *
  99215. * @param world the matrix to bind
  99216. */
  99217. bindOnlyWorldMatrix(world: Matrix): void;
  99218. /**
  99219. * Binds the given normal matrix to the active effect
  99220. *
  99221. * @param normalMatrix the matrix to bind
  99222. */
  99223. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99224. bind(world: Matrix, mesh?: Mesh): void;
  99225. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99226. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99227. }
  99228. }
  99229. declare module BABYLON {
  99230. /**
  99231. * This groups all the flags used to control the materials channel.
  99232. */
  99233. export class MaterialFlags {
  99234. private static _DiffuseTextureEnabled;
  99235. /**
  99236. * Are diffuse textures enabled in the application.
  99237. */
  99238. static get DiffuseTextureEnabled(): boolean;
  99239. static set DiffuseTextureEnabled(value: boolean);
  99240. private static _AmbientTextureEnabled;
  99241. /**
  99242. * Are ambient textures enabled in the application.
  99243. */
  99244. static get AmbientTextureEnabled(): boolean;
  99245. static set AmbientTextureEnabled(value: boolean);
  99246. private static _OpacityTextureEnabled;
  99247. /**
  99248. * Are opacity textures enabled in the application.
  99249. */
  99250. static get OpacityTextureEnabled(): boolean;
  99251. static set OpacityTextureEnabled(value: boolean);
  99252. private static _ReflectionTextureEnabled;
  99253. /**
  99254. * Are reflection textures enabled in the application.
  99255. */
  99256. static get ReflectionTextureEnabled(): boolean;
  99257. static set ReflectionTextureEnabled(value: boolean);
  99258. private static _EmissiveTextureEnabled;
  99259. /**
  99260. * Are emissive textures enabled in the application.
  99261. */
  99262. static get EmissiveTextureEnabled(): boolean;
  99263. static set EmissiveTextureEnabled(value: boolean);
  99264. private static _SpecularTextureEnabled;
  99265. /**
  99266. * Are specular textures enabled in the application.
  99267. */
  99268. static get SpecularTextureEnabled(): boolean;
  99269. static set SpecularTextureEnabled(value: boolean);
  99270. private static _BumpTextureEnabled;
  99271. /**
  99272. * Are bump textures enabled in the application.
  99273. */
  99274. static get BumpTextureEnabled(): boolean;
  99275. static set BumpTextureEnabled(value: boolean);
  99276. private static _LightmapTextureEnabled;
  99277. /**
  99278. * Are lightmap textures enabled in the application.
  99279. */
  99280. static get LightmapTextureEnabled(): boolean;
  99281. static set LightmapTextureEnabled(value: boolean);
  99282. private static _RefractionTextureEnabled;
  99283. /**
  99284. * Are refraction textures enabled in the application.
  99285. */
  99286. static get RefractionTextureEnabled(): boolean;
  99287. static set RefractionTextureEnabled(value: boolean);
  99288. private static _ColorGradingTextureEnabled;
  99289. /**
  99290. * Are color grading textures enabled in the application.
  99291. */
  99292. static get ColorGradingTextureEnabled(): boolean;
  99293. static set ColorGradingTextureEnabled(value: boolean);
  99294. private static _FresnelEnabled;
  99295. /**
  99296. * Are fresnels enabled in the application.
  99297. */
  99298. static get FresnelEnabled(): boolean;
  99299. static set FresnelEnabled(value: boolean);
  99300. private static _ClearCoatTextureEnabled;
  99301. /**
  99302. * Are clear coat textures enabled in the application.
  99303. */
  99304. static get ClearCoatTextureEnabled(): boolean;
  99305. static set ClearCoatTextureEnabled(value: boolean);
  99306. private static _ClearCoatBumpTextureEnabled;
  99307. /**
  99308. * Are clear coat bump textures enabled in the application.
  99309. */
  99310. static get ClearCoatBumpTextureEnabled(): boolean;
  99311. static set ClearCoatBumpTextureEnabled(value: boolean);
  99312. private static _ClearCoatTintTextureEnabled;
  99313. /**
  99314. * Are clear coat tint textures enabled in the application.
  99315. */
  99316. static get ClearCoatTintTextureEnabled(): boolean;
  99317. static set ClearCoatTintTextureEnabled(value: boolean);
  99318. private static _SheenTextureEnabled;
  99319. /**
  99320. * Are sheen textures enabled in the application.
  99321. */
  99322. static get SheenTextureEnabled(): boolean;
  99323. static set SheenTextureEnabled(value: boolean);
  99324. private static _AnisotropicTextureEnabled;
  99325. /**
  99326. * Are anisotropic textures enabled in the application.
  99327. */
  99328. static get AnisotropicTextureEnabled(): boolean;
  99329. static set AnisotropicTextureEnabled(value: boolean);
  99330. private static _ThicknessTextureEnabled;
  99331. /**
  99332. * Are thickness textures enabled in the application.
  99333. */
  99334. static get ThicknessTextureEnabled(): boolean;
  99335. static set ThicknessTextureEnabled(value: boolean);
  99336. }
  99337. }
  99338. declare module BABYLON {
  99339. /** @hidden */
  99340. export var defaultFragmentDeclaration: {
  99341. name: string;
  99342. shader: string;
  99343. };
  99344. }
  99345. declare module BABYLON {
  99346. /** @hidden */
  99347. export var defaultUboDeclaration: {
  99348. name: string;
  99349. shader: string;
  99350. };
  99351. }
  99352. declare module BABYLON {
  99353. /** @hidden */
  99354. export var lightFragmentDeclaration: {
  99355. name: string;
  99356. shader: string;
  99357. };
  99358. }
  99359. declare module BABYLON {
  99360. /** @hidden */
  99361. export var lightUboDeclaration: {
  99362. name: string;
  99363. shader: string;
  99364. };
  99365. }
  99366. declare module BABYLON {
  99367. /** @hidden */
  99368. export var lightsFragmentFunctions: {
  99369. name: string;
  99370. shader: string;
  99371. };
  99372. }
  99373. declare module BABYLON {
  99374. /** @hidden */
  99375. export var shadowsFragmentFunctions: {
  99376. name: string;
  99377. shader: string;
  99378. };
  99379. }
  99380. declare module BABYLON {
  99381. /** @hidden */
  99382. export var fresnelFunction: {
  99383. name: string;
  99384. shader: string;
  99385. };
  99386. }
  99387. declare module BABYLON {
  99388. /** @hidden */
  99389. export var reflectionFunction: {
  99390. name: string;
  99391. shader: string;
  99392. };
  99393. }
  99394. declare module BABYLON {
  99395. /** @hidden */
  99396. export var bumpFragmentFunctions: {
  99397. name: string;
  99398. shader: string;
  99399. };
  99400. }
  99401. declare module BABYLON {
  99402. /** @hidden */
  99403. export var logDepthDeclaration: {
  99404. name: string;
  99405. shader: string;
  99406. };
  99407. }
  99408. declare module BABYLON {
  99409. /** @hidden */
  99410. export var bumpFragment: {
  99411. name: string;
  99412. shader: string;
  99413. };
  99414. }
  99415. declare module BABYLON {
  99416. /** @hidden */
  99417. export var depthPrePass: {
  99418. name: string;
  99419. shader: string;
  99420. };
  99421. }
  99422. declare module BABYLON {
  99423. /** @hidden */
  99424. export var lightFragment: {
  99425. name: string;
  99426. shader: string;
  99427. };
  99428. }
  99429. declare module BABYLON {
  99430. /** @hidden */
  99431. export var logDepthFragment: {
  99432. name: string;
  99433. shader: string;
  99434. };
  99435. }
  99436. declare module BABYLON {
  99437. /** @hidden */
  99438. export var defaultPixelShader: {
  99439. name: string;
  99440. shader: string;
  99441. };
  99442. }
  99443. declare module BABYLON {
  99444. /** @hidden */
  99445. export var defaultVertexDeclaration: {
  99446. name: string;
  99447. shader: string;
  99448. };
  99449. }
  99450. declare module BABYLON {
  99451. /** @hidden */
  99452. export var bumpVertexDeclaration: {
  99453. name: string;
  99454. shader: string;
  99455. };
  99456. }
  99457. declare module BABYLON {
  99458. /** @hidden */
  99459. export var bumpVertex: {
  99460. name: string;
  99461. shader: string;
  99462. };
  99463. }
  99464. declare module BABYLON {
  99465. /** @hidden */
  99466. export var fogVertex: {
  99467. name: string;
  99468. shader: string;
  99469. };
  99470. }
  99471. declare module BABYLON {
  99472. /** @hidden */
  99473. export var shadowsVertex: {
  99474. name: string;
  99475. shader: string;
  99476. };
  99477. }
  99478. declare module BABYLON {
  99479. /** @hidden */
  99480. export var pointCloudVertex: {
  99481. name: string;
  99482. shader: string;
  99483. };
  99484. }
  99485. declare module BABYLON {
  99486. /** @hidden */
  99487. export var logDepthVertex: {
  99488. name: string;
  99489. shader: string;
  99490. };
  99491. }
  99492. declare module BABYLON {
  99493. /** @hidden */
  99494. export var defaultVertexShader: {
  99495. name: string;
  99496. shader: string;
  99497. };
  99498. }
  99499. declare module BABYLON {
  99500. /** @hidden */
  99501. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99502. MAINUV1: boolean;
  99503. MAINUV2: boolean;
  99504. DIFFUSE: boolean;
  99505. DIFFUSEDIRECTUV: number;
  99506. AMBIENT: boolean;
  99507. AMBIENTDIRECTUV: number;
  99508. OPACITY: boolean;
  99509. OPACITYDIRECTUV: number;
  99510. OPACITYRGB: boolean;
  99511. REFLECTION: boolean;
  99512. EMISSIVE: boolean;
  99513. EMISSIVEDIRECTUV: number;
  99514. SPECULAR: boolean;
  99515. SPECULARDIRECTUV: number;
  99516. BUMP: boolean;
  99517. BUMPDIRECTUV: number;
  99518. PARALLAX: boolean;
  99519. PARALLAXOCCLUSION: boolean;
  99520. SPECULAROVERALPHA: boolean;
  99521. CLIPPLANE: boolean;
  99522. CLIPPLANE2: boolean;
  99523. CLIPPLANE3: boolean;
  99524. CLIPPLANE4: boolean;
  99525. CLIPPLANE5: boolean;
  99526. CLIPPLANE6: boolean;
  99527. ALPHATEST: boolean;
  99528. DEPTHPREPASS: boolean;
  99529. ALPHAFROMDIFFUSE: boolean;
  99530. POINTSIZE: boolean;
  99531. FOG: boolean;
  99532. SPECULARTERM: boolean;
  99533. DIFFUSEFRESNEL: boolean;
  99534. OPACITYFRESNEL: boolean;
  99535. REFLECTIONFRESNEL: boolean;
  99536. REFRACTIONFRESNEL: boolean;
  99537. EMISSIVEFRESNEL: boolean;
  99538. FRESNEL: boolean;
  99539. NORMAL: boolean;
  99540. UV1: boolean;
  99541. UV2: boolean;
  99542. VERTEXCOLOR: boolean;
  99543. VERTEXALPHA: boolean;
  99544. NUM_BONE_INFLUENCERS: number;
  99545. BonesPerMesh: number;
  99546. BONETEXTURE: boolean;
  99547. INSTANCES: boolean;
  99548. GLOSSINESS: boolean;
  99549. ROUGHNESS: boolean;
  99550. EMISSIVEASILLUMINATION: boolean;
  99551. LINKEMISSIVEWITHDIFFUSE: boolean;
  99552. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99553. LIGHTMAP: boolean;
  99554. LIGHTMAPDIRECTUV: number;
  99555. OBJECTSPACE_NORMALMAP: boolean;
  99556. USELIGHTMAPASSHADOWMAP: boolean;
  99557. REFLECTIONMAP_3D: boolean;
  99558. REFLECTIONMAP_SPHERICAL: boolean;
  99559. REFLECTIONMAP_PLANAR: boolean;
  99560. REFLECTIONMAP_CUBIC: boolean;
  99561. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99562. REFLECTIONMAP_PROJECTION: boolean;
  99563. REFLECTIONMAP_SKYBOX: boolean;
  99564. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  99565. REFLECTIONMAP_EXPLICIT: boolean;
  99566. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99567. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99568. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99569. INVERTCUBICMAP: boolean;
  99570. LOGARITHMICDEPTH: boolean;
  99571. REFRACTION: boolean;
  99572. REFRACTIONMAP_3D: boolean;
  99573. REFLECTIONOVERALPHA: boolean;
  99574. TWOSIDEDLIGHTING: boolean;
  99575. SHADOWFLOAT: boolean;
  99576. MORPHTARGETS: boolean;
  99577. MORPHTARGETS_NORMAL: boolean;
  99578. MORPHTARGETS_TANGENT: boolean;
  99579. MORPHTARGETS_UV: boolean;
  99580. NUM_MORPH_INFLUENCERS: number;
  99581. NONUNIFORMSCALING: boolean;
  99582. PREMULTIPLYALPHA: boolean;
  99583. IMAGEPROCESSING: boolean;
  99584. VIGNETTE: boolean;
  99585. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99586. VIGNETTEBLENDMODEOPAQUE: boolean;
  99587. TONEMAPPING: boolean;
  99588. TONEMAPPING_ACES: boolean;
  99589. CONTRAST: boolean;
  99590. COLORCURVES: boolean;
  99591. COLORGRADING: boolean;
  99592. COLORGRADING3D: boolean;
  99593. SAMPLER3DGREENDEPTH: boolean;
  99594. SAMPLER3DBGRMAP: boolean;
  99595. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99596. MULTIVIEW: boolean;
  99597. /**
  99598. * If the reflection texture on this material is in linear color space
  99599. * @hidden
  99600. */
  99601. IS_REFLECTION_LINEAR: boolean;
  99602. /**
  99603. * If the refraction texture on this material is in linear color space
  99604. * @hidden
  99605. */
  99606. IS_REFRACTION_LINEAR: boolean;
  99607. EXPOSURE: boolean;
  99608. constructor();
  99609. setReflectionMode(modeToEnable: string): void;
  99610. }
  99611. /**
  99612. * This is the default material used in Babylon. It is the best trade off between quality
  99613. * and performances.
  99614. * @see http://doc.babylonjs.com/babylon101/materials
  99615. */
  99616. export class StandardMaterial extends PushMaterial {
  99617. private _diffuseTexture;
  99618. /**
  99619. * The basic texture of the material as viewed under a light.
  99620. */
  99621. diffuseTexture: Nullable<BaseTexture>;
  99622. private _ambientTexture;
  99623. /**
  99624. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99625. */
  99626. ambientTexture: Nullable<BaseTexture>;
  99627. private _opacityTexture;
  99628. /**
  99629. * Define the transparency of the material from a texture.
  99630. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99631. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99632. */
  99633. opacityTexture: Nullable<BaseTexture>;
  99634. private _reflectionTexture;
  99635. /**
  99636. * Define the texture used to display the reflection.
  99637. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99638. */
  99639. reflectionTexture: Nullable<BaseTexture>;
  99640. private _emissiveTexture;
  99641. /**
  99642. * Define texture of the material as if self lit.
  99643. * This will be mixed in the final result even in the absence of light.
  99644. */
  99645. emissiveTexture: Nullable<BaseTexture>;
  99646. private _specularTexture;
  99647. /**
  99648. * Define how the color and intensity of the highlight given by the light in the material.
  99649. */
  99650. specularTexture: Nullable<BaseTexture>;
  99651. private _bumpTexture;
  99652. /**
  99653. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99654. * 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.
  99655. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99656. */
  99657. bumpTexture: Nullable<BaseTexture>;
  99658. private _lightmapTexture;
  99659. /**
  99660. * Complex lighting can be computationally expensive to compute at runtime.
  99661. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99662. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99663. */
  99664. lightmapTexture: Nullable<BaseTexture>;
  99665. private _refractionTexture;
  99666. /**
  99667. * Define the texture used to display the refraction.
  99668. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99669. */
  99670. refractionTexture: Nullable<BaseTexture>;
  99671. /**
  99672. * The color of the material lit by the environmental background lighting.
  99673. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99674. */
  99675. ambientColor: Color3;
  99676. /**
  99677. * The basic color of the material as viewed under a light.
  99678. */
  99679. diffuseColor: Color3;
  99680. /**
  99681. * Define how the color and intensity of the highlight given by the light in the material.
  99682. */
  99683. specularColor: Color3;
  99684. /**
  99685. * Define the color of the material as if self lit.
  99686. * This will be mixed in the final result even in the absence of light.
  99687. */
  99688. emissiveColor: Color3;
  99689. /**
  99690. * Defines how sharp are the highlights in the material.
  99691. * The bigger the value the sharper giving a more glossy feeling to the result.
  99692. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99693. */
  99694. specularPower: number;
  99695. private _useAlphaFromDiffuseTexture;
  99696. /**
  99697. * Does the transparency come from the diffuse texture alpha channel.
  99698. */
  99699. useAlphaFromDiffuseTexture: boolean;
  99700. private _useEmissiveAsIllumination;
  99701. /**
  99702. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99703. */
  99704. useEmissiveAsIllumination: boolean;
  99705. private _linkEmissiveWithDiffuse;
  99706. /**
  99707. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99708. * the emissive level when the final color is close to one.
  99709. */
  99710. linkEmissiveWithDiffuse: boolean;
  99711. private _useSpecularOverAlpha;
  99712. /**
  99713. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99714. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99715. */
  99716. useSpecularOverAlpha: boolean;
  99717. private _useReflectionOverAlpha;
  99718. /**
  99719. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99720. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99721. */
  99722. useReflectionOverAlpha: boolean;
  99723. private _disableLighting;
  99724. /**
  99725. * Does lights from the scene impacts this material.
  99726. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99727. */
  99728. disableLighting: boolean;
  99729. private _useObjectSpaceNormalMap;
  99730. /**
  99731. * Allows using an object space normal map (instead of tangent space).
  99732. */
  99733. useObjectSpaceNormalMap: boolean;
  99734. private _useParallax;
  99735. /**
  99736. * Is parallax enabled or not.
  99737. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99738. */
  99739. useParallax: boolean;
  99740. private _useParallaxOcclusion;
  99741. /**
  99742. * Is parallax occlusion enabled or not.
  99743. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99744. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99745. */
  99746. useParallaxOcclusion: boolean;
  99747. /**
  99748. * 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.
  99749. */
  99750. parallaxScaleBias: number;
  99751. private _roughness;
  99752. /**
  99753. * Helps to define how blurry the reflections should appears in the material.
  99754. */
  99755. roughness: number;
  99756. /**
  99757. * In case of refraction, define the value of the index of refraction.
  99758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99759. */
  99760. indexOfRefraction: number;
  99761. /**
  99762. * Invert the refraction texture alongside the y axis.
  99763. * It can be useful with procedural textures or probe for instance.
  99764. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99765. */
  99766. invertRefractionY: boolean;
  99767. /**
  99768. * Defines the alpha limits in alpha test mode.
  99769. */
  99770. alphaCutOff: number;
  99771. private _useLightmapAsShadowmap;
  99772. /**
  99773. * In case of light mapping, define whether the map contains light or shadow informations.
  99774. */
  99775. useLightmapAsShadowmap: boolean;
  99776. private _diffuseFresnelParameters;
  99777. /**
  99778. * Define the diffuse fresnel parameters of the material.
  99779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99780. */
  99781. diffuseFresnelParameters: FresnelParameters;
  99782. private _opacityFresnelParameters;
  99783. /**
  99784. * Define the opacity fresnel parameters of the material.
  99785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99786. */
  99787. opacityFresnelParameters: FresnelParameters;
  99788. private _reflectionFresnelParameters;
  99789. /**
  99790. * Define the reflection fresnel parameters of the material.
  99791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99792. */
  99793. reflectionFresnelParameters: FresnelParameters;
  99794. private _refractionFresnelParameters;
  99795. /**
  99796. * Define the refraction fresnel parameters of the material.
  99797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99798. */
  99799. refractionFresnelParameters: FresnelParameters;
  99800. private _emissiveFresnelParameters;
  99801. /**
  99802. * Define the emissive fresnel parameters of the material.
  99803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99804. */
  99805. emissiveFresnelParameters: FresnelParameters;
  99806. private _useReflectionFresnelFromSpecular;
  99807. /**
  99808. * If true automatically deducts the fresnels values from the material specularity.
  99809. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99810. */
  99811. useReflectionFresnelFromSpecular: boolean;
  99812. private _useGlossinessFromSpecularMapAlpha;
  99813. /**
  99814. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99815. */
  99816. useGlossinessFromSpecularMapAlpha: boolean;
  99817. private _maxSimultaneousLights;
  99818. /**
  99819. * Defines the maximum number of lights that can be used in the material
  99820. */
  99821. maxSimultaneousLights: number;
  99822. private _invertNormalMapX;
  99823. /**
  99824. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99825. */
  99826. invertNormalMapX: boolean;
  99827. private _invertNormalMapY;
  99828. /**
  99829. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99830. */
  99831. invertNormalMapY: boolean;
  99832. private _twoSidedLighting;
  99833. /**
  99834. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99835. */
  99836. twoSidedLighting: boolean;
  99837. /**
  99838. * Default configuration related to image processing available in the standard Material.
  99839. */
  99840. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99841. /**
  99842. * Gets the image processing configuration used either in this material.
  99843. */
  99844. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99845. /**
  99846. * Sets the Default image processing configuration used either in the this material.
  99847. *
  99848. * If sets to null, the scene one is in use.
  99849. */
  99850. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99851. /**
  99852. * Keep track of the image processing observer to allow dispose and replace.
  99853. */
  99854. private _imageProcessingObserver;
  99855. /**
  99856. * Attaches a new image processing configuration to the Standard Material.
  99857. * @param configuration
  99858. */
  99859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99860. /**
  99861. * Gets wether the color curves effect is enabled.
  99862. */
  99863. get cameraColorCurvesEnabled(): boolean;
  99864. /**
  99865. * Sets wether the color curves effect is enabled.
  99866. */
  99867. set cameraColorCurvesEnabled(value: boolean);
  99868. /**
  99869. * Gets wether the color grading effect is enabled.
  99870. */
  99871. get cameraColorGradingEnabled(): boolean;
  99872. /**
  99873. * Gets wether the color grading effect is enabled.
  99874. */
  99875. set cameraColorGradingEnabled(value: boolean);
  99876. /**
  99877. * Gets wether tonemapping is enabled or not.
  99878. */
  99879. get cameraToneMappingEnabled(): boolean;
  99880. /**
  99881. * Sets wether tonemapping is enabled or not
  99882. */
  99883. set cameraToneMappingEnabled(value: boolean);
  99884. /**
  99885. * The camera exposure used on this material.
  99886. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99887. * This corresponds to a photographic exposure.
  99888. */
  99889. get cameraExposure(): number;
  99890. /**
  99891. * The camera exposure used on this material.
  99892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99893. * This corresponds to a photographic exposure.
  99894. */
  99895. set cameraExposure(value: number);
  99896. /**
  99897. * Gets The camera contrast used on this material.
  99898. */
  99899. get cameraContrast(): number;
  99900. /**
  99901. * Sets The camera contrast used on this material.
  99902. */
  99903. set cameraContrast(value: number);
  99904. /**
  99905. * Gets the Color Grading 2D Lookup Texture.
  99906. */
  99907. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99908. /**
  99909. * Sets the Color Grading 2D Lookup Texture.
  99910. */
  99911. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99912. /**
  99913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99915. * 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;
  99916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99917. */
  99918. get cameraColorCurves(): Nullable<ColorCurves>;
  99919. /**
  99920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99922. * 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;
  99923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99924. */
  99925. set cameraColorCurves(value: Nullable<ColorCurves>);
  99926. /**
  99927. * Custom callback helping to override the default shader used in the material.
  99928. */
  99929. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99930. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99931. protected _worldViewProjectionMatrix: Matrix;
  99932. protected _globalAmbientColor: Color3;
  99933. protected _useLogarithmicDepth: boolean;
  99934. protected _rebuildInParallel: boolean;
  99935. /**
  99936. * Instantiates a new standard material.
  99937. * This is the default material used in Babylon. It is the best trade off between quality
  99938. * and performances.
  99939. * @see http://doc.babylonjs.com/babylon101/materials
  99940. * @param name Define the name of the material in the scene
  99941. * @param scene Define the scene the material belong to
  99942. */
  99943. constructor(name: string, scene: Scene);
  99944. /**
  99945. * Gets a boolean indicating that current material needs to register RTT
  99946. */
  99947. get hasRenderTargetTextures(): boolean;
  99948. /**
  99949. * Gets the current class name of the material e.g. "StandardMaterial"
  99950. * Mainly use in serialization.
  99951. * @returns the class name
  99952. */
  99953. getClassName(): string;
  99954. /**
  99955. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99956. * You can try switching to logarithmic depth.
  99957. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99958. */
  99959. get useLogarithmicDepth(): boolean;
  99960. set useLogarithmicDepth(value: boolean);
  99961. /**
  99962. * Specifies if the material will require alpha blending
  99963. * @returns a boolean specifying if alpha blending is needed
  99964. */
  99965. needAlphaBlending(): boolean;
  99966. /**
  99967. * Specifies if this material should be rendered in alpha test mode
  99968. * @returns a boolean specifying if an alpha test is needed.
  99969. */
  99970. needAlphaTesting(): boolean;
  99971. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99972. /**
  99973. * Get the texture used for alpha test purpose.
  99974. * @returns the diffuse texture in case of the standard material.
  99975. */
  99976. getAlphaTestTexture(): Nullable<BaseTexture>;
  99977. /**
  99978. * Get if the submesh is ready to be used and all its information available.
  99979. * Child classes can use it to update shaders
  99980. * @param mesh defines the mesh to check
  99981. * @param subMesh defines which submesh to check
  99982. * @param useInstances specifies that instances should be used
  99983. * @returns a boolean indicating that the submesh is ready or not
  99984. */
  99985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99986. /**
  99987. * Builds the material UBO layouts.
  99988. * Used internally during the effect preparation.
  99989. */
  99990. buildUniformLayout(): void;
  99991. /**
  99992. * Unbinds the material from the mesh
  99993. */
  99994. unbind(): void;
  99995. /**
  99996. * Binds the submesh to this material by preparing the effect and shader to draw
  99997. * @param world defines the world transformation matrix
  99998. * @param mesh defines the mesh containing the submesh
  99999. * @param subMesh defines the submesh to bind the material to
  100000. */
  100001. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100002. /**
  100003. * Get the list of animatables in the material.
  100004. * @returns the list of animatables object used in the material
  100005. */
  100006. getAnimatables(): IAnimatable[];
  100007. /**
  100008. * Gets the active textures from the material
  100009. * @returns an array of textures
  100010. */
  100011. getActiveTextures(): BaseTexture[];
  100012. /**
  100013. * Specifies if the material uses a texture
  100014. * @param texture defines the texture to check against the material
  100015. * @returns a boolean specifying if the material uses the texture
  100016. */
  100017. hasTexture(texture: BaseTexture): boolean;
  100018. /**
  100019. * Disposes the material
  100020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100022. */
  100023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100024. /**
  100025. * Makes a duplicate of the material, and gives it a new name
  100026. * @param name defines the new name for the duplicated material
  100027. * @returns the cloned material
  100028. */
  100029. clone(name: string): StandardMaterial;
  100030. /**
  100031. * Serializes this material in a JSON representation
  100032. * @returns the serialized material object
  100033. */
  100034. serialize(): any;
  100035. /**
  100036. * Creates a standard material from parsed material data
  100037. * @param source defines the JSON representation of the material
  100038. * @param scene defines the hosting scene
  100039. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100040. * @returns a new standard material
  100041. */
  100042. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100043. /**
  100044. * Are diffuse textures enabled in the application.
  100045. */
  100046. static get DiffuseTextureEnabled(): boolean;
  100047. static set DiffuseTextureEnabled(value: boolean);
  100048. /**
  100049. * Are ambient textures enabled in the application.
  100050. */
  100051. static get AmbientTextureEnabled(): boolean;
  100052. static set AmbientTextureEnabled(value: boolean);
  100053. /**
  100054. * Are opacity textures enabled in the application.
  100055. */
  100056. static get OpacityTextureEnabled(): boolean;
  100057. static set OpacityTextureEnabled(value: boolean);
  100058. /**
  100059. * Are reflection textures enabled in the application.
  100060. */
  100061. static get ReflectionTextureEnabled(): boolean;
  100062. static set ReflectionTextureEnabled(value: boolean);
  100063. /**
  100064. * Are emissive textures enabled in the application.
  100065. */
  100066. static get EmissiveTextureEnabled(): boolean;
  100067. static set EmissiveTextureEnabled(value: boolean);
  100068. /**
  100069. * Are specular textures enabled in the application.
  100070. */
  100071. static get SpecularTextureEnabled(): boolean;
  100072. static set SpecularTextureEnabled(value: boolean);
  100073. /**
  100074. * Are bump textures enabled in the application.
  100075. */
  100076. static get BumpTextureEnabled(): boolean;
  100077. static set BumpTextureEnabled(value: boolean);
  100078. /**
  100079. * Are lightmap textures enabled in the application.
  100080. */
  100081. static get LightmapTextureEnabled(): boolean;
  100082. static set LightmapTextureEnabled(value: boolean);
  100083. /**
  100084. * Are refraction textures enabled in the application.
  100085. */
  100086. static get RefractionTextureEnabled(): boolean;
  100087. static set RefractionTextureEnabled(value: boolean);
  100088. /**
  100089. * Are color grading textures enabled in the application.
  100090. */
  100091. static get ColorGradingTextureEnabled(): boolean;
  100092. static set ColorGradingTextureEnabled(value: boolean);
  100093. /**
  100094. * Are fresnels enabled in the application.
  100095. */
  100096. static get FresnelEnabled(): boolean;
  100097. static set FresnelEnabled(value: boolean);
  100098. }
  100099. }
  100100. declare module BABYLON {
  100101. /**
  100102. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100103. *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.
  100104. * The SPS is also a particle system. It provides some methods to manage the particles.
  100105. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100106. *
  100107. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100108. */
  100109. export class SolidParticleSystem implements IDisposable {
  100110. /**
  100111. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100112. * Example : var p = SPS.particles[i];
  100113. */
  100114. particles: SolidParticle[];
  100115. /**
  100116. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100117. */
  100118. nbParticles: number;
  100119. /**
  100120. * If the particles must ever face the camera (default false). Useful for planar particles.
  100121. */
  100122. billboard: boolean;
  100123. /**
  100124. * Recompute normals when adding a shape
  100125. */
  100126. recomputeNormals: boolean;
  100127. /**
  100128. * This a counter ofr your own usage. It's not set by any SPS functions.
  100129. */
  100130. counter: number;
  100131. /**
  100132. * The SPS name. This name is also given to the underlying mesh.
  100133. */
  100134. name: string;
  100135. /**
  100136. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100137. */
  100138. mesh: Mesh;
  100139. /**
  100140. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100141. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100142. */
  100143. vars: any;
  100144. /**
  100145. * This array is populated when the SPS is set as 'pickable'.
  100146. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100147. * Each element of this array is an object `{idx: int, faceId: int}`.
  100148. * `idx` is the picked particle index in the `SPS.particles` array
  100149. * `faceId` is the picked face index counted within this particle.
  100150. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100151. */
  100152. pickedParticles: {
  100153. idx: number;
  100154. faceId: number;
  100155. }[];
  100156. /**
  100157. * This array is populated when `enableDepthSort` is set to true.
  100158. * Each element of this array is an instance of the class DepthSortedParticle.
  100159. */
  100160. depthSortedParticles: DepthSortedParticle[];
  100161. /**
  100162. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100163. * @hidden
  100164. */
  100165. _bSphereOnly: boolean;
  100166. /**
  100167. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100168. * @hidden
  100169. */
  100170. _bSphereRadiusFactor: number;
  100171. private _scene;
  100172. private _positions;
  100173. private _indices;
  100174. private _normals;
  100175. private _colors;
  100176. private _uvs;
  100177. private _indices32;
  100178. private _positions32;
  100179. private _normals32;
  100180. private _fixedNormal32;
  100181. private _colors32;
  100182. private _uvs32;
  100183. private _index;
  100184. private _updatable;
  100185. private _pickable;
  100186. private _isVisibilityBoxLocked;
  100187. private _alwaysVisible;
  100188. private _depthSort;
  100189. private _expandable;
  100190. private _shapeCounter;
  100191. private _copy;
  100192. private _color;
  100193. private _computeParticleColor;
  100194. private _computeParticleTexture;
  100195. private _computeParticleRotation;
  100196. private _computeParticleVertex;
  100197. private _computeBoundingBox;
  100198. private _depthSortParticles;
  100199. private _camera;
  100200. private _mustUnrotateFixedNormals;
  100201. private _particlesIntersect;
  100202. private _needs32Bits;
  100203. private _isNotBuilt;
  100204. private _lastParticleId;
  100205. private _idxOfId;
  100206. private _multimaterialEnabled;
  100207. private _useModelMaterial;
  100208. private _indicesByMaterial;
  100209. private _materialIndexes;
  100210. private _depthSortFunction;
  100211. private _materialSortFunction;
  100212. private _materials;
  100213. private _multimaterial;
  100214. private _materialIndexesById;
  100215. private _defaultMaterial;
  100216. private _autoUpdateSubMeshes;
  100217. /**
  100218. * Creates a SPS (Solid Particle System) object.
  100219. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100220. * @param scene (Scene) is the scene in which the SPS is added.
  100221. * @param options defines the options of the sps e.g.
  100222. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100223. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100224. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100225. * * 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.
  100226. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100227. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100228. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100229. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100230. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100231. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100232. */
  100233. constructor(name: string, scene: Scene, options?: {
  100234. updatable?: boolean;
  100235. isPickable?: boolean;
  100236. enableDepthSort?: boolean;
  100237. particleIntersection?: boolean;
  100238. boundingSphereOnly?: boolean;
  100239. bSphereRadiusFactor?: number;
  100240. expandable?: boolean;
  100241. useModelMaterial?: boolean;
  100242. enableMultiMaterial?: boolean;
  100243. });
  100244. /**
  100245. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100246. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100247. * @returns the created mesh
  100248. */
  100249. buildMesh(): Mesh;
  100250. /**
  100251. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100252. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100253. * Thus the particles generated from `digest()` have their property `position` set yet.
  100254. * @param mesh ( Mesh ) is the mesh to be digested
  100255. * @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
  100256. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100257. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100258. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100259. * @returns the current SPS
  100260. */
  100261. digest(mesh: Mesh, options?: {
  100262. facetNb?: number;
  100263. number?: number;
  100264. delta?: number;
  100265. storage?: [];
  100266. }): SolidParticleSystem;
  100267. /**
  100268. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100269. * @hidden
  100270. */
  100271. private _unrotateFixedNormals;
  100272. /**
  100273. * Resets the temporary working copy particle
  100274. * @hidden
  100275. */
  100276. private _resetCopy;
  100277. /**
  100278. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100279. * @param p the current index in the positions array to be updated
  100280. * @param ind the current index in the indices array
  100281. * @param shape a Vector3 array, the shape geometry
  100282. * @param positions the positions array to be updated
  100283. * @param meshInd the shape indices array
  100284. * @param indices the indices array to be updated
  100285. * @param meshUV the shape uv array
  100286. * @param uvs the uv array to be updated
  100287. * @param meshCol the shape color array
  100288. * @param colors the color array to be updated
  100289. * @param meshNor the shape normals array
  100290. * @param normals the normals array to be updated
  100291. * @param idx the particle index
  100292. * @param idxInShape the particle index in its shape
  100293. * @param options the addShape() method passed options
  100294. * @model the particle model
  100295. * @hidden
  100296. */
  100297. private _meshBuilder;
  100298. /**
  100299. * Returns a shape Vector3 array from positions float array
  100300. * @param positions float array
  100301. * @returns a vector3 array
  100302. * @hidden
  100303. */
  100304. private _posToShape;
  100305. /**
  100306. * Returns a shapeUV array from a float uvs (array deep copy)
  100307. * @param uvs as a float array
  100308. * @returns a shapeUV array
  100309. * @hidden
  100310. */
  100311. private _uvsToShapeUV;
  100312. /**
  100313. * Adds a new particle object in the particles array
  100314. * @param idx particle index in particles array
  100315. * @param id particle id
  100316. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100317. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100318. * @param model particle ModelShape object
  100319. * @param shapeId model shape identifier
  100320. * @param idxInShape index of the particle in the current model
  100321. * @param bInfo model bounding info object
  100322. * @param storage target storage array, if any
  100323. * @hidden
  100324. */
  100325. private _addParticle;
  100326. /**
  100327. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100328. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100329. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100330. * @param nb (positive integer) the number of particles to be created from this model
  100331. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100332. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100333. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100334. * @returns the number of shapes in the system
  100335. */
  100336. addShape(mesh: Mesh, nb: number, options?: {
  100337. positionFunction?: any;
  100338. vertexFunction?: any;
  100339. storage?: [];
  100340. }): number;
  100341. /**
  100342. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100343. * @hidden
  100344. */
  100345. private _rebuildParticle;
  100346. /**
  100347. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100348. * @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.
  100349. * @returns the SPS.
  100350. */
  100351. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100352. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100353. * Returns an array with the removed particles.
  100354. * 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.
  100355. * The SPS can't be empty so at least one particle needs to remain in place.
  100356. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100357. * @param start index of the first particle to remove
  100358. * @param end index of the last particle to remove (included)
  100359. * @returns an array populated with the removed particles
  100360. */
  100361. removeParticles(start: number, end: number): SolidParticle[];
  100362. /**
  100363. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100364. * @param solidParticleArray an array populated with Solid Particles objects
  100365. * @returns the SPS
  100366. */
  100367. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100368. /**
  100369. * Creates a new particle and modifies the SPS mesh geometry :
  100370. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100371. * - calls _addParticle() to populate the particle array
  100372. * factorized code from addShape() and insertParticlesFromArray()
  100373. * @param idx particle index in the particles array
  100374. * @param i particle index in its shape
  100375. * @param modelShape particle ModelShape object
  100376. * @param shape shape vertex array
  100377. * @param meshInd shape indices array
  100378. * @param meshUV shape uv array
  100379. * @param meshCol shape color array
  100380. * @param meshNor shape normals array
  100381. * @param bbInfo shape bounding info
  100382. * @param storage target particle storage
  100383. * @options addShape() passed options
  100384. * @hidden
  100385. */
  100386. private _insertNewParticle;
  100387. /**
  100388. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100389. * This method calls `updateParticle()` for each particle of the SPS.
  100390. * For an animated SPS, it is usually called within the render loop.
  100391. * 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.
  100392. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100393. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100394. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100395. * @returns the SPS.
  100396. */
  100397. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100398. /**
  100399. * Disposes the SPS.
  100400. */
  100401. dispose(): void;
  100402. /**
  100403. * Returns a SolidParticle object from its identifier : particle.id
  100404. * @param id (integer) the particle Id
  100405. * @returns the searched particle or null if not found in the SPS.
  100406. */
  100407. getParticleById(id: number): Nullable<SolidParticle>;
  100408. /**
  100409. * Returns a new array populated with the particles having the passed shapeId.
  100410. * @param shapeId (integer) the shape identifier
  100411. * @returns a new solid particle array
  100412. */
  100413. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100414. /**
  100415. * Populates the passed array "ref" with the particles having the passed shapeId.
  100416. * @param shapeId the shape identifier
  100417. * @returns the SPS
  100418. * @param ref
  100419. */
  100420. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100421. /**
  100422. * Computes the required SubMeshes according the materials assigned to the particles.
  100423. * @returns the solid particle system.
  100424. * Does nothing if called before the SPS mesh is built.
  100425. */
  100426. computeSubMeshes(): SolidParticleSystem;
  100427. /**
  100428. * Sorts the solid particles by material when MultiMaterial is enabled.
  100429. * Updates the indices32 array.
  100430. * Updates the indicesByMaterial array.
  100431. * Updates the mesh indices array.
  100432. * @returns the SPS
  100433. * @hidden
  100434. */
  100435. private _sortParticlesByMaterial;
  100436. /**
  100437. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100438. * @hidden
  100439. */
  100440. private _setMaterialIndexesById;
  100441. /**
  100442. * Returns an array with unique values of Materials from the passed array
  100443. * @param array the material array to be checked and filtered
  100444. * @hidden
  100445. */
  100446. private _filterUniqueMaterialId;
  100447. /**
  100448. * Sets a new Standard Material as _defaultMaterial if not already set.
  100449. * @hidden
  100450. */
  100451. private _setDefaultMaterial;
  100452. /**
  100453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100454. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100455. * @returns the SPS.
  100456. */
  100457. refreshVisibleSize(): SolidParticleSystem;
  100458. /**
  100459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100460. * @param size the size (float) of the visibility box
  100461. * note : this doesn't lock the SPS mesh bounding box.
  100462. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100463. */
  100464. setVisibilityBox(size: number): void;
  100465. /**
  100466. * Gets whether the SPS as always visible or not
  100467. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100468. */
  100469. get isAlwaysVisible(): boolean;
  100470. /**
  100471. * Sets the SPS as always visible or not
  100472. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100473. */
  100474. set isAlwaysVisible(val: boolean);
  100475. /**
  100476. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100477. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100478. */
  100479. set isVisibilityBoxLocked(val: boolean);
  100480. /**
  100481. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100482. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100483. */
  100484. get isVisibilityBoxLocked(): boolean;
  100485. /**
  100486. * Tells to `setParticles()` to compute the particle rotations or not.
  100487. * Default value : true. The SPS is faster when it's set to false.
  100488. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100489. */
  100490. set computeParticleRotation(val: boolean);
  100491. /**
  100492. * Tells to `setParticles()` to compute the particle colors or not.
  100493. * Default value : true. The SPS is faster when it's set to false.
  100494. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100495. */
  100496. set computeParticleColor(val: boolean);
  100497. set computeParticleTexture(val: boolean);
  100498. /**
  100499. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100500. * Default value : false. The SPS is faster when it's set to false.
  100501. * Note : the particle custom vertex positions aren't stored values.
  100502. */
  100503. set computeParticleVertex(val: boolean);
  100504. /**
  100505. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100506. */
  100507. set computeBoundingBox(val: boolean);
  100508. /**
  100509. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100510. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100511. * Default : `true`
  100512. */
  100513. set depthSortParticles(val: boolean);
  100514. /**
  100515. * Gets if `setParticles()` computes the particle rotations or not.
  100516. * Default value : true. The SPS is faster when it's set to false.
  100517. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100518. */
  100519. get computeParticleRotation(): boolean;
  100520. /**
  100521. * Gets if `setParticles()` computes the particle colors or not.
  100522. * Default value : true. The SPS is faster when it's set to false.
  100523. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100524. */
  100525. get computeParticleColor(): boolean;
  100526. /**
  100527. * Gets if `setParticles()` computes the particle textures or not.
  100528. * Default value : true. The SPS is faster when it's set to false.
  100529. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100530. */
  100531. get computeParticleTexture(): boolean;
  100532. /**
  100533. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100534. * Default value : false. The SPS is faster when it's set to false.
  100535. * Note : the particle custom vertex positions aren't stored values.
  100536. */
  100537. get computeParticleVertex(): boolean;
  100538. /**
  100539. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100540. */
  100541. get computeBoundingBox(): boolean;
  100542. /**
  100543. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100544. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100545. * Default : `true`
  100546. */
  100547. get depthSortParticles(): boolean;
  100548. /**
  100549. * Gets if the SPS is created as expandable at construction time.
  100550. * Default : `false`
  100551. */
  100552. get expandable(): boolean;
  100553. /**
  100554. * Gets if the SPS supports the Multi Materials
  100555. */
  100556. get multimaterialEnabled(): boolean;
  100557. /**
  100558. * Gets if the SPS uses the model materials for its own multimaterial.
  100559. */
  100560. get useModelMaterial(): boolean;
  100561. /**
  100562. * The SPS used material array.
  100563. */
  100564. get materials(): Material[];
  100565. /**
  100566. * Sets the SPS MultiMaterial from the passed materials.
  100567. * Note : the passed array is internally copied and not used then by reference.
  100568. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100569. */
  100570. setMultiMaterial(materials: Material[]): void;
  100571. /**
  100572. * The SPS computed multimaterial object
  100573. */
  100574. get multimaterial(): MultiMaterial;
  100575. set multimaterial(mm: MultiMaterial);
  100576. /**
  100577. * If the subMeshes must be updated on the next call to setParticles()
  100578. */
  100579. get autoUpdateSubMeshes(): boolean;
  100580. set autoUpdateSubMeshes(val: boolean);
  100581. /**
  100582. * This function does nothing. It may be overwritten to set all the particle first values.
  100583. * The SPS doesn't call this function, you may have to call it by your own.
  100584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100585. */
  100586. initParticles(): void;
  100587. /**
  100588. * This function does nothing. It may be overwritten to recycle a particle.
  100589. * The SPS doesn't call this function, you may have to call it by your own.
  100590. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100591. * @param particle The particle to recycle
  100592. * @returns the recycled particle
  100593. */
  100594. recycleParticle(particle: SolidParticle): SolidParticle;
  100595. /**
  100596. * Updates a particle : this function should be overwritten by the user.
  100597. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100598. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100599. * @example : just set a particle position or velocity and recycle conditions
  100600. * @param particle The particle to update
  100601. * @returns the updated particle
  100602. */
  100603. updateParticle(particle: SolidParticle): SolidParticle;
  100604. /**
  100605. * Updates a vertex of a particle : it can be overwritten by the user.
  100606. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100607. * @param particle the current particle
  100608. * @param vertex the current index of the current particle
  100609. * @param pt the index of the current vertex in the particle shape
  100610. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100611. * @example : just set a vertex particle position
  100612. * @returns the updated vertex
  100613. */
  100614. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100615. /**
  100616. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100623. /**
  100624. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100625. * This will be passed three parameters.
  100626. * This does nothing and may be overwritten by the user.
  100627. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100628. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100629. * @param update the boolean update value actually passed to setParticles()
  100630. */
  100631. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100632. }
  100633. }
  100634. declare module BABYLON {
  100635. /**
  100636. * Represents one particle of a solid particle system.
  100637. */
  100638. export class SolidParticle {
  100639. /**
  100640. * particle global index
  100641. */
  100642. idx: number;
  100643. /**
  100644. * particle identifier
  100645. */
  100646. id: number;
  100647. /**
  100648. * The color of the particle
  100649. */
  100650. color: Nullable<Color4>;
  100651. /**
  100652. * The world space position of the particle.
  100653. */
  100654. position: Vector3;
  100655. /**
  100656. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100657. */
  100658. rotation: Vector3;
  100659. /**
  100660. * The world space rotation quaternion of the particle.
  100661. */
  100662. rotationQuaternion: Nullable<Quaternion>;
  100663. /**
  100664. * The scaling of the particle.
  100665. */
  100666. scaling: Vector3;
  100667. /**
  100668. * The uvs of the particle.
  100669. */
  100670. uvs: Vector4;
  100671. /**
  100672. * The current speed of the particle.
  100673. */
  100674. velocity: Vector3;
  100675. /**
  100676. * The pivot point in the particle local space.
  100677. */
  100678. pivot: Vector3;
  100679. /**
  100680. * Must the particle be translated from its pivot point in its local space ?
  100681. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100682. * Default : false
  100683. */
  100684. translateFromPivot: boolean;
  100685. /**
  100686. * Is the particle active or not ?
  100687. */
  100688. alive: boolean;
  100689. /**
  100690. * Is the particle visible or not ?
  100691. */
  100692. isVisible: boolean;
  100693. /**
  100694. * Index of this particle in the global "positions" array (Internal use)
  100695. * @hidden
  100696. */
  100697. _pos: number;
  100698. /**
  100699. * @hidden Index of this particle in the global "indices" array (Internal use)
  100700. */
  100701. _ind: number;
  100702. /**
  100703. * @hidden ModelShape of this particle (Internal use)
  100704. */
  100705. _model: ModelShape;
  100706. /**
  100707. * ModelShape id of this particle
  100708. */
  100709. shapeId: number;
  100710. /**
  100711. * Index of the particle in its shape id
  100712. */
  100713. idxInShape: number;
  100714. /**
  100715. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100716. */
  100717. _modelBoundingInfo: BoundingInfo;
  100718. /**
  100719. * @hidden Particle BoundingInfo object (Internal use)
  100720. */
  100721. _boundingInfo: BoundingInfo;
  100722. /**
  100723. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100724. */
  100725. _sps: SolidParticleSystem;
  100726. /**
  100727. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100728. */
  100729. _stillInvisible: boolean;
  100730. /**
  100731. * @hidden Last computed particle rotation matrix
  100732. */
  100733. _rotationMatrix: number[];
  100734. /**
  100735. * Parent particle Id, if any.
  100736. * Default null.
  100737. */
  100738. parentId: Nullable<number>;
  100739. /**
  100740. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100741. */
  100742. materialIndex: Nullable<number>;
  100743. /**
  100744. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100745. * The possible values are :
  100746. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100747. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100748. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100749. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100750. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100751. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100752. * */
  100753. cullingStrategy: number;
  100754. /**
  100755. * @hidden Internal global position in the SPS.
  100756. */
  100757. _globalPosition: Vector3;
  100758. /**
  100759. * Creates a Solid Particle object.
  100760. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100761. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100762. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100763. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100764. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100765. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100766. * @param shapeId (integer) is the model shape identifier in the SPS.
  100767. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100768. * @param sps defines the sps it is associated to
  100769. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100770. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100771. */
  100772. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100773. /**
  100774. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100775. * @param target the particle target
  100776. * @returns the current particle
  100777. */
  100778. copyToRef(target: SolidParticle): SolidParticle;
  100779. /**
  100780. * Legacy support, changed scale to scaling
  100781. */
  100782. get scale(): Vector3;
  100783. /**
  100784. * Legacy support, changed scale to scaling
  100785. */
  100786. set scale(scale: Vector3);
  100787. /**
  100788. * Legacy support, changed quaternion to rotationQuaternion
  100789. */
  100790. get quaternion(): Nullable<Quaternion>;
  100791. /**
  100792. * Legacy support, changed quaternion to rotationQuaternion
  100793. */
  100794. set quaternion(q: Nullable<Quaternion>);
  100795. /**
  100796. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100797. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100798. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100799. * @returns true if it intersects
  100800. */
  100801. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100802. /**
  100803. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100804. * A particle is in the frustum if its bounding box intersects the frustum
  100805. * @param frustumPlanes defines the frustum to test
  100806. * @returns true if the particle is in the frustum planes
  100807. */
  100808. isInFrustum(frustumPlanes: Plane[]): boolean;
  100809. /**
  100810. * get the rotation matrix of the particle
  100811. * @hidden
  100812. */
  100813. getRotationMatrix(m: Matrix): void;
  100814. }
  100815. /**
  100816. * Represents the shape of the model used by one particle of a solid particle system.
  100817. * SPS internal tool, don't use it manually.
  100818. */
  100819. export class ModelShape {
  100820. /**
  100821. * The shape id
  100822. * @hidden
  100823. */
  100824. shapeID: number;
  100825. /**
  100826. * flat array of model positions (internal use)
  100827. * @hidden
  100828. */
  100829. _shape: Vector3[];
  100830. /**
  100831. * flat array of model UVs (internal use)
  100832. * @hidden
  100833. */
  100834. _shapeUV: number[];
  100835. /**
  100836. * color array of the model
  100837. * @hidden
  100838. */
  100839. _shapeColors: number[];
  100840. /**
  100841. * indices array of the model
  100842. * @hidden
  100843. */
  100844. _indices: number[];
  100845. /**
  100846. * normals array of the model
  100847. * @hidden
  100848. */
  100849. _normals: number[];
  100850. /**
  100851. * length of the shape in the model indices array (internal use)
  100852. * @hidden
  100853. */
  100854. _indicesLength: number;
  100855. /**
  100856. * Custom position function (internal use)
  100857. * @hidden
  100858. */
  100859. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100860. /**
  100861. * Custom vertex function (internal use)
  100862. * @hidden
  100863. */
  100864. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100865. /**
  100866. * Model material (internal use)
  100867. * @hidden
  100868. */
  100869. _material: Nullable<Material>;
  100870. /**
  100871. * 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.
  100872. * SPS internal tool, don't use it manually.
  100873. * @hidden
  100874. */
  100875. 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>);
  100876. }
  100877. /**
  100878. * Represents a Depth Sorted Particle in the solid particle system.
  100879. * @hidden
  100880. */
  100881. export class DepthSortedParticle {
  100882. /**
  100883. * Index of the particle in the "indices" array
  100884. */
  100885. ind: number;
  100886. /**
  100887. * Length of the particle shape in the "indices" array
  100888. */
  100889. indicesLength: number;
  100890. /**
  100891. * Squared distance from the particle to the camera
  100892. */
  100893. sqDistance: number;
  100894. /**
  100895. * Material index when used with MultiMaterials
  100896. */
  100897. materialIndex: number;
  100898. /**
  100899. * Creates a new sorted particle
  100900. * @param materialIndex
  100901. */
  100902. constructor(ind: number, indLength: number, materialIndex: number);
  100903. }
  100904. }
  100905. declare module BABYLON {
  100906. /**
  100907. * @hidden
  100908. */
  100909. export class _MeshCollisionData {
  100910. _checkCollisions: boolean;
  100911. _collisionMask: number;
  100912. _collisionGroup: number;
  100913. _collider: Nullable<Collider>;
  100914. _oldPositionForCollisions: Vector3;
  100915. _diffPositionForCollisions: Vector3;
  100916. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100917. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /** @hidden */
  100922. class _FacetDataStorage {
  100923. facetPositions: Vector3[];
  100924. facetNormals: Vector3[];
  100925. facetPartitioning: number[][];
  100926. facetNb: number;
  100927. partitioningSubdivisions: number;
  100928. partitioningBBoxRatio: number;
  100929. facetDataEnabled: boolean;
  100930. facetParameters: any;
  100931. bbSize: Vector3;
  100932. subDiv: {
  100933. max: number;
  100934. X: number;
  100935. Y: number;
  100936. Z: number;
  100937. };
  100938. facetDepthSort: boolean;
  100939. facetDepthSortEnabled: boolean;
  100940. depthSortedIndices: IndicesArray;
  100941. depthSortedFacets: {
  100942. ind: number;
  100943. sqDistance: number;
  100944. }[];
  100945. facetDepthSortFunction: (f1: {
  100946. ind: number;
  100947. sqDistance: number;
  100948. }, f2: {
  100949. ind: number;
  100950. sqDistance: number;
  100951. }) => number;
  100952. facetDepthSortFrom: Vector3;
  100953. facetDepthSortOrigin: Vector3;
  100954. invertedMatrix: Matrix;
  100955. }
  100956. /**
  100957. * @hidden
  100958. **/
  100959. class _InternalAbstractMeshDataInfo {
  100960. _hasVertexAlpha: boolean;
  100961. _useVertexColors: boolean;
  100962. _numBoneInfluencers: number;
  100963. _applyFog: boolean;
  100964. _receiveShadows: boolean;
  100965. _facetData: _FacetDataStorage;
  100966. _visibility: number;
  100967. _skeleton: Nullable<Skeleton>;
  100968. _layerMask: number;
  100969. _computeBonesUsingShaders: boolean;
  100970. _isActive: boolean;
  100971. _onlyForInstances: boolean;
  100972. _isActiveIntermediate: boolean;
  100973. _onlyForInstancesIntermediate: boolean;
  100974. _actAsRegularMesh: boolean;
  100975. }
  100976. /**
  100977. * Class used to store all common mesh properties
  100978. */
  100979. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100980. /** No occlusion */
  100981. static OCCLUSION_TYPE_NONE: number;
  100982. /** Occlusion set to optimisitic */
  100983. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100984. /** Occlusion set to strict */
  100985. static OCCLUSION_TYPE_STRICT: number;
  100986. /** Use an accurante occlusion algorithm */
  100987. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100988. /** Use a conservative occlusion algorithm */
  100989. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100990. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100991. * Test order :
  100992. * Is the bounding sphere outside the frustum ?
  100993. * If not, are the bounding box vertices outside the frustum ?
  100994. * It not, then the cullable object is in the frustum.
  100995. */
  100996. static readonly CULLINGSTRATEGY_STANDARD: number;
  100997. /** Culling strategy : Bounding Sphere Only.
  100998. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100999. * It's also less accurate than the standard because some not visible objects can still be selected.
  101000. * Test : is the bounding sphere outside the frustum ?
  101001. * If not, then the cullable object is in the frustum.
  101002. */
  101003. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101004. /** Culling strategy : Optimistic Inclusion.
  101005. * This in an inclusion test first, then the standard exclusion test.
  101006. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101007. * 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.
  101008. * Anyway, it's as accurate as the standard strategy.
  101009. * Test :
  101010. * Is the cullable object bounding sphere center in the frustum ?
  101011. * If not, apply the default culling strategy.
  101012. */
  101013. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101014. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101015. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101016. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101017. * 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.
  101018. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101019. * Test :
  101020. * Is the cullable object bounding sphere center in the frustum ?
  101021. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101022. */
  101023. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101024. /**
  101025. * No billboard
  101026. */
  101027. static get BILLBOARDMODE_NONE(): number;
  101028. /** Billboard on X axis */
  101029. static get BILLBOARDMODE_X(): number;
  101030. /** Billboard on Y axis */
  101031. static get BILLBOARDMODE_Y(): number;
  101032. /** Billboard on Z axis */
  101033. static get BILLBOARDMODE_Z(): number;
  101034. /** Billboard on all axes */
  101035. static get BILLBOARDMODE_ALL(): number;
  101036. /** Billboard on using position instead of orientation */
  101037. static get BILLBOARDMODE_USE_POSITION(): number;
  101038. /** @hidden */
  101039. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101040. /**
  101041. * The culling strategy to use to check whether the mesh must be rendered or not.
  101042. * This value can be changed at any time and will be used on the next render mesh selection.
  101043. * The possible values are :
  101044. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101045. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101046. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101047. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101048. * Please read each static variable documentation to get details about the culling process.
  101049. * */
  101050. cullingStrategy: number;
  101051. /**
  101052. * Gets the number of facets in the mesh
  101053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101054. */
  101055. get facetNb(): number;
  101056. /**
  101057. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101059. */
  101060. get partitioningSubdivisions(): number;
  101061. set partitioningSubdivisions(nb: number);
  101062. /**
  101063. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101064. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101066. */
  101067. get partitioningBBoxRatio(): number;
  101068. set partitioningBBoxRatio(ratio: number);
  101069. /**
  101070. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101071. * Works only for updatable meshes.
  101072. * Doesn't work with multi-materials
  101073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101074. */
  101075. get mustDepthSortFacets(): boolean;
  101076. set mustDepthSortFacets(sort: boolean);
  101077. /**
  101078. * The location (Vector3) where the facet depth sort must be computed from.
  101079. * By default, the active camera position.
  101080. * Used only when facet depth sort is enabled
  101081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101082. */
  101083. get facetDepthSortFrom(): Vector3;
  101084. set facetDepthSortFrom(location: Vector3);
  101085. /**
  101086. * gets a boolean indicating if facetData is enabled
  101087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101088. */
  101089. get isFacetDataEnabled(): boolean;
  101090. /** @hidden */
  101091. _updateNonUniformScalingState(value: boolean): boolean;
  101092. /**
  101093. * An event triggered when this mesh collides with another one
  101094. */
  101095. onCollideObservable: Observable<AbstractMesh>;
  101096. /** Set a function to call when this mesh collides with another one */
  101097. set onCollide(callback: () => void);
  101098. /**
  101099. * An event triggered when the collision's position changes
  101100. */
  101101. onCollisionPositionChangeObservable: Observable<Vector3>;
  101102. /** Set a function to call when the collision's position changes */
  101103. set onCollisionPositionChange(callback: () => void);
  101104. /**
  101105. * An event triggered when material is changed
  101106. */
  101107. onMaterialChangedObservable: Observable<AbstractMesh>;
  101108. /**
  101109. * Gets or sets the orientation for POV movement & rotation
  101110. */
  101111. definedFacingForward: boolean;
  101112. /** @hidden */
  101113. _occlusionQuery: Nullable<WebGLQuery>;
  101114. /** @hidden */
  101115. _renderingGroup: Nullable<RenderingGroup>;
  101116. /**
  101117. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101118. */
  101119. get visibility(): number;
  101120. /**
  101121. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101122. */
  101123. set visibility(value: number);
  101124. /** Gets or sets the alpha index used to sort transparent meshes
  101125. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101126. */
  101127. alphaIndex: number;
  101128. /**
  101129. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101130. */
  101131. isVisible: boolean;
  101132. /**
  101133. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101134. */
  101135. isPickable: boolean;
  101136. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101137. showSubMeshesBoundingBox: boolean;
  101138. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101139. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101140. */
  101141. isBlocker: boolean;
  101142. /**
  101143. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101144. */
  101145. enablePointerMoveEvents: boolean;
  101146. /**
  101147. * Specifies the rendering group id for this mesh (0 by default)
  101148. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101149. */
  101150. renderingGroupId: number;
  101151. private _material;
  101152. /** Gets or sets current material */
  101153. get material(): Nullable<Material>;
  101154. set material(value: Nullable<Material>);
  101155. /**
  101156. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101157. * @see http://doc.babylonjs.com/babylon101/shadows
  101158. */
  101159. get receiveShadows(): boolean;
  101160. set receiveShadows(value: boolean);
  101161. /** Defines color to use when rendering outline */
  101162. outlineColor: Color3;
  101163. /** Define width to use when rendering outline */
  101164. outlineWidth: number;
  101165. /** Defines color to use when rendering overlay */
  101166. overlayColor: Color3;
  101167. /** Defines alpha to use when rendering overlay */
  101168. overlayAlpha: number;
  101169. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101170. get hasVertexAlpha(): boolean;
  101171. set hasVertexAlpha(value: boolean);
  101172. /** 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) */
  101173. get useVertexColors(): boolean;
  101174. set useVertexColors(value: boolean);
  101175. /**
  101176. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101177. */
  101178. get computeBonesUsingShaders(): boolean;
  101179. set computeBonesUsingShaders(value: boolean);
  101180. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101181. get numBoneInfluencers(): number;
  101182. set numBoneInfluencers(value: number);
  101183. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101184. get applyFog(): boolean;
  101185. set applyFog(value: boolean);
  101186. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101187. useOctreeForRenderingSelection: boolean;
  101188. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101189. useOctreeForPicking: boolean;
  101190. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101191. useOctreeForCollisions: boolean;
  101192. /**
  101193. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101194. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101195. */
  101196. get layerMask(): number;
  101197. set layerMask(value: number);
  101198. /**
  101199. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101200. */
  101201. alwaysSelectAsActiveMesh: boolean;
  101202. /**
  101203. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101204. */
  101205. doNotSyncBoundingInfo: boolean;
  101206. /**
  101207. * Gets or sets the current action manager
  101208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101209. */
  101210. actionManager: Nullable<AbstractActionManager>;
  101211. private _meshCollisionData;
  101212. /**
  101213. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101215. */
  101216. ellipsoid: Vector3;
  101217. /**
  101218. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101220. */
  101221. ellipsoidOffset: Vector3;
  101222. /**
  101223. * Gets or sets a collision mask used to mask collisions (default is -1).
  101224. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101225. */
  101226. get collisionMask(): number;
  101227. set collisionMask(mask: number);
  101228. /**
  101229. * Gets or sets the current collision group mask (-1 by default).
  101230. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101231. */
  101232. get collisionGroup(): number;
  101233. set collisionGroup(mask: number);
  101234. /**
  101235. * Defines edge width used when edgesRenderer is enabled
  101236. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101237. */
  101238. edgesWidth: number;
  101239. /**
  101240. * Defines edge color used when edgesRenderer is enabled
  101241. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101242. */
  101243. edgesColor: Color4;
  101244. /** @hidden */
  101245. _edgesRenderer: Nullable<IEdgesRenderer>;
  101246. /** @hidden */
  101247. _masterMesh: Nullable<AbstractMesh>;
  101248. /** @hidden */
  101249. _boundingInfo: Nullable<BoundingInfo>;
  101250. /** @hidden */
  101251. _renderId: number;
  101252. /**
  101253. * Gets or sets the list of subMeshes
  101254. * @see http://doc.babylonjs.com/how_to/multi_materials
  101255. */
  101256. subMeshes: SubMesh[];
  101257. /** @hidden */
  101258. _intersectionsInProgress: AbstractMesh[];
  101259. /** @hidden */
  101260. _unIndexed: boolean;
  101261. /** @hidden */
  101262. _lightSources: Light[];
  101263. /** Gets the list of lights affecting that mesh */
  101264. get lightSources(): Light[];
  101265. /** @hidden */
  101266. get _positions(): Nullable<Vector3[]>;
  101267. /** @hidden */
  101268. _waitingData: {
  101269. lods: Nullable<any>;
  101270. actions: Nullable<any>;
  101271. freezeWorldMatrix: Nullable<boolean>;
  101272. };
  101273. /** @hidden */
  101274. _bonesTransformMatrices: Nullable<Float32Array>;
  101275. /** @hidden */
  101276. _transformMatrixTexture: Nullable<RawTexture>;
  101277. /**
  101278. * Gets or sets a skeleton to apply skining transformations
  101279. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101280. */
  101281. set skeleton(value: Nullable<Skeleton>);
  101282. get skeleton(): Nullable<Skeleton>;
  101283. /**
  101284. * An event triggered when the mesh is rebuilt.
  101285. */
  101286. onRebuildObservable: Observable<AbstractMesh>;
  101287. /**
  101288. * Creates a new AbstractMesh
  101289. * @param name defines the name of the mesh
  101290. * @param scene defines the hosting scene
  101291. */
  101292. constructor(name: string, scene?: Nullable<Scene>);
  101293. /**
  101294. * Returns the string "AbstractMesh"
  101295. * @returns "AbstractMesh"
  101296. */
  101297. getClassName(): string;
  101298. /**
  101299. * Gets a string representation of the current mesh
  101300. * @param fullDetails defines a boolean indicating if full details must be included
  101301. * @returns a string representation of the current mesh
  101302. */
  101303. toString(fullDetails?: boolean): string;
  101304. /**
  101305. * @hidden
  101306. */
  101307. protected _getEffectiveParent(): Nullable<Node>;
  101308. /** @hidden */
  101309. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101310. /** @hidden */
  101311. _rebuild(): void;
  101312. /** @hidden */
  101313. _resyncLightSources(): void;
  101314. /** @hidden */
  101315. _resyncLightSource(light: Light): void;
  101316. /** @hidden */
  101317. _unBindEffect(): void;
  101318. /** @hidden */
  101319. _removeLightSource(light: Light, dispose: boolean): void;
  101320. private _markSubMeshesAsDirty;
  101321. /** @hidden */
  101322. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101323. /** @hidden */
  101324. _markSubMeshesAsAttributesDirty(): void;
  101325. /** @hidden */
  101326. _markSubMeshesAsMiscDirty(): void;
  101327. /**
  101328. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101329. */
  101330. get scaling(): Vector3;
  101331. set scaling(newScaling: Vector3);
  101332. /**
  101333. * Returns true if the mesh is blocked. Implemented by child classes
  101334. */
  101335. get isBlocked(): boolean;
  101336. /**
  101337. * Returns the mesh itself by default. Implemented by child classes
  101338. * @param camera defines the camera to use to pick the right LOD level
  101339. * @returns the currentAbstractMesh
  101340. */
  101341. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101342. /**
  101343. * Returns 0 by default. Implemented by child classes
  101344. * @returns an integer
  101345. */
  101346. getTotalVertices(): number;
  101347. /**
  101348. * Returns a positive integer : the total number of indices in this mesh geometry.
  101349. * @returns the numner of indices or zero if the mesh has no geometry.
  101350. */
  101351. getTotalIndices(): number;
  101352. /**
  101353. * Returns null by default. Implemented by child classes
  101354. * @returns null
  101355. */
  101356. getIndices(): Nullable<IndicesArray>;
  101357. /**
  101358. * Returns the array of the requested vertex data kind. Implemented by child classes
  101359. * @param kind defines the vertex data kind to use
  101360. * @returns null
  101361. */
  101362. getVerticesData(kind: string): Nullable<FloatArray>;
  101363. /**
  101364. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101365. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101366. * Note that a new underlying VertexBuffer object is created each call.
  101367. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101368. * @param kind defines vertex data kind:
  101369. * * VertexBuffer.PositionKind
  101370. * * VertexBuffer.UVKind
  101371. * * VertexBuffer.UV2Kind
  101372. * * VertexBuffer.UV3Kind
  101373. * * VertexBuffer.UV4Kind
  101374. * * VertexBuffer.UV5Kind
  101375. * * VertexBuffer.UV6Kind
  101376. * * VertexBuffer.ColorKind
  101377. * * VertexBuffer.MatricesIndicesKind
  101378. * * VertexBuffer.MatricesIndicesExtraKind
  101379. * * VertexBuffer.MatricesWeightsKind
  101380. * * VertexBuffer.MatricesWeightsExtraKind
  101381. * @param data defines the data source
  101382. * @param updatable defines if the data must be flagged as updatable (or static)
  101383. * @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
  101384. * @returns the current mesh
  101385. */
  101386. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101387. /**
  101388. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101389. * If the mesh has no geometry, it is simply returned as it is.
  101390. * @param kind defines vertex data kind:
  101391. * * VertexBuffer.PositionKind
  101392. * * VertexBuffer.UVKind
  101393. * * VertexBuffer.UV2Kind
  101394. * * VertexBuffer.UV3Kind
  101395. * * VertexBuffer.UV4Kind
  101396. * * VertexBuffer.UV5Kind
  101397. * * VertexBuffer.UV6Kind
  101398. * * VertexBuffer.ColorKind
  101399. * * VertexBuffer.MatricesIndicesKind
  101400. * * VertexBuffer.MatricesIndicesExtraKind
  101401. * * VertexBuffer.MatricesWeightsKind
  101402. * * VertexBuffer.MatricesWeightsExtraKind
  101403. * @param data defines the data source
  101404. * @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
  101405. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101406. * @returns the current mesh
  101407. */
  101408. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101409. /**
  101410. * Sets the mesh indices,
  101411. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101412. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101413. * @param totalVertices Defines the total number of vertices
  101414. * @returns the current mesh
  101415. */
  101416. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101417. /**
  101418. * Gets a boolean indicating if specific vertex data is present
  101419. * @param kind defines the vertex data kind to use
  101420. * @returns true is data kind is present
  101421. */
  101422. isVerticesDataPresent(kind: string): boolean;
  101423. /**
  101424. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101425. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101426. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101427. * @returns a BoundingInfo
  101428. */
  101429. getBoundingInfo(): BoundingInfo;
  101430. /**
  101431. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101432. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101433. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101434. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101435. * @returns the current mesh
  101436. */
  101437. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101438. /**
  101439. * Overwrite the current bounding info
  101440. * @param boundingInfo defines the new bounding info
  101441. * @returns the current mesh
  101442. */
  101443. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101444. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101445. get useBones(): boolean;
  101446. /** @hidden */
  101447. _preActivate(): void;
  101448. /** @hidden */
  101449. _preActivateForIntermediateRendering(renderId: number): void;
  101450. /** @hidden */
  101451. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101452. /** @hidden */
  101453. _postActivate(): void;
  101454. /** @hidden */
  101455. _freeze(): void;
  101456. /** @hidden */
  101457. _unFreeze(): void;
  101458. /**
  101459. * Gets the current world matrix
  101460. * @returns a Matrix
  101461. */
  101462. getWorldMatrix(): Matrix;
  101463. /** @hidden */
  101464. _getWorldMatrixDeterminant(): number;
  101465. /**
  101466. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101467. */
  101468. get isAnInstance(): boolean;
  101469. /**
  101470. * Gets a boolean indicating if this mesh has instances
  101471. */
  101472. get hasInstances(): boolean;
  101473. /**
  101474. * Perform relative position change from the point of view of behind the front of the mesh.
  101475. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101476. * Supports definition of mesh facing forward or backward
  101477. * @param amountRight defines the distance on the right axis
  101478. * @param amountUp defines the distance on the up axis
  101479. * @param amountForward defines the distance on the forward axis
  101480. * @returns the current mesh
  101481. */
  101482. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101483. /**
  101484. * Calculate relative position change from the point of view of behind the front of the mesh.
  101485. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101486. * Supports definition of mesh facing forward or backward
  101487. * @param amountRight defines the distance on the right axis
  101488. * @param amountUp defines the distance on the up axis
  101489. * @param amountForward defines the distance on the forward axis
  101490. * @returns the new displacement vector
  101491. */
  101492. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101493. /**
  101494. * Perform 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 current mesh
  101500. */
  101501. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101502. /**
  101503. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101504. * Supports definition of mesh facing forward or backward.
  101505. * @param flipBack defines the flip
  101506. * @param twirlClockwise defines the twirl
  101507. * @param tiltRight defines the tilt
  101508. * @returns the new rotation vector
  101509. */
  101510. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101511. /**
  101512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101513. * This means the mesh underlying bounding box and sphere are recomputed.
  101514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101515. * @returns the current mesh
  101516. */
  101517. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101518. /** @hidden */
  101519. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101520. /** @hidden */
  101521. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101522. /** @hidden */
  101523. _updateBoundingInfo(): AbstractMesh;
  101524. /** @hidden */
  101525. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101526. /** @hidden */
  101527. protected _afterComputeWorldMatrix(): void;
  101528. /** @hidden */
  101529. get _effectiveMesh(): AbstractMesh;
  101530. /**
  101531. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101532. * A mesh is in the frustum if its bounding box intersects the frustum
  101533. * @param frustumPlanes defines the frustum to test
  101534. * @returns true if the mesh is in the frustum planes
  101535. */
  101536. isInFrustum(frustumPlanes: Plane[]): boolean;
  101537. /**
  101538. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101539. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101540. * @param frustumPlanes defines the frustum to test
  101541. * @returns true if the mesh is completely in the frustum planes
  101542. */
  101543. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101544. /**
  101545. * True if the mesh intersects another mesh or a SolidParticle object
  101546. * @param mesh defines a target mesh or SolidParticle to test
  101547. * @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)
  101548. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101549. * @returns true if there is an intersection
  101550. */
  101551. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101552. /**
  101553. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101554. * @param point defines the point to test
  101555. * @returns true if there is an intersection
  101556. */
  101557. intersectsPoint(point: Vector3): boolean;
  101558. /**
  101559. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101560. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101561. */
  101562. get checkCollisions(): boolean;
  101563. set checkCollisions(collisionEnabled: boolean);
  101564. /**
  101565. * Gets Collider object used to compute collisions (not physics)
  101566. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101567. */
  101568. get collider(): Nullable<Collider>;
  101569. /**
  101570. * Move the mesh using collision engine
  101571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101572. * @param displacement defines the requested displacement vector
  101573. * @returns the current mesh
  101574. */
  101575. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101576. private _onCollisionPositionChange;
  101577. /** @hidden */
  101578. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101579. /** @hidden */
  101580. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101581. /** @hidden */
  101582. _checkCollision(collider: Collider): AbstractMesh;
  101583. /** @hidden */
  101584. _generatePointsArray(): boolean;
  101585. /**
  101586. * Checks if the passed Ray intersects with the mesh
  101587. * @param ray defines the ray to use
  101588. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101590. * @returns the picking info
  101591. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101592. */
  101593. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101594. /**
  101595. * Clones the current mesh
  101596. * @param name defines the mesh name
  101597. * @param newParent defines the new mesh parent
  101598. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101599. * @returns the new mesh
  101600. */
  101601. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101602. /**
  101603. * Disposes all the submeshes of the current meshnp
  101604. * @returns the current mesh
  101605. */
  101606. releaseSubMeshes(): AbstractMesh;
  101607. /**
  101608. * Releases resources associated with this abstract mesh.
  101609. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101610. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101611. */
  101612. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101613. /**
  101614. * Adds the passed mesh as a child to the current mesh
  101615. * @param mesh defines the child mesh
  101616. * @returns the current mesh
  101617. */
  101618. addChild(mesh: AbstractMesh): AbstractMesh;
  101619. /**
  101620. * Removes the passed mesh from the current mesh children list
  101621. * @param mesh defines the child mesh
  101622. * @returns the current mesh
  101623. */
  101624. removeChild(mesh: AbstractMesh): AbstractMesh;
  101625. /** @hidden */
  101626. private _initFacetData;
  101627. /**
  101628. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101629. * This method can be called within the render loop.
  101630. * 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
  101631. * @returns the current mesh
  101632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101633. */
  101634. updateFacetData(): AbstractMesh;
  101635. /**
  101636. * Returns the facetLocalNormals array.
  101637. * The normals are expressed in the mesh local spac
  101638. * @returns an array of Vector3
  101639. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101640. */
  101641. getFacetLocalNormals(): Vector3[];
  101642. /**
  101643. * Returns the facetLocalPositions array.
  101644. * The facet positions are expressed in the mesh local space
  101645. * @returns an array of Vector3
  101646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101647. */
  101648. getFacetLocalPositions(): Vector3[];
  101649. /**
  101650. * Returns the facetLocalPartioning array
  101651. * @returns an array of array of numbers
  101652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101653. */
  101654. getFacetLocalPartitioning(): number[][];
  101655. /**
  101656. * Returns the i-th facet position in the world system.
  101657. * This method allocates a new Vector3 per call
  101658. * @param i defines the facet index
  101659. * @returns a new Vector3
  101660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101661. */
  101662. getFacetPosition(i: number): Vector3;
  101663. /**
  101664. * Sets the reference Vector3 with the i-th facet position in the world system
  101665. * @param i defines the facet index
  101666. * @param ref defines the target vector
  101667. * @returns the current mesh
  101668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101669. */
  101670. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101671. /**
  101672. * Returns the i-th facet normal in the world system.
  101673. * This method allocates a new Vector3 per call
  101674. * @param i defines the facet index
  101675. * @returns a new Vector3
  101676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101677. */
  101678. getFacetNormal(i: number): Vector3;
  101679. /**
  101680. * Sets the reference Vector3 with the i-th facet normal in the world system
  101681. * @param i defines the facet index
  101682. * @param ref defines the target vector
  101683. * @returns the current mesh
  101684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101685. */
  101686. getFacetNormalToRef(i: number, ref: Vector3): this;
  101687. /**
  101688. * 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)
  101689. * @param x defines x coordinate
  101690. * @param y defines y coordinate
  101691. * @param z defines z coordinate
  101692. * @returns the array of facet indexes
  101693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101694. */
  101695. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101696. /**
  101697. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101698. * @param projected sets as the (x,y,z) world projection on the facet
  101699. * @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
  101700. * @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
  101701. * @param x defines x coordinate
  101702. * @param y defines y coordinate
  101703. * @param z defines z coordinate
  101704. * @returns the face index if found (or null instead)
  101705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101706. */
  101707. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101708. /**
  101709. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101710. * @param projected sets as the (x,y,z) local projection on the facet
  101711. * @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
  101712. * @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
  101713. * @param x defines x coordinate
  101714. * @param y defines y coordinate
  101715. * @param z defines z coordinate
  101716. * @returns the face index if found (or null instead)
  101717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101718. */
  101719. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101720. /**
  101721. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101722. * @returns the parameters
  101723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101724. */
  101725. getFacetDataParameters(): any;
  101726. /**
  101727. * Disables the feature FacetData and frees the related memory
  101728. * @returns the current mesh
  101729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101730. */
  101731. disableFacetData(): AbstractMesh;
  101732. /**
  101733. * Updates the AbstractMesh indices array
  101734. * @param indices defines the data source
  101735. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101736. * @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)
  101737. * @returns the current mesh
  101738. */
  101739. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101740. /**
  101741. * Creates new normals data for the mesh
  101742. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101743. * @returns the current mesh
  101744. */
  101745. createNormals(updatable: boolean): AbstractMesh;
  101746. /**
  101747. * Align the mesh with a normal
  101748. * @param normal defines the normal to use
  101749. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101750. * @returns the current mesh
  101751. */
  101752. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101753. /** @hidden */
  101754. _checkOcclusionQuery(): boolean;
  101755. /**
  101756. * Disables the mesh edge rendering mode
  101757. * @returns the currentAbstractMesh
  101758. */
  101759. disableEdgesRendering(): AbstractMesh;
  101760. /**
  101761. * Enables the edge rendering mode on the mesh.
  101762. * This mode makes the mesh edges visible
  101763. * @param epsilon defines the maximal distance between two angles to detect a face
  101764. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101765. * @returns the currentAbstractMesh
  101766. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101767. */
  101768. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101769. }
  101770. }
  101771. declare module BABYLON {
  101772. /**
  101773. * Interface used to define ActionEvent
  101774. */
  101775. export interface IActionEvent {
  101776. /** The mesh or sprite that triggered the action */
  101777. source: any;
  101778. /** The X mouse cursor position at the time of the event */
  101779. pointerX: number;
  101780. /** The Y mouse cursor position at the time of the event */
  101781. pointerY: number;
  101782. /** The mesh that is currently pointed at (can be null) */
  101783. meshUnderPointer: Nullable<AbstractMesh>;
  101784. /** the original (browser) event that triggered the ActionEvent */
  101785. sourceEvent?: any;
  101786. /** additional data for the event */
  101787. additionalData?: any;
  101788. }
  101789. /**
  101790. * ActionEvent is the event being sent when an action is triggered.
  101791. */
  101792. export class ActionEvent implements IActionEvent {
  101793. /** The mesh or sprite that triggered the action */
  101794. source: any;
  101795. /** The X mouse cursor position at the time of the event */
  101796. pointerX: number;
  101797. /** The Y mouse cursor position at the time of the event */
  101798. pointerY: number;
  101799. /** The mesh that is currently pointed at (can be null) */
  101800. meshUnderPointer: Nullable<AbstractMesh>;
  101801. /** the original (browser) event that triggered the ActionEvent */
  101802. sourceEvent?: any;
  101803. /** additional data for the event */
  101804. additionalData?: any;
  101805. /**
  101806. * Creates a new ActionEvent
  101807. * @param source The mesh or sprite that triggered the action
  101808. * @param pointerX The X mouse cursor position at the time of the event
  101809. * @param pointerY The Y mouse cursor position at the time of the event
  101810. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101811. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101812. * @param additionalData additional data for the event
  101813. */
  101814. constructor(
  101815. /** The mesh or sprite that triggered the action */
  101816. source: any,
  101817. /** The X mouse cursor position at the time of the event */
  101818. pointerX: number,
  101819. /** The Y mouse cursor position at the time of the event */
  101820. pointerY: number,
  101821. /** The mesh that is currently pointed at (can be null) */
  101822. meshUnderPointer: Nullable<AbstractMesh>,
  101823. /** the original (browser) event that triggered the ActionEvent */
  101824. sourceEvent?: any,
  101825. /** additional data for the event */
  101826. additionalData?: any);
  101827. /**
  101828. * Helper function to auto-create an ActionEvent from a source mesh.
  101829. * @param source The source mesh that triggered the event
  101830. * @param evt The original (browser) event
  101831. * @param additionalData additional data for the event
  101832. * @returns the new ActionEvent
  101833. */
  101834. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101835. /**
  101836. * Helper function to auto-create an ActionEvent from a source sprite
  101837. * @param source The source sprite that triggered the event
  101838. * @param scene Scene associated with the sprite
  101839. * @param evt The original (browser) event
  101840. * @param additionalData additional data for the event
  101841. * @returns the new ActionEvent
  101842. */
  101843. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101844. /**
  101845. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101846. * @param scene the scene where the event occurred
  101847. * @param evt The original (browser) event
  101848. * @returns the new ActionEvent
  101849. */
  101850. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101851. /**
  101852. * Helper function to auto-create an ActionEvent from a primitive
  101853. * @param prim defines the target primitive
  101854. * @param pointerPos defines the pointer position
  101855. * @param evt The original (browser) event
  101856. * @param additionalData additional data for the event
  101857. * @returns the new ActionEvent
  101858. */
  101859. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101860. }
  101861. }
  101862. declare module BABYLON {
  101863. /**
  101864. * Abstract class used to decouple action Manager from scene and meshes.
  101865. * Do not instantiate.
  101866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101867. */
  101868. export abstract class AbstractActionManager implements IDisposable {
  101869. /** Gets the list of active triggers */
  101870. static Triggers: {
  101871. [key: string]: number;
  101872. };
  101873. /** Gets the cursor to use when hovering items */
  101874. hoverCursor: string;
  101875. /** Gets the list of actions */
  101876. actions: IAction[];
  101877. /**
  101878. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101879. */
  101880. isRecursive: boolean;
  101881. /**
  101882. * Releases all associated resources
  101883. */
  101884. abstract dispose(): void;
  101885. /**
  101886. * Does this action manager has pointer triggers
  101887. */
  101888. abstract get hasPointerTriggers(): boolean;
  101889. /**
  101890. * Does this action manager has pick triggers
  101891. */
  101892. abstract get hasPickTriggers(): boolean;
  101893. /**
  101894. * Process a specific trigger
  101895. * @param trigger defines the trigger to process
  101896. * @param evt defines the event details to be processed
  101897. */
  101898. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101899. /**
  101900. * Does this action manager handles actions of any of the given triggers
  101901. * @param triggers defines the triggers to be tested
  101902. * @return a boolean indicating whether one (or more) of the triggers is handled
  101903. */
  101904. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101905. /**
  101906. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101907. * speed.
  101908. * @param triggerA defines the trigger to be tested
  101909. * @param triggerB defines the trigger to be tested
  101910. * @return a boolean indicating whether one (or more) of the triggers is handled
  101911. */
  101912. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101913. /**
  101914. * Does this action manager handles actions of a given trigger
  101915. * @param trigger defines the trigger to be tested
  101916. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101917. * @return whether the trigger is handled
  101918. */
  101919. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101920. /**
  101921. * Serialize this manager to a JSON object
  101922. * @param name defines the property name to store this manager
  101923. * @returns a JSON representation of this manager
  101924. */
  101925. abstract serialize(name: string): any;
  101926. /**
  101927. * Registers an action to this action manager
  101928. * @param action defines the action to be registered
  101929. * @return the action amended (prepared) after registration
  101930. */
  101931. abstract registerAction(action: IAction): Nullable<IAction>;
  101932. /**
  101933. * Unregisters an action to this action manager
  101934. * @param action defines the action to be unregistered
  101935. * @return a boolean indicating whether the action has been unregistered
  101936. */
  101937. abstract unregisterAction(action: IAction): Boolean;
  101938. /**
  101939. * Does exist one action manager with at least one trigger
  101940. **/
  101941. static get HasTriggers(): boolean;
  101942. /**
  101943. * Does exist one action manager with at least one pick trigger
  101944. **/
  101945. static get HasPickTriggers(): boolean;
  101946. /**
  101947. * Does exist one action manager that handles actions of a given trigger
  101948. * @param trigger defines the trigger to be tested
  101949. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101950. **/
  101951. static HasSpecificTrigger(trigger: number): boolean;
  101952. }
  101953. }
  101954. declare module BABYLON {
  101955. /**
  101956. * Defines how a node can be built from a string name.
  101957. */
  101958. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101959. /**
  101960. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101961. */
  101962. export class Node implements IBehaviorAware<Node> {
  101963. /** @hidden */
  101964. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101965. private static _NodeConstructors;
  101966. /**
  101967. * Add a new node constructor
  101968. * @param type defines the type name of the node to construct
  101969. * @param constructorFunc defines the constructor function
  101970. */
  101971. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101972. /**
  101973. * Returns a node constructor based on type name
  101974. * @param type defines the type name
  101975. * @param name defines the new node name
  101976. * @param scene defines the hosting scene
  101977. * @param options defines optional options to transmit to constructors
  101978. * @returns the new constructor or null
  101979. */
  101980. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101981. /**
  101982. * Gets or sets the name of the node
  101983. */
  101984. name: string;
  101985. /**
  101986. * Gets or sets the id of the node
  101987. */
  101988. id: string;
  101989. /**
  101990. * Gets or sets the unique id of the node
  101991. */
  101992. uniqueId: number;
  101993. /**
  101994. * Gets or sets a string used to store user defined state for the node
  101995. */
  101996. state: string;
  101997. /**
  101998. * Gets or sets an object used to store user defined information for the node
  101999. */
  102000. metadata: any;
  102001. /**
  102002. * For internal use only. Please do not use.
  102003. */
  102004. reservedDataStore: any;
  102005. /**
  102006. * List of inspectable custom properties (used by the Inspector)
  102007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102008. */
  102009. inspectableCustomProperties: IInspectable[];
  102010. private _doNotSerialize;
  102011. /**
  102012. * Gets or sets a boolean used to define if the node must be serialized
  102013. */
  102014. get doNotSerialize(): boolean;
  102015. set doNotSerialize(value: boolean);
  102016. /** @hidden */
  102017. _isDisposed: boolean;
  102018. /**
  102019. * Gets a list of Animations associated with the node
  102020. */
  102021. animations: Animation[];
  102022. protected _ranges: {
  102023. [name: string]: Nullable<AnimationRange>;
  102024. };
  102025. /**
  102026. * Callback raised when the node is ready to be used
  102027. */
  102028. onReady: Nullable<(node: Node) => void>;
  102029. private _isEnabled;
  102030. private _isParentEnabled;
  102031. private _isReady;
  102032. /** @hidden */
  102033. _currentRenderId: number;
  102034. private _parentUpdateId;
  102035. /** @hidden */
  102036. _childUpdateId: number;
  102037. /** @hidden */
  102038. _waitingParentId: Nullable<string>;
  102039. /** @hidden */
  102040. _scene: Scene;
  102041. /** @hidden */
  102042. _cache: any;
  102043. private _parentNode;
  102044. private _children;
  102045. /** @hidden */
  102046. _worldMatrix: Matrix;
  102047. /** @hidden */
  102048. _worldMatrixDeterminant: number;
  102049. /** @hidden */
  102050. _worldMatrixDeterminantIsDirty: boolean;
  102051. /** @hidden */
  102052. private _sceneRootNodesIndex;
  102053. /**
  102054. * Gets a boolean indicating if the node has been disposed
  102055. * @returns true if the node was disposed
  102056. */
  102057. isDisposed(): boolean;
  102058. /**
  102059. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102060. * @see https://doc.babylonjs.com/how_to/parenting
  102061. */
  102062. set parent(parent: Nullable<Node>);
  102063. get parent(): Nullable<Node>;
  102064. /** @hidden */
  102065. _addToSceneRootNodes(): void;
  102066. /** @hidden */
  102067. _removeFromSceneRootNodes(): void;
  102068. private _animationPropertiesOverride;
  102069. /**
  102070. * Gets or sets the animation properties override
  102071. */
  102072. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102073. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102074. /**
  102075. * Gets a string idenfifying the name of the class
  102076. * @returns "Node" string
  102077. */
  102078. getClassName(): string;
  102079. /** @hidden */
  102080. readonly _isNode: boolean;
  102081. /**
  102082. * An event triggered when the mesh is disposed
  102083. */
  102084. onDisposeObservable: Observable<Node>;
  102085. private _onDisposeObserver;
  102086. /**
  102087. * Sets a callback that will be raised when the node will be disposed
  102088. */
  102089. set onDispose(callback: () => void);
  102090. /**
  102091. * Creates a new Node
  102092. * @param name the name and id to be given to this node
  102093. * @param scene the scene this node will be added to
  102094. */
  102095. constructor(name: string, scene?: Nullable<Scene>);
  102096. /**
  102097. * Gets the scene of the node
  102098. * @returns a scene
  102099. */
  102100. getScene(): Scene;
  102101. /**
  102102. * Gets the engine of the node
  102103. * @returns a Engine
  102104. */
  102105. getEngine(): Engine;
  102106. private _behaviors;
  102107. /**
  102108. * Attach a behavior to the node
  102109. * @see http://doc.babylonjs.com/features/behaviour
  102110. * @param behavior defines the behavior to attach
  102111. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102112. * @returns the current Node
  102113. */
  102114. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102115. /**
  102116. * Remove an attached behavior
  102117. * @see http://doc.babylonjs.com/features/behaviour
  102118. * @param behavior defines the behavior to attach
  102119. * @returns the current Node
  102120. */
  102121. removeBehavior(behavior: Behavior<Node>): Node;
  102122. /**
  102123. * Gets the list of attached behaviors
  102124. * @see http://doc.babylonjs.com/features/behaviour
  102125. */
  102126. get behaviors(): Behavior<Node>[];
  102127. /**
  102128. * Gets an attached behavior by name
  102129. * @param name defines the name of the behavior to look for
  102130. * @see http://doc.babylonjs.com/features/behaviour
  102131. * @returns null if behavior was not found else the requested behavior
  102132. */
  102133. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102134. /**
  102135. * Returns the latest update of the World matrix
  102136. * @returns a Matrix
  102137. */
  102138. getWorldMatrix(): Matrix;
  102139. /** @hidden */
  102140. _getWorldMatrixDeterminant(): number;
  102141. /**
  102142. * Returns directly the latest state of the mesh World matrix.
  102143. * A Matrix is returned.
  102144. */
  102145. get worldMatrixFromCache(): Matrix;
  102146. /** @hidden */
  102147. _initCache(): void;
  102148. /** @hidden */
  102149. updateCache(force?: boolean): void;
  102150. /** @hidden */
  102151. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102152. /** @hidden */
  102153. _updateCache(ignoreParentClass?: boolean): void;
  102154. /** @hidden */
  102155. _isSynchronized(): boolean;
  102156. /** @hidden */
  102157. _markSyncedWithParent(): void;
  102158. /** @hidden */
  102159. isSynchronizedWithParent(): boolean;
  102160. /** @hidden */
  102161. isSynchronized(): boolean;
  102162. /**
  102163. * Is this node ready to be used/rendered
  102164. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102165. * @return true if the node is ready
  102166. */
  102167. isReady(completeCheck?: boolean): boolean;
  102168. /**
  102169. * Is this node enabled?
  102170. * 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
  102171. * @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
  102172. * @return whether this node (and its parent) is enabled
  102173. */
  102174. isEnabled(checkAncestors?: boolean): boolean;
  102175. /** @hidden */
  102176. protected _syncParentEnabledState(): void;
  102177. /**
  102178. * Set the enabled state of this node
  102179. * @param value defines the new enabled state
  102180. */
  102181. setEnabled(value: boolean): void;
  102182. /**
  102183. * Is this node a descendant of the given node?
  102184. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102185. * @param ancestor defines the parent node to inspect
  102186. * @returns a boolean indicating if this node is a descendant of the given node
  102187. */
  102188. isDescendantOf(ancestor: Node): boolean;
  102189. /** @hidden */
  102190. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102191. /**
  102192. * Will return all nodes that have this node as ascendant
  102193. * @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
  102194. * @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
  102195. * @return all children nodes of all types
  102196. */
  102197. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102198. /**
  102199. * Get all child-meshes of this node
  102200. * @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)
  102201. * @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
  102202. * @returns an array of AbstractMesh
  102203. */
  102204. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102205. /**
  102206. * Get all direct children of this node
  102207. * @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
  102208. * @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)
  102209. * @returns an array of Node
  102210. */
  102211. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102212. /** @hidden */
  102213. _setReady(state: boolean): void;
  102214. /**
  102215. * Get an animation by name
  102216. * @param name defines the name of the animation to look for
  102217. * @returns null if not found else the requested animation
  102218. */
  102219. getAnimationByName(name: string): Nullable<Animation>;
  102220. /**
  102221. * Creates an animation range for this node
  102222. * @param name defines the name of the range
  102223. * @param from defines the starting key
  102224. * @param to defines the end key
  102225. */
  102226. createAnimationRange(name: string, from: number, to: number): void;
  102227. /**
  102228. * Delete a specific animation range
  102229. * @param name defines the name of the range to delete
  102230. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102231. */
  102232. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102233. /**
  102234. * Get an animation range by name
  102235. * @param name defines the name of the animation range to look for
  102236. * @returns null if not found else the requested animation range
  102237. */
  102238. getAnimationRange(name: string): Nullable<AnimationRange>;
  102239. /**
  102240. * Gets the list of all animation ranges defined on this node
  102241. * @returns an array
  102242. */
  102243. getAnimationRanges(): Nullable<AnimationRange>[];
  102244. /**
  102245. * Will start the animation sequence
  102246. * @param name defines the range frames for animation sequence
  102247. * @param loop defines if the animation should loop (false by default)
  102248. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102249. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102250. * @returns the object created for this animation. If range does not exist, it will return null
  102251. */
  102252. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102253. /**
  102254. * Serialize animation ranges into a JSON compatible object
  102255. * @returns serialization object
  102256. */
  102257. serializeAnimationRanges(): any;
  102258. /**
  102259. * Computes the world matrix of the node
  102260. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102261. * @returns the world matrix
  102262. */
  102263. computeWorldMatrix(force?: boolean): Matrix;
  102264. /**
  102265. * Releases resources associated with this node.
  102266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102268. */
  102269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102270. /**
  102271. * Parse animation range data from a serialization object and store them into a given node
  102272. * @param node defines where to store the animation ranges
  102273. * @param parsedNode defines the serialization object to read data from
  102274. * @param scene defines the hosting scene
  102275. */
  102276. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102277. /**
  102278. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102279. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102280. * @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
  102281. * @returns the new bounding vectors
  102282. */
  102283. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102284. min: Vector3;
  102285. max: Vector3;
  102286. };
  102287. }
  102288. }
  102289. declare module BABYLON {
  102290. /**
  102291. * @hidden
  102292. */
  102293. export class _IAnimationState {
  102294. key: number;
  102295. repeatCount: number;
  102296. workValue?: any;
  102297. loopMode?: number;
  102298. offsetValue?: any;
  102299. highLimitValue?: any;
  102300. }
  102301. /**
  102302. * Class used to store any kind of animation
  102303. */
  102304. export class Animation {
  102305. /**Name of the animation */
  102306. name: string;
  102307. /**Property to animate */
  102308. targetProperty: string;
  102309. /**The frames per second of the animation */
  102310. framePerSecond: number;
  102311. /**The data type of the animation */
  102312. dataType: number;
  102313. /**The loop mode of the animation */
  102314. loopMode?: number | undefined;
  102315. /**Specifies if blending should be enabled */
  102316. enableBlending?: boolean | undefined;
  102317. /**
  102318. * Use matrix interpolation instead of using direct key value when animating matrices
  102319. */
  102320. static AllowMatricesInterpolation: boolean;
  102321. /**
  102322. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102323. */
  102324. static AllowMatrixDecomposeForInterpolation: boolean;
  102325. /**
  102326. * Stores the key frames of the animation
  102327. */
  102328. private _keys;
  102329. /**
  102330. * Stores the easing function of the animation
  102331. */
  102332. private _easingFunction;
  102333. /**
  102334. * @hidden Internal use only
  102335. */
  102336. _runtimeAnimations: RuntimeAnimation[];
  102337. /**
  102338. * The set of event that will be linked to this animation
  102339. */
  102340. private _events;
  102341. /**
  102342. * Stores an array of target property paths
  102343. */
  102344. targetPropertyPath: string[];
  102345. /**
  102346. * Stores the blending speed of the animation
  102347. */
  102348. blendingSpeed: number;
  102349. /**
  102350. * Stores the animation ranges for the animation
  102351. */
  102352. private _ranges;
  102353. /**
  102354. * @hidden Internal use
  102355. */
  102356. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102357. /**
  102358. * Sets up an animation
  102359. * @param property The property to animate
  102360. * @param animationType The animation type to apply
  102361. * @param framePerSecond The frames per second of the animation
  102362. * @param easingFunction The easing function used in the animation
  102363. * @returns The created animation
  102364. */
  102365. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102366. /**
  102367. * Create and start an animation on a node
  102368. * @param name defines the name of the global animation that will be run on all nodes
  102369. * @param node defines the root node where the animation will take place
  102370. * @param targetProperty defines property to animate
  102371. * @param framePerSecond defines the number of frame per second yo use
  102372. * @param totalFrame defines the number of frames in total
  102373. * @param from defines the initial value
  102374. * @param to defines the final value
  102375. * @param loopMode defines which loop mode you want to use (off by default)
  102376. * @param easingFunction defines the easing function to use (linear by default)
  102377. * @param onAnimationEnd defines the callback to call when animation end
  102378. * @returns the animatable created for this animation
  102379. */
  102380. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102381. /**
  102382. * Create and start an animation on a node and its descendants
  102383. * @param name defines the name of the global animation that will be run on all nodes
  102384. * @param node defines the root node where the animation will take place
  102385. * @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
  102386. * @param targetProperty defines property to animate
  102387. * @param framePerSecond defines the number of frame per second to use
  102388. * @param totalFrame defines the number of frames in total
  102389. * @param from defines the initial value
  102390. * @param to defines the final value
  102391. * @param loopMode defines which loop mode you want to use (off by default)
  102392. * @param easingFunction defines the easing function to use (linear by default)
  102393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102394. * @returns the list of animatables created for all nodes
  102395. * @example https://www.babylonjs-playground.com/#MH0VLI
  102396. */
  102397. 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[]>;
  102398. /**
  102399. * Creates a new animation, merges it with the existing animations and starts it
  102400. * @param name Name of the animation
  102401. * @param node Node which contains the scene that begins the animations
  102402. * @param targetProperty Specifies which property to animate
  102403. * @param framePerSecond The frames per second of the animation
  102404. * @param totalFrame The total number of frames
  102405. * @param from The frame at the beginning of the animation
  102406. * @param to The frame at the end of the animation
  102407. * @param loopMode Specifies the loop mode of the animation
  102408. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102409. * @param onAnimationEnd Callback to run once the animation is complete
  102410. * @returns Nullable animation
  102411. */
  102412. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102413. /**
  102414. * Transition property of an host to the target Value
  102415. * @param property The property to transition
  102416. * @param targetValue The target Value of the property
  102417. * @param host The object where the property to animate belongs
  102418. * @param scene Scene used to run the animation
  102419. * @param frameRate Framerate (in frame/s) to use
  102420. * @param transition The transition type we want to use
  102421. * @param duration The duration of the animation, in milliseconds
  102422. * @param onAnimationEnd Callback trigger at the end of the animation
  102423. * @returns Nullable animation
  102424. */
  102425. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102426. /**
  102427. * Return the array of runtime animations currently using this animation
  102428. */
  102429. get runtimeAnimations(): RuntimeAnimation[];
  102430. /**
  102431. * Specifies if any of the runtime animations are currently running
  102432. */
  102433. get hasRunningRuntimeAnimations(): boolean;
  102434. /**
  102435. * Initializes the animation
  102436. * @param name Name of the animation
  102437. * @param targetProperty Property to animate
  102438. * @param framePerSecond The frames per second of the animation
  102439. * @param dataType The data type of the animation
  102440. * @param loopMode The loop mode of the animation
  102441. * @param enableBlending Specifies if blending should be enabled
  102442. */
  102443. constructor(
  102444. /**Name of the animation */
  102445. name: string,
  102446. /**Property to animate */
  102447. targetProperty: string,
  102448. /**The frames per second of the animation */
  102449. framePerSecond: number,
  102450. /**The data type of the animation */
  102451. dataType: number,
  102452. /**The loop mode of the animation */
  102453. loopMode?: number | undefined,
  102454. /**Specifies if blending should be enabled */
  102455. enableBlending?: boolean | undefined);
  102456. /**
  102457. * Converts the animation to a string
  102458. * @param fullDetails support for multiple levels of logging within scene loading
  102459. * @returns String form of the animation
  102460. */
  102461. toString(fullDetails?: boolean): string;
  102462. /**
  102463. * Add an event to this animation
  102464. * @param event Event to add
  102465. */
  102466. addEvent(event: AnimationEvent): void;
  102467. /**
  102468. * Remove all events found at the given frame
  102469. * @param frame The frame to remove events from
  102470. */
  102471. removeEvents(frame: number): void;
  102472. /**
  102473. * Retrieves all the events from the animation
  102474. * @returns Events from the animation
  102475. */
  102476. getEvents(): AnimationEvent[];
  102477. /**
  102478. * Creates an animation range
  102479. * @param name Name of the animation range
  102480. * @param from Starting frame of the animation range
  102481. * @param to Ending frame of the animation
  102482. */
  102483. createRange(name: string, from: number, to: number): void;
  102484. /**
  102485. * Deletes an animation range by name
  102486. * @param name Name of the animation range to delete
  102487. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102488. */
  102489. deleteRange(name: string, deleteFrames?: boolean): void;
  102490. /**
  102491. * Gets the animation range by name, or null if not defined
  102492. * @param name Name of the animation range
  102493. * @returns Nullable animation range
  102494. */
  102495. getRange(name: string): Nullable<AnimationRange>;
  102496. /**
  102497. * Gets the key frames from the animation
  102498. * @returns The key frames of the animation
  102499. */
  102500. getKeys(): Array<IAnimationKey>;
  102501. /**
  102502. * Gets the highest frame rate of the animation
  102503. * @returns Highest frame rate of the animation
  102504. */
  102505. getHighestFrame(): number;
  102506. /**
  102507. * Gets the easing function of the animation
  102508. * @returns Easing function of the animation
  102509. */
  102510. getEasingFunction(): IEasingFunction;
  102511. /**
  102512. * Sets the easing function of the animation
  102513. * @param easingFunction A custom mathematical formula for animation
  102514. */
  102515. setEasingFunction(easingFunction: EasingFunction): void;
  102516. /**
  102517. * Interpolates a scalar linearly
  102518. * @param startValue Start value of the animation curve
  102519. * @param endValue End value of the animation curve
  102520. * @param gradient Scalar amount to interpolate
  102521. * @returns Interpolated scalar value
  102522. */
  102523. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102524. /**
  102525. * Interpolates a scalar cubically
  102526. * @param startValue Start value of the animation curve
  102527. * @param outTangent End tangent of the animation
  102528. * @param endValue End value of the animation curve
  102529. * @param inTangent Start tangent of the animation curve
  102530. * @param gradient Scalar amount to interpolate
  102531. * @returns Interpolated scalar value
  102532. */
  102533. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102534. /**
  102535. * Interpolates a quaternion using a spherical linear interpolation
  102536. * @param startValue Start value of the animation curve
  102537. * @param endValue End value of the animation curve
  102538. * @param gradient Scalar amount to interpolate
  102539. * @returns Interpolated quaternion value
  102540. */
  102541. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102542. /**
  102543. * Interpolates a quaternion cubically
  102544. * @param startValue Start value of the animation curve
  102545. * @param outTangent End tangent of the animation curve
  102546. * @param endValue End value of the animation curve
  102547. * @param inTangent Start tangent of the animation curve
  102548. * @param gradient Scalar amount to interpolate
  102549. * @returns Interpolated quaternion value
  102550. */
  102551. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102552. /**
  102553. * Interpolates a Vector3 linearl
  102554. * @param startValue Start value of the animation curve
  102555. * @param endValue End value of the animation curve
  102556. * @param gradient Scalar amount to interpolate
  102557. * @returns Interpolated scalar value
  102558. */
  102559. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102560. /**
  102561. * Interpolates a Vector3 cubically
  102562. * @param startValue Start value of the animation curve
  102563. * @param outTangent End tangent of the animation
  102564. * @param endValue End value of the animation curve
  102565. * @param inTangent Start tangent of the animation curve
  102566. * @param gradient Scalar amount to interpolate
  102567. * @returns InterpolatedVector3 value
  102568. */
  102569. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102570. /**
  102571. * Interpolates a Vector2 linearly
  102572. * @param startValue Start value of the animation curve
  102573. * @param endValue End value of the animation curve
  102574. * @param gradient Scalar amount to interpolate
  102575. * @returns Interpolated Vector2 value
  102576. */
  102577. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102578. /**
  102579. * Interpolates a Vector2 cubically
  102580. * @param startValue Start value of the animation curve
  102581. * @param outTangent End tangent of the animation
  102582. * @param endValue End value of the animation curve
  102583. * @param inTangent Start tangent of the animation curve
  102584. * @param gradient Scalar amount to interpolate
  102585. * @returns Interpolated Vector2 value
  102586. */
  102587. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102588. /**
  102589. * Interpolates a size linearly
  102590. * @param startValue Start value of the animation curve
  102591. * @param endValue End value of the animation curve
  102592. * @param gradient Scalar amount to interpolate
  102593. * @returns Interpolated Size value
  102594. */
  102595. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102596. /**
  102597. * Interpolates a Color3 linearly
  102598. * @param startValue Start value of the animation curve
  102599. * @param endValue End value of the animation curve
  102600. * @param gradient Scalar amount to interpolate
  102601. * @returns Interpolated Color3 value
  102602. */
  102603. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102604. /**
  102605. * Interpolates a Color4 linearly
  102606. * @param startValue Start value of the animation curve
  102607. * @param endValue End value of the animation curve
  102608. * @param gradient Scalar amount to interpolate
  102609. * @returns Interpolated Color3 value
  102610. */
  102611. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102612. /**
  102613. * @hidden Internal use only
  102614. */
  102615. _getKeyValue(value: any): any;
  102616. /**
  102617. * @hidden Internal use only
  102618. */
  102619. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102620. /**
  102621. * Defines the function to use to interpolate matrices
  102622. * @param startValue defines the start matrix
  102623. * @param endValue defines the end matrix
  102624. * @param gradient defines the gradient between both matrices
  102625. * @param result defines an optional target matrix where to store the interpolation
  102626. * @returns the interpolated matrix
  102627. */
  102628. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102629. /**
  102630. * Makes a copy of the animation
  102631. * @returns Cloned animation
  102632. */
  102633. clone(): Animation;
  102634. /**
  102635. * Sets the key frames of the animation
  102636. * @param values The animation key frames to set
  102637. */
  102638. setKeys(values: Array<IAnimationKey>): void;
  102639. /**
  102640. * Serializes the animation to an object
  102641. * @returns Serialized object
  102642. */
  102643. serialize(): any;
  102644. /**
  102645. * Float animation type
  102646. */
  102647. static readonly ANIMATIONTYPE_FLOAT: number;
  102648. /**
  102649. * Vector3 animation type
  102650. */
  102651. static readonly ANIMATIONTYPE_VECTOR3: number;
  102652. /**
  102653. * Quaternion animation type
  102654. */
  102655. static readonly ANIMATIONTYPE_QUATERNION: number;
  102656. /**
  102657. * Matrix animation type
  102658. */
  102659. static readonly ANIMATIONTYPE_MATRIX: number;
  102660. /**
  102661. * Color3 animation type
  102662. */
  102663. static readonly ANIMATIONTYPE_COLOR3: number;
  102664. /**
  102665. * Color3 animation type
  102666. */
  102667. static readonly ANIMATIONTYPE_COLOR4: number;
  102668. /**
  102669. * Vector2 animation type
  102670. */
  102671. static readonly ANIMATIONTYPE_VECTOR2: number;
  102672. /**
  102673. * Size animation type
  102674. */
  102675. static readonly ANIMATIONTYPE_SIZE: number;
  102676. /**
  102677. * Relative Loop Mode
  102678. */
  102679. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102680. /**
  102681. * Cycle Loop Mode
  102682. */
  102683. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102684. /**
  102685. * Constant Loop Mode
  102686. */
  102687. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102688. /** @hidden */
  102689. static _UniversalLerp(left: any, right: any, amount: number): any;
  102690. /**
  102691. * Parses an animation object and creates an animation
  102692. * @param parsedAnimation Parsed animation object
  102693. * @returns Animation object
  102694. */
  102695. static Parse(parsedAnimation: any): Animation;
  102696. /**
  102697. * Appends the serialized animations from the source animations
  102698. * @param source Source containing the animations
  102699. * @param destination Target to store the animations
  102700. */
  102701. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102702. }
  102703. }
  102704. declare module BABYLON {
  102705. /**
  102706. * Interface containing an array of animations
  102707. */
  102708. export interface IAnimatable {
  102709. /**
  102710. * Array of animations
  102711. */
  102712. animations: Nullable<Array<Animation>>;
  102713. }
  102714. }
  102715. declare module BABYLON {
  102716. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102717. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102718. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102719. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102720. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102721. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102722. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102723. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102724. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102725. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102726. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102727. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102728. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102729. /**
  102730. * Decorator used to define property that can be serialized as reference to a camera
  102731. * @param sourceName defines the name of the property to decorate
  102732. */
  102733. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102734. /**
  102735. * Class used to help serialization objects
  102736. */
  102737. export class SerializationHelper {
  102738. /** @hidden */
  102739. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102740. /** @hidden */
  102741. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102742. /** @hidden */
  102743. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102744. /** @hidden */
  102745. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102746. /**
  102747. * Appends the serialized animations from the source animations
  102748. * @param source Source containing the animations
  102749. * @param destination Target to store the animations
  102750. */
  102751. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102752. /**
  102753. * Static function used to serialized a specific entity
  102754. * @param entity defines the entity to serialize
  102755. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102756. * @returns a JSON compatible object representing the serialization of the entity
  102757. */
  102758. static Serialize<T>(entity: T, serializationObject?: any): any;
  102759. /**
  102760. * Creates a new entity from a serialization data object
  102761. * @param creationFunction defines a function used to instanciated the new entity
  102762. * @param source defines the source serialization data
  102763. * @param scene defines the hosting scene
  102764. * @param rootUrl defines the root url for resources
  102765. * @returns a new entity
  102766. */
  102767. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102768. /**
  102769. * Clones an object
  102770. * @param creationFunction defines the function used to instanciate the new object
  102771. * @param source defines the source object
  102772. * @returns the cloned object
  102773. */
  102774. static Clone<T>(creationFunction: () => T, source: T): T;
  102775. /**
  102776. * Instanciates a new object based on a source one (some data will be shared between both object)
  102777. * @param creationFunction defines the function used to instanciate the new object
  102778. * @param source defines the source object
  102779. * @returns the new object
  102780. */
  102781. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102782. }
  102783. }
  102784. declare module BABYLON {
  102785. /**
  102786. * Class used to manipulate GUIDs
  102787. */
  102788. export class GUID {
  102789. /**
  102790. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102791. * Be aware Math.random() could cause collisions, but:
  102792. * "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"
  102793. * @returns a pseudo random id
  102794. */
  102795. static RandomId(): string;
  102796. }
  102797. }
  102798. declare module BABYLON {
  102799. /**
  102800. * Base class of all the textures in babylon.
  102801. * It groups all the common properties the materials, post process, lights... might need
  102802. * in order to make a correct use of the texture.
  102803. */
  102804. export class BaseTexture implements IAnimatable {
  102805. /**
  102806. * Default anisotropic filtering level for the application.
  102807. * It is set to 4 as a good tradeoff between perf and quality.
  102808. */
  102809. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102810. /**
  102811. * Gets or sets the unique id of the texture
  102812. */
  102813. uniqueId: number;
  102814. /**
  102815. * Define the name of the texture.
  102816. */
  102817. name: string;
  102818. /**
  102819. * Gets or sets an object used to store user defined information.
  102820. */
  102821. metadata: any;
  102822. /**
  102823. * For internal use only. Please do not use.
  102824. */
  102825. reservedDataStore: any;
  102826. private _hasAlpha;
  102827. /**
  102828. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102829. */
  102830. set hasAlpha(value: boolean);
  102831. get hasAlpha(): boolean;
  102832. /**
  102833. * Defines if the alpha value should be determined via the rgb values.
  102834. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102835. */
  102836. getAlphaFromRGB: boolean;
  102837. /**
  102838. * Intensity or strength of the texture.
  102839. * It is commonly used by materials to fine tune the intensity of the texture
  102840. */
  102841. level: number;
  102842. /**
  102843. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102844. * This is part of the texture as textures usually maps to one uv set.
  102845. */
  102846. coordinatesIndex: number;
  102847. private _coordinatesMode;
  102848. /**
  102849. * How a texture is mapped.
  102850. *
  102851. * | Value | Type | Description |
  102852. * | ----- | ----------------------------------- | ----------- |
  102853. * | 0 | EXPLICIT_MODE | |
  102854. * | 1 | SPHERICAL_MODE | |
  102855. * | 2 | PLANAR_MODE | |
  102856. * | 3 | CUBIC_MODE | |
  102857. * | 4 | PROJECTION_MODE | |
  102858. * | 5 | SKYBOX_MODE | |
  102859. * | 6 | INVCUBIC_MODE | |
  102860. * | 7 | EQUIRECTANGULAR_MODE | |
  102861. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102862. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102863. */
  102864. set coordinatesMode(value: number);
  102865. get coordinatesMode(): number;
  102866. /**
  102867. * | Value | Type | Description |
  102868. * | ----- | ------------------ | ----------- |
  102869. * | 0 | CLAMP_ADDRESSMODE | |
  102870. * | 1 | WRAP_ADDRESSMODE | |
  102871. * | 2 | MIRROR_ADDRESSMODE | |
  102872. */
  102873. wrapU: number;
  102874. /**
  102875. * | Value | Type | Description |
  102876. * | ----- | ------------------ | ----------- |
  102877. * | 0 | CLAMP_ADDRESSMODE | |
  102878. * | 1 | WRAP_ADDRESSMODE | |
  102879. * | 2 | MIRROR_ADDRESSMODE | |
  102880. */
  102881. wrapV: number;
  102882. /**
  102883. * | Value | Type | Description |
  102884. * | ----- | ------------------ | ----------- |
  102885. * | 0 | CLAMP_ADDRESSMODE | |
  102886. * | 1 | WRAP_ADDRESSMODE | |
  102887. * | 2 | MIRROR_ADDRESSMODE | |
  102888. */
  102889. wrapR: number;
  102890. /**
  102891. * With compliant hardware and browser (supporting anisotropic filtering)
  102892. * this defines the level of anisotropic filtering in the texture.
  102893. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102894. */
  102895. anisotropicFilteringLevel: number;
  102896. /**
  102897. * Define if the texture is a cube texture or if false a 2d texture.
  102898. */
  102899. get isCube(): boolean;
  102900. set isCube(value: boolean);
  102901. /**
  102902. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102903. */
  102904. get is3D(): boolean;
  102905. set is3D(value: boolean);
  102906. /**
  102907. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102908. */
  102909. get is2DArray(): boolean;
  102910. set is2DArray(value: boolean);
  102911. /**
  102912. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102913. * HDR texture are usually stored in linear space.
  102914. * This only impacts the PBR and Background materials
  102915. */
  102916. gammaSpace: boolean;
  102917. /**
  102918. * Gets or sets whether or not the texture contains RGBD data.
  102919. */
  102920. get isRGBD(): boolean;
  102921. set isRGBD(value: boolean);
  102922. /**
  102923. * Is Z inverted in the texture (useful in a cube texture).
  102924. */
  102925. invertZ: boolean;
  102926. /**
  102927. * Are mip maps generated for this texture or not.
  102928. */
  102929. get noMipmap(): boolean;
  102930. /**
  102931. * @hidden
  102932. */
  102933. lodLevelInAlpha: boolean;
  102934. /**
  102935. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102936. */
  102937. get lodGenerationOffset(): number;
  102938. set lodGenerationOffset(value: number);
  102939. /**
  102940. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102941. */
  102942. get lodGenerationScale(): number;
  102943. set lodGenerationScale(value: number);
  102944. /**
  102945. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102946. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102947. * average roughness values.
  102948. */
  102949. get linearSpecularLOD(): boolean;
  102950. set linearSpecularLOD(value: boolean);
  102951. /**
  102952. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102953. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102954. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102955. */
  102956. get irradianceTexture(): Nullable<BaseTexture>;
  102957. set irradianceTexture(value: Nullable<BaseTexture>);
  102958. /**
  102959. * Define if the texture is a render target.
  102960. */
  102961. isRenderTarget: boolean;
  102962. /**
  102963. * Define the unique id of the texture in the scene.
  102964. */
  102965. get uid(): string;
  102966. /**
  102967. * Return a string representation of the texture.
  102968. * @returns the texture as a string
  102969. */
  102970. toString(): string;
  102971. /**
  102972. * Get the class name of the texture.
  102973. * @returns "BaseTexture"
  102974. */
  102975. getClassName(): string;
  102976. /**
  102977. * Define the list of animation attached to the texture.
  102978. */
  102979. animations: Animation[];
  102980. /**
  102981. * An event triggered when the texture is disposed.
  102982. */
  102983. onDisposeObservable: Observable<BaseTexture>;
  102984. private _onDisposeObserver;
  102985. /**
  102986. * Callback triggered when the texture has been disposed.
  102987. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102988. */
  102989. set onDispose(callback: () => void);
  102990. /**
  102991. * Define the current state of the loading sequence when in delayed load mode.
  102992. */
  102993. delayLoadState: number;
  102994. private _scene;
  102995. /** @hidden */
  102996. _texture: Nullable<InternalTexture>;
  102997. private _uid;
  102998. /**
  102999. * Define if the texture is preventinga material to render or not.
  103000. * If not and the texture is not ready, the engine will use a default black texture instead.
  103001. */
  103002. get isBlocking(): boolean;
  103003. /**
  103004. * Instantiates a new BaseTexture.
  103005. * Base class of all the textures in babylon.
  103006. * It groups all the common properties the materials, post process, lights... might need
  103007. * in order to make a correct use of the texture.
  103008. * @param scene Define the scene the texture blongs to
  103009. */
  103010. constructor(scene: Nullable<Scene>);
  103011. /**
  103012. * Get the scene the texture belongs to.
  103013. * @returns the scene or null if undefined
  103014. */
  103015. getScene(): Nullable<Scene>;
  103016. /**
  103017. * Get the texture transform matrix used to offset tile the texture for istance.
  103018. * @returns the transformation matrix
  103019. */
  103020. getTextureMatrix(): Matrix;
  103021. /**
  103022. * Get the texture reflection matrix used to rotate/transform the reflection.
  103023. * @returns the reflection matrix
  103024. */
  103025. getReflectionTextureMatrix(): Matrix;
  103026. /**
  103027. * Get the underlying lower level texture from Babylon.
  103028. * @returns the insternal texture
  103029. */
  103030. getInternalTexture(): Nullable<InternalTexture>;
  103031. /**
  103032. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103033. * @returns true if ready or not blocking
  103034. */
  103035. isReadyOrNotBlocking(): boolean;
  103036. /**
  103037. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103038. * @returns true if fully ready
  103039. */
  103040. isReady(): boolean;
  103041. private _cachedSize;
  103042. /**
  103043. * Get the size of the texture.
  103044. * @returns the texture size.
  103045. */
  103046. getSize(): ISize;
  103047. /**
  103048. * Get the base size of the texture.
  103049. * It can be different from the size if the texture has been resized for POT for instance
  103050. * @returns the base size
  103051. */
  103052. getBaseSize(): ISize;
  103053. /**
  103054. * Update the sampling mode of the texture.
  103055. * Default is Trilinear mode.
  103056. *
  103057. * | Value | Type | Description |
  103058. * | ----- | ------------------ | ----------- |
  103059. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103060. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103061. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103062. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103063. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103064. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103065. * | 7 | NEAREST_LINEAR | |
  103066. * | 8 | NEAREST_NEAREST | |
  103067. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103068. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103069. * | 11 | LINEAR_LINEAR | |
  103070. * | 12 | LINEAR_NEAREST | |
  103071. *
  103072. * > _mag_: magnification filter (close to the viewer)
  103073. * > _min_: minification filter (far from the viewer)
  103074. * > _mip_: filter used between mip map levels
  103075. *@param samplingMode Define the new sampling mode of the texture
  103076. */
  103077. updateSamplingMode(samplingMode: number): void;
  103078. /**
  103079. * Scales the texture if is `canRescale()`
  103080. * @param ratio the resize factor we want to use to rescale
  103081. */
  103082. scale(ratio: number): void;
  103083. /**
  103084. * Get if the texture can rescale.
  103085. */
  103086. get canRescale(): boolean;
  103087. /** @hidden */
  103088. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103089. /** @hidden */
  103090. _rebuild(): void;
  103091. /**
  103092. * Triggers the load sequence in delayed load mode.
  103093. */
  103094. delayLoad(): void;
  103095. /**
  103096. * Clones the texture.
  103097. * @returns the cloned texture
  103098. */
  103099. clone(): Nullable<BaseTexture>;
  103100. /**
  103101. * Get the texture underlying type (INT, FLOAT...)
  103102. */
  103103. get textureType(): number;
  103104. /**
  103105. * Get the texture underlying format (RGB, RGBA...)
  103106. */
  103107. get textureFormat(): number;
  103108. /**
  103109. * Indicates that textures need to be re-calculated for all materials
  103110. */
  103111. protected _markAllSubMeshesAsTexturesDirty(): void;
  103112. /**
  103113. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103114. * This will returns an RGBA array buffer containing either in values (0-255) or
  103115. * float values (0-1) depending of the underlying buffer type.
  103116. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103117. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103118. * @param buffer defines a user defined buffer to fill with data (can be null)
  103119. * @returns The Array buffer containing the pixels data.
  103120. */
  103121. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103122. /**
  103123. * Release and destroy the underlying lower level texture aka internalTexture.
  103124. */
  103125. releaseInternalTexture(): void;
  103126. /** @hidden */
  103127. get _lodTextureHigh(): Nullable<BaseTexture>;
  103128. /** @hidden */
  103129. get _lodTextureMid(): Nullable<BaseTexture>;
  103130. /** @hidden */
  103131. get _lodTextureLow(): Nullable<BaseTexture>;
  103132. /**
  103133. * Dispose the texture and release its associated resources.
  103134. */
  103135. dispose(): void;
  103136. /**
  103137. * Serialize the texture into a JSON representation that can be parsed later on.
  103138. * @returns the JSON representation of the texture
  103139. */
  103140. serialize(): any;
  103141. /**
  103142. * Helper function to be called back once a list of texture contains only ready textures.
  103143. * @param textures Define the list of textures to wait for
  103144. * @param callback Define the callback triggered once the entire list will be ready
  103145. */
  103146. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103147. }
  103148. }
  103149. declare module BABYLON {
  103150. /**
  103151. * Options to be used when creating an effect.
  103152. */
  103153. export interface IEffectCreationOptions {
  103154. /**
  103155. * Atrributes that will be used in the shader.
  103156. */
  103157. attributes: string[];
  103158. /**
  103159. * Uniform varible names that will be set in the shader.
  103160. */
  103161. uniformsNames: string[];
  103162. /**
  103163. * Uniform buffer variable names that will be set in the shader.
  103164. */
  103165. uniformBuffersNames: string[];
  103166. /**
  103167. * Sampler texture variable names that will be set in the shader.
  103168. */
  103169. samplers: string[];
  103170. /**
  103171. * Define statements that will be set in the shader.
  103172. */
  103173. defines: any;
  103174. /**
  103175. * Possible fallbacks for this effect to improve performance when needed.
  103176. */
  103177. fallbacks: Nullable<IEffectFallbacks>;
  103178. /**
  103179. * Callback that will be called when the shader is compiled.
  103180. */
  103181. onCompiled: Nullable<(effect: Effect) => void>;
  103182. /**
  103183. * Callback that will be called if an error occurs during shader compilation.
  103184. */
  103185. onError: Nullable<(effect: Effect, errors: string) => void>;
  103186. /**
  103187. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103188. */
  103189. indexParameters?: any;
  103190. /**
  103191. * Max number of lights that can be used in the shader.
  103192. */
  103193. maxSimultaneousLights?: number;
  103194. /**
  103195. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103196. */
  103197. transformFeedbackVaryings?: Nullable<string[]>;
  103198. }
  103199. /**
  103200. * Effect containing vertex and fragment shader that can be executed on an object.
  103201. */
  103202. export class Effect implements IDisposable {
  103203. /**
  103204. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103205. */
  103206. static ShadersRepository: string;
  103207. /**
  103208. * Name of the effect.
  103209. */
  103210. name: any;
  103211. /**
  103212. * String container all the define statements that should be set on the shader.
  103213. */
  103214. defines: string;
  103215. /**
  103216. * Callback that will be called when the shader is compiled.
  103217. */
  103218. onCompiled: Nullable<(effect: Effect) => void>;
  103219. /**
  103220. * Callback that will be called if an error occurs during shader compilation.
  103221. */
  103222. onError: Nullable<(effect: Effect, errors: string) => void>;
  103223. /**
  103224. * Callback that will be called when effect is bound.
  103225. */
  103226. onBind: Nullable<(effect: Effect) => void>;
  103227. /**
  103228. * Unique ID of the effect.
  103229. */
  103230. uniqueId: number;
  103231. /**
  103232. * Observable that will be called when the shader is compiled.
  103233. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103234. */
  103235. onCompileObservable: Observable<Effect>;
  103236. /**
  103237. * Observable that will be called if an error occurs during shader compilation.
  103238. */
  103239. onErrorObservable: Observable<Effect>;
  103240. /** @hidden */
  103241. _onBindObservable: Nullable<Observable<Effect>>;
  103242. /**
  103243. * @hidden
  103244. * Specifies if the effect was previously ready
  103245. */
  103246. _wasPreviouslyReady: boolean;
  103247. /**
  103248. * Observable that will be called when effect is bound.
  103249. */
  103250. get onBindObservable(): Observable<Effect>;
  103251. /** @hidden */
  103252. _bonesComputationForcedToCPU: boolean;
  103253. private static _uniqueIdSeed;
  103254. private _engine;
  103255. private _uniformBuffersNames;
  103256. private _uniformsNames;
  103257. private _samplerList;
  103258. private _samplers;
  103259. private _isReady;
  103260. private _compilationError;
  103261. private _allFallbacksProcessed;
  103262. private _attributesNames;
  103263. private _attributes;
  103264. private _attributeLocationByName;
  103265. private _uniforms;
  103266. /**
  103267. * Key for the effect.
  103268. * @hidden
  103269. */
  103270. _key: string;
  103271. private _indexParameters;
  103272. private _fallbacks;
  103273. private _vertexSourceCode;
  103274. private _fragmentSourceCode;
  103275. private _vertexSourceCodeOverride;
  103276. private _fragmentSourceCodeOverride;
  103277. private _transformFeedbackVaryings;
  103278. /**
  103279. * Compiled shader to webGL program.
  103280. * @hidden
  103281. */
  103282. _pipelineContext: Nullable<IPipelineContext>;
  103283. private _valueCache;
  103284. private static _baseCache;
  103285. /**
  103286. * Instantiates an effect.
  103287. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103288. * @param baseName Name of the effect.
  103289. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103290. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103291. * @param samplers List of sampler variables that will be passed to the shader.
  103292. * @param engine Engine to be used to render the effect
  103293. * @param defines Define statements to be added to the shader.
  103294. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103295. * @param onCompiled Callback that will be called when the shader is compiled.
  103296. * @param onError Callback that will be called if an error occurs during shader compilation.
  103297. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103298. */
  103299. 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);
  103300. private _useFinalCode;
  103301. /**
  103302. * Unique key for this effect
  103303. */
  103304. get key(): string;
  103305. /**
  103306. * If the effect has been compiled and prepared.
  103307. * @returns if the effect is compiled and prepared.
  103308. */
  103309. isReady(): boolean;
  103310. private _isReadyInternal;
  103311. /**
  103312. * The engine the effect was initialized with.
  103313. * @returns the engine.
  103314. */
  103315. getEngine(): Engine;
  103316. /**
  103317. * The pipeline context for this effect
  103318. * @returns the associated pipeline context
  103319. */
  103320. getPipelineContext(): Nullable<IPipelineContext>;
  103321. /**
  103322. * The set of names of attribute variables for the shader.
  103323. * @returns An array of attribute names.
  103324. */
  103325. getAttributesNames(): string[];
  103326. /**
  103327. * Returns the attribute at the given index.
  103328. * @param index The index of the attribute.
  103329. * @returns The location of the attribute.
  103330. */
  103331. getAttributeLocation(index: number): number;
  103332. /**
  103333. * Returns the attribute based on the name of the variable.
  103334. * @param name of the attribute to look up.
  103335. * @returns the attribute location.
  103336. */
  103337. getAttributeLocationByName(name: string): number;
  103338. /**
  103339. * The number of attributes.
  103340. * @returns the numnber of attributes.
  103341. */
  103342. getAttributesCount(): number;
  103343. /**
  103344. * Gets the index of a uniform variable.
  103345. * @param uniformName of the uniform to look up.
  103346. * @returns the index.
  103347. */
  103348. getUniformIndex(uniformName: string): number;
  103349. /**
  103350. * Returns the attribute based on the name of the variable.
  103351. * @param uniformName of the uniform to look up.
  103352. * @returns the location of the uniform.
  103353. */
  103354. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103355. /**
  103356. * Returns an array of sampler variable names
  103357. * @returns The array of sampler variable neames.
  103358. */
  103359. getSamplers(): string[];
  103360. /**
  103361. * The error from the last compilation.
  103362. * @returns the error string.
  103363. */
  103364. getCompilationError(): string;
  103365. /**
  103366. * Gets a boolean indicating that all fallbacks were used during compilation
  103367. * @returns true if all fallbacks were used
  103368. */
  103369. allFallbacksProcessed(): boolean;
  103370. /**
  103371. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103372. * @param func The callback to be used.
  103373. */
  103374. executeWhenCompiled(func: (effect: Effect) => void): void;
  103375. private _checkIsReady;
  103376. private _loadShader;
  103377. /**
  103378. * Recompiles the webGL program
  103379. * @param vertexSourceCode The source code for the vertex shader.
  103380. * @param fragmentSourceCode The source code for the fragment shader.
  103381. * @param onCompiled Callback called when completed.
  103382. * @param onError Callback called on error.
  103383. * @hidden
  103384. */
  103385. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103386. /**
  103387. * Prepares the effect
  103388. * @hidden
  103389. */
  103390. _prepareEffect(): void;
  103391. private _processCompilationErrors;
  103392. /**
  103393. * Checks if the effect is supported. (Must be called after compilation)
  103394. */
  103395. get isSupported(): boolean;
  103396. /**
  103397. * Binds a texture to the engine to be used as output of the shader.
  103398. * @param channel Name of the output variable.
  103399. * @param texture Texture to bind.
  103400. * @hidden
  103401. */
  103402. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103403. /**
  103404. * Sets a texture on the engine to be used in the shader.
  103405. * @param channel Name of the sampler variable.
  103406. * @param texture Texture to set.
  103407. */
  103408. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103409. /**
  103410. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103411. * @param channel Name of the sampler variable.
  103412. * @param texture Texture to set.
  103413. */
  103414. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103415. /**
  103416. * Sets an array of textures on the engine to be used in the shader.
  103417. * @param channel Name of the variable.
  103418. * @param textures Textures to set.
  103419. */
  103420. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103421. /**
  103422. * 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)
  103423. * @param channel Name of the sampler variable.
  103424. * @param postProcess Post process to get the input texture from.
  103425. */
  103426. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103427. /**
  103428. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103429. * 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)
  103430. * @param channel Name of the sampler variable.
  103431. * @param postProcess Post process to get the output texture from.
  103432. */
  103433. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103434. /** @hidden */
  103435. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103436. /** @hidden */
  103437. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103438. /** @hidden */
  103439. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103440. /** @hidden */
  103441. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103442. /**
  103443. * Binds a buffer to a uniform.
  103444. * @param buffer Buffer to bind.
  103445. * @param name Name of the uniform variable to bind to.
  103446. */
  103447. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103448. /**
  103449. * Binds block to a uniform.
  103450. * @param blockName Name of the block to bind.
  103451. * @param index Index to bind.
  103452. */
  103453. bindUniformBlock(blockName: string, index: number): void;
  103454. /**
  103455. * Sets an interger value on a uniform variable.
  103456. * @param uniformName Name of the variable.
  103457. * @param value Value to be set.
  103458. * @returns this effect.
  103459. */
  103460. setInt(uniformName: string, value: number): Effect;
  103461. /**
  103462. * Sets an int array on a uniform variable.
  103463. * @param uniformName Name of the variable.
  103464. * @param array array to be set.
  103465. * @returns this effect.
  103466. */
  103467. setIntArray(uniformName: string, array: Int32Array): Effect;
  103468. /**
  103469. * 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)
  103470. * @param uniformName Name of the variable.
  103471. * @param array array to be set.
  103472. * @returns this effect.
  103473. */
  103474. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103475. /**
  103476. * 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)
  103477. * @param uniformName Name of the variable.
  103478. * @param array array to be set.
  103479. * @returns this effect.
  103480. */
  103481. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103482. /**
  103483. * 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)
  103484. * @param uniformName Name of the variable.
  103485. * @param array array to be set.
  103486. * @returns this effect.
  103487. */
  103488. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103489. /**
  103490. * Sets an float array on a uniform variable.
  103491. * @param uniformName Name of the variable.
  103492. * @param array array to be set.
  103493. * @returns this effect.
  103494. */
  103495. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103496. /**
  103497. * 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)
  103498. * @param uniformName Name of the variable.
  103499. * @param array array to be set.
  103500. * @returns this effect.
  103501. */
  103502. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103503. /**
  103504. * 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)
  103505. * @param uniformName Name of the variable.
  103506. * @param array array to be set.
  103507. * @returns this effect.
  103508. */
  103509. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103510. /**
  103511. * 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)
  103512. * @param uniformName Name of the variable.
  103513. * @param array array to be set.
  103514. * @returns this effect.
  103515. */
  103516. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103517. /**
  103518. * Sets an array on a uniform variable.
  103519. * @param uniformName Name of the variable.
  103520. * @param array array to be set.
  103521. * @returns this effect.
  103522. */
  103523. setArray(uniformName: string, array: number[]): Effect;
  103524. /**
  103525. * 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)
  103526. * @param uniformName Name of the variable.
  103527. * @param array array to be set.
  103528. * @returns this effect.
  103529. */
  103530. setArray2(uniformName: string, array: number[]): Effect;
  103531. /**
  103532. * 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)
  103533. * @param uniformName Name of the variable.
  103534. * @param array array to be set.
  103535. * @returns this effect.
  103536. */
  103537. setArray3(uniformName: string, array: number[]): Effect;
  103538. /**
  103539. * 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)
  103540. * @param uniformName Name of the variable.
  103541. * @param array array to be set.
  103542. * @returns this effect.
  103543. */
  103544. setArray4(uniformName: string, array: number[]): Effect;
  103545. /**
  103546. * Sets matrices on a uniform variable.
  103547. * @param uniformName Name of the variable.
  103548. * @param matrices matrices to be set.
  103549. * @returns this effect.
  103550. */
  103551. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103552. /**
  103553. * Sets matrix on a uniform variable.
  103554. * @param uniformName Name of the variable.
  103555. * @param matrix matrix to be set.
  103556. * @returns this effect.
  103557. */
  103558. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103559. /**
  103560. * 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)
  103561. * @param uniformName Name of the variable.
  103562. * @param matrix matrix to be set.
  103563. * @returns this effect.
  103564. */
  103565. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103566. /**
  103567. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103568. * @param uniformName Name of the variable.
  103569. * @param matrix matrix to be set.
  103570. * @returns this effect.
  103571. */
  103572. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103573. /**
  103574. * Sets a float on a uniform variable.
  103575. * @param uniformName Name of the variable.
  103576. * @param value value to be set.
  103577. * @returns this effect.
  103578. */
  103579. setFloat(uniformName: string, value: number): Effect;
  103580. /**
  103581. * Sets a boolean on a uniform variable.
  103582. * @param uniformName Name of the variable.
  103583. * @param bool value to be set.
  103584. * @returns this effect.
  103585. */
  103586. setBool(uniformName: string, bool: boolean): Effect;
  103587. /**
  103588. * Sets a Vector2 on a uniform variable.
  103589. * @param uniformName Name of the variable.
  103590. * @param vector2 vector2 to be set.
  103591. * @returns this effect.
  103592. */
  103593. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103594. /**
  103595. * Sets a float2 on a uniform variable.
  103596. * @param uniformName Name of the variable.
  103597. * @param x First float in float2.
  103598. * @param y Second float in float2.
  103599. * @returns this effect.
  103600. */
  103601. setFloat2(uniformName: string, x: number, y: number): Effect;
  103602. /**
  103603. * Sets a Vector3 on a uniform variable.
  103604. * @param uniformName Name of the variable.
  103605. * @param vector3 Value to be set.
  103606. * @returns this effect.
  103607. */
  103608. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103609. /**
  103610. * Sets a float3 on a uniform variable.
  103611. * @param uniformName Name of the variable.
  103612. * @param x First float in float3.
  103613. * @param y Second float in float3.
  103614. * @param z Third float in float3.
  103615. * @returns this effect.
  103616. */
  103617. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103618. /**
  103619. * Sets a Vector4 on a uniform variable.
  103620. * @param uniformName Name of the variable.
  103621. * @param vector4 Value to be set.
  103622. * @returns this effect.
  103623. */
  103624. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103625. /**
  103626. * Sets a float4 on a uniform variable.
  103627. * @param uniformName Name of the variable.
  103628. * @param x First float in float4.
  103629. * @param y Second float in float4.
  103630. * @param z Third float in float4.
  103631. * @param w Fourth float in float4.
  103632. * @returns this effect.
  103633. */
  103634. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103635. /**
  103636. * Sets a Color3 on a uniform variable.
  103637. * @param uniformName Name of the variable.
  103638. * @param color3 Value to be set.
  103639. * @returns this effect.
  103640. */
  103641. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103642. /**
  103643. * Sets a Color4 on a uniform variable.
  103644. * @param uniformName Name of the variable.
  103645. * @param color3 Value to be set.
  103646. * @param alpha Alpha value to be set.
  103647. * @returns this effect.
  103648. */
  103649. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103650. /**
  103651. * Sets a Color4 on a uniform variable
  103652. * @param uniformName defines the name of the variable
  103653. * @param color4 defines the value to be set
  103654. * @returns this effect.
  103655. */
  103656. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103657. /** Release all associated resources */
  103658. dispose(): void;
  103659. /**
  103660. * This function will add a new shader to the shader store
  103661. * @param name the name of the shader
  103662. * @param pixelShader optional pixel shader content
  103663. * @param vertexShader optional vertex shader content
  103664. */
  103665. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103666. /**
  103667. * Store of each shader (The can be looked up using effect.key)
  103668. */
  103669. static ShadersStore: {
  103670. [key: string]: string;
  103671. };
  103672. /**
  103673. * Store of each included file for a shader (The can be looked up using effect.key)
  103674. */
  103675. static IncludesShadersStore: {
  103676. [key: string]: string;
  103677. };
  103678. /**
  103679. * Resets the cache of effects.
  103680. */
  103681. static ResetCache(): void;
  103682. }
  103683. }
  103684. declare module BABYLON {
  103685. /**
  103686. * Interface used to describe the capabilities of the engine relatively to the current browser
  103687. */
  103688. export interface EngineCapabilities {
  103689. /** Maximum textures units per fragment shader */
  103690. maxTexturesImageUnits: number;
  103691. /** Maximum texture units per vertex shader */
  103692. maxVertexTextureImageUnits: number;
  103693. /** Maximum textures units in the entire pipeline */
  103694. maxCombinedTexturesImageUnits: number;
  103695. /** Maximum texture size */
  103696. maxTextureSize: number;
  103697. /** Maximum texture samples */
  103698. maxSamples?: number;
  103699. /** Maximum cube texture size */
  103700. maxCubemapTextureSize: number;
  103701. /** Maximum render texture size */
  103702. maxRenderTextureSize: number;
  103703. /** Maximum number of vertex attributes */
  103704. maxVertexAttribs: number;
  103705. /** Maximum number of varyings */
  103706. maxVaryingVectors: number;
  103707. /** Maximum number of uniforms per vertex shader */
  103708. maxVertexUniformVectors: number;
  103709. /** Maximum number of uniforms per fragment shader */
  103710. maxFragmentUniformVectors: number;
  103711. /** Defines if standard derivates (dx/dy) are supported */
  103712. standardDerivatives: boolean;
  103713. /** Defines if s3tc texture compression is supported */
  103714. s3tc?: WEBGL_compressed_texture_s3tc;
  103715. /** Defines if pvrtc texture compression is supported */
  103716. pvrtc: any;
  103717. /** Defines if etc1 texture compression is supported */
  103718. etc1: any;
  103719. /** Defines if etc2 texture compression is supported */
  103720. etc2: any;
  103721. /** Defines if astc texture compression is supported */
  103722. astc: any;
  103723. /** Defines if float textures are supported */
  103724. textureFloat: boolean;
  103725. /** Defines if vertex array objects are supported */
  103726. vertexArrayObject: boolean;
  103727. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103728. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103729. /** Gets the maximum level of anisotropy supported */
  103730. maxAnisotropy: number;
  103731. /** Defines if instancing is supported */
  103732. instancedArrays: boolean;
  103733. /** Defines if 32 bits indices are supported */
  103734. uintIndices: boolean;
  103735. /** Defines if high precision shaders are supported */
  103736. highPrecisionShaderSupported: boolean;
  103737. /** Defines if depth reading in the fragment shader is supported */
  103738. fragmentDepthSupported: boolean;
  103739. /** Defines if float texture linear filtering is supported*/
  103740. textureFloatLinearFiltering: boolean;
  103741. /** Defines if rendering to float textures is supported */
  103742. textureFloatRender: boolean;
  103743. /** Defines if half float textures are supported*/
  103744. textureHalfFloat: boolean;
  103745. /** Defines if half float texture linear filtering is supported*/
  103746. textureHalfFloatLinearFiltering: boolean;
  103747. /** Defines if rendering to half float textures is supported */
  103748. textureHalfFloatRender: boolean;
  103749. /** Defines if textureLOD shader command is supported */
  103750. textureLOD: boolean;
  103751. /** Defines if draw buffers extension is supported */
  103752. drawBuffersExtension: boolean;
  103753. /** Defines if depth textures are supported */
  103754. depthTextureExtension: boolean;
  103755. /** Defines if float color buffer are supported */
  103756. colorBufferFloat: boolean;
  103757. /** Gets disjoint timer query extension (null if not supported) */
  103758. timerQuery?: EXT_disjoint_timer_query;
  103759. /** Defines if timestamp can be used with timer query */
  103760. canUseTimestampForTimerQuery: boolean;
  103761. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103762. multiview?: any;
  103763. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103764. oculusMultiview?: any;
  103765. /** Function used to let the system compiles shaders in background */
  103766. parallelShaderCompile?: {
  103767. COMPLETION_STATUS_KHR: number;
  103768. };
  103769. /** Max number of texture samples for MSAA */
  103770. maxMSAASamples: number;
  103771. /** Defines if the blend min max extension is supported */
  103772. blendMinMax: boolean;
  103773. }
  103774. }
  103775. declare module BABYLON {
  103776. /**
  103777. * @hidden
  103778. **/
  103779. export class DepthCullingState {
  103780. private _isDepthTestDirty;
  103781. private _isDepthMaskDirty;
  103782. private _isDepthFuncDirty;
  103783. private _isCullFaceDirty;
  103784. private _isCullDirty;
  103785. private _isZOffsetDirty;
  103786. private _isFrontFaceDirty;
  103787. private _depthTest;
  103788. private _depthMask;
  103789. private _depthFunc;
  103790. private _cull;
  103791. private _cullFace;
  103792. private _zOffset;
  103793. private _frontFace;
  103794. /**
  103795. * Initializes the state.
  103796. */
  103797. constructor();
  103798. get isDirty(): boolean;
  103799. get zOffset(): number;
  103800. set zOffset(value: number);
  103801. get cullFace(): Nullable<number>;
  103802. set cullFace(value: Nullable<number>);
  103803. get cull(): Nullable<boolean>;
  103804. set cull(value: Nullable<boolean>);
  103805. get depthFunc(): Nullable<number>;
  103806. set depthFunc(value: Nullable<number>);
  103807. get depthMask(): boolean;
  103808. set depthMask(value: boolean);
  103809. get depthTest(): boolean;
  103810. set depthTest(value: boolean);
  103811. get frontFace(): Nullable<number>;
  103812. set frontFace(value: Nullable<number>);
  103813. reset(): void;
  103814. apply(gl: WebGLRenderingContext): void;
  103815. }
  103816. }
  103817. declare module BABYLON {
  103818. /**
  103819. * @hidden
  103820. **/
  103821. export class StencilState {
  103822. /** 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 */
  103823. static readonly ALWAYS: number;
  103824. /** Passed to stencilOperation to specify that stencil value must be kept */
  103825. static readonly KEEP: number;
  103826. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103827. static readonly REPLACE: number;
  103828. private _isStencilTestDirty;
  103829. private _isStencilMaskDirty;
  103830. private _isStencilFuncDirty;
  103831. private _isStencilOpDirty;
  103832. private _stencilTest;
  103833. private _stencilMask;
  103834. private _stencilFunc;
  103835. private _stencilFuncRef;
  103836. private _stencilFuncMask;
  103837. private _stencilOpStencilFail;
  103838. private _stencilOpDepthFail;
  103839. private _stencilOpStencilDepthPass;
  103840. get isDirty(): boolean;
  103841. get stencilFunc(): number;
  103842. set stencilFunc(value: number);
  103843. get stencilFuncRef(): number;
  103844. set stencilFuncRef(value: number);
  103845. get stencilFuncMask(): number;
  103846. set stencilFuncMask(value: number);
  103847. get stencilOpStencilFail(): number;
  103848. set stencilOpStencilFail(value: number);
  103849. get stencilOpDepthFail(): number;
  103850. set stencilOpDepthFail(value: number);
  103851. get stencilOpStencilDepthPass(): number;
  103852. set stencilOpStencilDepthPass(value: number);
  103853. get stencilMask(): number;
  103854. set stencilMask(value: number);
  103855. get stencilTest(): boolean;
  103856. set stencilTest(value: boolean);
  103857. constructor();
  103858. reset(): void;
  103859. apply(gl: WebGLRenderingContext): void;
  103860. }
  103861. }
  103862. declare module BABYLON {
  103863. /**
  103864. * @hidden
  103865. **/
  103866. export class AlphaState {
  103867. private _isAlphaBlendDirty;
  103868. private _isBlendFunctionParametersDirty;
  103869. private _isBlendEquationParametersDirty;
  103870. private _isBlendConstantsDirty;
  103871. private _alphaBlend;
  103872. private _blendFunctionParameters;
  103873. private _blendEquationParameters;
  103874. private _blendConstants;
  103875. /**
  103876. * Initializes the state.
  103877. */
  103878. constructor();
  103879. get isDirty(): boolean;
  103880. get alphaBlend(): boolean;
  103881. set alphaBlend(value: boolean);
  103882. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103883. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103884. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103885. reset(): void;
  103886. apply(gl: WebGLRenderingContext): void;
  103887. }
  103888. }
  103889. declare module BABYLON {
  103890. /** @hidden */
  103891. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103892. attributeProcessor(attribute: string): string;
  103893. varyingProcessor(varying: string, isFragment: boolean): string;
  103894. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103895. }
  103896. }
  103897. declare module BABYLON {
  103898. /**
  103899. * Interface for attribute information associated with buffer instanciation
  103900. */
  103901. export interface InstancingAttributeInfo {
  103902. /**
  103903. * Name of the GLSL attribute
  103904. * if attribute index is not specified, this is used to retrieve the index from the effect
  103905. */
  103906. attributeName: string;
  103907. /**
  103908. * Index/offset of the attribute in the vertex shader
  103909. * if not specified, this will be computes from the name.
  103910. */
  103911. index?: number;
  103912. /**
  103913. * size of the attribute, 1, 2, 3 or 4
  103914. */
  103915. attributeSize: number;
  103916. /**
  103917. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103918. */
  103919. offset: number;
  103920. /**
  103921. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103922. * default to 1
  103923. */
  103924. divisor?: number;
  103925. /**
  103926. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103927. * default is FLOAT
  103928. */
  103929. attributeType?: number;
  103930. /**
  103931. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103932. */
  103933. normalized?: boolean;
  103934. }
  103935. }
  103936. declare module BABYLON {
  103937. interface ThinEngine {
  103938. /**
  103939. * Update a video texture
  103940. * @param texture defines the texture to update
  103941. * @param video defines the video element to use
  103942. * @param invertY defines if data must be stored with Y axis inverted
  103943. */
  103944. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103945. }
  103946. }
  103947. declare module BABYLON {
  103948. /**
  103949. * Settings for finer control over video usage
  103950. */
  103951. export interface VideoTextureSettings {
  103952. /**
  103953. * Applies `autoplay` to video, if specified
  103954. */
  103955. autoPlay?: boolean;
  103956. /**
  103957. * Applies `loop` to video, if specified
  103958. */
  103959. loop?: boolean;
  103960. /**
  103961. * Automatically updates internal texture from video at every frame in the render loop
  103962. */
  103963. autoUpdateTexture: boolean;
  103964. /**
  103965. * Image src displayed during the video loading or until the user interacts with the video.
  103966. */
  103967. poster?: string;
  103968. }
  103969. /**
  103970. * If you want to display a video in your scene, this is the special texture for that.
  103971. * This special texture works similar to other textures, with the exception of a few parameters.
  103972. * @see https://doc.babylonjs.com/how_to/video_texture
  103973. */
  103974. export class VideoTexture extends Texture {
  103975. /**
  103976. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103977. */
  103978. readonly autoUpdateTexture: boolean;
  103979. /**
  103980. * The video instance used by the texture internally
  103981. */
  103982. readonly video: HTMLVideoElement;
  103983. private _onUserActionRequestedObservable;
  103984. /**
  103985. * Event triggerd when a dom action is required by the user to play the video.
  103986. * This happens due to recent changes in browser policies preventing video to auto start.
  103987. */
  103988. get onUserActionRequestedObservable(): Observable<Texture>;
  103989. private _generateMipMaps;
  103990. private _engine;
  103991. private _stillImageCaptured;
  103992. private _displayingPosterTexture;
  103993. private _settings;
  103994. private _createInternalTextureOnEvent;
  103995. private _frameId;
  103996. private _currentSrc;
  103997. /**
  103998. * Creates a video texture.
  103999. * If you want to display a video in your scene, this is the special texture for that.
  104000. * This special texture works similar to other textures, with the exception of a few parameters.
  104001. * @see https://doc.babylonjs.com/how_to/video_texture
  104002. * @param name optional name, will detect from video source, if not defined
  104003. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104004. * @param scene is obviously the current scene.
  104005. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104006. * @param invertY is false by default but can be used to invert video on Y axis
  104007. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104008. * @param settings allows finer control over video usage
  104009. */
  104010. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104011. private _getName;
  104012. private _getVideo;
  104013. private _createInternalTexture;
  104014. private reset;
  104015. /**
  104016. * @hidden Internal method to initiate `update`.
  104017. */
  104018. _rebuild(): void;
  104019. /**
  104020. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104021. */
  104022. update(): void;
  104023. /**
  104024. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104025. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104026. */
  104027. updateTexture(isVisible: boolean): void;
  104028. protected _updateInternalTexture: () => void;
  104029. /**
  104030. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104031. * @param url New url.
  104032. */
  104033. updateURL(url: string): void;
  104034. /**
  104035. * Clones the texture.
  104036. * @returns the cloned texture
  104037. */
  104038. clone(): VideoTexture;
  104039. /**
  104040. * Dispose the texture and release its associated resources.
  104041. */
  104042. dispose(): void;
  104043. /**
  104044. * Creates a video texture straight from a stream.
  104045. * @param scene Define the scene the texture should be created in
  104046. * @param stream Define the stream the texture should be created from
  104047. * @returns The created video texture as a promise
  104048. */
  104049. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104050. /**
  104051. * Creates a video texture straight from your WebCam video feed.
  104052. * @param scene Define the scene the texture should be created in
  104053. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104054. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104055. * @returns The created video texture as a promise
  104056. */
  104057. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104058. minWidth: number;
  104059. maxWidth: number;
  104060. minHeight: number;
  104061. maxHeight: number;
  104062. deviceId: string;
  104063. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104064. /**
  104065. * Creates a video texture straight from your WebCam video feed.
  104066. * @param scene Define the scene the texture should be created in
  104067. * @param onReady Define a callback to triggered once the texture will be ready
  104068. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104069. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104070. */
  104071. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104072. minWidth: number;
  104073. maxWidth: number;
  104074. minHeight: number;
  104075. maxHeight: number;
  104076. deviceId: string;
  104077. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104078. }
  104079. }
  104080. declare module BABYLON {
  104081. /**
  104082. * Defines the interface used by objects working like Scene
  104083. * @hidden
  104084. */
  104085. interface ISceneLike {
  104086. _addPendingData(data: any): void;
  104087. _removePendingData(data: any): void;
  104088. offlineProvider: IOfflineProvider;
  104089. }
  104090. /** Interface defining initialization parameters for Engine class */
  104091. export interface EngineOptions extends WebGLContextAttributes {
  104092. /**
  104093. * Defines if the engine should no exceed a specified device ratio
  104094. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104095. */
  104096. limitDeviceRatio?: number;
  104097. /**
  104098. * Defines if webvr should be enabled automatically
  104099. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104100. */
  104101. autoEnableWebVR?: boolean;
  104102. /**
  104103. * Defines if webgl2 should be turned off even if supported
  104104. * @see http://doc.babylonjs.com/features/webgl2
  104105. */
  104106. disableWebGL2Support?: boolean;
  104107. /**
  104108. * Defines if webaudio should be initialized as well
  104109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104110. */
  104111. audioEngine?: boolean;
  104112. /**
  104113. * Defines if animations should run using a deterministic lock step
  104114. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104115. */
  104116. deterministicLockstep?: boolean;
  104117. /** Defines the maximum steps to use with deterministic lock step mode */
  104118. lockstepMaxSteps?: number;
  104119. /** Defines the seconds between each deterministic lock step */
  104120. timeStep?: number;
  104121. /**
  104122. * Defines that engine should ignore context lost events
  104123. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104124. */
  104125. doNotHandleContextLost?: boolean;
  104126. /**
  104127. * Defines that engine should ignore modifying touch action attribute and style
  104128. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104129. */
  104130. doNotHandleTouchAction?: boolean;
  104131. /**
  104132. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104133. */
  104134. useHighPrecisionFloats?: boolean;
  104135. }
  104136. /**
  104137. * The base engine class (root of all engines)
  104138. */
  104139. export class ThinEngine {
  104140. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104141. static ExceptionList: ({
  104142. key: string;
  104143. capture: string;
  104144. captureConstraint: number;
  104145. targets: string[];
  104146. } | {
  104147. key: string;
  104148. capture: null;
  104149. captureConstraint: null;
  104150. targets: string[];
  104151. })[];
  104152. /** @hidden */
  104153. static _TextureLoaders: IInternalTextureLoader[];
  104154. /**
  104155. * Returns the current npm package of the sdk
  104156. */
  104157. static get NpmPackage(): string;
  104158. /**
  104159. * Returns the current version of the framework
  104160. */
  104161. static get Version(): string;
  104162. /**
  104163. * Returns a string describing the current engine
  104164. */
  104165. get description(): string;
  104166. /**
  104167. * Gets or sets the epsilon value used by collision engine
  104168. */
  104169. static CollisionsEpsilon: number;
  104170. /**
  104171. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104172. */
  104173. static get ShadersRepository(): string;
  104174. static set ShadersRepository(value: string);
  104175. /**
  104176. * Gets or sets the textures that the engine should not attempt to load as compressed
  104177. */
  104178. protected _excludedCompressedTextures: string[];
  104179. /**
  104180. * Filters the compressed texture formats to only include
  104181. * files that are not included in the skippable list
  104182. *
  104183. * @param url the current extension
  104184. * @param textureFormatInUse the current compressed texture format
  104185. * @returns "format" string
  104186. */
  104187. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104188. /** @hidden */
  104189. _shaderProcessor: IShaderProcessor;
  104190. /**
  104191. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104192. */
  104193. forcePOTTextures: boolean;
  104194. /**
  104195. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104196. */
  104197. isFullscreen: boolean;
  104198. /**
  104199. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104200. */
  104201. cullBackFaces: boolean;
  104202. /**
  104203. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104204. */
  104205. renderEvenInBackground: boolean;
  104206. /**
  104207. * Gets or sets a boolean indicating that cache can be kept between frames
  104208. */
  104209. preventCacheWipeBetweenFrames: boolean;
  104210. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104211. validateShaderPrograms: boolean;
  104212. /**
  104213. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104214. * This can provide greater z depth for distant objects.
  104215. */
  104216. useReverseDepthBuffer: boolean;
  104217. /**
  104218. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104219. */
  104220. disableUniformBuffers: boolean;
  104221. /** @hidden */
  104222. _uniformBuffers: UniformBuffer[];
  104223. /**
  104224. * Gets a boolean indicating that the engine supports uniform buffers
  104225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104226. */
  104227. get supportsUniformBuffers(): boolean;
  104228. /** @hidden */
  104229. _gl: WebGLRenderingContext;
  104230. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104231. protected _windowIsBackground: boolean;
  104232. protected _webGLVersion: number;
  104233. protected _creationOptions: EngineOptions;
  104234. protected _highPrecisionShadersAllowed: boolean;
  104235. /** @hidden */
  104236. get _shouldUseHighPrecisionShader(): boolean;
  104237. /**
  104238. * Gets a boolean indicating that only power of 2 textures are supported
  104239. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104240. */
  104241. get needPOTTextures(): boolean;
  104242. /** @hidden */
  104243. _badOS: boolean;
  104244. /** @hidden */
  104245. _badDesktopOS: boolean;
  104246. private _hardwareScalingLevel;
  104247. /** @hidden */
  104248. _caps: EngineCapabilities;
  104249. private _isStencilEnable;
  104250. private _glVersion;
  104251. private _glRenderer;
  104252. private _glVendor;
  104253. /** @hidden */
  104254. _videoTextureSupported: boolean;
  104255. protected _renderingQueueLaunched: boolean;
  104256. protected _activeRenderLoops: (() => void)[];
  104257. /**
  104258. * Observable signaled when a context lost event is raised
  104259. */
  104260. onContextLostObservable: Observable<ThinEngine>;
  104261. /**
  104262. * Observable signaled when a context restored event is raised
  104263. */
  104264. onContextRestoredObservable: Observable<ThinEngine>;
  104265. private _onContextLost;
  104266. private _onContextRestored;
  104267. protected _contextWasLost: boolean;
  104268. /** @hidden */
  104269. _doNotHandleContextLost: boolean;
  104270. /**
  104271. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104273. */
  104274. get doNotHandleContextLost(): boolean;
  104275. set doNotHandleContextLost(value: boolean);
  104276. /**
  104277. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104278. */
  104279. disableVertexArrayObjects: boolean;
  104280. /** @hidden */
  104281. protected _colorWrite: boolean;
  104282. /** @hidden */
  104283. protected _colorWriteChanged: boolean;
  104284. /** @hidden */
  104285. protected _depthCullingState: DepthCullingState;
  104286. /** @hidden */
  104287. protected _stencilState: StencilState;
  104288. /** @hidden */
  104289. _alphaState: AlphaState;
  104290. /** @hidden */
  104291. _alphaMode: number;
  104292. /** @hidden */
  104293. _alphaEquation: number;
  104294. /** @hidden */
  104295. _internalTexturesCache: InternalTexture[];
  104296. /** @hidden */
  104297. protected _activeChannel: number;
  104298. private _currentTextureChannel;
  104299. /** @hidden */
  104300. protected _boundTexturesCache: {
  104301. [key: string]: Nullable<InternalTexture>;
  104302. };
  104303. /** @hidden */
  104304. protected _currentEffect: Nullable<Effect>;
  104305. /** @hidden */
  104306. protected _currentProgram: Nullable<WebGLProgram>;
  104307. private _compiledEffects;
  104308. private _vertexAttribArraysEnabled;
  104309. /** @hidden */
  104310. protected _cachedViewport: Nullable<IViewportLike>;
  104311. private _cachedVertexArrayObject;
  104312. /** @hidden */
  104313. protected _cachedVertexBuffers: any;
  104314. /** @hidden */
  104315. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104316. /** @hidden */
  104317. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104318. /** @hidden */
  104319. _currentRenderTarget: Nullable<InternalTexture>;
  104320. private _uintIndicesCurrentlySet;
  104321. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104322. /** @hidden */
  104323. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104324. private _currentBufferPointers;
  104325. private _currentInstanceLocations;
  104326. private _currentInstanceBuffers;
  104327. private _textureUnits;
  104328. /** @hidden */
  104329. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104330. /** @hidden */
  104331. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104332. /** @hidden */
  104333. _boundRenderFunction: any;
  104334. private _vaoRecordInProgress;
  104335. private _mustWipeVertexAttributes;
  104336. private _emptyTexture;
  104337. private _emptyCubeTexture;
  104338. private _emptyTexture3D;
  104339. private _emptyTexture2DArray;
  104340. /** @hidden */
  104341. _frameHandler: number;
  104342. private _nextFreeTextureSlots;
  104343. private _maxSimultaneousTextures;
  104344. private _activeRequests;
  104345. protected _texturesSupported: string[];
  104346. /** @hidden */
  104347. _textureFormatInUse: Nullable<string>;
  104348. protected get _supportsHardwareTextureRescaling(): boolean;
  104349. /**
  104350. * Gets the list of texture formats supported
  104351. */
  104352. get texturesSupported(): Array<string>;
  104353. /**
  104354. * Gets the list of texture formats in use
  104355. */
  104356. get textureFormatInUse(): Nullable<string>;
  104357. /**
  104358. * Gets the current viewport
  104359. */
  104360. get currentViewport(): Nullable<IViewportLike>;
  104361. /**
  104362. * Gets the default empty texture
  104363. */
  104364. get emptyTexture(): InternalTexture;
  104365. /**
  104366. * Gets the default empty 3D texture
  104367. */
  104368. get emptyTexture3D(): InternalTexture;
  104369. /**
  104370. * Gets the default empty 2D array texture
  104371. */
  104372. get emptyTexture2DArray(): InternalTexture;
  104373. /**
  104374. * Gets the default empty cube texture
  104375. */
  104376. get emptyCubeTexture(): InternalTexture;
  104377. /**
  104378. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104379. */
  104380. readonly premultipliedAlpha: boolean;
  104381. /**
  104382. * Observable event triggered before each texture is initialized
  104383. */
  104384. onBeforeTextureInitObservable: Observable<Texture>;
  104385. /**
  104386. * Creates a new engine
  104387. * @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
  104388. * @param antialias defines enable antialiasing (default: false)
  104389. * @param options defines further options to be sent to the getContext() function
  104390. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104391. */
  104392. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104393. private _rebuildInternalTextures;
  104394. private _rebuildEffects;
  104395. /**
  104396. * Gets a boolean indicating if all created effects are ready
  104397. * @returns true if all effects are ready
  104398. */
  104399. areAllEffectsReady(): boolean;
  104400. protected _rebuildBuffers(): void;
  104401. private _initGLContext;
  104402. /**
  104403. * Gets version of the current webGL context
  104404. */
  104405. get webGLVersion(): number;
  104406. /**
  104407. * Gets a string idenfifying the name of the class
  104408. * @returns "Engine" string
  104409. */
  104410. getClassName(): string;
  104411. /**
  104412. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104413. */
  104414. get isStencilEnable(): boolean;
  104415. /** @hidden */
  104416. _prepareWorkingCanvas(): void;
  104417. /**
  104418. * Reset the texture cache to empty state
  104419. */
  104420. resetTextureCache(): void;
  104421. /**
  104422. * Gets an object containing information about the current webGL context
  104423. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104424. */
  104425. getGlInfo(): {
  104426. vendor: string;
  104427. renderer: string;
  104428. version: string;
  104429. };
  104430. /**
  104431. * Defines the hardware scaling level.
  104432. * By default the hardware scaling level is computed from the window device ratio.
  104433. * 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.
  104434. * @param level defines the level to use
  104435. */
  104436. setHardwareScalingLevel(level: number): void;
  104437. /**
  104438. * Gets the current hardware scaling level.
  104439. * By default the hardware scaling level is computed from the window device ratio.
  104440. * 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.
  104441. * @returns a number indicating the current hardware scaling level
  104442. */
  104443. getHardwareScalingLevel(): number;
  104444. /**
  104445. * Gets the list of loaded textures
  104446. * @returns an array containing all loaded textures
  104447. */
  104448. getLoadedTexturesCache(): InternalTexture[];
  104449. /**
  104450. * Gets the object containing all engine capabilities
  104451. * @returns the EngineCapabilities object
  104452. */
  104453. getCaps(): EngineCapabilities;
  104454. /**
  104455. * stop executing a render loop function and remove it from the execution array
  104456. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104457. */
  104458. stopRenderLoop(renderFunction?: () => void): void;
  104459. /** @hidden */
  104460. _renderLoop(): void;
  104461. /**
  104462. * Gets the HTML canvas attached with the current webGL context
  104463. * @returns a HTML canvas
  104464. */
  104465. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104466. /**
  104467. * Gets host window
  104468. * @returns the host window object
  104469. */
  104470. getHostWindow(): Nullable<Window>;
  104471. /**
  104472. * Gets the current render width
  104473. * @param useScreen defines if screen size must be used (or the current render target if any)
  104474. * @returns a number defining the current render width
  104475. */
  104476. getRenderWidth(useScreen?: boolean): number;
  104477. /**
  104478. * Gets the current render height
  104479. * @param useScreen defines if screen size must be used (or the current render target if any)
  104480. * @returns a number defining the current render height
  104481. */
  104482. getRenderHeight(useScreen?: boolean): number;
  104483. /**
  104484. * Can be used to override the current requestAnimationFrame requester.
  104485. * @hidden
  104486. */
  104487. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104488. /**
  104489. * Register and execute a render loop. The engine can have more than one render function
  104490. * @param renderFunction defines the function to continuously execute
  104491. */
  104492. runRenderLoop(renderFunction: () => void): void;
  104493. /**
  104494. * Clear the current render buffer or the current render target (if any is set up)
  104495. * @param color defines the color to use
  104496. * @param backBuffer defines if the back buffer must be cleared
  104497. * @param depth defines if the depth buffer must be cleared
  104498. * @param stencil defines if the stencil buffer must be cleared
  104499. */
  104500. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104501. private _viewportCached;
  104502. /** @hidden */
  104503. _viewport(x: number, y: number, width: number, height: number): void;
  104504. /**
  104505. * Set the WebGL's viewport
  104506. * @param viewport defines the viewport element to be used
  104507. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104508. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104509. */
  104510. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104511. /**
  104512. * Begin a new frame
  104513. */
  104514. beginFrame(): void;
  104515. /**
  104516. * Enf the current frame
  104517. */
  104518. endFrame(): void;
  104519. /**
  104520. * Resize the view according to the canvas' size
  104521. */
  104522. resize(): void;
  104523. /**
  104524. * Force a specific size of the canvas
  104525. * @param width defines the new canvas' width
  104526. * @param height defines the new canvas' height
  104527. */
  104528. setSize(width: number, height: number): void;
  104529. /**
  104530. * Binds the frame buffer to the specified texture.
  104531. * @param texture The texture to render to or null for the default canvas
  104532. * @param faceIndex The face of the texture to render to in case of cube texture
  104533. * @param requiredWidth The width of the target to render to
  104534. * @param requiredHeight The height of the target to render to
  104535. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104536. * @param lodLevel defines the lod level to bind to the frame buffer
  104537. * @param layer defines the 2d array index to bind to frame buffer to
  104538. */
  104539. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104540. /** @hidden */
  104541. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104542. /**
  104543. * Unbind the current render target texture from the webGL context
  104544. * @param texture defines the render target texture to unbind
  104545. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104546. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104547. */
  104548. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104549. /**
  104550. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104551. */
  104552. flushFramebuffer(): void;
  104553. /**
  104554. * Unbind the current render target and bind the default framebuffer
  104555. */
  104556. restoreDefaultFramebuffer(): void;
  104557. /** @hidden */
  104558. protected _resetVertexBufferBinding(): void;
  104559. /**
  104560. * Creates a vertex buffer
  104561. * @param data the data for the vertex buffer
  104562. * @returns the new WebGL static buffer
  104563. */
  104564. createVertexBuffer(data: DataArray): DataBuffer;
  104565. private _createVertexBuffer;
  104566. /**
  104567. * Creates a dynamic vertex buffer
  104568. * @param data the data for the dynamic vertex buffer
  104569. * @returns the new WebGL dynamic buffer
  104570. */
  104571. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104572. protected _resetIndexBufferBinding(): void;
  104573. /**
  104574. * Creates a new index buffer
  104575. * @param indices defines the content of the index buffer
  104576. * @param updatable defines if the index buffer must be updatable
  104577. * @returns a new webGL buffer
  104578. */
  104579. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104580. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104581. /**
  104582. * Bind a webGL buffer to the webGL context
  104583. * @param buffer defines the buffer to bind
  104584. */
  104585. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104586. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104587. private bindBuffer;
  104588. /**
  104589. * update the bound buffer with the given data
  104590. * @param data defines the data to update
  104591. */
  104592. updateArrayBuffer(data: Float32Array): void;
  104593. private _vertexAttribPointer;
  104594. /** @hidden */
  104595. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104596. private _bindVertexBuffersAttributes;
  104597. /**
  104598. * Records a vertex array object
  104599. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104600. * @param vertexBuffers defines the list of vertex buffers to store
  104601. * @param indexBuffer defines the index buffer to store
  104602. * @param effect defines the effect to store
  104603. * @returns the new vertex array object
  104604. */
  104605. recordVertexArrayObject(vertexBuffers: {
  104606. [key: string]: VertexBuffer;
  104607. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104608. /**
  104609. * Bind a specific vertex array object
  104610. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104611. * @param vertexArrayObject defines the vertex array object to bind
  104612. * @param indexBuffer defines the index buffer to bind
  104613. */
  104614. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104615. /**
  104616. * Bind webGl buffers directly to the webGL context
  104617. * @param vertexBuffer defines the vertex buffer to bind
  104618. * @param indexBuffer defines the index buffer to bind
  104619. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104620. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104621. * @param effect defines the effect associated with the vertex buffer
  104622. */
  104623. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104624. private _unbindVertexArrayObject;
  104625. /**
  104626. * Bind a list of vertex buffers to the webGL context
  104627. * @param vertexBuffers defines the list of vertex buffers to bind
  104628. * @param indexBuffer defines the index buffer to bind
  104629. * @param effect defines the effect associated with the vertex buffers
  104630. */
  104631. bindBuffers(vertexBuffers: {
  104632. [key: string]: Nullable<VertexBuffer>;
  104633. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104634. /**
  104635. * Unbind all instance attributes
  104636. */
  104637. unbindInstanceAttributes(): void;
  104638. /**
  104639. * Release and free the memory of a vertex array object
  104640. * @param vao defines the vertex array object to delete
  104641. */
  104642. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104643. /** @hidden */
  104644. _releaseBuffer(buffer: DataBuffer): boolean;
  104645. protected _deleteBuffer(buffer: DataBuffer): void;
  104646. /**
  104647. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104648. * @param instancesBuffer defines the webGL buffer to update and bind
  104649. * @param data defines the data to store in the buffer
  104650. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104651. */
  104652. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104653. /**
  104654. * Bind the content of a webGL buffer used with instantiation
  104655. * @param instancesBuffer defines the webGL buffer to bind
  104656. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104657. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104658. */
  104659. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104660. /**
  104661. * Disable the instance attribute corresponding to the name in parameter
  104662. * @param name defines the name of the attribute to disable
  104663. */
  104664. disableInstanceAttributeByName(name: string): void;
  104665. /**
  104666. * Disable the instance attribute corresponding to the location in parameter
  104667. * @param attributeLocation defines the attribute location of the attribute to disable
  104668. */
  104669. disableInstanceAttribute(attributeLocation: number): void;
  104670. /**
  104671. * Disable the attribute corresponding to the location in parameter
  104672. * @param attributeLocation defines the attribute location of the attribute to disable
  104673. */
  104674. disableAttributeByIndex(attributeLocation: number): void;
  104675. /**
  104676. * Send a draw order
  104677. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104678. * @param indexStart defines the starting index
  104679. * @param indexCount defines the number of index to draw
  104680. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104681. */
  104682. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104683. /**
  104684. * Draw a list of points
  104685. * @param verticesStart defines the index of first vertex to draw
  104686. * @param verticesCount defines the count of vertices to draw
  104687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104688. */
  104689. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104690. /**
  104691. * Draw a list of unindexed primitives
  104692. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104693. * @param verticesStart defines the index of first vertex to draw
  104694. * @param verticesCount defines the count of vertices to draw
  104695. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104696. */
  104697. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104698. /**
  104699. * Draw a list of indexed primitives
  104700. * @param fillMode defines the primitive to use
  104701. * @param indexStart defines the starting index
  104702. * @param indexCount defines the number of index to draw
  104703. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104704. */
  104705. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104706. /**
  104707. * Draw a list of unindexed primitives
  104708. * @param fillMode defines the primitive to use
  104709. * @param verticesStart defines the index of first vertex to draw
  104710. * @param verticesCount defines the count of vertices to draw
  104711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104712. */
  104713. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104714. private _drawMode;
  104715. /** @hidden */
  104716. protected _reportDrawCall(): void;
  104717. /** @hidden */
  104718. _releaseEffect(effect: Effect): void;
  104719. /** @hidden */
  104720. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104721. /**
  104722. * Create a new effect (used to store vertex/fragment shaders)
  104723. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104724. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104725. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104726. * @param samplers defines an array of string used to represent textures
  104727. * @param defines defines the string containing the defines to use to compile the shaders
  104728. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104729. * @param onCompiled defines a function to call when the effect creation is successful
  104730. * @param onError defines a function to call when the effect creation has failed
  104731. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104732. * @returns the new Effect
  104733. */
  104734. 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;
  104735. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104736. private _compileShader;
  104737. private _compileRawShader;
  104738. /**
  104739. * Directly creates a webGL program
  104740. * @param pipelineContext defines the pipeline context to attach to
  104741. * @param vertexCode defines the vertex shader code to use
  104742. * @param fragmentCode defines the fragment shader code to use
  104743. * @param context defines the webGL context to use (if not set, the current one will be used)
  104744. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104745. * @returns the new webGL program
  104746. */
  104747. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104748. /**
  104749. * Creates a webGL program
  104750. * @param pipelineContext defines the pipeline context to attach to
  104751. * @param vertexCode defines the vertex shader code to use
  104752. * @param fragmentCode defines the fragment shader code to use
  104753. * @param defines defines the string containing the defines to use to compile the shaders
  104754. * @param context defines the webGL context to use (if not set, the current one will be used)
  104755. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104756. * @returns the new webGL program
  104757. */
  104758. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104759. /**
  104760. * Creates a new pipeline context
  104761. * @returns the new pipeline
  104762. */
  104763. createPipelineContext(): IPipelineContext;
  104764. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104765. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104766. /** @hidden */
  104767. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104768. /** @hidden */
  104769. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104770. /** @hidden */
  104771. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104772. /**
  104773. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104774. * @param pipelineContext defines the pipeline context to use
  104775. * @param uniformsNames defines the list of uniform names
  104776. * @returns an array of webGL uniform locations
  104777. */
  104778. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104779. /**
  104780. * Gets the lsit of active attributes for a given webGL program
  104781. * @param pipelineContext defines the pipeline context to use
  104782. * @param attributesNames defines the list of attribute names to get
  104783. * @returns an array of indices indicating the offset of each attribute
  104784. */
  104785. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104786. /**
  104787. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104788. * @param effect defines the effect to activate
  104789. */
  104790. enableEffect(effect: Nullable<Effect>): void;
  104791. /**
  104792. * Set the value of an uniform to a number (int)
  104793. * @param uniform defines the webGL uniform location where to store the value
  104794. * @param value defines the int number to store
  104795. */
  104796. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104797. /**
  104798. * Set the value of an uniform to an array of int32
  104799. * @param uniform defines the webGL uniform location where to store the value
  104800. * @param array defines the array of int32 to store
  104801. */
  104802. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104803. /**
  104804. * Set the value of an uniform to an array of int32 (stored as vec2)
  104805. * @param uniform defines the webGL uniform location where to store the value
  104806. * @param array defines the array of int32 to store
  104807. */
  104808. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104809. /**
  104810. * Set the value of an uniform to an array of int32 (stored as vec3)
  104811. * @param uniform defines the webGL uniform location where to store the value
  104812. * @param array defines the array of int32 to store
  104813. */
  104814. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104815. /**
  104816. * Set the value of an uniform to an array of int32 (stored as vec4)
  104817. * @param uniform defines the webGL uniform location where to store the value
  104818. * @param array defines the array of int32 to store
  104819. */
  104820. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104821. /**
  104822. * Set the value of an uniform to an array of number
  104823. * @param uniform defines the webGL uniform location where to store the value
  104824. * @param array defines the array of number to store
  104825. */
  104826. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104827. /**
  104828. * Set the value of an uniform to an array of number (stored as vec2)
  104829. * @param uniform defines the webGL uniform location where to store the value
  104830. * @param array defines the array of number to store
  104831. */
  104832. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104833. /**
  104834. * Set the value of an uniform to an array of number (stored as vec3)
  104835. * @param uniform defines the webGL uniform location where to store the value
  104836. * @param array defines the array of number to store
  104837. */
  104838. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104839. /**
  104840. * Set the value of an uniform to an array of number (stored as vec4)
  104841. * @param uniform defines the webGL uniform location where to store the value
  104842. * @param array defines the array of number to store
  104843. */
  104844. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104845. /**
  104846. * Set the value of an uniform to an array of float32 (stored as matrices)
  104847. * @param uniform defines the webGL uniform location where to store the value
  104848. * @param matrices defines the array of float32 to store
  104849. */
  104850. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104851. /**
  104852. * Set the value of an uniform to a matrix (3x3)
  104853. * @param uniform defines the webGL uniform location where to store the value
  104854. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104855. */
  104856. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104857. /**
  104858. * Set the value of an uniform to a matrix (2x2)
  104859. * @param uniform defines the webGL uniform location where to store the value
  104860. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104861. */
  104862. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104863. /**
  104864. * Set the value of an uniform to a number (float)
  104865. * @param uniform defines the webGL uniform location where to store the value
  104866. * @param value defines the float number to store
  104867. */
  104868. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104869. /**
  104870. * Set the value of an uniform to a vec2
  104871. * @param uniform defines the webGL uniform location where to store the value
  104872. * @param x defines the 1st component of the value
  104873. * @param y defines the 2nd component of the value
  104874. */
  104875. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104876. /**
  104877. * Set the value of an uniform to a vec3
  104878. * @param uniform defines the webGL uniform location where to store the value
  104879. * @param x defines the 1st component of the value
  104880. * @param y defines the 2nd component of the value
  104881. * @param z defines the 3rd component of the value
  104882. */
  104883. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104884. /**
  104885. * Set the value of an uniform to a vec4
  104886. * @param uniform defines the webGL uniform location where to store the value
  104887. * @param x defines the 1st component of the value
  104888. * @param y defines the 2nd component of the value
  104889. * @param z defines the 3rd component of the value
  104890. * @param w defines the 4th component of the value
  104891. */
  104892. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104893. /**
  104894. * Apply all cached states (depth, culling, stencil and alpha)
  104895. */
  104896. applyStates(): void;
  104897. /**
  104898. * Enable or disable color writing
  104899. * @param enable defines the state to set
  104900. */
  104901. setColorWrite(enable: boolean): void;
  104902. /**
  104903. * Gets a boolean indicating if color writing is enabled
  104904. * @returns the current color writing state
  104905. */
  104906. getColorWrite(): boolean;
  104907. /**
  104908. * Gets the depth culling state manager
  104909. */
  104910. get depthCullingState(): DepthCullingState;
  104911. /**
  104912. * Gets the alpha state manager
  104913. */
  104914. get alphaState(): AlphaState;
  104915. /**
  104916. * Gets the stencil state manager
  104917. */
  104918. get stencilState(): StencilState;
  104919. /**
  104920. * Clears the list of texture accessible through engine.
  104921. * This can help preventing texture load conflict due to name collision.
  104922. */
  104923. clearInternalTexturesCache(): void;
  104924. /**
  104925. * Force the entire cache to be cleared
  104926. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104927. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104928. */
  104929. wipeCaches(bruteForce?: boolean): void;
  104930. /** @hidden */
  104931. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104932. min: number;
  104933. mag: number;
  104934. };
  104935. /** @hidden */
  104936. _createTexture(): WebGLTexture;
  104937. /**
  104938. * Usually called from Texture.ts.
  104939. * Passed information to create a WebGLTexture
  104940. * @param urlArg defines a value which contains one of the following:
  104941. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104942. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104943. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104945. * @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)
  104946. * @param scene needed for loading to the correct scene
  104947. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104948. * @param onLoad optional callback to be called upon successful completion
  104949. * @param onError optional callback to be called upon failure
  104950. * @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
  104951. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104952. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104953. * @param forcedExtension defines the extension to use to pick the right loader
  104954. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104955. * @param mimeType defines an optional mime type
  104956. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104957. */
  104958. 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;
  104959. /**
  104960. * Loads an image as an HTMLImageElement.
  104961. * @param input url string, ArrayBuffer, or Blob to load
  104962. * @param onLoad callback called when the image successfully loads
  104963. * @param onError callback called when the image fails to load
  104964. * @param offlineProvider offline provider for caching
  104965. * @param mimeType optional mime type
  104966. * @returns the HTMLImageElement of the loaded image
  104967. * @hidden
  104968. */
  104969. 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>;
  104970. /**
  104971. * @hidden
  104972. */
  104973. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104974. /**
  104975. * Creates a raw texture
  104976. * @param data defines the data to store in the texture
  104977. * @param width defines the width of the texture
  104978. * @param height defines the height of the texture
  104979. * @param format defines the format of the data
  104980. * @param generateMipMaps defines if the engine should generate the mip levels
  104981. * @param invertY defines if data must be stored with Y axis inverted
  104982. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104983. * @param compression defines the compression used (null by default)
  104984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104985. * @returns the raw texture inside an InternalTexture
  104986. */
  104987. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104988. /**
  104989. * Creates a new raw cube texture
  104990. * @param data defines the array of data to use to create each face
  104991. * @param size defines the size of the textures
  104992. * @param format defines the format of the data
  104993. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104994. * @param generateMipMaps defines if the engine should generate the mip levels
  104995. * @param invertY defines if data must be stored with Y axis inverted
  104996. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104997. * @param compression defines the compression used (null by default)
  104998. * @returns the cube texture as an InternalTexture
  104999. */
  105000. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105001. /**
  105002. * Creates a new raw 3D texture
  105003. * @param data defines the data used to create the texture
  105004. * @param width defines the width of the texture
  105005. * @param height defines the height of the texture
  105006. * @param depth defines the depth of the texture
  105007. * @param format defines the format of the texture
  105008. * @param generateMipMaps defines if the engine must generate mip levels
  105009. * @param invertY defines if data must be stored with Y axis inverted
  105010. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105011. * @param compression defines the compressed used (can be null)
  105012. * @param textureType defines the compressed used (can be null)
  105013. * @returns a new raw 3D texture (stored in an InternalTexture)
  105014. */
  105015. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105016. /**
  105017. * Creates a new raw 2D array texture
  105018. * @param data defines the data used to create the texture
  105019. * @param width defines the width of the texture
  105020. * @param height defines the height of the texture
  105021. * @param depth defines the number of layers of the texture
  105022. * @param format defines the format of the texture
  105023. * @param generateMipMaps defines if the engine must generate mip levels
  105024. * @param invertY defines if data must be stored with Y axis inverted
  105025. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105026. * @param compression defines the compressed used (can be null)
  105027. * @param textureType defines the compressed used (can be null)
  105028. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105029. */
  105030. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105031. private _unpackFlipYCached;
  105032. /**
  105033. * In case you are sharing the context with other applications, it might
  105034. * be interested to not cache the unpack flip y state to ensure a consistent
  105035. * value would be set.
  105036. */
  105037. enableUnpackFlipYCached: boolean;
  105038. /** @hidden */
  105039. _unpackFlipY(value: boolean): void;
  105040. /** @hidden */
  105041. _getUnpackAlignement(): number;
  105042. private _getTextureTarget;
  105043. /**
  105044. * Update the sampling mode of a given texture
  105045. * @param samplingMode defines the required sampling mode
  105046. * @param texture defines the texture to update
  105047. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105048. */
  105049. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105050. /**
  105051. * Update the sampling mode of a given texture
  105052. * @param texture defines the texture to update
  105053. * @param wrapU defines the texture wrap mode of the u coordinates
  105054. * @param wrapV defines the texture wrap mode of the v coordinates
  105055. * @param wrapR defines the texture wrap mode of the r coordinates
  105056. */
  105057. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105058. /** @hidden */
  105059. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105060. width: number;
  105061. height: number;
  105062. layers?: number;
  105063. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105064. /** @hidden */
  105065. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105066. /** @hidden */
  105067. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105068. /**
  105069. * Update a portion of an internal texture
  105070. * @param texture defines the texture to update
  105071. * @param imageData defines the data to store into the texture
  105072. * @param xOffset defines the x coordinates of the update rectangle
  105073. * @param yOffset defines the y coordinates of the update rectangle
  105074. * @param width defines the width of the update rectangle
  105075. * @param height defines the height of the update rectangle
  105076. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105077. * @param lod defines the lod level to update (0 by default)
  105078. */
  105079. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105080. /** @hidden */
  105081. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105082. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105083. private _prepareWebGLTexture;
  105084. /** @hidden */
  105085. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105086. private _getDepthStencilBuffer;
  105087. /** @hidden */
  105088. _releaseFramebufferObjects(texture: InternalTexture): void;
  105089. /** @hidden */
  105090. _releaseTexture(texture: InternalTexture): void;
  105091. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105092. protected _setProgram(program: WebGLProgram): void;
  105093. protected _boundUniforms: {
  105094. [key: number]: WebGLUniformLocation;
  105095. };
  105096. /**
  105097. * Binds an effect to the webGL context
  105098. * @param effect defines the effect to bind
  105099. */
  105100. bindSamplers(effect: Effect): void;
  105101. private _activateCurrentTexture;
  105102. /** @hidden */
  105103. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105104. /** @hidden */
  105105. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105106. /**
  105107. * Unbind all textures from the webGL context
  105108. */
  105109. unbindAllTextures(): void;
  105110. /**
  105111. * Sets a texture to the according uniform.
  105112. * @param channel The texture channel
  105113. * @param uniform The uniform to set
  105114. * @param texture The texture to apply
  105115. */
  105116. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105117. private _bindSamplerUniformToChannel;
  105118. private _getTextureWrapMode;
  105119. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105120. /**
  105121. * Sets an array of texture to the webGL context
  105122. * @param channel defines the channel where the texture array must be set
  105123. * @param uniform defines the associated uniform location
  105124. * @param textures defines the array of textures to bind
  105125. */
  105126. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105127. /** @hidden */
  105128. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105129. private _setTextureParameterFloat;
  105130. private _setTextureParameterInteger;
  105131. /**
  105132. * Unbind all vertex attributes from the webGL context
  105133. */
  105134. unbindAllAttributes(): void;
  105135. /**
  105136. * 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
  105137. */
  105138. releaseEffects(): void;
  105139. /**
  105140. * Dispose and release all associated resources
  105141. */
  105142. dispose(): void;
  105143. /**
  105144. * Attach a new callback raised when context lost event is fired
  105145. * @param callback defines the callback to call
  105146. */
  105147. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105148. /**
  105149. * Attach a new callback raised when context restored event is fired
  105150. * @param callback defines the callback to call
  105151. */
  105152. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105153. /**
  105154. * Get the current error code of the webGL context
  105155. * @returns the error code
  105156. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105157. */
  105158. getError(): number;
  105159. private _canRenderToFloatFramebuffer;
  105160. private _canRenderToHalfFloatFramebuffer;
  105161. private _canRenderToFramebuffer;
  105162. /** @hidden */
  105163. _getWebGLTextureType(type: number): number;
  105164. /** @hidden */
  105165. _getInternalFormat(format: number): number;
  105166. /** @hidden */
  105167. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105168. /** @hidden */
  105169. _getRGBAMultiSampleBufferFormat(type: number): number;
  105170. /** @hidden */
  105171. _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;
  105172. /**
  105173. * Loads a file from a url
  105174. * @param url url to load
  105175. * @param onSuccess callback called when the file successfully loads
  105176. * @param onProgress callback called while file is loading (if the server supports this mode)
  105177. * @param offlineProvider defines the offline provider for caching
  105178. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105179. * @param onError callback called when the file fails to load
  105180. * @returns a file request object
  105181. * @hidden
  105182. */
  105183. 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;
  105184. /**
  105185. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105186. * @param x defines the x coordinate of the rectangle where pixels must be read
  105187. * @param y defines the y coordinate of the rectangle where pixels must be read
  105188. * @param width defines the width of the rectangle where pixels must be read
  105189. * @param height defines the height of the rectangle where pixels must be read
  105190. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105191. * @returns a Uint8Array containing RGBA colors
  105192. */
  105193. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105194. private static _isSupported;
  105195. /**
  105196. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105197. * @returns true if the engine can be created
  105198. * @ignorenaming
  105199. */
  105200. static isSupported(): boolean;
  105201. /**
  105202. * Find the next highest power of two.
  105203. * @param x Number to start search from.
  105204. * @return Next highest power of two.
  105205. */
  105206. static CeilingPOT(x: number): number;
  105207. /**
  105208. * Find the next lowest power of two.
  105209. * @param x Number to start search from.
  105210. * @return Next lowest power of two.
  105211. */
  105212. static FloorPOT(x: number): number;
  105213. /**
  105214. * Find the nearest power of two.
  105215. * @param x Number to start search from.
  105216. * @return Next nearest power of two.
  105217. */
  105218. static NearestPOT(x: number): number;
  105219. /**
  105220. * Get the closest exponent of two
  105221. * @param value defines the value to approximate
  105222. * @param max defines the maximum value to return
  105223. * @param mode defines how to define the closest value
  105224. * @returns closest exponent of two of the given value
  105225. */
  105226. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105227. /**
  105228. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105229. * @param func - the function to be called
  105230. * @param requester - the object that will request the next frame. Falls back to window.
  105231. * @returns frame number
  105232. */
  105233. static QueueNewFrame(func: () => void, requester?: any): number;
  105234. /**
  105235. * Gets host document
  105236. * @returns the host document object
  105237. */
  105238. getHostDocument(): Nullable<Document>;
  105239. }
  105240. }
  105241. declare module BABYLON {
  105242. /**
  105243. * Class representing spherical harmonics coefficients to the 3rd degree
  105244. */
  105245. export class SphericalHarmonics {
  105246. /**
  105247. * Defines whether or not the harmonics have been prescaled for rendering.
  105248. */
  105249. preScaled: boolean;
  105250. /**
  105251. * The l0,0 coefficients of the spherical harmonics
  105252. */
  105253. l00: Vector3;
  105254. /**
  105255. * The l1,-1 coefficients of the spherical harmonics
  105256. */
  105257. l1_1: Vector3;
  105258. /**
  105259. * The l1,0 coefficients of the spherical harmonics
  105260. */
  105261. l10: Vector3;
  105262. /**
  105263. * The l1,1 coefficients of the spherical harmonics
  105264. */
  105265. l11: Vector3;
  105266. /**
  105267. * The l2,-2 coefficients of the spherical harmonics
  105268. */
  105269. l2_2: Vector3;
  105270. /**
  105271. * The l2,-1 coefficients of the spherical harmonics
  105272. */
  105273. l2_1: Vector3;
  105274. /**
  105275. * The l2,0 coefficients of the spherical harmonics
  105276. */
  105277. l20: Vector3;
  105278. /**
  105279. * The l2,1 coefficients of the spherical harmonics
  105280. */
  105281. l21: Vector3;
  105282. /**
  105283. * The l2,2 coefficients of the spherical harmonics
  105284. */
  105285. l22: Vector3;
  105286. /**
  105287. * Adds a light to the spherical harmonics
  105288. * @param direction the direction of the light
  105289. * @param color the color of the light
  105290. * @param deltaSolidAngle the delta solid angle of the light
  105291. */
  105292. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105293. /**
  105294. * Scales the spherical harmonics by the given amount
  105295. * @param scale the amount to scale
  105296. */
  105297. scaleInPlace(scale: number): void;
  105298. /**
  105299. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105300. *
  105301. * ```
  105302. * E_lm = A_l * L_lm
  105303. * ```
  105304. *
  105305. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105306. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105307. * the scaling factors are given in equation 9.
  105308. */
  105309. convertIncidentRadianceToIrradiance(): void;
  105310. /**
  105311. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105312. *
  105313. * ```
  105314. * L = (1/pi) * E * rho
  105315. * ```
  105316. *
  105317. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105318. */
  105319. convertIrradianceToLambertianRadiance(): void;
  105320. /**
  105321. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105322. * required operations at run time.
  105323. *
  105324. * This is simply done by scaling back the SH with Ylm constants parameter.
  105325. * The trigonometric part being applied by the shader at run time.
  105326. */
  105327. preScaleForRendering(): void;
  105328. /**
  105329. * Constructs a spherical harmonics from an array.
  105330. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105331. * @returns the spherical harmonics
  105332. */
  105333. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105334. /**
  105335. * Gets the spherical harmonics from polynomial
  105336. * @param polynomial the spherical polynomial
  105337. * @returns the spherical harmonics
  105338. */
  105339. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105340. }
  105341. /**
  105342. * Class representing spherical polynomial coefficients to the 3rd degree
  105343. */
  105344. export class SphericalPolynomial {
  105345. private _harmonics;
  105346. /**
  105347. * The spherical harmonics used to create the polynomials.
  105348. */
  105349. get preScaledHarmonics(): SphericalHarmonics;
  105350. /**
  105351. * The x coefficients of the spherical polynomial
  105352. */
  105353. x: Vector3;
  105354. /**
  105355. * The y coefficients of the spherical polynomial
  105356. */
  105357. y: Vector3;
  105358. /**
  105359. * The z coefficients of the spherical polynomial
  105360. */
  105361. z: Vector3;
  105362. /**
  105363. * The xx coefficients of the spherical polynomial
  105364. */
  105365. xx: Vector3;
  105366. /**
  105367. * The yy coefficients of the spherical polynomial
  105368. */
  105369. yy: Vector3;
  105370. /**
  105371. * The zz coefficients of the spherical polynomial
  105372. */
  105373. zz: Vector3;
  105374. /**
  105375. * The xy coefficients of the spherical polynomial
  105376. */
  105377. xy: Vector3;
  105378. /**
  105379. * The yz coefficients of the spherical polynomial
  105380. */
  105381. yz: Vector3;
  105382. /**
  105383. * The zx coefficients of the spherical polynomial
  105384. */
  105385. zx: Vector3;
  105386. /**
  105387. * Adds an ambient color to the spherical polynomial
  105388. * @param color the color to add
  105389. */
  105390. addAmbient(color: Color3): void;
  105391. /**
  105392. * Scales the spherical polynomial by the given amount
  105393. * @param scale the amount to scale
  105394. */
  105395. scaleInPlace(scale: number): void;
  105396. /**
  105397. * Gets the spherical polynomial from harmonics
  105398. * @param harmonics the spherical harmonics
  105399. * @returns the spherical polynomial
  105400. */
  105401. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105402. /**
  105403. * Constructs a spherical polynomial from an array.
  105404. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105405. * @returns the spherical polynomial
  105406. */
  105407. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105408. }
  105409. }
  105410. declare module BABYLON {
  105411. /**
  105412. * Defines the source of the internal texture
  105413. */
  105414. export enum InternalTextureSource {
  105415. /**
  105416. * The source of the texture data is unknown
  105417. */
  105418. Unknown = 0,
  105419. /**
  105420. * Texture data comes from an URL
  105421. */
  105422. Url = 1,
  105423. /**
  105424. * Texture data is only used for temporary storage
  105425. */
  105426. Temp = 2,
  105427. /**
  105428. * Texture data comes from raw data (ArrayBuffer)
  105429. */
  105430. Raw = 3,
  105431. /**
  105432. * Texture content is dynamic (video or dynamic texture)
  105433. */
  105434. Dynamic = 4,
  105435. /**
  105436. * Texture content is generated by rendering to it
  105437. */
  105438. RenderTarget = 5,
  105439. /**
  105440. * Texture content is part of a multi render target process
  105441. */
  105442. MultiRenderTarget = 6,
  105443. /**
  105444. * Texture data comes from a cube data file
  105445. */
  105446. Cube = 7,
  105447. /**
  105448. * Texture data comes from a raw cube data
  105449. */
  105450. CubeRaw = 8,
  105451. /**
  105452. * Texture data come from a prefiltered cube data file
  105453. */
  105454. CubePrefiltered = 9,
  105455. /**
  105456. * Texture content is raw 3D data
  105457. */
  105458. Raw3D = 10,
  105459. /**
  105460. * Texture content is raw 2D array data
  105461. */
  105462. Raw2DArray = 11,
  105463. /**
  105464. * Texture content is a depth texture
  105465. */
  105466. Depth = 12,
  105467. /**
  105468. * Texture data comes from a raw cube data encoded with RGBD
  105469. */
  105470. CubeRawRGBD = 13
  105471. }
  105472. /**
  105473. * Class used to store data associated with WebGL texture data for the engine
  105474. * This class should not be used directly
  105475. */
  105476. export class InternalTexture {
  105477. /** @hidden */
  105478. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105479. /**
  105480. * Defines if the texture is ready
  105481. */
  105482. isReady: boolean;
  105483. /**
  105484. * Defines if the texture is a cube texture
  105485. */
  105486. isCube: boolean;
  105487. /**
  105488. * Defines if the texture contains 3D data
  105489. */
  105490. is3D: boolean;
  105491. /**
  105492. * Defines if the texture contains 2D array data
  105493. */
  105494. is2DArray: boolean;
  105495. /**
  105496. * Defines if the texture contains multiview data
  105497. */
  105498. isMultiview: boolean;
  105499. /**
  105500. * Gets the URL used to load this texture
  105501. */
  105502. url: string;
  105503. /**
  105504. * Gets the sampling mode of the texture
  105505. */
  105506. samplingMode: number;
  105507. /**
  105508. * Gets a boolean indicating if the texture needs mipmaps generation
  105509. */
  105510. generateMipMaps: boolean;
  105511. /**
  105512. * Gets the number of samples used by the texture (WebGL2+ only)
  105513. */
  105514. samples: number;
  105515. /**
  105516. * Gets the type of the texture (int, float...)
  105517. */
  105518. type: number;
  105519. /**
  105520. * Gets the format of the texture (RGB, RGBA...)
  105521. */
  105522. format: number;
  105523. /**
  105524. * Observable called when the texture is loaded
  105525. */
  105526. onLoadedObservable: Observable<InternalTexture>;
  105527. /**
  105528. * Gets the width of the texture
  105529. */
  105530. width: number;
  105531. /**
  105532. * Gets the height of the texture
  105533. */
  105534. height: number;
  105535. /**
  105536. * Gets the depth of the texture
  105537. */
  105538. depth: number;
  105539. /**
  105540. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105541. */
  105542. baseWidth: number;
  105543. /**
  105544. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105545. */
  105546. baseHeight: number;
  105547. /**
  105548. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105549. */
  105550. baseDepth: number;
  105551. /**
  105552. * Gets a boolean indicating if the texture is inverted on Y axis
  105553. */
  105554. invertY: boolean;
  105555. /** @hidden */
  105556. _invertVScale: boolean;
  105557. /** @hidden */
  105558. _associatedChannel: number;
  105559. /** @hidden */
  105560. _source: InternalTextureSource;
  105561. /** @hidden */
  105562. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105563. /** @hidden */
  105564. _bufferView: Nullable<ArrayBufferView>;
  105565. /** @hidden */
  105566. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105567. /** @hidden */
  105568. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105569. /** @hidden */
  105570. _size: number;
  105571. /** @hidden */
  105572. _extension: string;
  105573. /** @hidden */
  105574. _files: Nullable<string[]>;
  105575. /** @hidden */
  105576. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105577. /** @hidden */
  105578. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105579. /** @hidden */
  105580. _framebuffer: Nullable<WebGLFramebuffer>;
  105581. /** @hidden */
  105582. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105583. /** @hidden */
  105584. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105585. /** @hidden */
  105586. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105587. /** @hidden */
  105588. _attachments: Nullable<number[]>;
  105589. /** @hidden */
  105590. _cachedCoordinatesMode: Nullable<number>;
  105591. /** @hidden */
  105592. _cachedWrapU: Nullable<number>;
  105593. /** @hidden */
  105594. _cachedWrapV: Nullable<number>;
  105595. /** @hidden */
  105596. _cachedWrapR: Nullable<number>;
  105597. /** @hidden */
  105598. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105599. /** @hidden */
  105600. _isDisabled: boolean;
  105601. /** @hidden */
  105602. _compression: Nullable<string>;
  105603. /** @hidden */
  105604. _generateStencilBuffer: boolean;
  105605. /** @hidden */
  105606. _generateDepthBuffer: boolean;
  105607. /** @hidden */
  105608. _comparisonFunction: number;
  105609. /** @hidden */
  105610. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105611. /** @hidden */
  105612. _lodGenerationScale: number;
  105613. /** @hidden */
  105614. _lodGenerationOffset: number;
  105615. /** @hidden */
  105616. _depthStencilTexture: Nullable<InternalTexture>;
  105617. /** @hidden */
  105618. _colorTextureArray: Nullable<WebGLTexture>;
  105619. /** @hidden */
  105620. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105621. /** @hidden */
  105622. _lodTextureHigh: Nullable<BaseTexture>;
  105623. /** @hidden */
  105624. _lodTextureMid: Nullable<BaseTexture>;
  105625. /** @hidden */
  105626. _lodTextureLow: Nullable<BaseTexture>;
  105627. /** @hidden */
  105628. _isRGBD: boolean;
  105629. /** @hidden */
  105630. _linearSpecularLOD: boolean;
  105631. /** @hidden */
  105632. _irradianceTexture: Nullable<BaseTexture>;
  105633. /** @hidden */
  105634. _webGLTexture: Nullable<WebGLTexture>;
  105635. /** @hidden */
  105636. _references: number;
  105637. private _engine;
  105638. /**
  105639. * Gets the Engine the texture belongs to.
  105640. * @returns The babylon engine
  105641. */
  105642. getEngine(): ThinEngine;
  105643. /**
  105644. * Gets the data source type of the texture
  105645. */
  105646. get source(): InternalTextureSource;
  105647. /**
  105648. * Creates a new InternalTexture
  105649. * @param engine defines the engine to use
  105650. * @param source defines the type of data that will be used
  105651. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105652. */
  105653. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105654. /**
  105655. * Increments the number of references (ie. the number of Texture that point to it)
  105656. */
  105657. incrementReferences(): void;
  105658. /**
  105659. * Change the size of the texture (not the size of the content)
  105660. * @param width defines the new width
  105661. * @param height defines the new height
  105662. * @param depth defines the new depth (1 by default)
  105663. */
  105664. updateSize(width: int, height: int, depth?: int): void;
  105665. /** @hidden */
  105666. _rebuild(): void;
  105667. /** @hidden */
  105668. _swapAndDie(target: InternalTexture): void;
  105669. /**
  105670. * Dispose the current allocated resources
  105671. */
  105672. dispose(): void;
  105673. }
  105674. }
  105675. declare module BABYLON {
  105676. /**
  105677. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105679. */
  105680. export class Analyser {
  105681. /**
  105682. * Gets or sets the smoothing
  105683. * @ignorenaming
  105684. */
  105685. SMOOTHING: number;
  105686. /**
  105687. * Gets or sets the FFT table size
  105688. * @ignorenaming
  105689. */
  105690. FFT_SIZE: number;
  105691. /**
  105692. * Gets or sets the bar graph amplitude
  105693. * @ignorenaming
  105694. */
  105695. BARGRAPHAMPLITUDE: number;
  105696. /**
  105697. * Gets or sets the position of the debug canvas
  105698. * @ignorenaming
  105699. */
  105700. DEBUGCANVASPOS: {
  105701. x: number;
  105702. y: number;
  105703. };
  105704. /**
  105705. * Gets or sets the debug canvas size
  105706. * @ignorenaming
  105707. */
  105708. DEBUGCANVASSIZE: {
  105709. width: number;
  105710. height: number;
  105711. };
  105712. private _byteFreqs;
  105713. private _byteTime;
  105714. private _floatFreqs;
  105715. private _webAudioAnalyser;
  105716. private _debugCanvas;
  105717. private _debugCanvasContext;
  105718. private _scene;
  105719. private _registerFunc;
  105720. private _audioEngine;
  105721. /**
  105722. * Creates a new analyser
  105723. * @param scene defines hosting scene
  105724. */
  105725. constructor(scene: Scene);
  105726. /**
  105727. * Get the number of data values you will have to play with for the visualization
  105728. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105729. * @returns a number
  105730. */
  105731. getFrequencyBinCount(): number;
  105732. /**
  105733. * Gets the current frequency data as a byte array
  105734. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105735. * @returns a Uint8Array
  105736. */
  105737. getByteFrequencyData(): Uint8Array;
  105738. /**
  105739. * Gets the current waveform as a byte array
  105740. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105741. * @returns a Uint8Array
  105742. */
  105743. getByteTimeDomainData(): Uint8Array;
  105744. /**
  105745. * Gets the current frequency data as a float array
  105746. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105747. * @returns a Float32Array
  105748. */
  105749. getFloatFrequencyData(): Float32Array;
  105750. /**
  105751. * Renders the debug canvas
  105752. */
  105753. drawDebugCanvas(): void;
  105754. /**
  105755. * Stops rendering the debug canvas and removes it
  105756. */
  105757. stopDebugCanvas(): void;
  105758. /**
  105759. * Connects two audio nodes
  105760. * @param inputAudioNode defines first node to connect
  105761. * @param outputAudioNode defines second node to connect
  105762. */
  105763. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105764. /**
  105765. * Releases all associated resources
  105766. */
  105767. dispose(): void;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * This represents an audio engine and it is responsible
  105773. * to play, synchronize and analyse sounds throughout the application.
  105774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105775. */
  105776. export interface IAudioEngine extends IDisposable {
  105777. /**
  105778. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105779. */
  105780. readonly canUseWebAudio: boolean;
  105781. /**
  105782. * Gets the current AudioContext if available.
  105783. */
  105784. readonly audioContext: Nullable<AudioContext>;
  105785. /**
  105786. * The master gain node defines the global audio volume of your audio engine.
  105787. */
  105788. readonly masterGain: GainNode;
  105789. /**
  105790. * Gets whether or not mp3 are supported by your browser.
  105791. */
  105792. readonly isMP3supported: boolean;
  105793. /**
  105794. * Gets whether or not ogg are supported by your browser.
  105795. */
  105796. readonly isOGGsupported: boolean;
  105797. /**
  105798. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105799. * @ignoreNaming
  105800. */
  105801. WarnedWebAudioUnsupported: boolean;
  105802. /**
  105803. * Defines if the audio engine relies on a custom unlocked button.
  105804. * In this case, the embedded button will not be displayed.
  105805. */
  105806. useCustomUnlockedButton: boolean;
  105807. /**
  105808. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105809. */
  105810. readonly unlocked: boolean;
  105811. /**
  105812. * Event raised when audio has been unlocked on the browser.
  105813. */
  105814. onAudioUnlockedObservable: Observable<AudioEngine>;
  105815. /**
  105816. * Event raised when audio has been locked on the browser.
  105817. */
  105818. onAudioLockedObservable: Observable<AudioEngine>;
  105819. /**
  105820. * Flags the audio engine in Locked state.
  105821. * This happens due to new browser policies preventing audio to autoplay.
  105822. */
  105823. lock(): void;
  105824. /**
  105825. * Unlocks the audio engine once a user action has been done on the dom.
  105826. * This is helpful to resume play once browser policies have been satisfied.
  105827. */
  105828. unlock(): void;
  105829. }
  105830. /**
  105831. * This represents the default audio engine used in babylon.
  105832. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105834. */
  105835. export class AudioEngine implements IAudioEngine {
  105836. private _audioContext;
  105837. private _audioContextInitialized;
  105838. private _muteButton;
  105839. private _hostElement;
  105840. /**
  105841. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105842. */
  105843. canUseWebAudio: boolean;
  105844. /**
  105845. * The master gain node defines the global audio volume of your audio engine.
  105846. */
  105847. masterGain: GainNode;
  105848. /**
  105849. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105850. * @ignoreNaming
  105851. */
  105852. WarnedWebAudioUnsupported: boolean;
  105853. /**
  105854. * Gets whether or not mp3 are supported by your browser.
  105855. */
  105856. isMP3supported: boolean;
  105857. /**
  105858. * Gets whether or not ogg are supported by your browser.
  105859. */
  105860. isOGGsupported: boolean;
  105861. /**
  105862. * Gets whether audio has been unlocked on the device.
  105863. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105864. * a user interaction has happened.
  105865. */
  105866. unlocked: boolean;
  105867. /**
  105868. * Defines if the audio engine relies on a custom unlocked button.
  105869. * In this case, the embedded button will not be displayed.
  105870. */
  105871. useCustomUnlockedButton: boolean;
  105872. /**
  105873. * Event raised when audio has been unlocked on the browser.
  105874. */
  105875. onAudioUnlockedObservable: Observable<AudioEngine>;
  105876. /**
  105877. * Event raised when audio has been locked on the browser.
  105878. */
  105879. onAudioLockedObservable: Observable<AudioEngine>;
  105880. /**
  105881. * Gets the current AudioContext if available.
  105882. */
  105883. get audioContext(): Nullable<AudioContext>;
  105884. private _connectedAnalyser;
  105885. /**
  105886. * Instantiates a new audio engine.
  105887. *
  105888. * There should be only one per page as some browsers restrict the number
  105889. * of audio contexts you can create.
  105890. * @param hostElement defines the host element where to display the mute icon if necessary
  105891. */
  105892. constructor(hostElement?: Nullable<HTMLElement>);
  105893. /**
  105894. * Flags the audio engine in Locked state.
  105895. * This happens due to new browser policies preventing audio to autoplay.
  105896. */
  105897. lock(): void;
  105898. /**
  105899. * Unlocks the audio engine once a user action has been done on the dom.
  105900. * This is helpful to resume play once browser policies have been satisfied.
  105901. */
  105902. unlock(): void;
  105903. private _resumeAudioContext;
  105904. private _initializeAudioContext;
  105905. private _tryToRun;
  105906. private _triggerRunningState;
  105907. private _triggerSuspendedState;
  105908. private _displayMuteButton;
  105909. private _moveButtonToTopLeft;
  105910. private _onResize;
  105911. private _hideMuteButton;
  105912. /**
  105913. * Destroy and release the resources associated with the audio ccontext.
  105914. */
  105915. dispose(): void;
  105916. /**
  105917. * Gets the global volume sets on the master gain.
  105918. * @returns the global volume if set or -1 otherwise
  105919. */
  105920. getGlobalVolume(): number;
  105921. /**
  105922. * Sets the global volume of your experience (sets on the master gain).
  105923. * @param newVolume Defines the new global volume of the application
  105924. */
  105925. setGlobalVolume(newVolume: number): void;
  105926. /**
  105927. * Connect the audio engine to an audio analyser allowing some amazing
  105928. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105930. * @param analyser The analyser to connect to the engine
  105931. */
  105932. connectToAnalyser(analyser: Analyser): void;
  105933. }
  105934. }
  105935. declare module BABYLON {
  105936. /**
  105937. * Interface used to present a loading screen while loading a scene
  105938. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105939. */
  105940. export interface ILoadingScreen {
  105941. /**
  105942. * Function called to display the loading screen
  105943. */
  105944. displayLoadingUI: () => void;
  105945. /**
  105946. * Function called to hide the loading screen
  105947. */
  105948. hideLoadingUI: () => void;
  105949. /**
  105950. * Gets or sets the color to use for the background
  105951. */
  105952. loadingUIBackgroundColor: string;
  105953. /**
  105954. * Gets or sets the text to display while loading
  105955. */
  105956. loadingUIText: string;
  105957. }
  105958. /**
  105959. * Class used for the default loading screen
  105960. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105961. */
  105962. export class DefaultLoadingScreen implements ILoadingScreen {
  105963. private _renderingCanvas;
  105964. private _loadingText;
  105965. private _loadingDivBackgroundColor;
  105966. private _loadingDiv;
  105967. private _loadingTextDiv;
  105968. /** Gets or sets the logo url to use for the default loading screen */
  105969. static DefaultLogoUrl: string;
  105970. /** Gets or sets the spinner url to use for the default loading screen */
  105971. static DefaultSpinnerUrl: string;
  105972. /**
  105973. * Creates a new default loading screen
  105974. * @param _renderingCanvas defines the canvas used to render the scene
  105975. * @param _loadingText defines the default text to display
  105976. * @param _loadingDivBackgroundColor defines the default background color
  105977. */
  105978. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105979. /**
  105980. * Function called to display the loading screen
  105981. */
  105982. displayLoadingUI(): void;
  105983. /**
  105984. * Function called to hide the loading screen
  105985. */
  105986. hideLoadingUI(): void;
  105987. /**
  105988. * Gets or sets the text to display while loading
  105989. */
  105990. set loadingUIText(text: string);
  105991. get loadingUIText(): string;
  105992. /**
  105993. * Gets or sets the color to use for the background
  105994. */
  105995. get loadingUIBackgroundColor(): string;
  105996. set loadingUIBackgroundColor(color: string);
  105997. private _resizeLoadingUI;
  105998. }
  105999. }
  106000. declare module BABYLON {
  106001. /**
  106002. * Interface for any object that can request an animation frame
  106003. */
  106004. export interface ICustomAnimationFrameRequester {
  106005. /**
  106006. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106007. */
  106008. renderFunction?: Function;
  106009. /**
  106010. * Called to request the next frame to render to
  106011. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106012. */
  106013. requestAnimationFrame: Function;
  106014. /**
  106015. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106016. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106017. */
  106018. requestID?: number;
  106019. }
  106020. }
  106021. declare module BABYLON {
  106022. /**
  106023. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106024. */
  106025. export class PerformanceMonitor {
  106026. private _enabled;
  106027. private _rollingFrameTime;
  106028. private _lastFrameTimeMs;
  106029. /**
  106030. * constructor
  106031. * @param frameSampleSize The number of samples required to saturate the sliding window
  106032. */
  106033. constructor(frameSampleSize?: number);
  106034. /**
  106035. * Samples current frame
  106036. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106037. */
  106038. sampleFrame(timeMs?: number): void;
  106039. /**
  106040. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106041. */
  106042. get averageFrameTime(): number;
  106043. /**
  106044. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106045. */
  106046. get averageFrameTimeVariance(): number;
  106047. /**
  106048. * Returns the frame time of the most recent frame
  106049. */
  106050. get instantaneousFrameTime(): number;
  106051. /**
  106052. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106053. */
  106054. get averageFPS(): number;
  106055. /**
  106056. * Returns the average framerate in frames per second using the most recent frame time
  106057. */
  106058. get instantaneousFPS(): number;
  106059. /**
  106060. * Returns true if enough samples have been taken to completely fill the sliding window
  106061. */
  106062. get isSaturated(): boolean;
  106063. /**
  106064. * Enables contributions to the sliding window sample set
  106065. */
  106066. enable(): void;
  106067. /**
  106068. * Disables contributions to the sliding window sample set
  106069. * Samples will not be interpolated over the disabled period
  106070. */
  106071. disable(): void;
  106072. /**
  106073. * Returns true if sampling is enabled
  106074. */
  106075. get isEnabled(): boolean;
  106076. /**
  106077. * Resets performance monitor
  106078. */
  106079. reset(): void;
  106080. }
  106081. /**
  106082. * RollingAverage
  106083. *
  106084. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106085. */
  106086. export class RollingAverage {
  106087. /**
  106088. * Current average
  106089. */
  106090. average: number;
  106091. /**
  106092. * Current variance
  106093. */
  106094. variance: number;
  106095. protected _samples: Array<number>;
  106096. protected _sampleCount: number;
  106097. protected _pos: number;
  106098. protected _m2: number;
  106099. /**
  106100. * constructor
  106101. * @param length The number of samples required to saturate the sliding window
  106102. */
  106103. constructor(length: number);
  106104. /**
  106105. * Adds a sample to the sample set
  106106. * @param v The sample value
  106107. */
  106108. add(v: number): void;
  106109. /**
  106110. * Returns previously added values or null if outside of history or outside the sliding window domain
  106111. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106112. * @return Value previously recorded with add() or null if outside of range
  106113. */
  106114. history(i: number): number;
  106115. /**
  106116. * Returns true if enough samples have been taken to completely fill the sliding window
  106117. * @return true if sample-set saturated
  106118. */
  106119. isSaturated(): boolean;
  106120. /**
  106121. * Resets the rolling average (equivalent to 0 samples taken so far)
  106122. */
  106123. reset(): void;
  106124. /**
  106125. * Wraps a value around the sample range boundaries
  106126. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106127. * @return Wrapped position in sample range
  106128. */
  106129. protected _wrapPosition(i: number): number;
  106130. }
  106131. }
  106132. declare module BABYLON {
  106133. /**
  106134. * This class is used to track a performance counter which is number based.
  106135. * The user has access to many properties which give statistics of different nature.
  106136. *
  106137. * The implementer can track two kinds of Performance Counter: time and count.
  106138. * 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.
  106139. * 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.
  106140. */
  106141. export class PerfCounter {
  106142. /**
  106143. * Gets or sets a global boolean to turn on and off all the counters
  106144. */
  106145. static Enabled: boolean;
  106146. /**
  106147. * Returns the smallest value ever
  106148. */
  106149. get min(): number;
  106150. /**
  106151. * Returns the biggest value ever
  106152. */
  106153. get max(): number;
  106154. /**
  106155. * Returns the average value since the performance counter is running
  106156. */
  106157. get average(): number;
  106158. /**
  106159. * Returns the average value of the last second the counter was monitored
  106160. */
  106161. get lastSecAverage(): number;
  106162. /**
  106163. * Returns the current value
  106164. */
  106165. get current(): number;
  106166. /**
  106167. * Gets the accumulated total
  106168. */
  106169. get total(): number;
  106170. /**
  106171. * Gets the total value count
  106172. */
  106173. get count(): number;
  106174. /**
  106175. * Creates a new counter
  106176. */
  106177. constructor();
  106178. /**
  106179. * Call this method to start monitoring a new frame.
  106180. * 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.
  106181. */
  106182. fetchNewFrame(): void;
  106183. /**
  106184. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106185. * @param newCount the count value to add to the monitored count
  106186. * @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.
  106187. */
  106188. addCount(newCount: number, fetchResult: boolean): void;
  106189. /**
  106190. * Start monitoring this performance counter
  106191. */
  106192. beginMonitoring(): void;
  106193. /**
  106194. * Compute the time lapsed since the previous beginMonitoring() call.
  106195. * @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
  106196. */
  106197. endMonitoring(newFrame?: boolean): void;
  106198. private _fetchResult;
  106199. private _startMonitoringTime;
  106200. private _min;
  106201. private _max;
  106202. private _average;
  106203. private _current;
  106204. private _totalValueCount;
  106205. private _totalAccumulated;
  106206. private _lastSecAverage;
  106207. private _lastSecAccumulated;
  106208. private _lastSecTime;
  106209. private _lastSecValueCount;
  106210. }
  106211. }
  106212. declare module BABYLON {
  106213. interface ThinEngine {
  106214. /**
  106215. * Sets alpha constants used by some alpha blending modes
  106216. * @param r defines the red component
  106217. * @param g defines the green component
  106218. * @param b defines the blue component
  106219. * @param a defines the alpha component
  106220. */
  106221. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106222. /**
  106223. * Sets the current alpha mode
  106224. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106225. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106226. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106227. */
  106228. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106229. /**
  106230. * Gets the current alpha mode
  106231. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106232. * @returns the current alpha mode
  106233. */
  106234. getAlphaMode(): number;
  106235. /**
  106236. * Sets the current alpha equation
  106237. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106238. */
  106239. setAlphaEquation(equation: number): void;
  106240. /**
  106241. * Gets the current alpha equation.
  106242. * @returns the current alpha equation
  106243. */
  106244. getAlphaEquation(): number;
  106245. }
  106246. }
  106247. declare module BABYLON {
  106248. /**
  106249. * Defines the interface used by display changed events
  106250. */
  106251. export interface IDisplayChangedEventArgs {
  106252. /** Gets the vrDisplay object (if any) */
  106253. vrDisplay: Nullable<any>;
  106254. /** Gets a boolean indicating if webVR is supported */
  106255. vrSupported: boolean;
  106256. }
  106257. /**
  106258. * Defines the interface used by objects containing a viewport (like a camera)
  106259. */
  106260. interface IViewportOwnerLike {
  106261. /**
  106262. * Gets or sets the viewport
  106263. */
  106264. viewport: IViewportLike;
  106265. }
  106266. /**
  106267. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106268. */
  106269. export class Engine extends ThinEngine {
  106270. /** Defines that alpha blending is disabled */
  106271. static readonly ALPHA_DISABLE: number;
  106272. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106273. static readonly ALPHA_ADD: number;
  106274. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106275. static readonly ALPHA_COMBINE: number;
  106276. /** Defines that alpha blending to DEST - SRC * DEST */
  106277. static readonly ALPHA_SUBTRACT: number;
  106278. /** Defines that alpha blending to SRC * DEST */
  106279. static readonly ALPHA_MULTIPLY: number;
  106280. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106281. static readonly ALPHA_MAXIMIZED: number;
  106282. /** Defines that alpha blending to SRC + DEST */
  106283. static readonly ALPHA_ONEONE: number;
  106284. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106285. static readonly ALPHA_PREMULTIPLIED: number;
  106286. /**
  106287. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106288. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106289. */
  106290. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106291. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106292. static readonly ALPHA_INTERPOLATE: number;
  106293. /**
  106294. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106295. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106296. */
  106297. static readonly ALPHA_SCREENMODE: number;
  106298. /** Defines that the ressource is not delayed*/
  106299. static readonly DELAYLOADSTATE_NONE: number;
  106300. /** Defines that the ressource was successfully delay loaded */
  106301. static readonly DELAYLOADSTATE_LOADED: number;
  106302. /** Defines that the ressource is currently delay loading */
  106303. static readonly DELAYLOADSTATE_LOADING: number;
  106304. /** Defines that the ressource is delayed and has not started loading */
  106305. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106307. static readonly NEVER: number;
  106308. /** 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 */
  106309. static readonly ALWAYS: number;
  106310. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106311. static readonly LESS: number;
  106312. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106313. static readonly EQUAL: number;
  106314. /** 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 */
  106315. static readonly LEQUAL: number;
  106316. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106317. static readonly GREATER: number;
  106318. /** 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 */
  106319. static readonly GEQUAL: number;
  106320. /** 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 */
  106321. static readonly NOTEQUAL: number;
  106322. /** Passed to stencilOperation to specify that stencil value must be kept */
  106323. static readonly KEEP: number;
  106324. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106325. static readonly REPLACE: number;
  106326. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106327. static readonly INCR: number;
  106328. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106329. static readonly DECR: number;
  106330. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106331. static readonly INVERT: number;
  106332. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106333. static readonly INCR_WRAP: number;
  106334. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106335. static readonly DECR_WRAP: number;
  106336. /** Texture is not repeating outside of 0..1 UVs */
  106337. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106338. /** Texture is repeating outside of 0..1 UVs */
  106339. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106340. /** Texture is repeating and mirrored */
  106341. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106342. /** ALPHA */
  106343. static readonly TEXTUREFORMAT_ALPHA: number;
  106344. /** LUMINANCE */
  106345. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106346. /** LUMINANCE_ALPHA */
  106347. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106348. /** RGB */
  106349. static readonly TEXTUREFORMAT_RGB: number;
  106350. /** RGBA */
  106351. static readonly TEXTUREFORMAT_RGBA: number;
  106352. /** RED */
  106353. static readonly TEXTUREFORMAT_RED: number;
  106354. /** RED (2nd reference) */
  106355. static readonly TEXTUREFORMAT_R: number;
  106356. /** RG */
  106357. static readonly TEXTUREFORMAT_RG: number;
  106358. /** RED_INTEGER */
  106359. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106360. /** RED_INTEGER (2nd reference) */
  106361. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106362. /** RG_INTEGER */
  106363. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106364. /** RGB_INTEGER */
  106365. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106366. /** RGBA_INTEGER */
  106367. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106368. /** UNSIGNED_BYTE */
  106369. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106370. /** UNSIGNED_BYTE (2nd reference) */
  106371. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106372. /** FLOAT */
  106373. static readonly TEXTURETYPE_FLOAT: number;
  106374. /** HALF_FLOAT */
  106375. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106376. /** BYTE */
  106377. static readonly TEXTURETYPE_BYTE: number;
  106378. /** SHORT */
  106379. static readonly TEXTURETYPE_SHORT: number;
  106380. /** UNSIGNED_SHORT */
  106381. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106382. /** INT */
  106383. static readonly TEXTURETYPE_INT: number;
  106384. /** UNSIGNED_INT */
  106385. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106386. /** UNSIGNED_SHORT_4_4_4_4 */
  106387. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106388. /** UNSIGNED_SHORT_5_5_5_1 */
  106389. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106390. /** UNSIGNED_SHORT_5_6_5 */
  106391. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106392. /** UNSIGNED_INT_2_10_10_10_REV */
  106393. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106394. /** UNSIGNED_INT_24_8 */
  106395. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106396. /** UNSIGNED_INT_10F_11F_11F_REV */
  106397. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106398. /** UNSIGNED_INT_5_9_9_9_REV */
  106399. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106400. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106401. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106402. /** nearest is mag = nearest and min = nearest and mip = linear */
  106403. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106405. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106406. /** Trilinear is mag = linear and min = linear and mip = linear */
  106407. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106408. /** nearest is mag = nearest and min = nearest and mip = linear */
  106409. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106410. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106411. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106412. /** Trilinear is mag = linear and min = linear and mip = linear */
  106413. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106414. /** mag = nearest and min = nearest and mip = nearest */
  106415. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106416. /** mag = nearest and min = linear and mip = nearest */
  106417. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106418. /** mag = nearest and min = linear and mip = linear */
  106419. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106420. /** mag = nearest and min = linear and mip = none */
  106421. static readonly TEXTURE_NEAREST_LINEAR: number;
  106422. /** mag = nearest and min = nearest and mip = none */
  106423. static readonly TEXTURE_NEAREST_NEAREST: number;
  106424. /** mag = linear and min = nearest and mip = nearest */
  106425. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106426. /** mag = linear and min = nearest and mip = linear */
  106427. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106428. /** mag = linear and min = linear and mip = none */
  106429. static readonly TEXTURE_LINEAR_LINEAR: number;
  106430. /** mag = linear and min = nearest and mip = none */
  106431. static readonly TEXTURE_LINEAR_NEAREST: number;
  106432. /** Explicit coordinates mode */
  106433. static readonly TEXTURE_EXPLICIT_MODE: number;
  106434. /** Spherical coordinates mode */
  106435. static readonly TEXTURE_SPHERICAL_MODE: number;
  106436. /** Planar coordinates mode */
  106437. static readonly TEXTURE_PLANAR_MODE: number;
  106438. /** Cubic coordinates mode */
  106439. static readonly TEXTURE_CUBIC_MODE: number;
  106440. /** Projection coordinates mode */
  106441. static readonly TEXTURE_PROJECTION_MODE: number;
  106442. /** Skybox coordinates mode */
  106443. static readonly TEXTURE_SKYBOX_MODE: number;
  106444. /** Inverse Cubic coordinates mode */
  106445. static readonly TEXTURE_INVCUBIC_MODE: number;
  106446. /** Equirectangular coordinates mode */
  106447. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106448. /** Equirectangular Fixed coordinates mode */
  106449. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106450. /** Equirectangular Fixed Mirrored coordinates mode */
  106451. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106452. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106453. static readonly SCALEMODE_FLOOR: number;
  106454. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106455. static readonly SCALEMODE_NEAREST: number;
  106456. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106457. static readonly SCALEMODE_CEILING: number;
  106458. /**
  106459. * Returns the current npm package of the sdk
  106460. */
  106461. static get NpmPackage(): string;
  106462. /**
  106463. * Returns the current version of the framework
  106464. */
  106465. static get Version(): string;
  106466. /** Gets the list of created engines */
  106467. static get Instances(): Engine[];
  106468. /**
  106469. * Gets the latest created engine
  106470. */
  106471. static get LastCreatedEngine(): Nullable<Engine>;
  106472. /**
  106473. * Gets the latest created scene
  106474. */
  106475. static get LastCreatedScene(): Nullable<Scene>;
  106476. /**
  106477. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106478. * @param flag defines which part of the materials must be marked as dirty
  106479. * @param predicate defines a predicate used to filter which materials should be affected
  106480. */
  106481. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106482. /**
  106483. * Method called to create the default loading screen.
  106484. * This can be overriden in your own app.
  106485. * @param canvas The rendering canvas element
  106486. * @returns The loading screen
  106487. */
  106488. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106489. /**
  106490. * Method called to create the default rescale post process on each engine.
  106491. */
  106492. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106493. /**
  106494. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106495. **/
  106496. enableOfflineSupport: boolean;
  106497. /**
  106498. * 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)
  106499. **/
  106500. disableManifestCheck: boolean;
  106501. /**
  106502. * Gets the list of created scenes
  106503. */
  106504. scenes: Scene[];
  106505. /**
  106506. * Event raised when a new scene is created
  106507. */
  106508. onNewSceneAddedObservable: Observable<Scene>;
  106509. /**
  106510. * Gets the list of created postprocesses
  106511. */
  106512. postProcesses: PostProcess[];
  106513. /**
  106514. * Gets a boolean indicating if the pointer is currently locked
  106515. */
  106516. isPointerLock: boolean;
  106517. /**
  106518. * Observable event triggered each time the rendering canvas is resized
  106519. */
  106520. onResizeObservable: Observable<Engine>;
  106521. /**
  106522. * Observable event triggered each time the canvas loses focus
  106523. */
  106524. onCanvasBlurObservable: Observable<Engine>;
  106525. /**
  106526. * Observable event triggered each time the canvas gains focus
  106527. */
  106528. onCanvasFocusObservable: Observable<Engine>;
  106529. /**
  106530. * Observable event triggered each time the canvas receives pointerout event
  106531. */
  106532. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106533. /**
  106534. * Observable raised when the engine begins a new frame
  106535. */
  106536. onBeginFrameObservable: Observable<Engine>;
  106537. /**
  106538. * If set, will be used to request the next animation frame for the render loop
  106539. */
  106540. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106541. /**
  106542. * Observable raised when the engine ends the current frame
  106543. */
  106544. onEndFrameObservable: Observable<Engine>;
  106545. /**
  106546. * Observable raised when the engine is about to compile a shader
  106547. */
  106548. onBeforeShaderCompilationObservable: Observable<Engine>;
  106549. /**
  106550. * Observable raised when the engine has jsut compiled a shader
  106551. */
  106552. onAfterShaderCompilationObservable: Observable<Engine>;
  106553. /**
  106554. * Gets the audio engine
  106555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106556. * @ignorenaming
  106557. */
  106558. static audioEngine: IAudioEngine;
  106559. /**
  106560. * Default AudioEngine factory responsible of creating the Audio Engine.
  106561. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106562. */
  106563. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106564. /**
  106565. * Default offline support factory responsible of creating a tool used to store data locally.
  106566. * By default, this will create a Database object if the workload has been embedded.
  106567. */
  106568. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106569. private _loadingScreen;
  106570. private _pointerLockRequested;
  106571. private _dummyFramebuffer;
  106572. private _rescalePostProcess;
  106573. private _deterministicLockstep;
  106574. private _lockstepMaxSteps;
  106575. private _timeStep;
  106576. protected get _supportsHardwareTextureRescaling(): boolean;
  106577. private _fps;
  106578. private _deltaTime;
  106579. /** @hidden */
  106580. _drawCalls: PerfCounter;
  106581. /** 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 */
  106582. canvasTabIndex: number;
  106583. /**
  106584. * Turn this value on if you want to pause FPS computation when in background
  106585. */
  106586. disablePerformanceMonitorInBackground: boolean;
  106587. private _performanceMonitor;
  106588. /**
  106589. * Gets the performance monitor attached to this engine
  106590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106591. */
  106592. get performanceMonitor(): PerformanceMonitor;
  106593. private _onFocus;
  106594. private _onBlur;
  106595. private _onCanvasPointerOut;
  106596. private _onCanvasBlur;
  106597. private _onCanvasFocus;
  106598. private _onFullscreenChange;
  106599. private _onPointerLockChange;
  106600. /**
  106601. * Gets the HTML element used to attach event listeners
  106602. * @returns a HTML element
  106603. */
  106604. getInputElement(): Nullable<HTMLElement>;
  106605. /**
  106606. * Creates a new engine
  106607. * @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
  106608. * @param antialias defines enable antialiasing (default: false)
  106609. * @param options defines further options to be sent to the getContext() function
  106610. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106611. */
  106612. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106613. /**
  106614. * Gets current aspect ratio
  106615. * @param viewportOwner defines the camera to use to get the aspect ratio
  106616. * @param useScreen defines if screen size must be used (or the current render target if any)
  106617. * @returns a number defining the aspect ratio
  106618. */
  106619. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106620. /**
  106621. * Gets current screen aspect ratio
  106622. * @returns a number defining the aspect ratio
  106623. */
  106624. getScreenAspectRatio(): number;
  106625. /**
  106626. * Gets the client rect of the HTML canvas attached with the current webGL context
  106627. * @returns a client rectanglee
  106628. */
  106629. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106630. /**
  106631. * Gets the client rect of the HTML element used for events
  106632. * @returns a client rectanglee
  106633. */
  106634. getInputElementClientRect(): Nullable<ClientRect>;
  106635. /**
  106636. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106638. * @returns true if engine is in deterministic lock step mode
  106639. */
  106640. isDeterministicLockStep(): boolean;
  106641. /**
  106642. * Gets the max steps when engine is running in deterministic lock step
  106643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106644. * @returns the max steps
  106645. */
  106646. getLockstepMaxSteps(): number;
  106647. /**
  106648. * Returns the time in ms between steps when using deterministic lock step.
  106649. * @returns time step in (ms)
  106650. */
  106651. getTimeStep(): number;
  106652. /**
  106653. * Force the mipmap generation for the given render target texture
  106654. * @param texture defines the render target texture to use
  106655. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106656. */
  106657. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106658. /** States */
  106659. /**
  106660. * Set various states to the webGL context
  106661. * @param culling defines backface culling state
  106662. * @param zOffset defines the value to apply to zOffset (0 by default)
  106663. * @param force defines if states must be applied even if cache is up to date
  106664. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106665. */
  106666. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106667. /**
  106668. * Set the z offset to apply to current rendering
  106669. * @param value defines the offset to apply
  106670. */
  106671. setZOffset(value: number): void;
  106672. /**
  106673. * Gets the current value of the zOffset
  106674. * @returns the current zOffset state
  106675. */
  106676. getZOffset(): number;
  106677. /**
  106678. * Enable or disable depth buffering
  106679. * @param enable defines the state to set
  106680. */
  106681. setDepthBuffer(enable: boolean): void;
  106682. /**
  106683. * Gets a boolean indicating if depth writing is enabled
  106684. * @returns the current depth writing state
  106685. */
  106686. getDepthWrite(): boolean;
  106687. /**
  106688. * Enable or disable depth writing
  106689. * @param enable defines the state to set
  106690. */
  106691. setDepthWrite(enable: boolean): void;
  106692. /**
  106693. * Gets a boolean indicating if stencil buffer is enabled
  106694. * @returns the current stencil buffer state
  106695. */
  106696. getStencilBuffer(): boolean;
  106697. /**
  106698. * Enable or disable the stencil buffer
  106699. * @param enable defines if the stencil buffer must be enabled or disabled
  106700. */
  106701. setStencilBuffer(enable: boolean): void;
  106702. /**
  106703. * Gets the current stencil mask
  106704. * @returns a number defining the new stencil mask to use
  106705. */
  106706. getStencilMask(): number;
  106707. /**
  106708. * Sets the current stencil mask
  106709. * @param mask defines the new stencil mask to use
  106710. */
  106711. setStencilMask(mask: number): void;
  106712. /**
  106713. * Gets the current stencil function
  106714. * @returns a number defining the stencil function to use
  106715. */
  106716. getStencilFunction(): number;
  106717. /**
  106718. * Gets the current stencil reference value
  106719. * @returns a number defining the stencil reference value to use
  106720. */
  106721. getStencilFunctionReference(): number;
  106722. /**
  106723. * Gets the current stencil mask
  106724. * @returns a number defining the stencil mask to use
  106725. */
  106726. getStencilFunctionMask(): number;
  106727. /**
  106728. * Sets the current stencil function
  106729. * @param stencilFunc defines the new stencil function to use
  106730. */
  106731. setStencilFunction(stencilFunc: number): void;
  106732. /**
  106733. * Sets the current stencil reference
  106734. * @param reference defines the new stencil reference to use
  106735. */
  106736. setStencilFunctionReference(reference: number): void;
  106737. /**
  106738. * Sets the current stencil mask
  106739. * @param mask defines the new stencil mask to use
  106740. */
  106741. setStencilFunctionMask(mask: number): void;
  106742. /**
  106743. * Gets the current stencil operation when stencil fails
  106744. * @returns a number defining stencil operation to use when stencil fails
  106745. */
  106746. getStencilOperationFail(): number;
  106747. /**
  106748. * Gets the current stencil operation when depth fails
  106749. * @returns a number defining stencil operation to use when depth fails
  106750. */
  106751. getStencilOperationDepthFail(): number;
  106752. /**
  106753. * Gets the current stencil operation when stencil passes
  106754. * @returns a number defining stencil operation to use when stencil passes
  106755. */
  106756. getStencilOperationPass(): number;
  106757. /**
  106758. * Sets the stencil operation to use when stencil fails
  106759. * @param operation defines the stencil operation to use when stencil fails
  106760. */
  106761. setStencilOperationFail(operation: number): void;
  106762. /**
  106763. * Sets the stencil operation to use when depth fails
  106764. * @param operation defines the stencil operation to use when depth fails
  106765. */
  106766. setStencilOperationDepthFail(operation: number): void;
  106767. /**
  106768. * Sets the stencil operation to use when stencil passes
  106769. * @param operation defines the stencil operation to use when stencil passes
  106770. */
  106771. setStencilOperationPass(operation: number): void;
  106772. /**
  106773. * Sets a boolean indicating if the dithering state is enabled or disabled
  106774. * @param value defines the dithering state
  106775. */
  106776. setDitheringState(value: boolean): void;
  106777. /**
  106778. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106779. * @param value defines the rasterizer state
  106780. */
  106781. setRasterizerState(value: boolean): void;
  106782. /**
  106783. * Gets the current depth function
  106784. * @returns a number defining the depth function
  106785. */
  106786. getDepthFunction(): Nullable<number>;
  106787. /**
  106788. * Sets the current depth function
  106789. * @param depthFunc defines the function to use
  106790. */
  106791. setDepthFunction(depthFunc: number): void;
  106792. /**
  106793. * Sets the current depth function to GREATER
  106794. */
  106795. setDepthFunctionToGreater(): void;
  106796. /**
  106797. * Sets the current depth function to GEQUAL
  106798. */
  106799. setDepthFunctionToGreaterOrEqual(): void;
  106800. /**
  106801. * Sets the current depth function to LESS
  106802. */
  106803. setDepthFunctionToLess(): void;
  106804. /**
  106805. * Sets the current depth function to LEQUAL
  106806. */
  106807. setDepthFunctionToLessOrEqual(): void;
  106808. private _cachedStencilBuffer;
  106809. private _cachedStencilFunction;
  106810. private _cachedStencilMask;
  106811. private _cachedStencilOperationPass;
  106812. private _cachedStencilOperationFail;
  106813. private _cachedStencilOperationDepthFail;
  106814. private _cachedStencilReference;
  106815. /**
  106816. * Caches the the state of the stencil buffer
  106817. */
  106818. cacheStencilState(): void;
  106819. /**
  106820. * Restores the state of the stencil buffer
  106821. */
  106822. restoreStencilState(): void;
  106823. /**
  106824. * Directly set the WebGL Viewport
  106825. * @param x defines the x coordinate of the viewport (in screen space)
  106826. * @param y defines the y coordinate of the viewport (in screen space)
  106827. * @param width defines the width of the viewport (in screen space)
  106828. * @param height defines the height of the viewport (in screen space)
  106829. * @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
  106830. */
  106831. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106832. /**
  106833. * Executes a scissor clear (ie. a clear 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. * @param clearColor defines the clear color
  106839. */
  106840. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106841. /**
  106842. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106843. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106844. * @param y defines the y-coordinate of the corner of the clear rectangle
  106845. * @param width defines the width of the clear rectangle
  106846. * @param height defines the height of the clear rectangle
  106847. */
  106848. enableScissor(x: number, y: number, width: number, height: number): void;
  106849. /**
  106850. * Disable previously set scissor test rectangle
  106851. */
  106852. disableScissor(): void;
  106853. protected _reportDrawCall(): void;
  106854. /**
  106855. * Initializes a webVR display and starts listening to display change events
  106856. * The onVRDisplayChangedObservable will be notified upon these changes
  106857. * @returns The onVRDisplayChangedObservable
  106858. */
  106859. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106860. /** @hidden */
  106861. _prepareVRComponent(): void;
  106862. /** @hidden */
  106863. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106864. /** @hidden */
  106865. _submitVRFrame(): void;
  106866. /**
  106867. * Call this function to leave webVR mode
  106868. * Will do nothing if webVR is not supported or if there is no webVR device
  106869. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106870. */
  106871. disableVR(): void;
  106872. /**
  106873. * Gets a boolean indicating that the system is in VR mode and is presenting
  106874. * @returns true if VR mode is engaged
  106875. */
  106876. isVRPresenting(): boolean;
  106877. /** @hidden */
  106878. _requestVRFrame(): void;
  106879. /** @hidden */
  106880. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106881. /**
  106882. * Gets the source code of the vertex shader associated with a specific webGL program
  106883. * @param program defines the program to use
  106884. * @returns a string containing the source code of the vertex shader associated with the program
  106885. */
  106886. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106887. /**
  106888. * Gets the source code of the fragment shader associated with a specific webGL program
  106889. * @param program defines the program to use
  106890. * @returns a string containing the source code of the fragment shader associated with the program
  106891. */
  106892. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106893. /**
  106894. * Sets a depth stencil texture from a render target to the according uniform.
  106895. * @param channel The texture channel
  106896. * @param uniform The uniform to set
  106897. * @param texture The render target texture containing the depth stencil texture to apply
  106898. */
  106899. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106900. /**
  106901. * Sets a texture to the webGL context from a postprocess
  106902. * @param channel defines the channel to use
  106903. * @param postProcess defines the source postprocess
  106904. */
  106905. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106906. /**
  106907. * Binds the output of the passed in post process to the texture channel specified
  106908. * @param channel The channel the texture should be bound to
  106909. * @param postProcess The post process which's output should be bound
  106910. */
  106911. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106912. /** @hidden */
  106913. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106914. protected _rebuildBuffers(): void;
  106915. /** @hidden */
  106916. _renderFrame(): void;
  106917. _renderLoop(): void;
  106918. /** @hidden */
  106919. _renderViews(): boolean;
  106920. /**
  106921. * Toggle full screen mode
  106922. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106923. */
  106924. switchFullscreen(requestPointerLock: boolean): void;
  106925. /**
  106926. * Enters full screen mode
  106927. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106928. */
  106929. enterFullscreen(requestPointerLock: boolean): void;
  106930. /**
  106931. * Exits full screen mode
  106932. */
  106933. exitFullscreen(): void;
  106934. /**
  106935. * Enters Pointerlock mode
  106936. */
  106937. enterPointerlock(): void;
  106938. /**
  106939. * Exits Pointerlock mode
  106940. */
  106941. exitPointerlock(): void;
  106942. /**
  106943. * Begin a new frame
  106944. */
  106945. beginFrame(): void;
  106946. /**
  106947. * Enf the current frame
  106948. */
  106949. endFrame(): void;
  106950. resize(): void;
  106951. /**
  106952. * Set the compressed texture format to use, based on the formats you have, and the formats
  106953. * supported by the hardware / browser.
  106954. *
  106955. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106956. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106957. * to API arguments needed to compressed textures. This puts the burden on the container
  106958. * generator to house the arcane code for determining these for current & future formats.
  106959. *
  106960. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106961. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106962. *
  106963. * Note: The result of this call is not taken into account when a texture is base64.
  106964. *
  106965. * @param formatsAvailable defines the list of those format families you have created
  106966. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106967. *
  106968. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106969. * @returns The extension selected.
  106970. */
  106971. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106972. /**
  106973. * Set the compressed texture extensions or file names to skip.
  106974. *
  106975. * @param skippedFiles defines the list of those texture files you want to skip
  106976. * Example: [".dds", ".env", "myfile.png"]
  106977. */
  106978. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106979. /**
  106980. * Force a specific size of the canvas
  106981. * @param width defines the new canvas' width
  106982. * @param height defines the new canvas' height
  106983. */
  106984. setSize(width: number, height: number): void;
  106985. /**
  106986. * Updates a dynamic vertex buffer.
  106987. * @param vertexBuffer the vertex buffer to update
  106988. * @param data the data used to update the vertex buffer
  106989. * @param byteOffset the byte offset of the data
  106990. * @param byteLength the byte length of the data
  106991. */
  106992. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106993. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106994. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106995. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106996. _releaseTexture(texture: InternalTexture): void;
  106997. /**
  106998. * @hidden
  106999. * Rescales a texture
  107000. * @param source input texutre
  107001. * @param destination destination texture
  107002. * @param scene scene to use to render the resize
  107003. * @param internalFormat format to use when resizing
  107004. * @param onComplete callback to be called when resize has completed
  107005. */
  107006. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107007. /**
  107008. * Gets the current framerate
  107009. * @returns a number representing the framerate
  107010. */
  107011. getFps(): number;
  107012. /**
  107013. * Gets the time spent between current and previous frame
  107014. * @returns a number representing the delta time in ms
  107015. */
  107016. getDeltaTime(): number;
  107017. private _measureFps;
  107018. /** @hidden */
  107019. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107020. /**
  107021. * Update a dynamic index buffer
  107022. * @param indexBuffer defines the target index buffer
  107023. * @param indices defines the data to update
  107024. * @param offset defines the offset in the target index buffer where update should start
  107025. */
  107026. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107027. /**
  107028. * Updates the sample count of a render target texture
  107029. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107030. * @param texture defines the texture to update
  107031. * @param samples defines the sample count to set
  107032. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107033. */
  107034. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107035. /**
  107036. * Updates a depth texture Comparison Mode and Function.
  107037. * If the comparison Function is equal to 0, the mode will be set to none.
  107038. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107039. * @param texture The texture to set the comparison function for
  107040. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107041. */
  107042. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107043. /**
  107044. * Creates a webGL buffer to use with instanciation
  107045. * @param capacity defines the size of the buffer
  107046. * @returns the webGL buffer
  107047. */
  107048. createInstancesBuffer(capacity: number): DataBuffer;
  107049. /**
  107050. * Delete a webGL buffer used with instanciation
  107051. * @param buffer defines the webGL buffer to delete
  107052. */
  107053. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107054. /** @hidden */
  107055. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107056. dispose(): void;
  107057. private _disableTouchAction;
  107058. /**
  107059. * Display the loading screen
  107060. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107061. */
  107062. displayLoadingUI(): void;
  107063. /**
  107064. * Hide the loading screen
  107065. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107066. */
  107067. hideLoadingUI(): void;
  107068. /**
  107069. * Gets the current loading screen object
  107070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107071. */
  107072. get loadingScreen(): ILoadingScreen;
  107073. /**
  107074. * Sets the current loading screen object
  107075. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107076. */
  107077. set loadingScreen(loadingScreen: ILoadingScreen);
  107078. /**
  107079. * Sets the current loading screen text
  107080. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107081. */
  107082. set loadingUIText(text: string);
  107083. /**
  107084. * Sets the current loading screen background color
  107085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107086. */
  107087. set loadingUIBackgroundColor(color: string);
  107088. /** Pointerlock and fullscreen */
  107089. /**
  107090. * Ask the browser to promote the current element to pointerlock mode
  107091. * @param element defines the DOM element to promote
  107092. */
  107093. static _RequestPointerlock(element: HTMLElement): void;
  107094. /**
  107095. * Asks the browser to exit pointerlock mode
  107096. */
  107097. static _ExitPointerlock(): void;
  107098. /**
  107099. * Ask the browser to promote the current element to fullscreen rendering mode
  107100. * @param element defines the DOM element to promote
  107101. */
  107102. static _RequestFullscreen(element: HTMLElement): void;
  107103. /**
  107104. * Asks the browser to exit fullscreen mode
  107105. */
  107106. static _ExitFullscreen(): void;
  107107. }
  107108. }
  107109. declare module BABYLON {
  107110. /**
  107111. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107112. * during the life time of the application.
  107113. */
  107114. export class EngineStore {
  107115. /** Gets the list of created engines */
  107116. static Instances: Engine[];
  107117. /** @hidden */
  107118. static _LastCreatedScene: Nullable<Scene>;
  107119. /**
  107120. * Gets the latest created engine
  107121. */
  107122. static get LastCreatedEngine(): Nullable<Engine>;
  107123. /**
  107124. * Gets the latest created scene
  107125. */
  107126. static get LastCreatedScene(): Nullable<Scene>;
  107127. /**
  107128. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107129. * @ignorenaming
  107130. */
  107131. static UseFallbackTexture: boolean;
  107132. /**
  107133. * Texture content used if a texture cannot loaded
  107134. * @ignorenaming
  107135. */
  107136. static FallbackTexture: string;
  107137. }
  107138. }
  107139. declare module BABYLON {
  107140. /**
  107141. * Helper class that provides a small promise polyfill
  107142. */
  107143. export class PromisePolyfill {
  107144. /**
  107145. * Static function used to check if the polyfill is required
  107146. * If this is the case then the function will inject the polyfill to window.Promise
  107147. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107148. */
  107149. static Apply(force?: boolean): void;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /**
  107154. * Interface for screenshot methods with describe argument called `size` as object with options
  107155. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107156. */
  107157. export interface IScreenshotSize {
  107158. /**
  107159. * number in pixels for canvas height
  107160. */
  107161. height?: number;
  107162. /**
  107163. * multiplier allowing render at a higher or lower resolution
  107164. * If value is defined then height and width will be ignored and taken from camera
  107165. */
  107166. precision?: number;
  107167. /**
  107168. * number in pixels for canvas width
  107169. */
  107170. width?: number;
  107171. }
  107172. }
  107173. declare module BABYLON {
  107174. interface IColor4Like {
  107175. r: float;
  107176. g: float;
  107177. b: float;
  107178. a: float;
  107179. }
  107180. /**
  107181. * Class containing a set of static utilities functions
  107182. */
  107183. export class Tools {
  107184. /**
  107185. * Gets or sets the base URL to use to load assets
  107186. */
  107187. static get BaseUrl(): string;
  107188. static set BaseUrl(value: string);
  107189. /**
  107190. * Enable/Disable Custom HTTP Request Headers globally.
  107191. * default = false
  107192. * @see CustomRequestHeaders
  107193. */
  107194. static UseCustomRequestHeaders: boolean;
  107195. /**
  107196. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107197. * i.e. when loading files, where the server/service expects an Authorization header
  107198. */
  107199. static CustomRequestHeaders: {
  107200. [key: string]: string;
  107201. };
  107202. /**
  107203. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107204. */
  107205. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107206. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107207. /**
  107208. * Default behaviour for cors in the application.
  107209. * It can be a string if the expected behavior is identical in the entire app.
  107210. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107211. */
  107212. static CorsBehavior: string | ((url: string | string[]) => string);
  107213. /**
  107214. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107215. * @ignorenaming
  107216. */
  107217. static get UseFallbackTexture(): boolean;
  107218. static set UseFallbackTexture(value: boolean);
  107219. /**
  107220. * Use this object to register external classes like custom textures or material
  107221. * to allow the laoders to instantiate them
  107222. */
  107223. static get RegisteredExternalClasses(): {
  107224. [key: string]: Object;
  107225. };
  107226. static set RegisteredExternalClasses(classes: {
  107227. [key: string]: Object;
  107228. });
  107229. /**
  107230. * Texture content used if a texture cannot loaded
  107231. * @ignorenaming
  107232. */
  107233. static get fallbackTexture(): string;
  107234. static set fallbackTexture(value: string);
  107235. /**
  107236. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107237. * @param u defines the coordinate on X axis
  107238. * @param v defines the coordinate on Y axis
  107239. * @param width defines the width of the source data
  107240. * @param height defines the height of the source data
  107241. * @param pixels defines the source byte array
  107242. * @param color defines the output color
  107243. */
  107244. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107245. /**
  107246. * Interpolates between a and b via alpha
  107247. * @param a The lower value (returned when alpha = 0)
  107248. * @param b The upper value (returned when alpha = 1)
  107249. * @param alpha The interpolation-factor
  107250. * @return The mixed value
  107251. */
  107252. static Mix(a: number, b: number, alpha: number): number;
  107253. /**
  107254. * Tries to instantiate a new object from a given class name
  107255. * @param className defines the class name to instantiate
  107256. * @returns the new object or null if the system was not able to do the instantiation
  107257. */
  107258. static Instantiate(className: string): any;
  107259. /**
  107260. * Provides a slice function that will work even on IE
  107261. * @param data defines the array to slice
  107262. * @param start defines the start of the data (optional)
  107263. * @param end defines the end of the data (optional)
  107264. * @returns the new sliced array
  107265. */
  107266. static Slice<T>(data: T, start?: number, end?: number): T;
  107267. /**
  107268. * Polyfill for setImmediate
  107269. * @param action defines the action to execute after the current execution block
  107270. */
  107271. static SetImmediate(action: () => void): void;
  107272. /**
  107273. * Function indicating if a number is an exponent of 2
  107274. * @param value defines the value to test
  107275. * @returns true if the value is an exponent of 2
  107276. */
  107277. static IsExponentOfTwo(value: number): boolean;
  107278. private static _tmpFloatArray;
  107279. /**
  107280. * Returns the nearest 32-bit single precision float representation of a Number
  107281. * @param value A Number. If the parameter is of a different type, it will get converted
  107282. * to a number or to NaN if it cannot be converted
  107283. * @returns number
  107284. */
  107285. static FloatRound(value: number): number;
  107286. /**
  107287. * Extracts the filename from a path
  107288. * @param path defines the path to use
  107289. * @returns the filename
  107290. */
  107291. static GetFilename(path: string): string;
  107292. /**
  107293. * Extracts the "folder" part of a path (everything before the filename).
  107294. * @param uri The URI to extract the info from
  107295. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107296. * @returns The "folder" part of the path
  107297. */
  107298. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107299. /**
  107300. * Extracts text content from a DOM element hierarchy
  107301. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107302. */
  107303. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107304. /**
  107305. * Convert an angle in radians to degrees
  107306. * @param angle defines the angle to convert
  107307. * @returns the angle in degrees
  107308. */
  107309. static ToDegrees(angle: number): number;
  107310. /**
  107311. * Convert an angle in degrees to radians
  107312. * @param angle defines the angle to convert
  107313. * @returns the angle in radians
  107314. */
  107315. static ToRadians(angle: number): number;
  107316. /**
  107317. * Returns an array if obj is not an array
  107318. * @param obj defines the object to evaluate as an array
  107319. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107320. * @returns either obj directly if obj is an array or a new array containing obj
  107321. */
  107322. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107323. /**
  107324. * Gets the pointer prefix to use
  107325. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107326. */
  107327. static GetPointerPrefix(): string;
  107328. /**
  107329. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107330. * @param url define the url we are trying
  107331. * @param element define the dom element where to configure the cors policy
  107332. */
  107333. static SetCorsBehavior(url: string | string[], element: {
  107334. crossOrigin: string | null;
  107335. }): void;
  107336. /**
  107337. * Removes unwanted characters from an url
  107338. * @param url defines the url to clean
  107339. * @returns the cleaned url
  107340. */
  107341. static CleanUrl(url: string): string;
  107342. /**
  107343. * Gets or sets a function used to pre-process url before using them to load assets
  107344. */
  107345. static get PreprocessUrl(): (url: string) => string;
  107346. static set PreprocessUrl(processor: (url: string) => string);
  107347. /**
  107348. * Loads an image as an HTMLImageElement.
  107349. * @param input url string, ArrayBuffer, or Blob to load
  107350. * @param onLoad callback called when the image successfully loads
  107351. * @param onError callback called when the image fails to load
  107352. * @param offlineProvider offline provider for caching
  107353. * @param mimeType optional mime type
  107354. * @returns the HTMLImageElement of the loaded image
  107355. */
  107356. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107357. /**
  107358. * Loads a file from a url
  107359. * @param url url string, ArrayBuffer, or Blob to load
  107360. * @param onSuccess callback called when the file successfully loads
  107361. * @param onProgress callback called while file is loading (if the server supports this mode)
  107362. * @param offlineProvider defines the offline provider for caching
  107363. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107364. * @param onError callback called when the file fails to load
  107365. * @returns a file request object
  107366. */
  107367. 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;
  107368. /**
  107369. * Loads a file from a url
  107370. * @param url the file url to load
  107371. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107372. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107373. */
  107374. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107375. /**
  107376. * Load a 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 onSuccess defines the callback called when the script is loaded
  107380. * @param onError defines the callback to call if an error occurs
  107381. * @param scriptId defines the id of the script element
  107382. */
  107383. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107384. /**
  107385. * Load an asynchronous script (identified by an url). When the url returns, the
  107386. * content of this file is added into a new script element, attached to the DOM (body element)
  107387. * @param scriptUrl defines the url of the script to laod
  107388. * @param scriptId defines the id of the script element
  107389. * @returns a promise request object
  107390. */
  107391. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107392. /**
  107393. * Loads a file from a blob
  107394. * @param fileToLoad defines the blob to use
  107395. * @param callback defines the callback to call when data is loaded
  107396. * @param progressCallback defines the callback to call during loading process
  107397. * @returns a file request object
  107398. */
  107399. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107400. /**
  107401. * Reads a file from a File object
  107402. * @param file defines the file to load
  107403. * @param onSuccess defines the callback to call when data is loaded
  107404. * @param onProgress defines the callback to call during loading process
  107405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107406. * @param onError defines the callback to call when an error occurs
  107407. * @returns a file request object
  107408. */
  107409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107410. /**
  107411. * Creates a data url from a given string content
  107412. * @param content defines the content to convert
  107413. * @returns the new data url link
  107414. */
  107415. static FileAsURL(content: string): string;
  107416. /**
  107417. * Format the given number to a specific decimal format
  107418. * @param value defines the number to format
  107419. * @param decimals defines the number of decimals to use
  107420. * @returns the formatted string
  107421. */
  107422. static Format(value: number, decimals?: number): string;
  107423. /**
  107424. * Tries to copy an object by duplicating every property
  107425. * @param source defines the source object
  107426. * @param destination defines the target object
  107427. * @param doNotCopyList defines a list of properties to avoid
  107428. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107429. */
  107430. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107431. /**
  107432. * Gets a boolean indicating if the given object has no own property
  107433. * @param obj defines the object to test
  107434. * @returns true if object has no own property
  107435. */
  107436. static IsEmpty(obj: any): boolean;
  107437. /**
  107438. * Function used to register events at window level
  107439. * @param windowElement defines the Window object to use
  107440. * @param events defines the events to register
  107441. */
  107442. static RegisterTopRootEvents(windowElement: Window, events: {
  107443. name: string;
  107444. handler: Nullable<(e: FocusEvent) => any>;
  107445. }[]): void;
  107446. /**
  107447. * Function used to unregister events from window level
  107448. * @param windowElement defines the Window object to use
  107449. * @param events defines the events to unregister
  107450. */
  107451. static UnregisterTopRootEvents(windowElement: Window, events: {
  107452. name: string;
  107453. handler: Nullable<(e: FocusEvent) => any>;
  107454. }[]): void;
  107455. /**
  107456. * @ignore
  107457. */
  107458. static _ScreenshotCanvas: HTMLCanvasElement;
  107459. /**
  107460. * Dumps the current bound framebuffer
  107461. * @param width defines the rendering width
  107462. * @param height defines the rendering height
  107463. * @param engine defines the hosting engine
  107464. * @param successCallback defines the callback triggered once the data are available
  107465. * @param mimeType defines the mime type of the result
  107466. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107467. */
  107468. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107469. /**
  107470. * Converts the canvas data to blob.
  107471. * This acts as a polyfill for browsers not supporting the to blob function.
  107472. * @param canvas Defines the canvas to extract the data from
  107473. * @param successCallback Defines the callback triggered once the data are available
  107474. * @param mimeType Defines the mime type of the result
  107475. */
  107476. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107477. /**
  107478. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107479. * @param successCallback defines the callback triggered once the data are available
  107480. * @param mimeType defines the mime type of the result
  107481. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107482. */
  107483. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107484. /**
  107485. * Downloads a blob in the browser
  107486. * @param blob defines the blob to download
  107487. * @param fileName defines the name of the downloaded file
  107488. */
  107489. static Download(blob: Blob, fileName: string): void;
  107490. /**
  107491. * Captures a screenshot of the current rendering
  107492. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107493. * @param engine defines the rendering engine
  107494. * @param camera defines the source camera
  107495. * @param size This parameter can be set to a single number or to an object with the
  107496. * following (optional) properties: precision, width, height. If a single number is passed,
  107497. * it will be used for both width and height. If an object is passed, the screenshot size
  107498. * will be derived from the parameters. The precision property is a multiplier allowing
  107499. * rendering at a higher or lower resolution
  107500. * @param successCallback defines the callback receives a single parameter which contains the
  107501. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107502. * src parameter of an <img> to display it
  107503. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107504. * Check your browser for supported MIME types
  107505. */
  107506. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107507. /**
  107508. * Captures a screenshot of the current rendering
  107509. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107510. * @param engine defines the rendering engine
  107511. * @param camera defines the source camera
  107512. * @param size This parameter can be set to a single number or to an object with the
  107513. * following (optional) properties: precision, width, height. If a single number is passed,
  107514. * it will be used for both width and height. If an object is passed, the screenshot size
  107515. * will be derived from the parameters. The precision property is a multiplier allowing
  107516. * rendering at a higher or lower resolution
  107517. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107518. * Check your browser for supported MIME types
  107519. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107520. * to the src parameter of an <img> to display it
  107521. */
  107522. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107523. /**
  107524. * Generates an image screenshot from the specified camera.
  107525. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107526. * @param engine The engine to use for rendering
  107527. * @param camera The camera to use for rendering
  107528. * @param size This parameter can be set to a single number or to an object with the
  107529. * following (optional) properties: precision, width, height. If a single number is passed,
  107530. * it will be used for both width and height. If an object is passed, the screenshot size
  107531. * will be derived from the parameters. The precision property is a multiplier allowing
  107532. * rendering at a higher or lower resolution
  107533. * @param successCallback The callback receives a single parameter which contains the
  107534. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107535. * src parameter of an <img> to display it
  107536. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107537. * Check your browser for supported MIME types
  107538. * @param samples Texture samples (default: 1)
  107539. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107540. * @param fileName A name for for the downloaded file.
  107541. */
  107542. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107543. /**
  107544. * Generates an image screenshot from the specified camera.
  107545. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107546. * @param engine The engine to use for rendering
  107547. * @param camera The camera to use for rendering
  107548. * @param size This parameter can be set to a single number or to an object with the
  107549. * following (optional) properties: precision, width, height. If a single number is passed,
  107550. * it will be used for both width and height. If an object is passed, the screenshot size
  107551. * will be derived from the parameters. The precision property is a multiplier allowing
  107552. * rendering at a higher or lower resolution
  107553. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107554. * Check your browser for supported MIME types
  107555. * @param samples Texture samples (default: 1)
  107556. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107557. * @param fileName A name for for the downloaded file.
  107558. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107559. * to the src parameter of an <img> to display it
  107560. */
  107561. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107562. /**
  107563. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107564. * Be aware Math.random() could cause collisions, but:
  107565. * "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"
  107566. * @returns a pseudo random id
  107567. */
  107568. static RandomId(): string;
  107569. /**
  107570. * Test if the given uri is a base64 string
  107571. * @param uri The uri to test
  107572. * @return True if the uri is a base64 string or false otherwise
  107573. */
  107574. static IsBase64(uri: string): boolean;
  107575. /**
  107576. * Decode the given base64 uri.
  107577. * @param uri The uri to decode
  107578. * @return The decoded base64 data.
  107579. */
  107580. static DecodeBase64(uri: string): ArrayBuffer;
  107581. /**
  107582. * Gets the absolute url.
  107583. * @param url the input url
  107584. * @return the absolute url
  107585. */
  107586. static GetAbsoluteUrl(url: string): string;
  107587. /**
  107588. * No log
  107589. */
  107590. static readonly NoneLogLevel: number;
  107591. /**
  107592. * Only message logs
  107593. */
  107594. static readonly MessageLogLevel: number;
  107595. /**
  107596. * Only warning logs
  107597. */
  107598. static readonly WarningLogLevel: number;
  107599. /**
  107600. * Only error logs
  107601. */
  107602. static readonly ErrorLogLevel: number;
  107603. /**
  107604. * All logs
  107605. */
  107606. static readonly AllLogLevel: number;
  107607. /**
  107608. * Gets a value indicating the number of loading errors
  107609. * @ignorenaming
  107610. */
  107611. static get errorsCount(): number;
  107612. /**
  107613. * Callback called when a new log is added
  107614. */
  107615. static OnNewCacheEntry: (entry: string) => void;
  107616. /**
  107617. * Log a message to the console
  107618. * @param message defines the message to log
  107619. */
  107620. static Log(message: string): void;
  107621. /**
  107622. * Write a warning message to the console
  107623. * @param message defines the message to log
  107624. */
  107625. static Warn(message: string): void;
  107626. /**
  107627. * Write an error message to the console
  107628. * @param message defines the message to log
  107629. */
  107630. static Error(message: string): void;
  107631. /**
  107632. * Gets current log cache (list of logs)
  107633. */
  107634. static get LogCache(): string;
  107635. /**
  107636. * Clears the log cache
  107637. */
  107638. static ClearLogCache(): void;
  107639. /**
  107640. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107641. */
  107642. static set LogLevels(level: number);
  107643. /**
  107644. * Checks if the window object exists
  107645. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107646. */
  107647. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107648. /**
  107649. * No performance log
  107650. */
  107651. static readonly PerformanceNoneLogLevel: number;
  107652. /**
  107653. * Use user marks to log performance
  107654. */
  107655. static readonly PerformanceUserMarkLogLevel: number;
  107656. /**
  107657. * Log performance to the console
  107658. */
  107659. static readonly PerformanceConsoleLogLevel: number;
  107660. private static _performance;
  107661. /**
  107662. * Sets the current performance log level
  107663. */
  107664. static set PerformanceLogLevel(level: number);
  107665. private static _StartPerformanceCounterDisabled;
  107666. private static _EndPerformanceCounterDisabled;
  107667. private static _StartUserMark;
  107668. private static _EndUserMark;
  107669. private static _StartPerformanceConsole;
  107670. private static _EndPerformanceConsole;
  107671. /**
  107672. * Starts a performance counter
  107673. */
  107674. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107675. /**
  107676. * Ends a specific performance coutner
  107677. */
  107678. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107679. /**
  107680. * Gets either window.performance.now() if supported or Date.now() else
  107681. */
  107682. static get Now(): number;
  107683. /**
  107684. * This method will return the name of the class used to create the instance of the given object.
  107685. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107686. * @param object the object to get the class name from
  107687. * @param isType defines if the object is actually a type
  107688. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107689. */
  107690. static GetClassName(object: any, isType?: boolean): string;
  107691. /**
  107692. * Gets the first element of an array satisfying a given predicate
  107693. * @param array defines the array to browse
  107694. * @param predicate defines the predicate to use
  107695. * @returns null if not found or the element
  107696. */
  107697. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107698. /**
  107699. * This method will return the name of the full name of the class, including its owning module (if any).
  107700. * 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).
  107701. * @param object the object to get the class name from
  107702. * @param isType defines if the object is actually a type
  107703. * @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.
  107704. * @ignorenaming
  107705. */
  107706. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107707. /**
  107708. * Returns a promise that resolves after the given amount of time.
  107709. * @param delay Number of milliseconds to delay
  107710. * @returns Promise that resolves after the given amount of time
  107711. */
  107712. static DelayAsync(delay: number): Promise<void>;
  107713. /**
  107714. * Utility function to detect if the current user agent is Safari
  107715. * @returns whether or not the current user agent is safari
  107716. */
  107717. static IsSafari(): boolean;
  107718. }
  107719. /**
  107720. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107721. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107722. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107723. * @param name The name of the class, case should be preserved
  107724. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107725. */
  107726. export function className(name: string, module?: string): (target: Object) => void;
  107727. /**
  107728. * An implementation of a loop for asynchronous functions.
  107729. */
  107730. export class AsyncLoop {
  107731. /**
  107732. * Defines the number of iterations for the loop
  107733. */
  107734. iterations: number;
  107735. /**
  107736. * Defines the current index of the loop.
  107737. */
  107738. index: number;
  107739. private _done;
  107740. private _fn;
  107741. private _successCallback;
  107742. /**
  107743. * Constructor.
  107744. * @param iterations the number of iterations.
  107745. * @param func the function to run each iteration
  107746. * @param successCallback the callback that will be called upon succesful execution
  107747. * @param offset starting offset.
  107748. */
  107749. constructor(
  107750. /**
  107751. * Defines the number of iterations for the loop
  107752. */
  107753. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107754. /**
  107755. * Execute the next iteration. Must be called after the last iteration was finished.
  107756. */
  107757. executeNext(): void;
  107758. /**
  107759. * Break the loop and run the success callback.
  107760. */
  107761. breakLoop(): void;
  107762. /**
  107763. * Create and run an async loop.
  107764. * @param iterations the number of iterations.
  107765. * @param fn the function to run each iteration
  107766. * @param successCallback the callback that will be called upon succesful execution
  107767. * @param offset starting offset.
  107768. * @returns the created async loop object
  107769. */
  107770. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107771. /**
  107772. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107773. * @param iterations total number of iterations
  107774. * @param syncedIterations number of synchronous iterations in each async iteration.
  107775. * @param fn the function to call each iteration.
  107776. * @param callback a success call back that will be called when iterating stops.
  107777. * @param breakFunction a break condition (optional)
  107778. * @param timeout timeout settings for the setTimeout function. default - 0.
  107779. * @returns the created async loop object
  107780. */
  107781. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107782. }
  107783. }
  107784. declare module BABYLON {
  107785. /**
  107786. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107787. * The underlying implementation relies on an associative array to ensure the best performances.
  107788. * The value can be anything including 'null' but except 'undefined'
  107789. */
  107790. export class StringDictionary<T> {
  107791. /**
  107792. * This will clear this dictionary and copy the content from the 'source' one.
  107793. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107794. * @param source the dictionary to take the content from and copy to this dictionary
  107795. */
  107796. copyFrom(source: StringDictionary<T>): void;
  107797. /**
  107798. * Get a value based from its key
  107799. * @param key the given key to get the matching value from
  107800. * @return the value if found, otherwise undefined is returned
  107801. */
  107802. get(key: string): T | undefined;
  107803. /**
  107804. * Get a value from its key or add it if it doesn't exist.
  107805. * This method will ensure you that a given key/data will be present in the dictionary.
  107806. * @param key the given key to get the matching value from
  107807. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107808. * The factory will only be invoked if there's no data for the given key.
  107809. * @return the value corresponding to the key.
  107810. */
  107811. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107812. /**
  107813. * Get a value from its key if present in the dictionary otherwise add it
  107814. * @param key the key to get the value from
  107815. * @param val if there's no such key/value pair in the dictionary add it with this value
  107816. * @return the value corresponding to the key
  107817. */
  107818. getOrAdd(key: string, val: T): T;
  107819. /**
  107820. * Check if there's a given key in the dictionary
  107821. * @param key the key to check for
  107822. * @return true if the key is present, false otherwise
  107823. */
  107824. contains(key: string): boolean;
  107825. /**
  107826. * Add a new key and its corresponding value
  107827. * @param key the key to add
  107828. * @param value the value corresponding to the key
  107829. * @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
  107830. */
  107831. add(key: string, value: T): boolean;
  107832. /**
  107833. * Update a specific value associated to a key
  107834. * @param key defines the key to use
  107835. * @param value defines the value to store
  107836. * @returns true if the value was updated (or false if the key was not found)
  107837. */
  107838. set(key: string, value: T): boolean;
  107839. /**
  107840. * Get the element of the given key and remove it from the dictionary
  107841. * @param key defines the key to search
  107842. * @returns the value associated with the key or null if not found
  107843. */
  107844. getAndRemove(key: string): Nullable<T>;
  107845. /**
  107846. * Remove a key/value from the dictionary.
  107847. * @param key the key to remove
  107848. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107849. */
  107850. remove(key: string): boolean;
  107851. /**
  107852. * Clear the whole content of the dictionary
  107853. */
  107854. clear(): void;
  107855. /**
  107856. * Gets the current count
  107857. */
  107858. get count(): number;
  107859. /**
  107860. * Execute a callback on each key/val of the dictionary.
  107861. * Note that you can remove any element in this dictionary in the callback implementation
  107862. * @param callback the callback to execute on a given key/value pair
  107863. */
  107864. forEach(callback: (key: string, val: T) => void): void;
  107865. /**
  107866. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107867. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107868. * Note that you can remove any element in this dictionary in the callback implementation
  107869. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107870. * @returns the first item
  107871. */
  107872. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107873. private _count;
  107874. private _data;
  107875. }
  107876. }
  107877. declare module BABYLON {
  107878. /** @hidden */
  107879. export interface ICollisionCoordinator {
  107880. createCollider(): Collider;
  107881. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107882. init(scene: Scene): void;
  107883. }
  107884. /** @hidden */
  107885. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107886. private _scene;
  107887. private _scaledPosition;
  107888. private _scaledVelocity;
  107889. private _finalPosition;
  107890. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107891. createCollider(): Collider;
  107892. init(scene: Scene): void;
  107893. private _collideWithWorld;
  107894. }
  107895. }
  107896. declare module BABYLON {
  107897. /**
  107898. * Class used to manage all inputs for the scene.
  107899. */
  107900. export class InputManager {
  107901. /** The distance in pixel that you have to move to prevent some events */
  107902. static DragMovementThreshold: number;
  107903. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107904. static LongPressDelay: number;
  107905. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107906. static DoubleClickDelay: number;
  107907. /** If you need to check double click without raising a single click at first click, enable this flag */
  107908. static ExclusiveDoubleClickMode: boolean;
  107909. private _wheelEventName;
  107910. private _onPointerMove;
  107911. private _onPointerDown;
  107912. private _onPointerUp;
  107913. private _initClickEvent;
  107914. private _initActionManager;
  107915. private _delayedSimpleClick;
  107916. private _delayedSimpleClickTimeout;
  107917. private _previousDelayedSimpleClickTimeout;
  107918. private _meshPickProceed;
  107919. private _previousButtonPressed;
  107920. private _currentPickResult;
  107921. private _previousPickResult;
  107922. private _totalPointersPressed;
  107923. private _doubleClickOccured;
  107924. private _pointerOverMesh;
  107925. private _pickedDownMesh;
  107926. private _pickedUpMesh;
  107927. private _pointerX;
  107928. private _pointerY;
  107929. private _unTranslatedPointerX;
  107930. private _unTranslatedPointerY;
  107931. private _startingPointerPosition;
  107932. private _previousStartingPointerPosition;
  107933. private _startingPointerTime;
  107934. private _previousStartingPointerTime;
  107935. private _pointerCaptures;
  107936. private _onKeyDown;
  107937. private _onKeyUp;
  107938. private _onCanvasFocusObserver;
  107939. private _onCanvasBlurObserver;
  107940. private _scene;
  107941. /**
  107942. * Creates a new InputManager
  107943. * @param scene defines the hosting scene
  107944. */
  107945. constructor(scene: Scene);
  107946. /**
  107947. * Gets the mesh that is currently under the pointer
  107948. */
  107949. get meshUnderPointer(): Nullable<AbstractMesh>;
  107950. /**
  107951. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107952. */
  107953. get unTranslatedPointer(): Vector2;
  107954. /**
  107955. * Gets or sets the current on-screen X position of the pointer
  107956. */
  107957. get pointerX(): number;
  107958. set pointerX(value: number);
  107959. /**
  107960. * Gets or sets the current on-screen Y position of the pointer
  107961. */
  107962. get pointerY(): number;
  107963. set pointerY(value: number);
  107964. private _updatePointerPosition;
  107965. private _processPointerMove;
  107966. private _setRayOnPointerInfo;
  107967. private _checkPrePointerObservable;
  107968. /**
  107969. * Use this method to simulate a pointer move on a mesh
  107970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107973. */
  107974. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107975. /**
  107976. * Use this method to simulate a pointer down on a mesh
  107977. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107978. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107979. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107980. */
  107981. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107982. private _processPointerDown;
  107983. /** @hidden */
  107984. _isPointerSwiping(): boolean;
  107985. /**
  107986. * Use this method to simulate a pointer up on a mesh
  107987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107990. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107991. */
  107992. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107993. private _processPointerUp;
  107994. /**
  107995. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107996. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107997. * @returns true if the pointer was captured
  107998. */
  107999. isPointerCaptured(pointerId?: number): boolean;
  108000. /**
  108001. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108002. * @param attachUp defines if you want to attach events to pointerup
  108003. * @param attachDown defines if you want to attach events to pointerdown
  108004. * @param attachMove defines if you want to attach events to pointermove
  108005. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108006. */
  108007. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108008. /**
  108009. * Detaches all event handlers
  108010. */
  108011. detachControl(): void;
  108012. /**
  108013. * Force the value of meshUnderPointer
  108014. * @param mesh defines the mesh to use
  108015. */
  108016. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108017. /**
  108018. * Gets the mesh under the pointer
  108019. * @returns a Mesh or null if no mesh is under the pointer
  108020. */
  108021. getPointerOverMesh(): Nullable<AbstractMesh>;
  108022. }
  108023. }
  108024. declare module BABYLON {
  108025. /**
  108026. * Helper class used to generate session unique ID
  108027. */
  108028. export class UniqueIdGenerator {
  108029. private static _UniqueIdCounter;
  108030. /**
  108031. * Gets an unique (relatively to the current scene) Id
  108032. */
  108033. static get UniqueId(): number;
  108034. }
  108035. }
  108036. declare module BABYLON {
  108037. /**
  108038. * This class defines the direct association between an animation and a target
  108039. */
  108040. export class TargetedAnimation {
  108041. /**
  108042. * Animation to perform
  108043. */
  108044. animation: Animation;
  108045. /**
  108046. * Target to animate
  108047. */
  108048. target: any;
  108049. /**
  108050. * Serialize the object
  108051. * @returns the JSON object representing the current entity
  108052. */
  108053. serialize(): any;
  108054. }
  108055. /**
  108056. * Use this class to create coordinated animations on multiple targets
  108057. */
  108058. export class AnimationGroup implements IDisposable {
  108059. /** The name of the animation group */
  108060. name: string;
  108061. private _scene;
  108062. private _targetedAnimations;
  108063. private _animatables;
  108064. private _from;
  108065. private _to;
  108066. private _isStarted;
  108067. private _isPaused;
  108068. private _speedRatio;
  108069. private _loopAnimation;
  108070. /**
  108071. * Gets or sets the unique id of the node
  108072. */
  108073. uniqueId: number;
  108074. /**
  108075. * This observable will notify when one animation have ended
  108076. */
  108077. onAnimationEndObservable: Observable<TargetedAnimation>;
  108078. /**
  108079. * Observer raised when one animation loops
  108080. */
  108081. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108082. /**
  108083. * Observer raised when all animations have looped
  108084. */
  108085. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108086. /**
  108087. * This observable will notify when all animations have ended.
  108088. */
  108089. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108090. /**
  108091. * This observable will notify when all animations have paused.
  108092. */
  108093. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108094. /**
  108095. * This observable will notify when all animations are playing.
  108096. */
  108097. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108098. /**
  108099. * Gets the first frame
  108100. */
  108101. get from(): number;
  108102. /**
  108103. * Gets the last frame
  108104. */
  108105. get to(): number;
  108106. /**
  108107. * Define if the animations are started
  108108. */
  108109. get isStarted(): boolean;
  108110. /**
  108111. * Gets a value indicating that the current group is playing
  108112. */
  108113. get isPlaying(): boolean;
  108114. /**
  108115. * Gets or sets the speed ratio to use for all animations
  108116. */
  108117. get speedRatio(): number;
  108118. /**
  108119. * Gets or sets the speed ratio to use for all animations
  108120. */
  108121. set speedRatio(value: number);
  108122. /**
  108123. * Gets or sets if all animations should loop or not
  108124. */
  108125. get loopAnimation(): boolean;
  108126. set loopAnimation(value: boolean);
  108127. /**
  108128. * Gets the targeted animations for this animation group
  108129. */
  108130. get targetedAnimations(): Array<TargetedAnimation>;
  108131. /**
  108132. * returning the list of animatables controlled by this animation group.
  108133. */
  108134. get animatables(): Array<Animatable>;
  108135. /**
  108136. * Instantiates a new Animation Group.
  108137. * This helps managing several animations at once.
  108138. * @see http://doc.babylonjs.com/how_to/group
  108139. * @param name Defines the name of the group
  108140. * @param scene Defines the scene the group belongs to
  108141. */
  108142. constructor(
  108143. /** The name of the animation group */
  108144. name: string, scene?: Nullable<Scene>);
  108145. /**
  108146. * Add an animation (with its target) in the group
  108147. * @param animation defines the animation we want to add
  108148. * @param target defines the target of the animation
  108149. * @returns the TargetedAnimation object
  108150. */
  108151. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108152. /**
  108153. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108154. * It can add constant keys at begin or end
  108155. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108156. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108157. * @returns the animation group
  108158. */
  108159. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108160. private _animationLoopCount;
  108161. private _animationLoopFlags;
  108162. private _processLoop;
  108163. /**
  108164. * Start all animations on given targets
  108165. * @param loop defines if animations must loop
  108166. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108167. * @param from defines the from key (optional)
  108168. * @param to defines the to key (optional)
  108169. * @returns the current animation group
  108170. */
  108171. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108172. /**
  108173. * Pause all animations
  108174. * @returns the animation group
  108175. */
  108176. pause(): AnimationGroup;
  108177. /**
  108178. * Play all animations to initial state
  108179. * This function will start() the animations if they were not started or will restart() them if they were paused
  108180. * @param loop defines if animations must loop
  108181. * @returns the animation group
  108182. */
  108183. play(loop?: boolean): AnimationGroup;
  108184. /**
  108185. * Reset all animations to initial state
  108186. * @returns the animation group
  108187. */
  108188. reset(): AnimationGroup;
  108189. /**
  108190. * Restart animations from key 0
  108191. * @returns the animation group
  108192. */
  108193. restart(): AnimationGroup;
  108194. /**
  108195. * Stop all animations
  108196. * @returns the animation group
  108197. */
  108198. stop(): AnimationGroup;
  108199. /**
  108200. * Set animation weight for all animatables
  108201. * @param weight defines the weight to use
  108202. * @return the animationGroup
  108203. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108204. */
  108205. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108206. /**
  108207. * Synchronize and normalize all animatables with a source animatable
  108208. * @param root defines the root animatable to synchronize with
  108209. * @return the animationGroup
  108210. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108211. */
  108212. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108213. /**
  108214. * Goes to a specific frame in this animation group
  108215. * @param frame the frame number to go to
  108216. * @return the animationGroup
  108217. */
  108218. goToFrame(frame: number): AnimationGroup;
  108219. /**
  108220. * Dispose all associated resources
  108221. */
  108222. dispose(): void;
  108223. private _checkAnimationGroupEnded;
  108224. /**
  108225. * Clone the current animation group and returns a copy
  108226. * @param newName defines the name of the new group
  108227. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108228. * @returns the new aniamtion group
  108229. */
  108230. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108231. /**
  108232. * Serializes the animationGroup to an object
  108233. * @returns Serialized object
  108234. */
  108235. serialize(): any;
  108236. /**
  108237. * Returns a new AnimationGroup object parsed from the source provided.
  108238. * @param parsedAnimationGroup defines the source
  108239. * @param scene defines the scene that will receive the animationGroup
  108240. * @returns a new AnimationGroup
  108241. */
  108242. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108243. /**
  108244. * Returns the string "AnimationGroup"
  108245. * @returns "AnimationGroup"
  108246. */
  108247. getClassName(): string;
  108248. /**
  108249. * Creates a detailled string about the object
  108250. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108251. * @returns a string representing the object
  108252. */
  108253. toString(fullDetails?: boolean): string;
  108254. }
  108255. }
  108256. declare module BABYLON {
  108257. /**
  108258. * Define an interface for all classes that will hold resources
  108259. */
  108260. export interface IDisposable {
  108261. /**
  108262. * Releases all held resources
  108263. */
  108264. dispose(): void;
  108265. }
  108266. /** Interface defining initialization parameters for Scene class */
  108267. export interface SceneOptions {
  108268. /**
  108269. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108270. * It will improve performance when the number of geometries becomes important.
  108271. */
  108272. useGeometryUniqueIdsMap?: boolean;
  108273. /**
  108274. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108275. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108276. */
  108277. useMaterialMeshMap?: boolean;
  108278. /**
  108279. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108280. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108281. */
  108282. useClonedMeshMap?: boolean;
  108283. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108284. virtual?: boolean;
  108285. }
  108286. /**
  108287. * Represents a scene to be rendered by the engine.
  108288. * @see http://doc.babylonjs.com/features/scene
  108289. */
  108290. export class Scene extends AbstractScene implements IAnimatable {
  108291. /** The fog is deactivated */
  108292. static readonly FOGMODE_NONE: number;
  108293. /** The fog density is following an exponential function */
  108294. static readonly FOGMODE_EXP: number;
  108295. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108296. static readonly FOGMODE_EXP2: number;
  108297. /** The fog density is following a linear function. */
  108298. static readonly FOGMODE_LINEAR: number;
  108299. /**
  108300. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108301. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108302. */
  108303. static MinDeltaTime: number;
  108304. /**
  108305. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108306. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108307. */
  108308. static MaxDeltaTime: number;
  108309. /**
  108310. * Factory used to create the default material.
  108311. * @param name The name of the material to create
  108312. * @param scene The scene to create the material for
  108313. * @returns The default material
  108314. */
  108315. static DefaultMaterialFactory(scene: Scene): Material;
  108316. /**
  108317. * Factory used to create the a collision coordinator.
  108318. * @returns The collision coordinator
  108319. */
  108320. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108321. /** @hidden */
  108322. _inputManager: InputManager;
  108323. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108324. cameraToUseForPointers: Nullable<Camera>;
  108325. /** @hidden */
  108326. readonly _isScene: boolean;
  108327. /**
  108328. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108329. */
  108330. autoClear: boolean;
  108331. /**
  108332. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108333. */
  108334. autoClearDepthAndStencil: boolean;
  108335. /**
  108336. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108337. */
  108338. clearColor: Color4;
  108339. /**
  108340. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108341. */
  108342. ambientColor: Color3;
  108343. /**
  108344. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108345. * It should only be one of the following (if not the default embedded one):
  108346. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108347. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108348. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108349. * The material properties need to be setup according to the type of texture in use.
  108350. */
  108351. environmentBRDFTexture: BaseTexture;
  108352. /** @hidden */
  108353. protected _environmentTexture: Nullable<BaseTexture>;
  108354. /**
  108355. * Texture used in all pbr material as the reflection texture.
  108356. * As in the majority of the scene they are the same (exception for multi room and so on),
  108357. * this is easier to reference from here than from all the materials.
  108358. */
  108359. get environmentTexture(): Nullable<BaseTexture>;
  108360. /**
  108361. * Texture used in all pbr material as the reflection texture.
  108362. * As in the majority of the scene they are the same (exception for multi room and so on),
  108363. * this is easier to set here than in all the materials.
  108364. */
  108365. set environmentTexture(value: Nullable<BaseTexture>);
  108366. /** @hidden */
  108367. protected _environmentIntensity: number;
  108368. /**
  108369. * Intensity of the environment in all pbr material.
  108370. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108371. * As in the majority of the scene they are the same (exception for multi room and so on),
  108372. * this is easier to reference from here than from all the materials.
  108373. */
  108374. get environmentIntensity(): number;
  108375. /**
  108376. * Intensity of the environment in all pbr material.
  108377. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108378. * As in the majority of the scene they are the same (exception for multi room and so on),
  108379. * this is easier to set here than in all the materials.
  108380. */
  108381. set environmentIntensity(value: number);
  108382. /** @hidden */
  108383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108384. /**
  108385. * Default image processing configuration used either in the rendering
  108386. * Forward main pass or through the imageProcessingPostProcess if present.
  108387. * As in the majority of the scene they are the same (exception for multi camera),
  108388. * this is easier to reference from here than from all the materials and post process.
  108389. *
  108390. * No setter as we it is a shared configuration, you can set the values instead.
  108391. */
  108392. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108393. private _forceWireframe;
  108394. /**
  108395. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108396. */
  108397. set forceWireframe(value: boolean);
  108398. get forceWireframe(): boolean;
  108399. private _skipFrustumClipping;
  108400. /**
  108401. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108402. */
  108403. set skipFrustumClipping(value: boolean);
  108404. get skipFrustumClipping(): boolean;
  108405. private _forcePointsCloud;
  108406. /**
  108407. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108408. */
  108409. set forcePointsCloud(value: boolean);
  108410. get forcePointsCloud(): boolean;
  108411. /**
  108412. * Gets or sets the active clipplane 1
  108413. */
  108414. clipPlane: Nullable<Plane>;
  108415. /**
  108416. * Gets or sets the active clipplane 2
  108417. */
  108418. clipPlane2: Nullable<Plane>;
  108419. /**
  108420. * Gets or sets the active clipplane 3
  108421. */
  108422. clipPlane3: Nullable<Plane>;
  108423. /**
  108424. * Gets or sets the active clipplane 4
  108425. */
  108426. clipPlane4: Nullable<Plane>;
  108427. /**
  108428. * Gets or sets the active clipplane 5
  108429. */
  108430. clipPlane5: Nullable<Plane>;
  108431. /**
  108432. * Gets or sets the active clipplane 6
  108433. */
  108434. clipPlane6: Nullable<Plane>;
  108435. /**
  108436. * Gets or sets a boolean indicating if animations are enabled
  108437. */
  108438. animationsEnabled: boolean;
  108439. private _animationPropertiesOverride;
  108440. /**
  108441. * Gets or sets the animation properties override
  108442. */
  108443. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108444. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108445. /**
  108446. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108447. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108448. */
  108449. useConstantAnimationDeltaTime: boolean;
  108450. /**
  108451. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108452. * Please note that it requires to run a ray cast through the scene on every frame
  108453. */
  108454. constantlyUpdateMeshUnderPointer: boolean;
  108455. /**
  108456. * Defines the HTML cursor to use when hovering over interactive elements
  108457. */
  108458. hoverCursor: string;
  108459. /**
  108460. * Defines the HTML default cursor to use (empty by default)
  108461. */
  108462. defaultCursor: string;
  108463. /**
  108464. * Defines whether cursors are handled by the scene.
  108465. */
  108466. doNotHandleCursors: boolean;
  108467. /**
  108468. * This is used to call preventDefault() on pointer down
  108469. * in order to block unwanted artifacts like system double clicks
  108470. */
  108471. preventDefaultOnPointerDown: boolean;
  108472. /**
  108473. * This is used to call preventDefault() on pointer up
  108474. * in order to block unwanted artifacts like system double clicks
  108475. */
  108476. preventDefaultOnPointerUp: boolean;
  108477. /**
  108478. * Gets or sets user defined metadata
  108479. */
  108480. metadata: any;
  108481. /**
  108482. * For internal use only. Please do not use.
  108483. */
  108484. reservedDataStore: any;
  108485. /**
  108486. * Gets the name of the plugin used to load this scene (null by default)
  108487. */
  108488. loadingPluginName: string;
  108489. /**
  108490. * Use this array to add regular expressions used to disable offline support for specific urls
  108491. */
  108492. disableOfflineSupportExceptionRules: RegExp[];
  108493. /**
  108494. * An event triggered when the scene is disposed.
  108495. */
  108496. onDisposeObservable: Observable<Scene>;
  108497. private _onDisposeObserver;
  108498. /** Sets a function to be executed when this scene is disposed. */
  108499. set onDispose(callback: () => void);
  108500. /**
  108501. * An event triggered before rendering the scene (right after animations and physics)
  108502. */
  108503. onBeforeRenderObservable: Observable<Scene>;
  108504. private _onBeforeRenderObserver;
  108505. /** Sets a function to be executed before rendering this scene */
  108506. set beforeRender(callback: Nullable<() => void>);
  108507. /**
  108508. * An event triggered after rendering the scene
  108509. */
  108510. onAfterRenderObservable: Observable<Scene>;
  108511. /**
  108512. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108513. */
  108514. onAfterRenderCameraObservable: Observable<Camera>;
  108515. private _onAfterRenderObserver;
  108516. /** Sets a function to be executed after rendering this scene */
  108517. set afterRender(callback: Nullable<() => void>);
  108518. /**
  108519. * An event triggered before animating the scene
  108520. */
  108521. onBeforeAnimationsObservable: Observable<Scene>;
  108522. /**
  108523. * An event triggered after animations processing
  108524. */
  108525. onAfterAnimationsObservable: Observable<Scene>;
  108526. /**
  108527. * An event triggered before draw calls are ready to be sent
  108528. */
  108529. onBeforeDrawPhaseObservable: Observable<Scene>;
  108530. /**
  108531. * An event triggered after draw calls have been sent
  108532. */
  108533. onAfterDrawPhaseObservable: Observable<Scene>;
  108534. /**
  108535. * An event triggered when the scene is ready
  108536. */
  108537. onReadyObservable: Observable<Scene>;
  108538. /**
  108539. * An event triggered before rendering a camera
  108540. */
  108541. onBeforeCameraRenderObservable: Observable<Camera>;
  108542. private _onBeforeCameraRenderObserver;
  108543. /** Sets a function to be executed before rendering a camera*/
  108544. set beforeCameraRender(callback: () => void);
  108545. /**
  108546. * An event triggered after rendering a camera
  108547. */
  108548. onAfterCameraRenderObservable: Observable<Camera>;
  108549. private _onAfterCameraRenderObserver;
  108550. /** Sets a function to be executed after rendering a camera*/
  108551. set afterCameraRender(callback: () => void);
  108552. /**
  108553. * An event triggered when active meshes evaluation is about to start
  108554. */
  108555. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108556. /**
  108557. * An event triggered when active meshes evaluation is done
  108558. */
  108559. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108560. /**
  108561. * An event triggered when particles rendering is about to start
  108562. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108563. */
  108564. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108565. /**
  108566. * An event triggered when particles rendering is done
  108567. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108568. */
  108569. onAfterParticlesRenderingObservable: Observable<Scene>;
  108570. /**
  108571. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108572. */
  108573. onDataLoadedObservable: Observable<Scene>;
  108574. /**
  108575. * An event triggered when a camera is created
  108576. */
  108577. onNewCameraAddedObservable: Observable<Camera>;
  108578. /**
  108579. * An event triggered when a camera is removed
  108580. */
  108581. onCameraRemovedObservable: Observable<Camera>;
  108582. /**
  108583. * An event triggered when a light is created
  108584. */
  108585. onNewLightAddedObservable: Observable<Light>;
  108586. /**
  108587. * An event triggered when a light is removed
  108588. */
  108589. onLightRemovedObservable: Observable<Light>;
  108590. /**
  108591. * An event triggered when a geometry is created
  108592. */
  108593. onNewGeometryAddedObservable: Observable<Geometry>;
  108594. /**
  108595. * An event triggered when a geometry is removed
  108596. */
  108597. onGeometryRemovedObservable: Observable<Geometry>;
  108598. /**
  108599. * An event triggered when a transform node is created
  108600. */
  108601. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108602. /**
  108603. * An event triggered when a transform node is removed
  108604. */
  108605. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108606. /**
  108607. * An event triggered when a mesh is created
  108608. */
  108609. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108610. /**
  108611. * An event triggered when a mesh is removed
  108612. */
  108613. onMeshRemovedObservable: Observable<AbstractMesh>;
  108614. /**
  108615. * An event triggered when a skeleton is created
  108616. */
  108617. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108618. /**
  108619. * An event triggered when a skeleton is removed
  108620. */
  108621. onSkeletonRemovedObservable: Observable<Skeleton>;
  108622. /**
  108623. * An event triggered when a material is created
  108624. */
  108625. onNewMaterialAddedObservable: Observable<Material>;
  108626. /**
  108627. * An event triggered when a material is removed
  108628. */
  108629. onMaterialRemovedObservable: Observable<Material>;
  108630. /**
  108631. * An event triggered when a texture is created
  108632. */
  108633. onNewTextureAddedObservable: Observable<BaseTexture>;
  108634. /**
  108635. * An event triggered when a texture is removed
  108636. */
  108637. onTextureRemovedObservable: Observable<BaseTexture>;
  108638. /**
  108639. * An event triggered when render targets are about to be rendered
  108640. * Can happen multiple times per frame.
  108641. */
  108642. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108643. /**
  108644. * An event triggered when render targets were rendered.
  108645. * Can happen multiple times per frame.
  108646. */
  108647. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108648. /**
  108649. * An event triggered before calculating deterministic simulation step
  108650. */
  108651. onBeforeStepObservable: Observable<Scene>;
  108652. /**
  108653. * An event triggered after calculating deterministic simulation step
  108654. */
  108655. onAfterStepObservable: Observable<Scene>;
  108656. /**
  108657. * An event triggered when the activeCamera property is updated
  108658. */
  108659. onActiveCameraChanged: Observable<Scene>;
  108660. /**
  108661. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108662. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108663. * 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)
  108664. */
  108665. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108666. /**
  108667. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108668. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108669. * 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)
  108670. */
  108671. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108672. /**
  108673. * This Observable will when a mesh has been imported into the scene.
  108674. */
  108675. onMeshImportedObservable: Observable<AbstractMesh>;
  108676. /**
  108677. * This Observable will when an animation file has been imported into the scene.
  108678. */
  108679. onAnimationFileImportedObservable: Observable<Scene>;
  108680. /**
  108681. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108682. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108683. */
  108684. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108685. /** @hidden */
  108686. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108687. /**
  108688. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108689. */
  108690. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108691. /**
  108692. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108693. */
  108694. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108695. /**
  108696. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108697. */
  108698. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108699. /** Callback called when a pointer move is detected */
  108700. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108701. /** Callback called when a pointer down is detected */
  108702. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108703. /** Callback called when a pointer up is detected */
  108704. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108705. /** Callback called when a pointer pick is detected */
  108706. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108707. /**
  108708. * 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).
  108709. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108710. */
  108711. onPrePointerObservable: Observable<PointerInfoPre>;
  108712. /**
  108713. * Observable event triggered each time an input event is received from the rendering canvas
  108714. */
  108715. onPointerObservable: Observable<PointerInfo>;
  108716. /**
  108717. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108718. */
  108719. get unTranslatedPointer(): Vector2;
  108720. /**
  108721. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108722. */
  108723. static get DragMovementThreshold(): number;
  108724. static set DragMovementThreshold(value: number);
  108725. /**
  108726. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108727. */
  108728. static get LongPressDelay(): number;
  108729. static set LongPressDelay(value: number);
  108730. /**
  108731. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108732. */
  108733. static get DoubleClickDelay(): number;
  108734. static set DoubleClickDelay(value: number);
  108735. /** If you need to check double click without raising a single click at first click, enable this flag */
  108736. static get ExclusiveDoubleClickMode(): boolean;
  108737. static set ExclusiveDoubleClickMode(value: boolean);
  108738. /** @hidden */
  108739. _mirroredCameraPosition: Nullable<Vector3>;
  108740. /**
  108741. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108742. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108743. */
  108744. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108745. /**
  108746. * Observable event triggered each time an keyboard event is received from the hosting window
  108747. */
  108748. onKeyboardObservable: Observable<KeyboardInfo>;
  108749. private _useRightHandedSystem;
  108750. /**
  108751. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108752. */
  108753. set useRightHandedSystem(value: boolean);
  108754. get useRightHandedSystem(): boolean;
  108755. private _timeAccumulator;
  108756. private _currentStepId;
  108757. private _currentInternalStep;
  108758. /**
  108759. * Sets the step Id used by deterministic lock step
  108760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108761. * @param newStepId defines the step Id
  108762. */
  108763. setStepId(newStepId: number): void;
  108764. /**
  108765. * Gets the step Id used by deterministic lock step
  108766. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108767. * @returns the step Id
  108768. */
  108769. getStepId(): number;
  108770. /**
  108771. * Gets the internal step used by deterministic lock step
  108772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108773. * @returns the internal step
  108774. */
  108775. getInternalStep(): number;
  108776. private _fogEnabled;
  108777. /**
  108778. * Gets or sets a boolean indicating if fog is enabled on this scene
  108779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108780. * (Default is true)
  108781. */
  108782. set fogEnabled(value: boolean);
  108783. get fogEnabled(): boolean;
  108784. private _fogMode;
  108785. /**
  108786. * Gets or sets the fog mode to use
  108787. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108788. * | mode | value |
  108789. * | --- | --- |
  108790. * | FOGMODE_NONE | 0 |
  108791. * | FOGMODE_EXP | 1 |
  108792. * | FOGMODE_EXP2 | 2 |
  108793. * | FOGMODE_LINEAR | 3 |
  108794. */
  108795. set fogMode(value: number);
  108796. get fogMode(): number;
  108797. /**
  108798. * Gets or sets the fog color to use
  108799. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108800. * (Default is Color3(0.2, 0.2, 0.3))
  108801. */
  108802. fogColor: Color3;
  108803. /**
  108804. * Gets or sets the fog density to use
  108805. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108806. * (Default is 0.1)
  108807. */
  108808. fogDensity: number;
  108809. /**
  108810. * Gets or sets the fog start distance to use
  108811. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108812. * (Default is 0)
  108813. */
  108814. fogStart: number;
  108815. /**
  108816. * Gets or sets the fog end distance to use
  108817. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108818. * (Default is 1000)
  108819. */
  108820. fogEnd: number;
  108821. private _shadowsEnabled;
  108822. /**
  108823. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108824. */
  108825. set shadowsEnabled(value: boolean);
  108826. get shadowsEnabled(): boolean;
  108827. private _lightsEnabled;
  108828. /**
  108829. * Gets or sets a boolean indicating if lights are enabled on this scene
  108830. */
  108831. set lightsEnabled(value: boolean);
  108832. get lightsEnabled(): boolean;
  108833. /** All of the active cameras added to this scene. */
  108834. activeCameras: Camera[];
  108835. /** @hidden */
  108836. _activeCamera: Nullable<Camera>;
  108837. /** Gets or sets the current active camera */
  108838. get activeCamera(): Nullable<Camera>;
  108839. set activeCamera(value: Nullable<Camera>);
  108840. private _defaultMaterial;
  108841. /** The default material used on meshes when no material is affected */
  108842. get defaultMaterial(): Material;
  108843. /** The default material used on meshes when no material is affected */
  108844. set defaultMaterial(value: Material);
  108845. private _texturesEnabled;
  108846. /**
  108847. * Gets or sets a boolean indicating if textures are enabled on this scene
  108848. */
  108849. set texturesEnabled(value: boolean);
  108850. get texturesEnabled(): boolean;
  108851. /**
  108852. * Gets or sets a boolean indicating if particles are enabled on this scene
  108853. */
  108854. particlesEnabled: boolean;
  108855. /**
  108856. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108857. */
  108858. spritesEnabled: boolean;
  108859. private _skeletonsEnabled;
  108860. /**
  108861. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108862. */
  108863. set skeletonsEnabled(value: boolean);
  108864. get skeletonsEnabled(): boolean;
  108865. /**
  108866. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108867. */
  108868. lensFlaresEnabled: boolean;
  108869. /**
  108870. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108872. */
  108873. collisionsEnabled: boolean;
  108874. private _collisionCoordinator;
  108875. /** @hidden */
  108876. get collisionCoordinator(): ICollisionCoordinator;
  108877. /**
  108878. * Defines the gravity applied to this scene (used only for collisions)
  108879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108880. */
  108881. gravity: Vector3;
  108882. /**
  108883. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108884. */
  108885. postProcessesEnabled: boolean;
  108886. /**
  108887. * The list of postprocesses added to the scene
  108888. */
  108889. postProcesses: PostProcess[];
  108890. /**
  108891. * Gets the current postprocess manager
  108892. */
  108893. postProcessManager: PostProcessManager;
  108894. /**
  108895. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108896. */
  108897. renderTargetsEnabled: boolean;
  108898. /**
  108899. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108900. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108901. */
  108902. dumpNextRenderTargets: boolean;
  108903. /**
  108904. * The list of user defined render targets added to the scene
  108905. */
  108906. customRenderTargets: RenderTargetTexture[];
  108907. /**
  108908. * Defines if texture loading must be delayed
  108909. * If true, textures will only be loaded when they need to be rendered
  108910. */
  108911. useDelayedTextureLoading: boolean;
  108912. /**
  108913. * Gets the list of meshes imported to the scene through SceneLoader
  108914. */
  108915. importedMeshesFiles: String[];
  108916. /**
  108917. * Gets or sets a boolean indicating if probes are enabled on this scene
  108918. */
  108919. probesEnabled: boolean;
  108920. /**
  108921. * Gets or sets the current offline provider to use to store scene data
  108922. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108923. */
  108924. offlineProvider: IOfflineProvider;
  108925. /**
  108926. * Gets or sets the action manager associated with the scene
  108927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108928. */
  108929. actionManager: AbstractActionManager;
  108930. private _meshesForIntersections;
  108931. /**
  108932. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108933. */
  108934. proceduralTexturesEnabled: boolean;
  108935. private _engine;
  108936. private _totalVertices;
  108937. /** @hidden */
  108938. _activeIndices: PerfCounter;
  108939. /** @hidden */
  108940. _activeParticles: PerfCounter;
  108941. /** @hidden */
  108942. _activeBones: PerfCounter;
  108943. private _animationRatio;
  108944. /** @hidden */
  108945. _animationTimeLast: number;
  108946. /** @hidden */
  108947. _animationTime: number;
  108948. /**
  108949. * Gets or sets a general scale for animation speed
  108950. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108951. */
  108952. animationTimeScale: number;
  108953. /** @hidden */
  108954. _cachedMaterial: Nullable<Material>;
  108955. /** @hidden */
  108956. _cachedEffect: Nullable<Effect>;
  108957. /** @hidden */
  108958. _cachedVisibility: Nullable<number>;
  108959. private _renderId;
  108960. private _frameId;
  108961. private _executeWhenReadyTimeoutId;
  108962. private _intermediateRendering;
  108963. private _viewUpdateFlag;
  108964. private _projectionUpdateFlag;
  108965. /** @hidden */
  108966. _toBeDisposed: Nullable<IDisposable>[];
  108967. private _activeRequests;
  108968. /** @hidden */
  108969. _pendingData: any[];
  108970. private _isDisposed;
  108971. /**
  108972. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108973. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108974. */
  108975. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108976. private _activeMeshes;
  108977. private _processedMaterials;
  108978. private _renderTargets;
  108979. /** @hidden */
  108980. _activeParticleSystems: SmartArray<IParticleSystem>;
  108981. private _activeSkeletons;
  108982. private _softwareSkinnedMeshes;
  108983. private _renderingManager;
  108984. /** @hidden */
  108985. _activeAnimatables: Animatable[];
  108986. private _transformMatrix;
  108987. private _sceneUbo;
  108988. /** @hidden */
  108989. _viewMatrix: Matrix;
  108990. private _projectionMatrix;
  108991. /** @hidden */
  108992. _forcedViewPosition: Nullable<Vector3>;
  108993. /** @hidden */
  108994. _frustumPlanes: Plane[];
  108995. /**
  108996. * Gets the list of frustum planes (built from the active camera)
  108997. */
  108998. get frustumPlanes(): Plane[];
  108999. /**
  109000. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109001. * This is useful if there are more lights that the maximum simulteanous authorized
  109002. */
  109003. requireLightSorting: boolean;
  109004. /** @hidden */
  109005. readonly useMaterialMeshMap: boolean;
  109006. /** @hidden */
  109007. readonly useClonedMeshMap: boolean;
  109008. private _externalData;
  109009. private _uid;
  109010. /**
  109011. * @hidden
  109012. * Backing store of defined scene components.
  109013. */
  109014. _components: ISceneComponent[];
  109015. /**
  109016. * @hidden
  109017. * Backing store of defined scene components.
  109018. */
  109019. _serializableComponents: ISceneSerializableComponent[];
  109020. /**
  109021. * List of components to register on the next registration step.
  109022. */
  109023. private _transientComponents;
  109024. /**
  109025. * Registers the transient components if needed.
  109026. */
  109027. private _registerTransientComponents;
  109028. /**
  109029. * @hidden
  109030. * Add a component to the scene.
  109031. * Note that the ccomponent could be registered on th next frame if this is called after
  109032. * the register component stage.
  109033. * @param component Defines the component to add to the scene
  109034. */
  109035. _addComponent(component: ISceneComponent): void;
  109036. /**
  109037. * @hidden
  109038. * Gets a component from the scene.
  109039. * @param name defines the name of the component to retrieve
  109040. * @returns the component or null if not present
  109041. */
  109042. _getComponent(name: string): Nullable<ISceneComponent>;
  109043. /**
  109044. * @hidden
  109045. * Defines the actions happening before camera updates.
  109046. */
  109047. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109048. /**
  109049. * @hidden
  109050. * Defines the actions happening before clear the canvas.
  109051. */
  109052. _beforeClearStage: Stage<SimpleStageAction>;
  109053. /**
  109054. * @hidden
  109055. * Defines the actions when collecting render targets for the frame.
  109056. */
  109057. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109058. /**
  109059. * @hidden
  109060. * Defines the actions happening for one camera in the frame.
  109061. */
  109062. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109063. /**
  109064. * @hidden
  109065. * Defines the actions happening during the per mesh ready checks.
  109066. */
  109067. _isReadyForMeshStage: Stage<MeshStageAction>;
  109068. /**
  109069. * @hidden
  109070. * Defines the actions happening before evaluate active mesh checks.
  109071. */
  109072. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109073. /**
  109074. * @hidden
  109075. * Defines the actions happening during the evaluate sub mesh checks.
  109076. */
  109077. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109078. /**
  109079. * @hidden
  109080. * Defines the actions happening during the active mesh stage.
  109081. */
  109082. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109083. /**
  109084. * @hidden
  109085. * Defines the actions happening during the per camera render target step.
  109086. */
  109087. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109088. /**
  109089. * @hidden
  109090. * Defines the actions happening just before the active camera is drawing.
  109091. */
  109092. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109093. /**
  109094. * @hidden
  109095. * Defines the actions happening just before a render target is drawing.
  109096. */
  109097. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109098. /**
  109099. * @hidden
  109100. * Defines the actions happening just before a rendering group is drawing.
  109101. */
  109102. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109103. /**
  109104. * @hidden
  109105. * Defines the actions happening just before a mesh is drawing.
  109106. */
  109107. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109108. /**
  109109. * @hidden
  109110. * Defines the actions happening just after a mesh has been drawn.
  109111. */
  109112. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109113. /**
  109114. * @hidden
  109115. * Defines the actions happening just after a rendering group has been drawn.
  109116. */
  109117. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109118. /**
  109119. * @hidden
  109120. * Defines the actions happening just after the active camera has been drawn.
  109121. */
  109122. _afterCameraDrawStage: Stage<CameraStageAction>;
  109123. /**
  109124. * @hidden
  109125. * Defines the actions happening just after a render target has been drawn.
  109126. */
  109127. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109128. /**
  109129. * @hidden
  109130. * Defines the actions happening just after rendering all cameras and computing intersections.
  109131. */
  109132. _afterRenderStage: Stage<SimpleStageAction>;
  109133. /**
  109134. * @hidden
  109135. * Defines the actions happening when a pointer move event happens.
  109136. */
  109137. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109138. /**
  109139. * @hidden
  109140. * Defines the actions happening when a pointer down event happens.
  109141. */
  109142. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109143. /**
  109144. * @hidden
  109145. * Defines the actions happening when a pointer up event happens.
  109146. */
  109147. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109148. /**
  109149. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109150. */
  109151. private geometriesByUniqueId;
  109152. /**
  109153. * Creates a new Scene
  109154. * @param engine defines the engine to use to render this scene
  109155. * @param options defines the scene options
  109156. */
  109157. constructor(engine: Engine, options?: SceneOptions);
  109158. /**
  109159. * Gets a string idenfifying the name of the class
  109160. * @returns "Scene" string
  109161. */
  109162. getClassName(): string;
  109163. private _defaultMeshCandidates;
  109164. /**
  109165. * @hidden
  109166. */
  109167. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109168. private _defaultSubMeshCandidates;
  109169. /**
  109170. * @hidden
  109171. */
  109172. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109173. /**
  109174. * Sets the default candidate providers for the scene.
  109175. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109176. * and getCollidingSubMeshCandidates to their default function
  109177. */
  109178. setDefaultCandidateProviders(): void;
  109179. /**
  109180. * Gets the mesh that is currently under the pointer
  109181. */
  109182. get meshUnderPointer(): Nullable<AbstractMesh>;
  109183. /**
  109184. * Gets or sets the current on-screen X position of the pointer
  109185. */
  109186. get pointerX(): number;
  109187. set pointerX(value: number);
  109188. /**
  109189. * Gets or sets the current on-screen Y position of the pointer
  109190. */
  109191. get pointerY(): number;
  109192. set pointerY(value: number);
  109193. /**
  109194. * Gets the cached material (ie. the latest rendered one)
  109195. * @returns the cached material
  109196. */
  109197. getCachedMaterial(): Nullable<Material>;
  109198. /**
  109199. * Gets the cached effect (ie. the latest rendered one)
  109200. * @returns the cached effect
  109201. */
  109202. getCachedEffect(): Nullable<Effect>;
  109203. /**
  109204. * Gets the cached visibility state (ie. the latest rendered one)
  109205. * @returns the cached visibility state
  109206. */
  109207. getCachedVisibility(): Nullable<number>;
  109208. /**
  109209. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109210. * @param material defines the current material
  109211. * @param effect defines the current effect
  109212. * @param visibility defines the current visibility state
  109213. * @returns true if one parameter is not cached
  109214. */
  109215. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109216. /**
  109217. * Gets the engine associated with the scene
  109218. * @returns an Engine
  109219. */
  109220. getEngine(): Engine;
  109221. /**
  109222. * Gets the total number of vertices rendered per frame
  109223. * @returns the total number of vertices rendered per frame
  109224. */
  109225. getTotalVertices(): number;
  109226. /**
  109227. * Gets the performance counter for total vertices
  109228. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109229. */
  109230. get totalVerticesPerfCounter(): PerfCounter;
  109231. /**
  109232. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109233. * @returns the total number of active indices rendered per frame
  109234. */
  109235. getActiveIndices(): number;
  109236. /**
  109237. * Gets the performance counter for active indices
  109238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109239. */
  109240. get totalActiveIndicesPerfCounter(): PerfCounter;
  109241. /**
  109242. * Gets the total number of active particles rendered per frame
  109243. * @returns the total number of active particles rendered per frame
  109244. */
  109245. getActiveParticles(): number;
  109246. /**
  109247. * Gets the performance counter for active particles
  109248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109249. */
  109250. get activeParticlesPerfCounter(): PerfCounter;
  109251. /**
  109252. * Gets the total number of active bones rendered per frame
  109253. * @returns the total number of active bones rendered per frame
  109254. */
  109255. getActiveBones(): number;
  109256. /**
  109257. * Gets the performance counter for active bones
  109258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109259. */
  109260. get activeBonesPerfCounter(): PerfCounter;
  109261. /**
  109262. * Gets the array of active meshes
  109263. * @returns an array of AbstractMesh
  109264. */
  109265. getActiveMeshes(): SmartArray<AbstractMesh>;
  109266. /**
  109267. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109268. * @returns a number
  109269. */
  109270. getAnimationRatio(): number;
  109271. /**
  109272. * Gets an unique Id for the current render phase
  109273. * @returns a number
  109274. */
  109275. getRenderId(): number;
  109276. /**
  109277. * Gets an unique Id for the current frame
  109278. * @returns a number
  109279. */
  109280. getFrameId(): number;
  109281. /** Call this function if you want to manually increment the render Id*/
  109282. incrementRenderId(): void;
  109283. private _createUbo;
  109284. /**
  109285. * Use this method to simulate a pointer move on a mesh
  109286. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109287. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109288. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109289. * @returns the current scene
  109290. */
  109291. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109292. /**
  109293. * Use this method to simulate a pointer down on a mesh
  109294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109297. * @returns the current scene
  109298. */
  109299. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109300. /**
  109301. * Use this method to simulate a pointer up on a mesh
  109302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109305. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109306. * @returns the current scene
  109307. */
  109308. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109309. /**
  109310. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109311. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109312. * @returns true if the pointer was captured
  109313. */
  109314. isPointerCaptured(pointerId?: number): boolean;
  109315. /**
  109316. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109317. * @param attachUp defines if you want to attach events to pointerup
  109318. * @param attachDown defines if you want to attach events to pointerdown
  109319. * @param attachMove defines if you want to attach events to pointermove
  109320. */
  109321. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109322. /** Detaches all event handlers*/
  109323. detachControl(): void;
  109324. /**
  109325. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109326. * Delay loaded resources are not taking in account
  109327. * @return true if all required resources are ready
  109328. */
  109329. isReady(): boolean;
  109330. /** Resets all cached information relative to material (including effect and visibility) */
  109331. resetCachedMaterial(): void;
  109332. /**
  109333. * Registers a function to be called before every frame render
  109334. * @param func defines the function to register
  109335. */
  109336. registerBeforeRender(func: () => void): void;
  109337. /**
  109338. * Unregisters a function called before every frame render
  109339. * @param func defines the function to unregister
  109340. */
  109341. unregisterBeforeRender(func: () => void): void;
  109342. /**
  109343. * Registers a function to be called after every frame render
  109344. * @param func defines the function to register
  109345. */
  109346. registerAfterRender(func: () => void): void;
  109347. /**
  109348. * Unregisters a function called after every frame render
  109349. * @param func defines the function to unregister
  109350. */
  109351. unregisterAfterRender(func: () => void): void;
  109352. private _executeOnceBeforeRender;
  109353. /**
  109354. * The provided function will run before render once and will be disposed afterwards.
  109355. * A timeout delay can be provided so that the function will be executed in N ms.
  109356. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109357. * @param func The function to be executed.
  109358. * @param timeout optional delay in ms
  109359. */
  109360. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109361. /** @hidden */
  109362. _addPendingData(data: any): void;
  109363. /** @hidden */
  109364. _removePendingData(data: any): void;
  109365. /**
  109366. * Returns the number of items waiting to be loaded
  109367. * @returns the number of items waiting to be loaded
  109368. */
  109369. getWaitingItemsCount(): number;
  109370. /**
  109371. * Returns a boolean indicating if the scene is still loading data
  109372. */
  109373. get isLoading(): boolean;
  109374. /**
  109375. * Registers a function to be executed when the scene is ready
  109376. * @param {Function} func - the function to be executed
  109377. */
  109378. executeWhenReady(func: () => void): void;
  109379. /**
  109380. * Returns a promise that resolves when the scene is ready
  109381. * @returns A promise that resolves when the scene is ready
  109382. */
  109383. whenReadyAsync(): Promise<void>;
  109384. /** @hidden */
  109385. _checkIsReady(): void;
  109386. /**
  109387. * Gets all animatable attached to the scene
  109388. */
  109389. get animatables(): Animatable[];
  109390. /**
  109391. * Resets the last animation time frame.
  109392. * Useful to override when animations start running when loading a scene for the first time.
  109393. */
  109394. resetLastAnimationTimeFrame(): void;
  109395. /**
  109396. * Gets the current view matrix
  109397. * @returns a Matrix
  109398. */
  109399. getViewMatrix(): Matrix;
  109400. /**
  109401. * Gets the current projection matrix
  109402. * @returns a Matrix
  109403. */
  109404. getProjectionMatrix(): Matrix;
  109405. /**
  109406. * Gets the current transform matrix
  109407. * @returns a Matrix made of View * Projection
  109408. */
  109409. getTransformMatrix(): Matrix;
  109410. /**
  109411. * Sets the current transform matrix
  109412. * @param viewL defines the View matrix to use
  109413. * @param projectionL defines the Projection matrix to use
  109414. * @param viewR defines the right View matrix to use (if provided)
  109415. * @param projectionR defines the right Projection matrix to use (if provided)
  109416. */
  109417. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109418. /**
  109419. * Gets the uniform buffer used to store scene data
  109420. * @returns a UniformBuffer
  109421. */
  109422. getSceneUniformBuffer(): UniformBuffer;
  109423. /**
  109424. * Gets an unique (relatively to the current scene) Id
  109425. * @returns an unique number for the scene
  109426. */
  109427. getUniqueId(): number;
  109428. /**
  109429. * Add a mesh to the list of scene's meshes
  109430. * @param newMesh defines the mesh to add
  109431. * @param recursive if all child meshes should also be added to the scene
  109432. */
  109433. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109434. /**
  109435. * Remove a mesh for the list of scene's meshes
  109436. * @param toRemove defines the mesh to remove
  109437. * @param recursive if all child meshes should also be removed from the scene
  109438. * @returns the index where the mesh was in the mesh list
  109439. */
  109440. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109441. /**
  109442. * Add a transform node to the list of scene's transform nodes
  109443. * @param newTransformNode defines the transform node to add
  109444. */
  109445. addTransformNode(newTransformNode: TransformNode): void;
  109446. /**
  109447. * Remove a transform node for the list of scene's transform nodes
  109448. * @param toRemove defines the transform node to remove
  109449. * @returns the index where the transform node was in the transform node list
  109450. */
  109451. removeTransformNode(toRemove: TransformNode): number;
  109452. /**
  109453. * Remove a skeleton for the list of scene's skeletons
  109454. * @param toRemove defines the skeleton to remove
  109455. * @returns the index where the skeleton was in the skeleton list
  109456. */
  109457. removeSkeleton(toRemove: Skeleton): number;
  109458. /**
  109459. * Remove a morph target for the list of scene's morph targets
  109460. * @param toRemove defines the morph target to remove
  109461. * @returns the index where the morph target was in the morph target list
  109462. */
  109463. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109464. /**
  109465. * Remove a light for the list of scene's lights
  109466. * @param toRemove defines the light to remove
  109467. * @returns the index where the light was in the light list
  109468. */
  109469. removeLight(toRemove: Light): number;
  109470. /**
  109471. * Remove a camera for the list of scene's cameras
  109472. * @param toRemove defines the camera to remove
  109473. * @returns the index where the camera was in the camera list
  109474. */
  109475. removeCamera(toRemove: Camera): number;
  109476. /**
  109477. * Remove a particle system for the list of scene's particle systems
  109478. * @param toRemove defines the particle system to remove
  109479. * @returns the index where the particle system was in the particle system list
  109480. */
  109481. removeParticleSystem(toRemove: IParticleSystem): number;
  109482. /**
  109483. * Remove a animation for the list of scene's animations
  109484. * @param toRemove defines the animation to remove
  109485. * @returns the index where the animation was in the animation list
  109486. */
  109487. removeAnimation(toRemove: Animation): number;
  109488. /**
  109489. * Will stop the animation of the given target
  109490. * @param target - the target
  109491. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109492. * @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)
  109493. */
  109494. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109495. /**
  109496. * Removes the given animation group from this scene.
  109497. * @param toRemove The animation group to remove
  109498. * @returns The index of the removed animation group
  109499. */
  109500. removeAnimationGroup(toRemove: AnimationGroup): number;
  109501. /**
  109502. * Removes the given multi-material from this scene.
  109503. * @param toRemove The multi-material to remove
  109504. * @returns The index of the removed multi-material
  109505. */
  109506. removeMultiMaterial(toRemove: MultiMaterial): number;
  109507. /**
  109508. * Removes the given material from this scene.
  109509. * @param toRemove The material to remove
  109510. * @returns The index of the removed material
  109511. */
  109512. removeMaterial(toRemove: Material): number;
  109513. /**
  109514. * Removes the given action manager from this scene.
  109515. * @param toRemove The action manager to remove
  109516. * @returns The index of the removed action manager
  109517. */
  109518. removeActionManager(toRemove: AbstractActionManager): number;
  109519. /**
  109520. * Removes the given texture from this scene.
  109521. * @param toRemove The texture to remove
  109522. * @returns The index of the removed texture
  109523. */
  109524. removeTexture(toRemove: BaseTexture): number;
  109525. /**
  109526. * Adds the given light to this scene
  109527. * @param newLight The light to add
  109528. */
  109529. addLight(newLight: Light): void;
  109530. /**
  109531. * Sorts the list list based on light priorities
  109532. */
  109533. sortLightsByPriority(): void;
  109534. /**
  109535. * Adds the given camera to this scene
  109536. * @param newCamera The camera to add
  109537. */
  109538. addCamera(newCamera: Camera): void;
  109539. /**
  109540. * Adds the given skeleton to this scene
  109541. * @param newSkeleton The skeleton to add
  109542. */
  109543. addSkeleton(newSkeleton: Skeleton): void;
  109544. /**
  109545. * Adds the given particle system to this scene
  109546. * @param newParticleSystem The particle system to add
  109547. */
  109548. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109549. /**
  109550. * Adds the given animation to this scene
  109551. * @param newAnimation The animation to add
  109552. */
  109553. addAnimation(newAnimation: Animation): void;
  109554. /**
  109555. * Adds the given animation group to this scene.
  109556. * @param newAnimationGroup The animation group to add
  109557. */
  109558. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109559. /**
  109560. * Adds the given multi-material to this scene
  109561. * @param newMultiMaterial The multi-material to add
  109562. */
  109563. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109564. /**
  109565. * Adds the given material to this scene
  109566. * @param newMaterial The material to add
  109567. */
  109568. addMaterial(newMaterial: Material): void;
  109569. /**
  109570. * Adds the given morph target to this scene
  109571. * @param newMorphTargetManager The morph target to add
  109572. */
  109573. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109574. /**
  109575. * Adds the given geometry to this scene
  109576. * @param newGeometry The geometry to add
  109577. */
  109578. addGeometry(newGeometry: Geometry): void;
  109579. /**
  109580. * Adds the given action manager to this scene
  109581. * @param newActionManager The action manager to add
  109582. */
  109583. addActionManager(newActionManager: AbstractActionManager): void;
  109584. /**
  109585. * Adds the given texture to this scene.
  109586. * @param newTexture The texture to add
  109587. */
  109588. addTexture(newTexture: BaseTexture): void;
  109589. /**
  109590. * Switch active camera
  109591. * @param newCamera defines the new active camera
  109592. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109593. */
  109594. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109595. /**
  109596. * sets the active camera of the scene using its ID
  109597. * @param id defines the camera's ID
  109598. * @return the new active camera or null if none found.
  109599. */
  109600. setActiveCameraByID(id: string): Nullable<Camera>;
  109601. /**
  109602. * sets the active camera of the scene using its name
  109603. * @param name defines the camera's name
  109604. * @returns the new active camera or null if none found.
  109605. */
  109606. setActiveCameraByName(name: string): Nullable<Camera>;
  109607. /**
  109608. * get an animation group using its name
  109609. * @param name defines the material's name
  109610. * @return the animation group or null if none found.
  109611. */
  109612. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109613. /**
  109614. * Get a material using its unique id
  109615. * @param uniqueId defines the material's unique id
  109616. * @return the material or null if none found.
  109617. */
  109618. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109619. /**
  109620. * get a material using its id
  109621. * @param id defines the material's ID
  109622. * @return the material or null if none found.
  109623. */
  109624. getMaterialByID(id: string): Nullable<Material>;
  109625. /**
  109626. * Gets a the last added material using a given id
  109627. * @param id defines the material's ID
  109628. * @return the last material with the given id or null if none found.
  109629. */
  109630. getLastMaterialByID(id: string): Nullable<Material>;
  109631. /**
  109632. * Gets a material using its name
  109633. * @param name defines the material's name
  109634. * @return the material or null if none found.
  109635. */
  109636. getMaterialByName(name: string): Nullable<Material>;
  109637. /**
  109638. * Get a texture using its unique id
  109639. * @param uniqueId defines the texture's unique id
  109640. * @return the texture or null if none found.
  109641. */
  109642. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109643. /**
  109644. * Gets a camera using its id
  109645. * @param id defines the id to look for
  109646. * @returns the camera or null if not found
  109647. */
  109648. getCameraByID(id: string): Nullable<Camera>;
  109649. /**
  109650. * Gets a camera using its unique id
  109651. * @param uniqueId defines the unique id to look for
  109652. * @returns the camera or null if not found
  109653. */
  109654. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109655. /**
  109656. * Gets a camera using its name
  109657. * @param name defines the camera's name
  109658. * @return the camera or null if none found.
  109659. */
  109660. getCameraByName(name: string): Nullable<Camera>;
  109661. /**
  109662. * Gets a bone using its id
  109663. * @param id defines the bone's id
  109664. * @return the bone or null if not found
  109665. */
  109666. getBoneByID(id: string): Nullable<Bone>;
  109667. /**
  109668. * Gets a bone using its id
  109669. * @param name defines the bone's name
  109670. * @return the bone or null if not found
  109671. */
  109672. getBoneByName(name: string): Nullable<Bone>;
  109673. /**
  109674. * Gets a light node using its name
  109675. * @param name defines the the light's name
  109676. * @return the light or null if none found.
  109677. */
  109678. getLightByName(name: string): Nullable<Light>;
  109679. /**
  109680. * Gets a light node using its id
  109681. * @param id defines the light's id
  109682. * @return the light or null if none found.
  109683. */
  109684. getLightByID(id: string): Nullable<Light>;
  109685. /**
  109686. * Gets a light node using its scene-generated unique ID
  109687. * @param uniqueId defines the light's unique id
  109688. * @return the light or null if none found.
  109689. */
  109690. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109691. /**
  109692. * Gets a particle system by id
  109693. * @param id defines the particle system id
  109694. * @return the corresponding system or null if none found
  109695. */
  109696. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109697. /**
  109698. * Gets a geometry using its ID
  109699. * @param id defines the geometry's id
  109700. * @return the geometry or null if none found.
  109701. */
  109702. getGeometryByID(id: string): Nullable<Geometry>;
  109703. private _getGeometryByUniqueID;
  109704. /**
  109705. * Add a new geometry to this scene
  109706. * @param geometry defines the geometry to be added to the scene.
  109707. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109708. * @return a boolean defining if the geometry was added or not
  109709. */
  109710. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109711. /**
  109712. * Removes an existing geometry
  109713. * @param geometry defines the geometry to be removed from the scene
  109714. * @return a boolean defining if the geometry was removed or not
  109715. */
  109716. removeGeometry(geometry: Geometry): boolean;
  109717. /**
  109718. * Gets the list of geometries attached to the scene
  109719. * @returns an array of Geometry
  109720. */
  109721. getGeometries(): Geometry[];
  109722. /**
  109723. * Gets the first added mesh found of a given ID
  109724. * @param id defines the id to search for
  109725. * @return the mesh found or null if not found at all
  109726. */
  109727. getMeshByID(id: string): Nullable<AbstractMesh>;
  109728. /**
  109729. * Gets a list of meshes using their id
  109730. * @param id defines the id to search for
  109731. * @returns a list of meshes
  109732. */
  109733. getMeshesByID(id: string): Array<AbstractMesh>;
  109734. /**
  109735. * Gets the first added transform node found of a given ID
  109736. * @param id defines the id to search for
  109737. * @return the found transform node or null if not found at all.
  109738. */
  109739. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109740. /**
  109741. * Gets a transform node with its auto-generated unique id
  109742. * @param uniqueId efines the unique id to search for
  109743. * @return the found transform node or null if not found at all.
  109744. */
  109745. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109746. /**
  109747. * Gets a list of transform nodes using their id
  109748. * @param id defines the id to search for
  109749. * @returns a list of transform nodes
  109750. */
  109751. getTransformNodesByID(id: string): Array<TransformNode>;
  109752. /**
  109753. * Gets a mesh with its auto-generated unique id
  109754. * @param uniqueId defines the unique id to search for
  109755. * @return the found mesh or null if not found at all.
  109756. */
  109757. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109758. /**
  109759. * Gets a the last added mesh using a given id
  109760. * @param id defines the id to search for
  109761. * @return the found mesh or null if not found at all.
  109762. */
  109763. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109764. /**
  109765. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109766. * @param id defines the id to search for
  109767. * @return the found node or null if not found at all
  109768. */
  109769. getLastEntryByID(id: string): Nullable<Node>;
  109770. /**
  109771. * Gets a node (Mesh, Camera, Light) using a given id
  109772. * @param id defines the id to search for
  109773. * @return the found node or null if not found at all
  109774. */
  109775. getNodeByID(id: string): Nullable<Node>;
  109776. /**
  109777. * Gets a node (Mesh, Camera, Light) using a given name
  109778. * @param name defines the name to search for
  109779. * @return the found node or null if not found at all.
  109780. */
  109781. getNodeByName(name: string): Nullable<Node>;
  109782. /**
  109783. * Gets a mesh using a given name
  109784. * @param name defines the name to search for
  109785. * @return the found mesh or null if not found at all.
  109786. */
  109787. getMeshByName(name: string): Nullable<AbstractMesh>;
  109788. /**
  109789. * Gets a transform node using a given name
  109790. * @param name defines the name to search for
  109791. * @return the found transform node or null if not found at all.
  109792. */
  109793. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109794. /**
  109795. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109796. * @param id defines the id to search for
  109797. * @return the found skeleton or null if not found at all.
  109798. */
  109799. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109800. /**
  109801. * Gets a skeleton using a given auto generated unique id
  109802. * @param uniqueId defines the unique id to search for
  109803. * @return the found skeleton or null if not found at all.
  109804. */
  109805. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109806. /**
  109807. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109808. * @param id defines the id to search for
  109809. * @return the found skeleton or null if not found at all.
  109810. */
  109811. getSkeletonById(id: string): Nullable<Skeleton>;
  109812. /**
  109813. * Gets a skeleton using a given name
  109814. * @param name defines the name to search for
  109815. * @return the found skeleton or null if not found at all.
  109816. */
  109817. getSkeletonByName(name: string): Nullable<Skeleton>;
  109818. /**
  109819. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109820. * @param id defines the id to search for
  109821. * @return the found morph target manager or null if not found at all.
  109822. */
  109823. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109824. /**
  109825. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109826. * @param id defines the id to search for
  109827. * @return the found morph target or null if not found at all.
  109828. */
  109829. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109830. /**
  109831. * Gets a boolean indicating if the given mesh is active
  109832. * @param mesh defines the mesh to look for
  109833. * @returns true if the mesh is in the active list
  109834. */
  109835. isActiveMesh(mesh: AbstractMesh): boolean;
  109836. /**
  109837. * Return a unique id as a string which can serve as an identifier for the scene
  109838. */
  109839. get uid(): string;
  109840. /**
  109841. * Add an externaly attached data from its key.
  109842. * This method call will fail and return false, if such key already exists.
  109843. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109844. * @param key the unique key that identifies the data
  109845. * @param data the data object to associate to the key for this Engine instance
  109846. * @return true if no such key were already present and the data was added successfully, false otherwise
  109847. */
  109848. addExternalData<T>(key: string, data: T): boolean;
  109849. /**
  109850. * Get an externaly attached data from its key
  109851. * @param key the unique key that identifies the data
  109852. * @return the associated data, if present (can be null), or undefined if not present
  109853. */
  109854. getExternalData<T>(key: string): Nullable<T>;
  109855. /**
  109856. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109857. * @param key the unique key that identifies the data
  109858. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109859. * @return the associated data, can be null if the factory returned null.
  109860. */
  109861. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109862. /**
  109863. * Remove an externaly attached data from the Engine instance
  109864. * @param key the unique key that identifies the data
  109865. * @return true if the data was successfully removed, false if it doesn't exist
  109866. */
  109867. removeExternalData(key: string): boolean;
  109868. private _evaluateSubMesh;
  109869. /**
  109870. * Clear the processed materials smart array preventing retention point in material dispose.
  109871. */
  109872. freeProcessedMaterials(): void;
  109873. private _preventFreeActiveMeshesAndRenderingGroups;
  109874. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109875. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109876. * when disposing several meshes in a row or a hierarchy of meshes.
  109877. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109878. */
  109879. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109880. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109881. /**
  109882. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109883. */
  109884. freeActiveMeshes(): void;
  109885. /**
  109886. * Clear the info related to rendering groups preventing retention points during dispose.
  109887. */
  109888. freeRenderingGroups(): void;
  109889. /** @hidden */
  109890. _isInIntermediateRendering(): boolean;
  109891. /**
  109892. * Lambda returning the list of potentially active meshes.
  109893. */
  109894. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109895. /**
  109896. * Lambda returning the list of potentially active sub meshes.
  109897. */
  109898. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109899. /**
  109900. * Lambda returning the list of potentially intersecting sub meshes.
  109901. */
  109902. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109903. /**
  109904. * Lambda returning the list of potentially colliding sub meshes.
  109905. */
  109906. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109907. private _activeMeshesFrozen;
  109908. private _skipEvaluateActiveMeshesCompletely;
  109909. /**
  109910. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109911. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109912. * @returns the current scene
  109913. */
  109914. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109915. /**
  109916. * Use this function to restart evaluating active meshes on every frame
  109917. * @returns the current scene
  109918. */
  109919. unfreezeActiveMeshes(): Scene;
  109920. private _evaluateActiveMeshes;
  109921. private _activeMesh;
  109922. /**
  109923. * Update the transform matrix to update from the current active camera
  109924. * @param force defines a boolean used to force the update even if cache is up to date
  109925. */
  109926. updateTransformMatrix(force?: boolean): void;
  109927. private _bindFrameBuffer;
  109928. /** @hidden */
  109929. _allowPostProcessClearColor: boolean;
  109930. /** @hidden */
  109931. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109932. private _processSubCameras;
  109933. private _checkIntersections;
  109934. /** @hidden */
  109935. _advancePhysicsEngineStep(step: number): void;
  109936. /**
  109937. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109938. */
  109939. getDeterministicFrameTime: () => number;
  109940. /** @hidden */
  109941. _animate(): void;
  109942. /** Execute all animations (for a frame) */
  109943. animate(): void;
  109944. /**
  109945. * Render the scene
  109946. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109947. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109948. */
  109949. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109950. /**
  109951. * Freeze all materials
  109952. * A frozen material will not be updatable but should be faster to render
  109953. */
  109954. freezeMaterials(): void;
  109955. /**
  109956. * Unfreeze all materials
  109957. * A frozen material will not be updatable but should be faster to render
  109958. */
  109959. unfreezeMaterials(): void;
  109960. /**
  109961. * Releases all held ressources
  109962. */
  109963. dispose(): void;
  109964. /**
  109965. * Gets if the scene is already disposed
  109966. */
  109967. get isDisposed(): boolean;
  109968. /**
  109969. * Call this function to reduce memory footprint of the scene.
  109970. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109971. */
  109972. clearCachedVertexData(): void;
  109973. /**
  109974. * This function will remove the local cached buffer data from texture.
  109975. * It will save memory but will prevent the texture from being rebuilt
  109976. */
  109977. cleanCachedTextureBuffer(): void;
  109978. /**
  109979. * Get the world extend vectors with an optional filter
  109980. *
  109981. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109982. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109983. */
  109984. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109985. min: Vector3;
  109986. max: Vector3;
  109987. };
  109988. /**
  109989. * Creates a ray that can be used to pick in the scene
  109990. * @param x defines the x coordinate of the origin (on-screen)
  109991. * @param y defines the y coordinate of the origin (on-screen)
  109992. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109993. * @param camera defines the camera to use for the picking
  109994. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109995. * @returns a Ray
  109996. */
  109997. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109998. /**
  109999. * Creates a ray that can be used to pick in the scene
  110000. * @param x defines the x coordinate of the origin (on-screen)
  110001. * @param y defines the y coordinate of the origin (on-screen)
  110002. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110003. * @param result defines the ray where to store the picking ray
  110004. * @param camera defines the camera to use for the picking
  110005. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110006. * @returns the current scene
  110007. */
  110008. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110009. /**
  110010. * Creates a ray that can be used to pick in the scene
  110011. * @param x defines the x coordinate of the origin (on-screen)
  110012. * @param y defines the y coordinate of the origin (on-screen)
  110013. * @param camera defines the camera to use for the picking
  110014. * @returns a Ray
  110015. */
  110016. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110017. /**
  110018. * Creates a ray that can be used to pick in the scene
  110019. * @param x defines the x coordinate of the origin (on-screen)
  110020. * @param y defines the y coordinate of the origin (on-screen)
  110021. * @param result defines the ray where to store the picking ray
  110022. * @param camera defines the camera to use for the picking
  110023. * @returns the current scene
  110024. */
  110025. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110026. /** Launch a ray to try to pick a mesh in the scene
  110027. * @param x position on screen
  110028. * @param y position on screen
  110029. * @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
  110030. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110031. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110032. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110033. * @returns a PickingInfo
  110034. */
  110035. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110036. /** Use the given ray to pick a mesh in the scene
  110037. * @param ray The ray to use to pick meshes
  110038. * @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
  110039. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110040. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110041. * @returns a PickingInfo
  110042. */
  110043. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110044. /**
  110045. * Launch a ray to try to pick a mesh in the scene
  110046. * @param x X position on screen
  110047. * @param y Y position on screen
  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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110050. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110051. * @returns an array of PickingInfo
  110052. */
  110053. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110054. /**
  110055. * Launch a ray to try to pick a mesh in the scene
  110056. * @param ray Ray to use
  110057. * @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
  110058. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110059. * @returns an array of PickingInfo
  110060. */
  110061. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110062. /**
  110063. * Force the value of meshUnderPointer
  110064. * @param mesh defines the mesh to use
  110065. */
  110066. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110067. /**
  110068. * Gets the mesh under the pointer
  110069. * @returns a Mesh or null if no mesh is under the pointer
  110070. */
  110071. getPointerOverMesh(): Nullable<AbstractMesh>;
  110072. /** @hidden */
  110073. _rebuildGeometries(): void;
  110074. /** @hidden */
  110075. _rebuildTextures(): void;
  110076. private _getByTags;
  110077. /**
  110078. * Get a list of meshes by tags
  110079. * @param tagsQuery defines the tags query to use
  110080. * @param forEach defines a predicate used to filter results
  110081. * @returns an array of Mesh
  110082. */
  110083. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110084. /**
  110085. * Get a list of cameras by tags
  110086. * @param tagsQuery defines the tags query to use
  110087. * @param forEach defines a predicate used to filter results
  110088. * @returns an array of Camera
  110089. */
  110090. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110091. /**
  110092. * Get a list of lights by tags
  110093. * @param tagsQuery defines the tags query to use
  110094. * @param forEach defines a predicate used to filter results
  110095. * @returns an array of Light
  110096. */
  110097. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110098. /**
  110099. * Get a list of materials by tags
  110100. * @param tagsQuery defines the tags query to use
  110101. * @param forEach defines a predicate used to filter results
  110102. * @returns an array of Material
  110103. */
  110104. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110105. /**
  110106. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110107. * This allowed control for front to back rendering or reversly depending of the special needs.
  110108. *
  110109. * @param renderingGroupId The rendering group id corresponding to its index
  110110. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110111. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110112. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110113. */
  110114. 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;
  110115. /**
  110116. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110117. *
  110118. * @param renderingGroupId The rendering group id corresponding to its index
  110119. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110120. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110121. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110122. */
  110123. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110124. /**
  110125. * Gets the current auto clear configuration for one rendering group of the rendering
  110126. * manager.
  110127. * @param index the rendering group index to get the information for
  110128. * @returns The auto clear setup for the requested rendering group
  110129. */
  110130. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110131. private _blockMaterialDirtyMechanism;
  110132. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110133. get blockMaterialDirtyMechanism(): boolean;
  110134. set blockMaterialDirtyMechanism(value: boolean);
  110135. /**
  110136. * Will flag all materials as dirty to trigger new shader compilation
  110137. * @param flag defines the flag used to specify which material part must be marked as dirty
  110138. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110139. */
  110140. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110141. /** @hidden */
  110142. _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;
  110143. /** @hidden */
  110144. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110145. /** @hidden */
  110146. _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;
  110147. /** @hidden */
  110148. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110149. /** @hidden */
  110150. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110151. /** @hidden */
  110152. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Set of assets to keep when moving a scene into an asset container.
  110158. */
  110159. export class KeepAssets extends AbstractScene {
  110160. }
  110161. /**
  110162. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110163. */
  110164. export class InstantiatedEntries {
  110165. /**
  110166. * List of new root nodes (eg. nodes with no parent)
  110167. */
  110168. rootNodes: TransformNode[];
  110169. /**
  110170. * List of new skeletons
  110171. */
  110172. skeletons: Skeleton[];
  110173. /**
  110174. * List of new animation groups
  110175. */
  110176. animationGroups: AnimationGroup[];
  110177. }
  110178. /**
  110179. * Container with a set of assets that can be added or removed from a scene.
  110180. */
  110181. export class AssetContainer extends AbstractScene {
  110182. /**
  110183. * The scene the AssetContainer belongs to.
  110184. */
  110185. scene: Scene;
  110186. /**
  110187. * Instantiates an AssetContainer.
  110188. * @param scene The scene the AssetContainer belongs to.
  110189. */
  110190. constructor(scene: Scene);
  110191. /**
  110192. * Instantiate or clone all meshes and add the new ones to the scene.
  110193. * Skeletons and animation groups will all be cloned
  110194. * @param nameFunction defines an optional function used to get new names for clones
  110195. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110196. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110197. */
  110198. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110199. /**
  110200. * Adds all the assets from the container to the scene.
  110201. */
  110202. addAllToScene(): void;
  110203. /**
  110204. * Removes all the assets in the container from the scene
  110205. */
  110206. removeAllFromScene(): void;
  110207. /**
  110208. * Disposes all the assets in the container
  110209. */
  110210. dispose(): void;
  110211. private _moveAssets;
  110212. /**
  110213. * Removes all the assets contained in the scene and adds them to the container.
  110214. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110215. */
  110216. moveAllFromScene(keepAssets?: KeepAssets): void;
  110217. /**
  110218. * 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.
  110219. * @returns the root mesh
  110220. */
  110221. createRootMesh(): Mesh;
  110222. /**
  110223. * Merge animations from this asset container into a scene
  110224. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110225. * @param animatables set of animatables to retarget to a node from the scene
  110226. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110227. */
  110228. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110229. }
  110230. }
  110231. declare module BABYLON {
  110232. /**
  110233. * Defines how the parser contract is defined.
  110234. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110235. */
  110236. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110237. /**
  110238. * Defines how the individual parser contract is defined.
  110239. * These parser can parse an individual asset
  110240. */
  110241. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110242. /**
  110243. * Base class of the scene acting as a container for the different elements composing a scene.
  110244. * This class is dynamically extended by the different components of the scene increasing
  110245. * flexibility and reducing coupling
  110246. */
  110247. export abstract class AbstractScene {
  110248. /**
  110249. * Stores the list of available parsers in the application.
  110250. */
  110251. private static _BabylonFileParsers;
  110252. /**
  110253. * Stores the list of available individual parsers in the application.
  110254. */
  110255. private static _IndividualBabylonFileParsers;
  110256. /**
  110257. * Adds a parser in the list of available ones
  110258. * @param name Defines the name of the parser
  110259. * @param parser Defines the parser to add
  110260. */
  110261. static AddParser(name: string, parser: BabylonFileParser): void;
  110262. /**
  110263. * Gets a general parser from the list of avaialble ones
  110264. * @param name Defines the name of the parser
  110265. * @returns the requested parser or null
  110266. */
  110267. static GetParser(name: string): Nullable<BabylonFileParser>;
  110268. /**
  110269. * Adds n individual parser in the list of available ones
  110270. * @param name Defines the name of the parser
  110271. * @param parser Defines the parser to add
  110272. */
  110273. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110274. /**
  110275. * Gets an individual parser from the list of avaialble ones
  110276. * @param name Defines the name of the parser
  110277. * @returns the requested parser or null
  110278. */
  110279. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110280. /**
  110281. * Parser json data and populate both a scene and its associated container object
  110282. * @param jsonData Defines the data to parse
  110283. * @param scene Defines the scene to parse the data for
  110284. * @param container Defines the container attached to the parsing sequence
  110285. * @param rootUrl Defines the root url of the data
  110286. */
  110287. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110288. /**
  110289. * Gets the list of root nodes (ie. nodes with no parent)
  110290. */
  110291. rootNodes: Node[];
  110292. /** All of the cameras added to this scene
  110293. * @see http://doc.babylonjs.com/babylon101/cameras
  110294. */
  110295. cameras: Camera[];
  110296. /**
  110297. * All of the lights added to this scene
  110298. * @see http://doc.babylonjs.com/babylon101/lights
  110299. */
  110300. lights: Light[];
  110301. /**
  110302. * All of the (abstract) meshes added to this scene
  110303. */
  110304. meshes: AbstractMesh[];
  110305. /**
  110306. * The list of skeletons added to the scene
  110307. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110308. */
  110309. skeletons: Skeleton[];
  110310. /**
  110311. * All of the particle systems added to this scene
  110312. * @see http://doc.babylonjs.com/babylon101/particles
  110313. */
  110314. particleSystems: IParticleSystem[];
  110315. /**
  110316. * Gets a list of Animations associated with the scene
  110317. */
  110318. animations: Animation[];
  110319. /**
  110320. * All of the animation groups added to this scene
  110321. * @see http://doc.babylonjs.com/how_to/group
  110322. */
  110323. animationGroups: AnimationGroup[];
  110324. /**
  110325. * All of the multi-materials added to this scene
  110326. * @see http://doc.babylonjs.com/how_to/multi_materials
  110327. */
  110328. multiMaterials: MultiMaterial[];
  110329. /**
  110330. * All of the materials added to this scene
  110331. * In the context of a Scene, it is not supposed to be modified manually.
  110332. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110333. * Note also that the order of the Material within the array is not significant and might change.
  110334. * @see http://doc.babylonjs.com/babylon101/materials
  110335. */
  110336. materials: Material[];
  110337. /**
  110338. * The list of morph target managers added to the scene
  110339. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110340. */
  110341. morphTargetManagers: MorphTargetManager[];
  110342. /**
  110343. * The list of geometries used in the scene.
  110344. */
  110345. geometries: Geometry[];
  110346. /**
  110347. * All of the tranform nodes added to this scene
  110348. * In the context of a Scene, it is not supposed to be modified manually.
  110349. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110350. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110351. * @see http://doc.babylonjs.com/how_to/transformnode
  110352. */
  110353. transformNodes: TransformNode[];
  110354. /**
  110355. * ActionManagers available on the scene.
  110356. */
  110357. actionManagers: AbstractActionManager[];
  110358. /**
  110359. * Textures to keep.
  110360. */
  110361. textures: BaseTexture[];
  110362. /**
  110363. * Environment texture for the scene
  110364. */
  110365. environmentTexture: Nullable<BaseTexture>;
  110366. /**
  110367. * @returns all meshes, lights, cameras, transformNodes and bones
  110368. */
  110369. getNodes(): Array<Node>;
  110370. }
  110371. }
  110372. declare module BABYLON {
  110373. /**
  110374. * Interface used to define options for Sound class
  110375. */
  110376. export interface ISoundOptions {
  110377. /**
  110378. * Does the sound autoplay once loaded.
  110379. */
  110380. autoplay?: boolean;
  110381. /**
  110382. * Does the sound loop after it finishes playing once.
  110383. */
  110384. loop?: boolean;
  110385. /**
  110386. * Sound's volume
  110387. */
  110388. volume?: number;
  110389. /**
  110390. * Is it a spatial sound?
  110391. */
  110392. spatialSound?: boolean;
  110393. /**
  110394. * Maximum distance to hear that sound
  110395. */
  110396. maxDistance?: number;
  110397. /**
  110398. * Uses user defined attenuation function
  110399. */
  110400. useCustomAttenuation?: boolean;
  110401. /**
  110402. * Define the roll off factor of spatial sounds.
  110403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110404. */
  110405. rolloffFactor?: number;
  110406. /**
  110407. * Define the reference distance the sound should be heard perfectly.
  110408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110409. */
  110410. refDistance?: number;
  110411. /**
  110412. * Define the distance attenuation model the sound will follow.
  110413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110414. */
  110415. distanceModel?: string;
  110416. /**
  110417. * Defines the playback speed (1 by default)
  110418. */
  110419. playbackRate?: number;
  110420. /**
  110421. * Defines if the sound is from a streaming source
  110422. */
  110423. streaming?: boolean;
  110424. /**
  110425. * Defines an optional length (in seconds) inside the sound file
  110426. */
  110427. length?: number;
  110428. /**
  110429. * Defines an optional offset (in seconds) inside the sound file
  110430. */
  110431. offset?: number;
  110432. /**
  110433. * If true, URLs will not be required to state the audio file codec to use.
  110434. */
  110435. skipCodecCheck?: boolean;
  110436. }
  110437. /**
  110438. * Defines a sound that can be played in the application.
  110439. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110441. */
  110442. export class Sound {
  110443. /**
  110444. * The name of the sound in the scene.
  110445. */
  110446. name: string;
  110447. /**
  110448. * Does the sound autoplay once loaded.
  110449. */
  110450. autoplay: boolean;
  110451. /**
  110452. * Does the sound loop after it finishes playing once.
  110453. */
  110454. loop: boolean;
  110455. /**
  110456. * Does the sound use a custom attenuation curve to simulate the falloff
  110457. * happening when the source gets further away from the camera.
  110458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110459. */
  110460. useCustomAttenuation: boolean;
  110461. /**
  110462. * The sound track id this sound belongs to.
  110463. */
  110464. soundTrackId: number;
  110465. /**
  110466. * Is this sound currently played.
  110467. */
  110468. isPlaying: boolean;
  110469. /**
  110470. * Is this sound currently paused.
  110471. */
  110472. isPaused: boolean;
  110473. /**
  110474. * Does this sound enables spatial sound.
  110475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110476. */
  110477. spatialSound: boolean;
  110478. /**
  110479. * Define the reference distance the sound should be heard perfectly.
  110480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110481. */
  110482. refDistance: number;
  110483. /**
  110484. * Define the roll off factor of spatial sounds.
  110485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110486. */
  110487. rolloffFactor: number;
  110488. /**
  110489. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110491. */
  110492. maxDistance: number;
  110493. /**
  110494. * Define the distance attenuation model the sound will follow.
  110495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110496. */
  110497. distanceModel: string;
  110498. /**
  110499. * @hidden
  110500. * Back Compat
  110501. **/
  110502. onended: () => any;
  110503. /**
  110504. * Observable event when the current playing sound finishes.
  110505. */
  110506. onEndedObservable: Observable<Sound>;
  110507. private _panningModel;
  110508. private _playbackRate;
  110509. private _streaming;
  110510. private _startTime;
  110511. private _startOffset;
  110512. private _position;
  110513. /** @hidden */
  110514. _positionInEmitterSpace: boolean;
  110515. private _localDirection;
  110516. private _volume;
  110517. private _isReadyToPlay;
  110518. private _isDirectional;
  110519. private _readyToPlayCallback;
  110520. private _audioBuffer;
  110521. private _soundSource;
  110522. private _streamingSource;
  110523. private _soundPanner;
  110524. private _soundGain;
  110525. private _inputAudioNode;
  110526. private _outputAudioNode;
  110527. private _coneInnerAngle;
  110528. private _coneOuterAngle;
  110529. private _coneOuterGain;
  110530. private _scene;
  110531. private _connectedTransformNode;
  110532. private _customAttenuationFunction;
  110533. private _registerFunc;
  110534. private _isOutputConnected;
  110535. private _htmlAudioElement;
  110536. private _urlType;
  110537. private _length?;
  110538. private _offset?;
  110539. /** @hidden */
  110540. static _SceneComponentInitialization: (scene: Scene) => void;
  110541. /**
  110542. * Create a sound and attach it to a scene
  110543. * @param name Name of your sound
  110544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110545. * @param scene defines the scene the sound belongs to
  110546. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110547. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110548. */
  110549. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110550. /**
  110551. * Release the sound and its associated resources
  110552. */
  110553. dispose(): void;
  110554. /**
  110555. * Gets if the sounds is ready to be played or not.
  110556. * @returns true if ready, otherwise false
  110557. */
  110558. isReady(): boolean;
  110559. private _soundLoaded;
  110560. /**
  110561. * Sets the data of the sound from an audiobuffer
  110562. * @param audioBuffer The audioBuffer containing the data
  110563. */
  110564. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110565. /**
  110566. * Updates the current sounds options such as maxdistance, loop...
  110567. * @param options A JSON object containing values named as the object properties
  110568. */
  110569. updateOptions(options: ISoundOptions): void;
  110570. private _createSpatialParameters;
  110571. private _updateSpatialParameters;
  110572. /**
  110573. * Switch the panning model to HRTF:
  110574. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110576. */
  110577. switchPanningModelToHRTF(): void;
  110578. /**
  110579. * Switch the panning model to Equal Power:
  110580. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110582. */
  110583. switchPanningModelToEqualPower(): void;
  110584. private _switchPanningModel;
  110585. /**
  110586. * Connect this sound to a sound track audio node like gain...
  110587. * @param soundTrackAudioNode the sound track audio node to connect to
  110588. */
  110589. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110590. /**
  110591. * Transform this sound into a directional source
  110592. * @param coneInnerAngle Size of the inner cone in degree
  110593. * @param coneOuterAngle Size of the outer cone in degree
  110594. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110595. */
  110596. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110597. /**
  110598. * Gets or sets the inner angle for the directional cone.
  110599. */
  110600. get directionalConeInnerAngle(): number;
  110601. /**
  110602. * Gets or sets the inner angle for the directional cone.
  110603. */
  110604. set directionalConeInnerAngle(value: number);
  110605. /**
  110606. * Gets or sets the outer angle for the directional cone.
  110607. */
  110608. get directionalConeOuterAngle(): number;
  110609. /**
  110610. * Gets or sets the outer angle for the directional cone.
  110611. */
  110612. set directionalConeOuterAngle(value: number);
  110613. /**
  110614. * Sets the position of the emitter if spatial sound is enabled
  110615. * @param newPosition Defines the new posisiton
  110616. */
  110617. setPosition(newPosition: Vector3): void;
  110618. /**
  110619. * Sets the local direction of the emitter if spatial sound is enabled
  110620. * @param newLocalDirection Defines the new local direction
  110621. */
  110622. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110623. private _updateDirection;
  110624. /** @hidden */
  110625. updateDistanceFromListener(): void;
  110626. /**
  110627. * Sets a new custom attenuation function for the sound.
  110628. * @param callback Defines the function used for the attenuation
  110629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110630. */
  110631. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110632. /**
  110633. * Play the sound
  110634. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110635. * @param offset (optional) Start the sound at a specific time in seconds
  110636. * @param length (optional) Sound duration (in seconds)
  110637. */
  110638. play(time?: number, offset?: number, length?: number): void;
  110639. private _onended;
  110640. /**
  110641. * Stop the sound
  110642. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110643. */
  110644. stop(time?: number): void;
  110645. /**
  110646. * Put the sound in pause
  110647. */
  110648. pause(): void;
  110649. /**
  110650. * Sets a dedicated volume for this sounds
  110651. * @param newVolume Define the new volume of the sound
  110652. * @param time Define time for gradual change to new volume
  110653. */
  110654. setVolume(newVolume: number, time?: number): void;
  110655. /**
  110656. * Set the sound play back rate
  110657. * @param newPlaybackRate Define the playback rate the sound should be played at
  110658. */
  110659. setPlaybackRate(newPlaybackRate: number): void;
  110660. /**
  110661. * Gets the volume of the sound.
  110662. * @returns the volume of the sound
  110663. */
  110664. getVolume(): number;
  110665. /**
  110666. * Attach the sound to a dedicated mesh
  110667. * @param transformNode The transform node to connect the sound with
  110668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110669. */
  110670. attachToMesh(transformNode: TransformNode): void;
  110671. /**
  110672. * Detach the sound from the previously attached mesh
  110673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110674. */
  110675. detachFromMesh(): void;
  110676. private _onRegisterAfterWorldMatrixUpdate;
  110677. /**
  110678. * Clone the current sound in the scene.
  110679. * @returns the new sound clone
  110680. */
  110681. clone(): Nullable<Sound>;
  110682. /**
  110683. * Gets the current underlying audio buffer containing the data
  110684. * @returns the audio buffer
  110685. */
  110686. getAudioBuffer(): Nullable<AudioBuffer>;
  110687. /**
  110688. * Serializes the Sound in a JSON representation
  110689. * @returns the JSON representation of the sound
  110690. */
  110691. serialize(): any;
  110692. /**
  110693. * Parse a JSON representation of a sound to innstantiate in a given scene
  110694. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110695. * @param scene Define the scene the new parsed sound should be created in
  110696. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110697. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110698. * @returns the newly parsed sound
  110699. */
  110700. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110701. }
  110702. }
  110703. declare module BABYLON {
  110704. /**
  110705. * This defines an action helpful to play a defined sound on a triggered action.
  110706. */
  110707. export class PlaySoundAction extends Action {
  110708. private _sound;
  110709. /**
  110710. * Instantiate the action
  110711. * @param triggerOptions defines the trigger options
  110712. * @param sound defines the sound to play
  110713. * @param condition defines the trigger related conditions
  110714. */
  110715. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110716. /** @hidden */
  110717. _prepare(): void;
  110718. /**
  110719. * Execute the action and play the sound.
  110720. */
  110721. execute(): void;
  110722. /**
  110723. * Serializes the actions and its related information.
  110724. * @param parent defines the object to serialize in
  110725. * @returns the serialized object
  110726. */
  110727. serialize(parent: any): any;
  110728. }
  110729. /**
  110730. * This defines an action helpful to stop a defined sound on a triggered action.
  110731. */
  110732. export class StopSoundAction extends Action {
  110733. private _sound;
  110734. /**
  110735. * Instantiate the action
  110736. * @param triggerOptions defines the trigger options
  110737. * @param sound defines the sound to stop
  110738. * @param condition defines the trigger related conditions
  110739. */
  110740. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110741. /** @hidden */
  110742. _prepare(): void;
  110743. /**
  110744. * Execute the action and stop the sound.
  110745. */
  110746. execute(): void;
  110747. /**
  110748. * Serializes the actions and its related information.
  110749. * @param parent defines the object to serialize in
  110750. * @returns the serialized object
  110751. */
  110752. serialize(parent: any): any;
  110753. }
  110754. }
  110755. declare module BABYLON {
  110756. /**
  110757. * This defines an action responsible to change the value of a property
  110758. * by interpolating between its current value and the newly set one once triggered.
  110759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110760. */
  110761. export class InterpolateValueAction extends Action {
  110762. /**
  110763. * Defines the path of the property where the value should be interpolated
  110764. */
  110765. propertyPath: string;
  110766. /**
  110767. * Defines the target value at the end of the interpolation.
  110768. */
  110769. value: any;
  110770. /**
  110771. * Defines the time it will take for the property to interpolate to the value.
  110772. */
  110773. duration: number;
  110774. /**
  110775. * Defines if the other scene animations should be stopped when the action has been triggered
  110776. */
  110777. stopOtherAnimations?: boolean;
  110778. /**
  110779. * Defines a callback raised once the interpolation animation has been done.
  110780. */
  110781. onInterpolationDone?: () => void;
  110782. /**
  110783. * Observable triggered once the interpolation animation has been done.
  110784. */
  110785. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110786. private _target;
  110787. private _effectiveTarget;
  110788. private _property;
  110789. /**
  110790. * Instantiate the action
  110791. * @param triggerOptions defines the trigger options
  110792. * @param target defines the object containing the value to interpolate
  110793. * @param propertyPath defines the path to the property in the target object
  110794. * @param value defines the target value at the end of the interpolation
  110795. * @param duration deines the time it will take for the property to interpolate to the value.
  110796. * @param condition defines the trigger related conditions
  110797. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110798. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110799. */
  110800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110801. /** @hidden */
  110802. _prepare(): void;
  110803. /**
  110804. * Execute the action starts the value interpolation.
  110805. */
  110806. execute(): void;
  110807. /**
  110808. * Serializes the actions and its related information.
  110809. * @param parent defines the object to serialize in
  110810. * @returns the serialized object
  110811. */
  110812. serialize(parent: any): any;
  110813. }
  110814. }
  110815. declare module BABYLON {
  110816. /**
  110817. * Options allowed during the creation of a sound track.
  110818. */
  110819. export interface ISoundTrackOptions {
  110820. /**
  110821. * The volume the sound track should take during creation
  110822. */
  110823. volume?: number;
  110824. /**
  110825. * Define if the sound track is the main sound track of the scene
  110826. */
  110827. mainTrack?: boolean;
  110828. }
  110829. /**
  110830. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110831. * It will be also used in a future release to apply effects on a specific track.
  110832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110833. */
  110834. export class SoundTrack {
  110835. /**
  110836. * The unique identifier of the sound track in the scene.
  110837. */
  110838. id: number;
  110839. /**
  110840. * The list of sounds included in the sound track.
  110841. */
  110842. soundCollection: Array<Sound>;
  110843. private _outputAudioNode;
  110844. private _scene;
  110845. private _connectedAnalyser;
  110846. private _options;
  110847. private _isInitialized;
  110848. /**
  110849. * Creates a new sound track.
  110850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110851. * @param scene Define the scene the sound track belongs to
  110852. * @param options
  110853. */
  110854. constructor(scene: Scene, options?: ISoundTrackOptions);
  110855. private _initializeSoundTrackAudioGraph;
  110856. /**
  110857. * Release the sound track and its associated resources
  110858. */
  110859. dispose(): void;
  110860. /**
  110861. * Adds a sound to this sound track
  110862. * @param sound define the cound to add
  110863. * @ignoreNaming
  110864. */
  110865. AddSound(sound: Sound): void;
  110866. /**
  110867. * Removes a sound to this sound track
  110868. * @param sound define the cound to remove
  110869. * @ignoreNaming
  110870. */
  110871. RemoveSound(sound: Sound): void;
  110872. /**
  110873. * Set a global volume for the full sound track.
  110874. * @param newVolume Define the new volume of the sound track
  110875. */
  110876. setVolume(newVolume: number): void;
  110877. /**
  110878. * Switch the panning model to HRTF:
  110879. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110881. */
  110882. switchPanningModelToHRTF(): void;
  110883. /**
  110884. * Switch the panning model to Equal Power:
  110885. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110887. */
  110888. switchPanningModelToEqualPower(): void;
  110889. /**
  110890. * Connect the sound track to an audio analyser allowing some amazing
  110891. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110893. * @param analyser The analyser to connect to the engine
  110894. */
  110895. connectToAnalyser(analyser: Analyser): void;
  110896. }
  110897. }
  110898. declare module BABYLON {
  110899. interface AbstractScene {
  110900. /**
  110901. * The list of sounds used in the scene.
  110902. */
  110903. sounds: Nullable<Array<Sound>>;
  110904. }
  110905. interface Scene {
  110906. /**
  110907. * @hidden
  110908. * Backing field
  110909. */
  110910. _mainSoundTrack: SoundTrack;
  110911. /**
  110912. * The main sound track played by the scene.
  110913. * It cotains your primary collection of sounds.
  110914. */
  110915. mainSoundTrack: SoundTrack;
  110916. /**
  110917. * The list of sound tracks added to the scene
  110918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110919. */
  110920. soundTracks: Nullable<Array<SoundTrack>>;
  110921. /**
  110922. * Gets a sound using a given name
  110923. * @param name defines the name to search for
  110924. * @return the found sound or null if not found at all.
  110925. */
  110926. getSoundByName(name: string): Nullable<Sound>;
  110927. /**
  110928. * Gets or sets if audio support is enabled
  110929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110930. */
  110931. audioEnabled: boolean;
  110932. /**
  110933. * Gets or sets if audio will be output to headphones
  110934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110935. */
  110936. headphone: boolean;
  110937. /**
  110938. * Gets or sets custom audio listener position provider
  110939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110940. */
  110941. audioListenerPositionProvider: Nullable<() => Vector3>;
  110942. /**
  110943. * Gets or sets a refresh rate when using 3D audio positioning
  110944. */
  110945. audioPositioningRefreshRate: number;
  110946. }
  110947. /**
  110948. * Defines the sound scene component responsible to manage any sounds
  110949. * in a given scene.
  110950. */
  110951. export class AudioSceneComponent implements ISceneSerializableComponent {
  110952. /**
  110953. * The component name helpfull to identify the component in the list of scene components.
  110954. */
  110955. readonly name: string;
  110956. /**
  110957. * The scene the component belongs to.
  110958. */
  110959. scene: Scene;
  110960. private _audioEnabled;
  110961. /**
  110962. * Gets whether audio is enabled or not.
  110963. * Please use related enable/disable method to switch state.
  110964. */
  110965. get audioEnabled(): boolean;
  110966. private _headphone;
  110967. /**
  110968. * Gets whether audio is outputing to headphone or not.
  110969. * Please use the according Switch methods to change output.
  110970. */
  110971. get headphone(): boolean;
  110972. /**
  110973. * Gets or sets a refresh rate when using 3D audio positioning
  110974. */
  110975. audioPositioningRefreshRate: number;
  110976. private _audioListenerPositionProvider;
  110977. /**
  110978. * Gets the current audio listener position provider
  110979. */
  110980. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110981. /**
  110982. * Sets a custom listener position for all sounds in the scene
  110983. * By default, this is the position of the first active camera
  110984. */
  110985. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110986. /**
  110987. * Creates a new instance of the component for the given scene
  110988. * @param scene Defines the scene to register the component in
  110989. */
  110990. constructor(scene: Scene);
  110991. /**
  110992. * Registers the component in a given scene
  110993. */
  110994. register(): void;
  110995. /**
  110996. * Rebuilds the elements related to this component in case of
  110997. * context lost for instance.
  110998. */
  110999. rebuild(): void;
  111000. /**
  111001. * Serializes the component data to the specified json object
  111002. * @param serializationObject The object to serialize to
  111003. */
  111004. serialize(serializationObject: any): void;
  111005. /**
  111006. * Adds all the elements from the container to the scene
  111007. * @param container the container holding the elements
  111008. */
  111009. addFromContainer(container: AbstractScene): void;
  111010. /**
  111011. * Removes all the elements in the container from the scene
  111012. * @param container contains the elements to remove
  111013. * @param dispose if the removed element should be disposed (default: false)
  111014. */
  111015. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111016. /**
  111017. * Disposes the component and the associated ressources.
  111018. */
  111019. dispose(): void;
  111020. /**
  111021. * Disables audio in the associated scene.
  111022. */
  111023. disableAudio(): void;
  111024. /**
  111025. * Enables audio in the associated scene.
  111026. */
  111027. enableAudio(): void;
  111028. /**
  111029. * Switch audio to headphone output.
  111030. */
  111031. switchAudioModeForHeadphones(): void;
  111032. /**
  111033. * Switch audio to normal speakers.
  111034. */
  111035. switchAudioModeForNormalSpeakers(): void;
  111036. private _cachedCameraDirection;
  111037. private _cachedCameraPosition;
  111038. private _lastCheck;
  111039. private _afterRender;
  111040. }
  111041. }
  111042. declare module BABYLON {
  111043. /**
  111044. * Wraps one or more Sound objects and selects one with random weight for playback.
  111045. */
  111046. export class WeightedSound {
  111047. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111048. loop: boolean;
  111049. private _coneInnerAngle;
  111050. private _coneOuterAngle;
  111051. private _volume;
  111052. /** A Sound is currently playing. */
  111053. isPlaying: boolean;
  111054. /** A Sound is currently paused. */
  111055. isPaused: boolean;
  111056. private _sounds;
  111057. private _weights;
  111058. private _currentIndex?;
  111059. /**
  111060. * Creates a new WeightedSound from the list of sounds given.
  111061. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111062. * @param sounds Array of Sounds that will be selected from.
  111063. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111064. */
  111065. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111066. /**
  111067. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111068. */
  111069. get directionalConeInnerAngle(): number;
  111070. /**
  111071. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111072. */
  111073. set directionalConeInnerAngle(value: number);
  111074. /**
  111075. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111076. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111077. */
  111078. get directionalConeOuterAngle(): number;
  111079. /**
  111080. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111081. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111082. */
  111083. set directionalConeOuterAngle(value: number);
  111084. /**
  111085. * Playback volume.
  111086. */
  111087. get volume(): number;
  111088. /**
  111089. * Playback volume.
  111090. */
  111091. set volume(value: number);
  111092. private _onended;
  111093. /**
  111094. * Suspend playback
  111095. */
  111096. pause(): void;
  111097. /**
  111098. * Stop playback
  111099. */
  111100. stop(): void;
  111101. /**
  111102. * Start playback.
  111103. * @param startOffset Position the clip head at a specific time in seconds.
  111104. */
  111105. play(startOffset?: number): void;
  111106. }
  111107. }
  111108. declare module BABYLON {
  111109. /**
  111110. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111112. */
  111113. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111114. /**
  111115. * Gets the name of the behavior.
  111116. */
  111117. get name(): string;
  111118. /**
  111119. * The easing function used by animations
  111120. */
  111121. static EasingFunction: BackEase;
  111122. /**
  111123. * The easing mode used by animations
  111124. */
  111125. static EasingMode: number;
  111126. /**
  111127. * The duration of the animation, in milliseconds
  111128. */
  111129. transitionDuration: number;
  111130. /**
  111131. * Length of the distance animated by the transition when lower radius is reached
  111132. */
  111133. lowerRadiusTransitionRange: number;
  111134. /**
  111135. * Length of the distance animated by the transition when upper radius is reached
  111136. */
  111137. upperRadiusTransitionRange: number;
  111138. private _autoTransitionRange;
  111139. /**
  111140. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111141. */
  111142. get autoTransitionRange(): boolean;
  111143. /**
  111144. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111145. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111146. */
  111147. set autoTransitionRange(value: boolean);
  111148. private _attachedCamera;
  111149. private _onAfterCheckInputsObserver;
  111150. private _onMeshTargetChangedObserver;
  111151. /**
  111152. * Initializes the behavior.
  111153. */
  111154. init(): void;
  111155. /**
  111156. * Attaches the behavior to its arc rotate camera.
  111157. * @param camera Defines the camera to attach the behavior to
  111158. */
  111159. attach(camera: ArcRotateCamera): void;
  111160. /**
  111161. * Detaches the behavior from its current arc rotate camera.
  111162. */
  111163. detach(): void;
  111164. private _radiusIsAnimating;
  111165. private _radiusBounceTransition;
  111166. private _animatables;
  111167. private _cachedWheelPrecision;
  111168. /**
  111169. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111170. * @param radiusLimit The limit to check against.
  111171. * @return Bool to indicate if at limit.
  111172. */
  111173. private _isRadiusAtLimit;
  111174. /**
  111175. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111176. * @param radiusDelta The delta by which to animate to. Can be negative.
  111177. */
  111178. private _applyBoundRadiusAnimation;
  111179. /**
  111180. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111181. */
  111182. protected _clearAnimationLocks(): void;
  111183. /**
  111184. * Stops and removes all animations that have been applied to the camera
  111185. */
  111186. stopAllAnimations(): void;
  111187. }
  111188. }
  111189. declare module BABYLON {
  111190. /**
  111191. * 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.
  111192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111193. */
  111194. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111195. /**
  111196. * Gets the name of the behavior.
  111197. */
  111198. get name(): string;
  111199. private _mode;
  111200. private _radiusScale;
  111201. private _positionScale;
  111202. private _defaultElevation;
  111203. private _elevationReturnTime;
  111204. private _elevationReturnWaitTime;
  111205. private _zoomStopsAnimation;
  111206. private _framingTime;
  111207. /**
  111208. * The easing function used by animations
  111209. */
  111210. static EasingFunction: ExponentialEase;
  111211. /**
  111212. * The easing mode used by animations
  111213. */
  111214. static EasingMode: number;
  111215. /**
  111216. * Sets the current mode used by the behavior
  111217. */
  111218. set mode(mode: number);
  111219. /**
  111220. * Gets current mode used by the behavior.
  111221. */
  111222. get mode(): number;
  111223. /**
  111224. * Sets the scale applied to the radius (1 by default)
  111225. */
  111226. set radiusScale(radius: number);
  111227. /**
  111228. * Gets the scale applied to the radius
  111229. */
  111230. get radiusScale(): number;
  111231. /**
  111232. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111233. */
  111234. set positionScale(scale: number);
  111235. /**
  111236. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111237. */
  111238. get positionScale(): number;
  111239. /**
  111240. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111241. * behaviour is triggered, in radians.
  111242. */
  111243. set defaultElevation(elevation: number);
  111244. /**
  111245. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111246. * behaviour is triggered, in radians.
  111247. */
  111248. get defaultElevation(): number;
  111249. /**
  111250. * Sets the time (in milliseconds) taken to return to the default beta position.
  111251. * Negative value indicates camera should not return to default.
  111252. */
  111253. set elevationReturnTime(speed: number);
  111254. /**
  111255. * Gets the time (in milliseconds) taken to return to the default beta position.
  111256. * Negative value indicates camera should not return to default.
  111257. */
  111258. get elevationReturnTime(): number;
  111259. /**
  111260. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111261. */
  111262. set elevationReturnWaitTime(time: number);
  111263. /**
  111264. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111265. */
  111266. get elevationReturnWaitTime(): number;
  111267. /**
  111268. * Sets the flag that indicates if user zooming should stop animation.
  111269. */
  111270. set zoomStopsAnimation(flag: boolean);
  111271. /**
  111272. * Gets the flag that indicates if user zooming should stop animation.
  111273. */
  111274. get zoomStopsAnimation(): boolean;
  111275. /**
  111276. * Sets the transition time when framing the mesh, in milliseconds
  111277. */
  111278. set framingTime(time: number);
  111279. /**
  111280. * Gets the transition time when framing the mesh, in milliseconds
  111281. */
  111282. get framingTime(): number;
  111283. /**
  111284. * Define if the behavior should automatically change the configured
  111285. * camera limits and sensibilities.
  111286. */
  111287. autoCorrectCameraLimitsAndSensibility: boolean;
  111288. private _onPrePointerObservableObserver;
  111289. private _onAfterCheckInputsObserver;
  111290. private _onMeshTargetChangedObserver;
  111291. private _attachedCamera;
  111292. private _isPointerDown;
  111293. private _lastInteractionTime;
  111294. /**
  111295. * Initializes the behavior.
  111296. */
  111297. init(): void;
  111298. /**
  111299. * Attaches the behavior to its arc rotate camera.
  111300. * @param camera Defines the camera to attach the behavior to
  111301. */
  111302. attach(camera: ArcRotateCamera): void;
  111303. /**
  111304. * Detaches the behavior from its current arc rotate camera.
  111305. */
  111306. detach(): void;
  111307. private _animatables;
  111308. private _betaIsAnimating;
  111309. private _betaTransition;
  111310. private _radiusTransition;
  111311. private _vectorTransition;
  111312. /**
  111313. * Targets the given mesh 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. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111321. /**
  111322. * Targets the given mesh with its children and updates zoom level accordingly.
  111323. * @param mesh 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. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111330. /**
  111331. * Targets the given meshes with their children and updates zoom level accordingly.
  111332. * @param meshes The mesh to target.
  111333. * @param radius Optional. If a cached radius position already exists, overrides default.
  111334. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111335. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111336. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111337. */
  111338. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111339. /**
  111340. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111341. * @param minimumWorld Determines the smaller position of the bounding box extend
  111342. * @param maximumWorld Determines the bigger position of the bounding box extend
  111343. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111344. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111345. */
  111346. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111347. /**
  111348. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111349. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111350. * frustum width.
  111351. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111352. * to fully enclose the mesh in the viewing frustum.
  111353. */
  111354. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111355. /**
  111356. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111357. * is automatically returned to its default position (expected to be above ground plane).
  111358. */
  111359. private _maintainCameraAboveGround;
  111360. /**
  111361. * Returns the frustum slope based on the canvas ratio and camera FOV
  111362. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111363. */
  111364. private _getFrustumSlope;
  111365. /**
  111366. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111367. */
  111368. private _clearAnimationLocks;
  111369. /**
  111370. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111371. */
  111372. private _applyUserInteraction;
  111373. /**
  111374. * Stops and removes all animations that have been applied to the camera
  111375. */
  111376. stopAllAnimations(): void;
  111377. /**
  111378. * Gets a value indicating if the user is moving the camera
  111379. */
  111380. get isUserIsMoving(): boolean;
  111381. /**
  111382. * The camera can move all the way towards the mesh.
  111383. */
  111384. static IgnoreBoundsSizeMode: number;
  111385. /**
  111386. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111387. */
  111388. static FitFrustumSidesMode: number;
  111389. }
  111390. }
  111391. declare module BABYLON {
  111392. /**
  111393. * Base class for Camera Pointer Inputs.
  111394. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111395. * for example usage.
  111396. */
  111397. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111398. /**
  111399. * Defines the camera the input is attached to.
  111400. */
  111401. abstract camera: Camera;
  111402. /**
  111403. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111404. */
  111405. protected _altKey: boolean;
  111406. protected _ctrlKey: boolean;
  111407. protected _metaKey: boolean;
  111408. protected _shiftKey: boolean;
  111409. /**
  111410. * Which mouse buttons were pressed at time of last mouse event.
  111411. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111412. */
  111413. protected _buttonsPressed: number;
  111414. /**
  111415. * Defines the buttons associated with the input to handle camera move.
  111416. */
  111417. buttons: number[];
  111418. /**
  111419. * Attach the input controls to a specific dom element to get the input from.
  111420. * @param element Defines the element the controls should be listened from
  111421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111422. */
  111423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111424. /**
  111425. * Detach the current controls from the specified dom element.
  111426. * @param element Defines the element to stop listening the inputs from
  111427. */
  111428. detachControl(element: Nullable<HTMLElement>): void;
  111429. /**
  111430. * Gets the class name of the current input.
  111431. * @returns the class name
  111432. */
  111433. getClassName(): string;
  111434. /**
  111435. * Get the friendly name associated with the input class.
  111436. * @returns the input friendly name
  111437. */
  111438. getSimpleName(): string;
  111439. /**
  111440. * Called on pointer POINTERDOUBLETAP event.
  111441. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111442. */
  111443. protected onDoubleTap(type: string): void;
  111444. /**
  111445. * Called on pointer POINTERMOVE event if only a single touch is active.
  111446. * Override this method to provide functionality.
  111447. */
  111448. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111449. /**
  111450. * Called on pointer POINTERMOVE event if multiple touches are active.
  111451. * Override this method to provide functionality.
  111452. */
  111453. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111454. /**
  111455. * Called on JS contextmenu event.
  111456. * Override this method to provide functionality.
  111457. */
  111458. protected onContextMenu(evt: PointerEvent): void;
  111459. /**
  111460. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111461. * press.
  111462. * Override this method to provide functionality.
  111463. */
  111464. protected onButtonDown(evt: PointerEvent): void;
  111465. /**
  111466. * Called each time a new POINTERUP event occurs. Ie, for each button
  111467. * release.
  111468. * Override this method to provide functionality.
  111469. */
  111470. protected onButtonUp(evt: PointerEvent): void;
  111471. /**
  111472. * Called when window becomes inactive.
  111473. * Override this method to provide functionality.
  111474. */
  111475. protected onLostFocus(): void;
  111476. private _pointerInput;
  111477. private _observer;
  111478. private _onLostFocus;
  111479. private pointA;
  111480. private pointB;
  111481. }
  111482. }
  111483. declare module BABYLON {
  111484. /**
  111485. * Manage the pointers inputs to control an arc rotate camera.
  111486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111487. */
  111488. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111489. /**
  111490. * Defines the camera the input is attached to.
  111491. */
  111492. camera: ArcRotateCamera;
  111493. /**
  111494. * Gets the class name of the current input.
  111495. * @returns the class name
  111496. */
  111497. getClassName(): string;
  111498. /**
  111499. * Defines the buttons associated with the input to handle camera move.
  111500. */
  111501. buttons: number[];
  111502. /**
  111503. * Defines the pointer angular sensibility along the X axis or how fast is
  111504. * the camera rotating.
  111505. */
  111506. angularSensibilityX: number;
  111507. /**
  111508. * Defines the pointer angular sensibility along the Y axis or how fast is
  111509. * the camera rotating.
  111510. */
  111511. angularSensibilityY: number;
  111512. /**
  111513. * Defines the pointer pinch precision or how fast is the camera zooming.
  111514. */
  111515. pinchPrecision: number;
  111516. /**
  111517. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111518. * from 0.
  111519. * It defines the percentage of current camera.radius to use as delta when
  111520. * pinch zoom is used.
  111521. */
  111522. pinchDeltaPercentage: number;
  111523. /**
  111524. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111525. * that any object in the plane at the camera's target point will scale
  111526. * perfectly with finger motion.
  111527. * Overrides pinchDeltaPercentage and pinchPrecision.
  111528. */
  111529. useNaturalPinchZoom: boolean;
  111530. /**
  111531. * Defines the pointer panning sensibility or how fast is the camera moving.
  111532. */
  111533. panningSensibility: number;
  111534. /**
  111535. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111536. */
  111537. multiTouchPanning: boolean;
  111538. /**
  111539. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111540. * zoom (pinch) through multitouch.
  111541. */
  111542. multiTouchPanAndZoom: boolean;
  111543. /**
  111544. * Revers pinch action direction.
  111545. */
  111546. pinchInwards: boolean;
  111547. private _isPanClick;
  111548. private _twoFingerActivityCount;
  111549. private _isPinching;
  111550. /**
  111551. * Called on pointer POINTERMOVE event if only a single touch is active.
  111552. */
  111553. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111554. /**
  111555. * Called on pointer POINTERDOUBLETAP event.
  111556. */
  111557. protected onDoubleTap(type: string): void;
  111558. /**
  111559. * Called on pointer POINTERMOVE event if multiple touches are active.
  111560. */
  111561. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111562. /**
  111563. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111564. * press.
  111565. */
  111566. protected onButtonDown(evt: PointerEvent): void;
  111567. /**
  111568. * Called each time a new POINTERUP event occurs. Ie, for each button
  111569. * release.
  111570. */
  111571. protected onButtonUp(evt: PointerEvent): void;
  111572. /**
  111573. * Called when window becomes inactive.
  111574. */
  111575. protected onLostFocus(): void;
  111576. }
  111577. }
  111578. declare module BABYLON {
  111579. /**
  111580. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111582. */
  111583. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111584. /**
  111585. * Defines the camera the input is attached to.
  111586. */
  111587. camera: ArcRotateCamera;
  111588. /**
  111589. * Defines the list of key codes associated with the up action (increase alpha)
  111590. */
  111591. keysUp: number[];
  111592. /**
  111593. * Defines the list of key codes associated with the down action (decrease alpha)
  111594. */
  111595. keysDown: number[];
  111596. /**
  111597. * Defines the list of key codes associated with the left action (increase beta)
  111598. */
  111599. keysLeft: number[];
  111600. /**
  111601. * Defines the list of key codes associated with the right action (decrease beta)
  111602. */
  111603. keysRight: number[];
  111604. /**
  111605. * Defines the list of key codes associated with the reset action.
  111606. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111607. */
  111608. keysReset: number[];
  111609. /**
  111610. * Defines the panning sensibility of the inputs.
  111611. * (How fast is the camera panning)
  111612. */
  111613. panningSensibility: number;
  111614. /**
  111615. * Defines the zooming sensibility of the inputs.
  111616. * (How fast is the camera zooming)
  111617. */
  111618. zoomingSensibility: number;
  111619. /**
  111620. * Defines whether maintaining the alt key down switch the movement mode from
  111621. * orientation to zoom.
  111622. */
  111623. useAltToZoom: boolean;
  111624. /**
  111625. * Rotation speed of the camera
  111626. */
  111627. angularSpeed: number;
  111628. private _keys;
  111629. private _ctrlPressed;
  111630. private _altPressed;
  111631. private _onCanvasBlurObserver;
  111632. private _onKeyboardObserver;
  111633. private _engine;
  111634. private _scene;
  111635. /**
  111636. * Attach the input controls to a specific dom element to get the input from.
  111637. * @param element Defines the element the controls should be listened from
  111638. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111639. */
  111640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111641. /**
  111642. * Detach the current controls from the specified dom element.
  111643. * @param element Defines the element to stop listening the inputs from
  111644. */
  111645. detachControl(element: Nullable<HTMLElement>): void;
  111646. /**
  111647. * Update the current camera state depending on the inputs that have been used this frame.
  111648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111649. */
  111650. checkInputs(): void;
  111651. /**
  111652. * Gets the class name of the current intput.
  111653. * @returns the class name
  111654. */
  111655. getClassName(): string;
  111656. /**
  111657. * Get the friendly name associated with the input class.
  111658. * @returns the input friendly name
  111659. */
  111660. getSimpleName(): string;
  111661. }
  111662. }
  111663. declare module BABYLON {
  111664. /**
  111665. * Manage the mouse wheel inputs to control an arc rotate camera.
  111666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111667. */
  111668. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111669. /**
  111670. * Defines the camera the input is attached to.
  111671. */
  111672. camera: ArcRotateCamera;
  111673. /**
  111674. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111675. */
  111676. wheelPrecision: number;
  111677. /**
  111678. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111679. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111680. */
  111681. wheelDeltaPercentage: number;
  111682. private _wheel;
  111683. private _observer;
  111684. private computeDeltaFromMouseWheelLegacyEvent;
  111685. /**
  111686. * Attach the input controls to a specific dom element to get the input from.
  111687. * @param element Defines the element the controls should be listened from
  111688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111689. */
  111690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111691. /**
  111692. * Detach the current controls from the specified dom element.
  111693. * @param element Defines the element to stop listening the inputs from
  111694. */
  111695. detachControl(element: Nullable<HTMLElement>): void;
  111696. /**
  111697. * Gets the class name of the current intput.
  111698. * @returns the class name
  111699. */
  111700. getClassName(): string;
  111701. /**
  111702. * Get the friendly name associated with the input class.
  111703. * @returns the input friendly name
  111704. */
  111705. getSimpleName(): string;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * Default Inputs manager for the ArcRotateCamera.
  111711. * It groups all the default supported inputs for ease of use.
  111712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111713. */
  111714. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111715. /**
  111716. * Instantiates a new ArcRotateCameraInputsManager.
  111717. * @param camera Defines the camera the inputs belong to
  111718. */
  111719. constructor(camera: ArcRotateCamera);
  111720. /**
  111721. * Add mouse wheel input support to the input manager.
  111722. * @returns the current input manager
  111723. */
  111724. addMouseWheel(): ArcRotateCameraInputsManager;
  111725. /**
  111726. * Add pointers input support to the input manager.
  111727. * @returns the current input manager
  111728. */
  111729. addPointers(): ArcRotateCameraInputsManager;
  111730. /**
  111731. * Add keyboard input support to the input manager.
  111732. * @returns the current input manager
  111733. */
  111734. addKeyboard(): ArcRotateCameraInputsManager;
  111735. }
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * This represents an orbital type of camera.
  111740. *
  111741. * 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.
  111742. * 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.
  111743. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111744. */
  111745. export class ArcRotateCamera extends TargetCamera {
  111746. /**
  111747. * Defines the rotation angle of the camera along the longitudinal axis.
  111748. */
  111749. alpha: number;
  111750. /**
  111751. * Defines the rotation angle of the camera along the latitudinal axis.
  111752. */
  111753. beta: number;
  111754. /**
  111755. * Defines the radius of the camera from it s target point.
  111756. */
  111757. radius: number;
  111758. protected _target: Vector3;
  111759. protected _targetHost: Nullable<AbstractMesh>;
  111760. /**
  111761. * Defines the target point of the camera.
  111762. * The camera looks towards it form the radius distance.
  111763. */
  111764. get target(): Vector3;
  111765. set target(value: Vector3);
  111766. /**
  111767. * Define the current local position of the camera in the scene
  111768. */
  111769. get position(): Vector3;
  111770. set position(newPosition: Vector3);
  111771. protected _upVector: Vector3;
  111772. protected _upToYMatrix: Matrix;
  111773. protected _YToUpMatrix: Matrix;
  111774. /**
  111775. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111776. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111777. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111778. */
  111779. set upVector(vec: Vector3);
  111780. get upVector(): Vector3;
  111781. /**
  111782. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111783. */
  111784. setMatUp(): void;
  111785. /**
  111786. * Current inertia value on the longitudinal axis.
  111787. * The bigger this number the longer it will take for the camera to stop.
  111788. */
  111789. inertialAlphaOffset: number;
  111790. /**
  111791. * Current inertia value on the latitudinal axis.
  111792. * The bigger this number the longer it will take for the camera to stop.
  111793. */
  111794. inertialBetaOffset: number;
  111795. /**
  111796. * Current inertia value on the radius axis.
  111797. * The bigger this number the longer it will take for the camera to stop.
  111798. */
  111799. inertialRadiusOffset: number;
  111800. /**
  111801. * Minimum allowed angle on the longitudinal axis.
  111802. * This can help limiting how the Camera is able to move in the scene.
  111803. */
  111804. lowerAlphaLimit: Nullable<number>;
  111805. /**
  111806. * Maximum allowed angle on the longitudinal axis.
  111807. * This can help limiting how the Camera is able to move in the scene.
  111808. */
  111809. upperAlphaLimit: Nullable<number>;
  111810. /**
  111811. * Minimum allowed angle on the latitudinal axis.
  111812. * This can help limiting how the Camera is able to move in the scene.
  111813. */
  111814. lowerBetaLimit: number;
  111815. /**
  111816. * Maximum allowed angle on the latitudinal axis.
  111817. * This can help limiting how the Camera is able to move in the scene.
  111818. */
  111819. upperBetaLimit: number;
  111820. /**
  111821. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111822. * This can help limiting how the Camera is able to move in the scene.
  111823. */
  111824. lowerRadiusLimit: Nullable<number>;
  111825. /**
  111826. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111827. * This can help limiting how the Camera is able to move in the scene.
  111828. */
  111829. upperRadiusLimit: Nullable<number>;
  111830. /**
  111831. * Defines the current inertia value used during panning of the camera along the X axis.
  111832. */
  111833. inertialPanningX: number;
  111834. /**
  111835. * Defines the current inertia value used during panning of the camera along the Y axis.
  111836. */
  111837. inertialPanningY: number;
  111838. /**
  111839. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111840. * Basically if your fingers moves away from more than this distance you will be considered
  111841. * in pinch mode.
  111842. */
  111843. pinchToPanMaxDistance: number;
  111844. /**
  111845. * Defines the maximum distance the camera can pan.
  111846. * This could help keeping the cammera always in your scene.
  111847. */
  111848. panningDistanceLimit: Nullable<number>;
  111849. /**
  111850. * Defines the target of the camera before paning.
  111851. */
  111852. panningOriginTarget: Vector3;
  111853. /**
  111854. * Defines the value of the inertia used during panning.
  111855. * 0 would mean stop inertia and one would mean no decelleration at all.
  111856. */
  111857. panningInertia: number;
  111858. /**
  111859. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111860. */
  111861. get angularSensibilityX(): number;
  111862. set angularSensibilityX(value: number);
  111863. /**
  111864. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111865. */
  111866. get angularSensibilityY(): number;
  111867. set angularSensibilityY(value: number);
  111868. /**
  111869. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111870. */
  111871. get pinchPrecision(): number;
  111872. set pinchPrecision(value: number);
  111873. /**
  111874. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111875. * It will be used instead of pinchDeltaPrecision if different from 0.
  111876. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111877. */
  111878. get pinchDeltaPercentage(): number;
  111879. set pinchDeltaPercentage(value: number);
  111880. /**
  111881. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111882. * and pinch delta percentage.
  111883. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111884. * that any object in the plane at the camera's target point will scale
  111885. * perfectly with finger motion.
  111886. */
  111887. get useNaturalPinchZoom(): boolean;
  111888. set useNaturalPinchZoom(value: boolean);
  111889. /**
  111890. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111891. */
  111892. get panningSensibility(): number;
  111893. set panningSensibility(value: number);
  111894. /**
  111895. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111896. */
  111897. get keysUp(): number[];
  111898. set keysUp(value: number[]);
  111899. /**
  111900. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111901. */
  111902. get keysDown(): number[];
  111903. set keysDown(value: number[]);
  111904. /**
  111905. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111906. */
  111907. get keysLeft(): number[];
  111908. set keysLeft(value: number[]);
  111909. /**
  111910. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111911. */
  111912. get keysRight(): number[];
  111913. set keysRight(value: number[]);
  111914. /**
  111915. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111916. */
  111917. get wheelPrecision(): number;
  111918. set wheelPrecision(value: number);
  111919. /**
  111920. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111921. * It will be used instead of pinchDeltaPrecision if different from 0.
  111922. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111923. */
  111924. get wheelDeltaPercentage(): number;
  111925. set wheelDeltaPercentage(value: number);
  111926. /**
  111927. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111928. */
  111929. zoomOnFactor: number;
  111930. /**
  111931. * Defines a screen offset for the camera position.
  111932. */
  111933. targetScreenOffset: Vector2;
  111934. /**
  111935. * Allows the camera to be completely reversed.
  111936. * If false the camera can not arrive upside down.
  111937. */
  111938. allowUpsideDown: boolean;
  111939. /**
  111940. * Define if double tap/click is used to restore the previously saved state of the camera.
  111941. */
  111942. useInputToRestoreState: boolean;
  111943. /** @hidden */
  111944. _viewMatrix: Matrix;
  111945. /** @hidden */
  111946. _useCtrlForPanning: boolean;
  111947. /** @hidden */
  111948. _panningMouseButton: number;
  111949. /**
  111950. * Defines the input associated to the camera.
  111951. */
  111952. inputs: ArcRotateCameraInputsManager;
  111953. /** @hidden */
  111954. _reset: () => void;
  111955. /**
  111956. * Defines the allowed panning axis.
  111957. */
  111958. panningAxis: Vector3;
  111959. protected _localDirection: Vector3;
  111960. protected _transformedDirection: Vector3;
  111961. private _bouncingBehavior;
  111962. /**
  111963. * Gets the bouncing behavior of the camera if it has been enabled.
  111964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111965. */
  111966. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111967. /**
  111968. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111969. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111970. */
  111971. get useBouncingBehavior(): boolean;
  111972. set useBouncingBehavior(value: boolean);
  111973. private _framingBehavior;
  111974. /**
  111975. * Gets the framing behavior of the camera if it has been enabled.
  111976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111977. */
  111978. get framingBehavior(): Nullable<FramingBehavior>;
  111979. /**
  111980. * Defines if the framing behavior of the camera is enabled on the camera.
  111981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111982. */
  111983. get useFramingBehavior(): boolean;
  111984. set useFramingBehavior(value: boolean);
  111985. private _autoRotationBehavior;
  111986. /**
  111987. * Gets the auto rotation behavior of the camera if it has been enabled.
  111988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111989. */
  111990. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111991. /**
  111992. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111994. */
  111995. get useAutoRotationBehavior(): boolean;
  111996. set useAutoRotationBehavior(value: boolean);
  111997. /**
  111998. * Observable triggered when the mesh target has been changed on the camera.
  111999. */
  112000. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112001. /**
  112002. * Event raised when the camera is colliding with a mesh.
  112003. */
  112004. onCollide: (collidedMesh: AbstractMesh) => void;
  112005. /**
  112006. * Defines whether the camera should check collision with the objects oh the scene.
  112007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112008. */
  112009. checkCollisions: boolean;
  112010. /**
  112011. * Defines the collision radius of the camera.
  112012. * This simulates a sphere around the camera.
  112013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112014. */
  112015. collisionRadius: Vector3;
  112016. protected _collider: Collider;
  112017. protected _previousPosition: Vector3;
  112018. protected _collisionVelocity: Vector3;
  112019. protected _newPosition: Vector3;
  112020. protected _previousAlpha: number;
  112021. protected _previousBeta: number;
  112022. protected _previousRadius: number;
  112023. protected _collisionTriggered: boolean;
  112024. protected _targetBoundingCenter: Nullable<Vector3>;
  112025. private _computationVector;
  112026. /**
  112027. * Instantiates a new ArcRotateCamera in a given scene
  112028. * @param name Defines the name of the camera
  112029. * @param alpha Defines the camera rotation along the logitudinal axis
  112030. * @param beta Defines the camera rotation along the latitudinal axis
  112031. * @param radius Defines the camera distance from its target
  112032. * @param target Defines the camera target
  112033. * @param scene Defines the scene the camera belongs to
  112034. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112035. */
  112036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112037. /** @hidden */
  112038. _initCache(): void;
  112039. /** @hidden */
  112040. _updateCache(ignoreParentClass?: boolean): void;
  112041. protected _getTargetPosition(): Vector3;
  112042. private _storedAlpha;
  112043. private _storedBeta;
  112044. private _storedRadius;
  112045. private _storedTarget;
  112046. private _storedTargetScreenOffset;
  112047. /**
  112048. * Stores the current state of the camera (alpha, beta, radius and target)
  112049. * @returns the camera itself
  112050. */
  112051. storeState(): Camera;
  112052. /**
  112053. * @hidden
  112054. * Restored camera state. You must call storeState() first
  112055. */
  112056. _restoreStateValues(): boolean;
  112057. /** @hidden */
  112058. _isSynchronizedViewMatrix(): boolean;
  112059. /**
  112060. * Attached controls to the current camera.
  112061. * @param element Defines the element the controls should be listened from
  112062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112063. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112064. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112065. */
  112066. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112067. /**
  112068. * Detach the current controls from the camera.
  112069. * The camera will stop reacting to inputs.
  112070. * @param element Defines the element to stop listening the inputs from
  112071. */
  112072. detachControl(element: HTMLElement): void;
  112073. /** @hidden */
  112074. _checkInputs(): void;
  112075. protected _checkLimits(): void;
  112076. /**
  112077. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112078. */
  112079. rebuildAnglesAndRadius(): void;
  112080. /**
  112081. * Use a position to define the current camera related information like alpha, beta and radius
  112082. * @param position Defines the position to set the camera at
  112083. */
  112084. setPosition(position: Vector3): void;
  112085. /**
  112086. * Defines the target the camera should look at.
  112087. * This will automatically adapt alpha beta and radius to fit within the new target.
  112088. * @param target Defines the new target as a Vector or a mesh
  112089. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112090. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112091. */
  112092. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112093. /** @hidden */
  112094. _getViewMatrix(): Matrix;
  112095. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112096. /**
  112097. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112098. * @param meshes Defines the mesh to zoom on
  112099. * @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)
  112100. */
  112101. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112102. /**
  112103. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112104. * The target will be changed but the radius
  112105. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112106. * @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)
  112107. */
  112108. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112109. min: Vector3;
  112110. max: Vector3;
  112111. distance: number;
  112112. }, doNotUpdateMaxZ?: boolean): void;
  112113. /**
  112114. * @override
  112115. * Override Camera.createRigCamera
  112116. */
  112117. createRigCamera(name: string, cameraIndex: number): Camera;
  112118. /**
  112119. * @hidden
  112120. * @override
  112121. * Override Camera._updateRigCameras
  112122. */
  112123. _updateRigCameras(): void;
  112124. /**
  112125. * Destroy the camera and release the current resources hold by it.
  112126. */
  112127. dispose(): void;
  112128. /**
  112129. * Gets the current object class name.
  112130. * @return the class name
  112131. */
  112132. getClassName(): string;
  112133. }
  112134. }
  112135. declare module BABYLON {
  112136. /**
  112137. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112139. */
  112140. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112141. /**
  112142. * Gets the name of the behavior.
  112143. */
  112144. get name(): string;
  112145. private _zoomStopsAnimation;
  112146. private _idleRotationSpeed;
  112147. private _idleRotationWaitTime;
  112148. private _idleRotationSpinupTime;
  112149. /**
  112150. * Sets the flag that indicates if user zooming should stop animation.
  112151. */
  112152. set zoomStopsAnimation(flag: boolean);
  112153. /**
  112154. * Gets the flag that indicates if user zooming should stop animation.
  112155. */
  112156. get zoomStopsAnimation(): boolean;
  112157. /**
  112158. * Sets the default speed at which the camera rotates around the model.
  112159. */
  112160. set idleRotationSpeed(speed: number);
  112161. /**
  112162. * Gets the default speed at which the camera rotates around the model.
  112163. */
  112164. get idleRotationSpeed(): number;
  112165. /**
  112166. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112167. */
  112168. set idleRotationWaitTime(time: number);
  112169. /**
  112170. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112171. */
  112172. get idleRotationWaitTime(): number;
  112173. /**
  112174. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112175. */
  112176. set idleRotationSpinupTime(time: number);
  112177. /**
  112178. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112179. */
  112180. get idleRotationSpinupTime(): number;
  112181. /**
  112182. * Gets a value indicating if the camera is currently rotating because of this behavior
  112183. */
  112184. get rotationInProgress(): boolean;
  112185. private _onPrePointerObservableObserver;
  112186. private _onAfterCheckInputsObserver;
  112187. private _attachedCamera;
  112188. private _isPointerDown;
  112189. private _lastFrameTime;
  112190. private _lastInteractionTime;
  112191. private _cameraRotationSpeed;
  112192. /**
  112193. * Initializes the behavior.
  112194. */
  112195. init(): void;
  112196. /**
  112197. * Attaches the behavior to its arc rotate camera.
  112198. * @param camera Defines the camera to attach the behavior to
  112199. */
  112200. attach(camera: ArcRotateCamera): void;
  112201. /**
  112202. * Detaches the behavior from its current arc rotate camera.
  112203. */
  112204. detach(): void;
  112205. /**
  112206. * Returns true if user is scrolling.
  112207. * @return true if user is scrolling.
  112208. */
  112209. private _userIsZooming;
  112210. private _lastFrameRadius;
  112211. private _shouldAnimationStopForInteraction;
  112212. /**
  112213. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112214. */
  112215. private _applyUserInteraction;
  112216. private _userIsMoving;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112222. */
  112223. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112224. private ui;
  112225. /**
  112226. * The name of the behavior
  112227. */
  112228. name: string;
  112229. /**
  112230. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112231. */
  112232. distanceAwayFromFace: number;
  112233. /**
  112234. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112235. */
  112236. distanceAwayFromBottomOfFace: number;
  112237. private _faceVectors;
  112238. private _target;
  112239. private _scene;
  112240. private _onRenderObserver;
  112241. private _tmpMatrix;
  112242. private _tmpVector;
  112243. /**
  112244. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112245. * @param ui The transform node that should be attched to the mesh
  112246. */
  112247. constructor(ui: TransformNode);
  112248. /**
  112249. * Initializes the behavior
  112250. */
  112251. init(): void;
  112252. private _closestFace;
  112253. private _zeroVector;
  112254. private _lookAtTmpMatrix;
  112255. private _lookAtToRef;
  112256. /**
  112257. * Attaches the AttachToBoxBehavior to the passed in mesh
  112258. * @param target The mesh that the specified node will be attached to
  112259. */
  112260. attach(target: Mesh): void;
  112261. /**
  112262. * Detaches the behavior from the mesh
  112263. */
  112264. detach(): void;
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. /**
  112269. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112270. */
  112271. export class FadeInOutBehavior implements Behavior<Mesh> {
  112272. /**
  112273. * Time in milliseconds to delay before fading in (Default: 0)
  112274. */
  112275. delay: number;
  112276. /**
  112277. * Time in milliseconds for the mesh to fade in (Default: 300)
  112278. */
  112279. fadeInTime: number;
  112280. private _millisecondsPerFrame;
  112281. private _hovered;
  112282. private _hoverValue;
  112283. private _ownerNode;
  112284. /**
  112285. * Instatiates the FadeInOutBehavior
  112286. */
  112287. constructor();
  112288. /**
  112289. * The name of the behavior
  112290. */
  112291. get name(): string;
  112292. /**
  112293. * Initializes the behavior
  112294. */
  112295. init(): void;
  112296. /**
  112297. * Attaches the fade behavior on the passed in mesh
  112298. * @param ownerNode The mesh that will be faded in/out once attached
  112299. */
  112300. attach(ownerNode: Mesh): void;
  112301. /**
  112302. * Detaches the behavior from the mesh
  112303. */
  112304. detach(): void;
  112305. /**
  112306. * Triggers the mesh to begin fading in or out
  112307. * @param value if the object should fade in or out (true to fade in)
  112308. */
  112309. fadeIn(value: boolean): void;
  112310. private _update;
  112311. private _setAllVisibility;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * Class containing a set of static utilities functions for managing Pivots
  112317. * @hidden
  112318. */
  112319. export class PivotTools {
  112320. private static _PivotCached;
  112321. private static _OldPivotPoint;
  112322. private static _PivotTranslation;
  112323. private static _PivotTmpVector;
  112324. /** @hidden */
  112325. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112326. /** @hidden */
  112327. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112328. }
  112329. }
  112330. declare module BABYLON {
  112331. /**
  112332. * Class containing static functions to help procedurally build meshes
  112333. */
  112334. export class PlaneBuilder {
  112335. /**
  112336. * Creates a plane mesh
  112337. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112338. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112339. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112343. * @param name defines the name of the mesh
  112344. * @param options defines the options used to create the mesh
  112345. * @param scene defines the hosting scene
  112346. * @returns the plane mesh
  112347. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112348. */
  112349. static CreatePlane(name: string, options: {
  112350. size?: number;
  112351. width?: number;
  112352. height?: number;
  112353. sideOrientation?: number;
  112354. frontUVs?: Vector4;
  112355. backUVs?: Vector4;
  112356. updatable?: boolean;
  112357. sourcePlane?: Plane;
  112358. }, scene?: Nullable<Scene>): Mesh;
  112359. }
  112360. }
  112361. declare module BABYLON {
  112362. /**
  112363. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112364. */
  112365. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112366. private static _AnyMouseID;
  112367. /**
  112368. * Abstract mesh the behavior is set on
  112369. */
  112370. attachedNode: AbstractMesh;
  112371. private _dragPlane;
  112372. private _scene;
  112373. private _pointerObserver;
  112374. private _beforeRenderObserver;
  112375. private static _planeScene;
  112376. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112377. /**
  112378. * 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)
  112379. */
  112380. maxDragAngle: number;
  112381. /**
  112382. * @hidden
  112383. */
  112384. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112385. /**
  112386. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112387. */
  112388. currentDraggingPointerID: number;
  112389. /**
  112390. * The last position where the pointer hit the drag plane in world space
  112391. */
  112392. lastDragPosition: Vector3;
  112393. /**
  112394. * If the behavior is currently in a dragging state
  112395. */
  112396. dragging: boolean;
  112397. /**
  112398. * 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)
  112399. */
  112400. dragDeltaRatio: number;
  112401. /**
  112402. * If the drag plane orientation should be updated during the dragging (Default: true)
  112403. */
  112404. updateDragPlane: boolean;
  112405. private _debugMode;
  112406. private _moving;
  112407. /**
  112408. * Fires each time the attached mesh is dragged with the pointer
  112409. * * delta between last drag position and current drag position in world space
  112410. * * dragDistance along the drag axis
  112411. * * dragPlaneNormal normal of the current drag plane used during the drag
  112412. * * dragPlanePoint in world space where the drag intersects the drag plane
  112413. */
  112414. onDragObservable: Observable<{
  112415. delta: Vector3;
  112416. dragPlanePoint: Vector3;
  112417. dragPlaneNormal: Vector3;
  112418. dragDistance: number;
  112419. pointerId: number;
  112420. }>;
  112421. /**
  112422. * Fires each time a drag begins (eg. mouse down on mesh)
  112423. */
  112424. onDragStartObservable: Observable<{
  112425. dragPlanePoint: Vector3;
  112426. pointerId: number;
  112427. }>;
  112428. /**
  112429. * Fires each time a drag ends (eg. mouse release after drag)
  112430. */
  112431. onDragEndObservable: Observable<{
  112432. dragPlanePoint: Vector3;
  112433. pointerId: number;
  112434. }>;
  112435. /**
  112436. * If the attached mesh should be moved when dragged
  112437. */
  112438. moveAttached: boolean;
  112439. /**
  112440. * If the drag behavior will react to drag events (Default: true)
  112441. */
  112442. enabled: boolean;
  112443. /**
  112444. * If pointer events should start and release the drag (Default: true)
  112445. */
  112446. startAndReleaseDragOnPointerEvents: boolean;
  112447. /**
  112448. * If camera controls should be detached during the drag
  112449. */
  112450. detachCameraControls: boolean;
  112451. /**
  112452. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112453. */
  112454. useObjectOrientationForDragging: boolean;
  112455. private _options;
  112456. /**
  112457. * Gets the options used by the behavior
  112458. */
  112459. get options(): {
  112460. dragAxis?: Vector3;
  112461. dragPlaneNormal?: Vector3;
  112462. };
  112463. /**
  112464. * Sets the options used by the behavior
  112465. */
  112466. set options(options: {
  112467. dragAxis?: Vector3;
  112468. dragPlaneNormal?: Vector3;
  112469. });
  112470. /**
  112471. * Creates a pointer drag behavior that can be attached to a mesh
  112472. * @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)
  112473. */
  112474. constructor(options?: {
  112475. dragAxis?: Vector3;
  112476. dragPlaneNormal?: Vector3;
  112477. });
  112478. /**
  112479. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112480. */
  112481. validateDrag: (targetPosition: Vector3) => boolean;
  112482. /**
  112483. * The name of the behavior
  112484. */
  112485. get name(): string;
  112486. /**
  112487. * Initializes the behavior
  112488. */
  112489. init(): void;
  112490. private _tmpVector;
  112491. private _alternatePickedPoint;
  112492. private _worldDragAxis;
  112493. private _targetPosition;
  112494. private _attachedElement;
  112495. /**
  112496. * Attaches the drag behavior the passed in mesh
  112497. * @param ownerNode The mesh that will be dragged around once attached
  112498. * @param predicate Predicate to use for pick filtering
  112499. */
  112500. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112501. /**
  112502. * Force relase the drag action by code.
  112503. */
  112504. releaseDrag(): void;
  112505. private _startDragRay;
  112506. private _lastPointerRay;
  112507. /**
  112508. * Simulates the start of a pointer drag event on the behavior
  112509. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112510. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112511. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112512. */
  112513. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112514. private _startDrag;
  112515. private _dragDelta;
  112516. private _moveDrag;
  112517. private _pickWithRayOnDragPlane;
  112518. private _pointA;
  112519. private _pointB;
  112520. private _pointC;
  112521. private _lineA;
  112522. private _lineB;
  112523. private _localAxis;
  112524. private _lookAt;
  112525. private _updateDragPlanePosition;
  112526. /**
  112527. * Detaches the behavior from the mesh
  112528. */
  112529. detach(): void;
  112530. }
  112531. }
  112532. declare module BABYLON {
  112533. /**
  112534. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112535. */
  112536. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112537. private _dragBehaviorA;
  112538. private _dragBehaviorB;
  112539. private _startDistance;
  112540. private _initialScale;
  112541. private _targetScale;
  112542. private _ownerNode;
  112543. private _sceneRenderObserver;
  112544. /**
  112545. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112546. */
  112547. constructor();
  112548. /**
  112549. * The name of the behavior
  112550. */
  112551. get name(): string;
  112552. /**
  112553. * Initializes the behavior
  112554. */
  112555. init(): void;
  112556. private _getCurrentDistance;
  112557. /**
  112558. * Attaches the scale behavior the passed in mesh
  112559. * @param ownerNode The mesh that will be scaled around once attached
  112560. */
  112561. attach(ownerNode: Mesh): void;
  112562. /**
  112563. * Detaches the behavior from the mesh
  112564. */
  112565. detach(): void;
  112566. }
  112567. }
  112568. declare module BABYLON {
  112569. /**
  112570. * 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
  112571. */
  112572. export class SixDofDragBehavior implements Behavior<Mesh> {
  112573. private static _virtualScene;
  112574. private _ownerNode;
  112575. private _sceneRenderObserver;
  112576. private _scene;
  112577. private _targetPosition;
  112578. private _virtualOriginMesh;
  112579. private _virtualDragMesh;
  112580. private _pointerObserver;
  112581. private _moving;
  112582. private _startingOrientation;
  112583. /**
  112584. * 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)
  112585. */
  112586. private zDragFactor;
  112587. /**
  112588. * If the object should rotate to face the drag origin
  112589. */
  112590. rotateDraggedObject: boolean;
  112591. /**
  112592. * If the behavior is currently in a dragging state
  112593. */
  112594. dragging: boolean;
  112595. /**
  112596. * 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)
  112597. */
  112598. dragDeltaRatio: number;
  112599. /**
  112600. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112601. */
  112602. currentDraggingPointerID: number;
  112603. /**
  112604. * If camera controls should be detached during the drag
  112605. */
  112606. detachCameraControls: boolean;
  112607. /**
  112608. * Fires each time a drag starts
  112609. */
  112610. onDragStartObservable: Observable<{}>;
  112611. /**
  112612. * Fires each time a drag ends (eg. mouse release after drag)
  112613. */
  112614. onDragEndObservable: Observable<{}>;
  112615. /**
  112616. * 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
  112617. */
  112618. constructor();
  112619. /**
  112620. * The name of the behavior
  112621. */
  112622. get name(): string;
  112623. /**
  112624. * Initializes the behavior
  112625. */
  112626. init(): void;
  112627. /**
  112628. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112629. */
  112630. private get _pointerCamera();
  112631. /**
  112632. * Attaches the scale behavior the passed in mesh
  112633. * @param ownerNode The mesh that will be scaled around once attached
  112634. */
  112635. attach(ownerNode: Mesh): void;
  112636. /**
  112637. * Detaches the behavior from the mesh
  112638. */
  112639. detach(): void;
  112640. }
  112641. }
  112642. declare module BABYLON {
  112643. /**
  112644. * Class used to apply inverse kinematics to bones
  112645. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112646. */
  112647. export class BoneIKController {
  112648. private static _tmpVecs;
  112649. private static _tmpQuat;
  112650. private static _tmpMats;
  112651. /**
  112652. * Gets or sets the target mesh
  112653. */
  112654. targetMesh: AbstractMesh;
  112655. /** Gets or sets the mesh used as pole */
  112656. poleTargetMesh: AbstractMesh;
  112657. /**
  112658. * Gets or sets the bone used as pole
  112659. */
  112660. poleTargetBone: Nullable<Bone>;
  112661. /**
  112662. * Gets or sets the target position
  112663. */
  112664. targetPosition: Vector3;
  112665. /**
  112666. * Gets or sets the pole target position
  112667. */
  112668. poleTargetPosition: Vector3;
  112669. /**
  112670. * Gets or sets the pole target local offset
  112671. */
  112672. poleTargetLocalOffset: Vector3;
  112673. /**
  112674. * Gets or sets the pole angle
  112675. */
  112676. poleAngle: number;
  112677. /**
  112678. * Gets or sets the mesh associated with the controller
  112679. */
  112680. mesh: AbstractMesh;
  112681. /**
  112682. * 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)
  112683. */
  112684. slerpAmount: number;
  112685. private _bone1Quat;
  112686. private _bone1Mat;
  112687. private _bone2Ang;
  112688. private _bone1;
  112689. private _bone2;
  112690. private _bone1Length;
  112691. private _bone2Length;
  112692. private _maxAngle;
  112693. private _maxReach;
  112694. private _rightHandedSystem;
  112695. private _bendAxis;
  112696. private _slerping;
  112697. private _adjustRoll;
  112698. /**
  112699. * Gets or sets maximum allowed angle
  112700. */
  112701. get maxAngle(): number;
  112702. set maxAngle(value: number);
  112703. /**
  112704. * Creates a new BoneIKController
  112705. * @param mesh defines the mesh to control
  112706. * @param bone defines the bone to control
  112707. * @param options defines options to set up the controller
  112708. */
  112709. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112710. targetMesh?: AbstractMesh;
  112711. poleTargetMesh?: AbstractMesh;
  112712. poleTargetBone?: Bone;
  112713. poleTargetLocalOffset?: Vector3;
  112714. poleAngle?: number;
  112715. bendAxis?: Vector3;
  112716. maxAngle?: number;
  112717. slerpAmount?: number;
  112718. });
  112719. private _setMaxAngle;
  112720. /**
  112721. * Force the controller to update the bones
  112722. */
  112723. update(): void;
  112724. }
  112725. }
  112726. declare module BABYLON {
  112727. /**
  112728. * Class used to make a bone look toward a point in space
  112729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112730. */
  112731. export class BoneLookController {
  112732. private static _tmpVecs;
  112733. private static _tmpQuat;
  112734. private static _tmpMats;
  112735. /**
  112736. * The target Vector3 that the bone will look at
  112737. */
  112738. target: Vector3;
  112739. /**
  112740. * The mesh that the bone is attached to
  112741. */
  112742. mesh: AbstractMesh;
  112743. /**
  112744. * The bone that will be looking to the target
  112745. */
  112746. bone: Bone;
  112747. /**
  112748. * The up axis of the coordinate system that is used when the bone is rotated
  112749. */
  112750. upAxis: Vector3;
  112751. /**
  112752. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112753. */
  112754. upAxisSpace: Space;
  112755. /**
  112756. * Used to make an adjustment to the yaw of the bone
  112757. */
  112758. adjustYaw: number;
  112759. /**
  112760. * Used to make an adjustment to the pitch of the bone
  112761. */
  112762. adjustPitch: number;
  112763. /**
  112764. * Used to make an adjustment to the roll of the bone
  112765. */
  112766. adjustRoll: number;
  112767. /**
  112768. * 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)
  112769. */
  112770. slerpAmount: number;
  112771. private _minYaw;
  112772. private _maxYaw;
  112773. private _minPitch;
  112774. private _maxPitch;
  112775. private _minYawSin;
  112776. private _minYawCos;
  112777. private _maxYawSin;
  112778. private _maxYawCos;
  112779. private _midYawConstraint;
  112780. private _minPitchTan;
  112781. private _maxPitchTan;
  112782. private _boneQuat;
  112783. private _slerping;
  112784. private _transformYawPitch;
  112785. private _transformYawPitchInv;
  112786. private _firstFrameSkipped;
  112787. private _yawRange;
  112788. private _fowardAxis;
  112789. /**
  112790. * Gets or sets the minimum yaw angle that the bone can look to
  112791. */
  112792. get minYaw(): number;
  112793. set minYaw(value: number);
  112794. /**
  112795. * Gets or sets the maximum yaw angle that the bone can look to
  112796. */
  112797. get maxYaw(): number;
  112798. set maxYaw(value: number);
  112799. /**
  112800. * Gets or sets the minimum pitch angle that the bone can look to
  112801. */
  112802. get minPitch(): number;
  112803. set minPitch(value: number);
  112804. /**
  112805. * Gets or sets the maximum pitch angle that the bone can look to
  112806. */
  112807. get maxPitch(): number;
  112808. set maxPitch(value: number);
  112809. /**
  112810. * Create a BoneLookController
  112811. * @param mesh the mesh that the bone belongs to
  112812. * @param bone the bone that will be looking to the target
  112813. * @param target the target Vector3 to look at
  112814. * @param options optional settings:
  112815. * * maxYaw: the maximum angle the bone will yaw to
  112816. * * minYaw: the minimum angle the bone will yaw to
  112817. * * maxPitch: the maximum angle the bone will pitch to
  112818. * * minPitch: the minimum angle the bone will yaw to
  112819. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112820. * * upAxis: the up axis of the coordinate system
  112821. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112822. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112823. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112824. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112825. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112826. * * adjustRoll: used to make an adjustment to the roll of the bone
  112827. **/
  112828. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112829. maxYaw?: number;
  112830. minYaw?: number;
  112831. maxPitch?: number;
  112832. minPitch?: number;
  112833. slerpAmount?: number;
  112834. upAxis?: Vector3;
  112835. upAxisSpace?: Space;
  112836. yawAxis?: Vector3;
  112837. pitchAxis?: Vector3;
  112838. adjustYaw?: number;
  112839. adjustPitch?: number;
  112840. adjustRoll?: number;
  112841. });
  112842. /**
  112843. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112844. */
  112845. update(): void;
  112846. private _getAngleDiff;
  112847. private _getAngleBetween;
  112848. private _isAngleBetween;
  112849. }
  112850. }
  112851. declare module BABYLON {
  112852. /**
  112853. * Manage the gamepad inputs to control an arc rotate camera.
  112854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112855. */
  112856. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112857. /**
  112858. * Defines the camera the input is attached to.
  112859. */
  112860. camera: ArcRotateCamera;
  112861. /**
  112862. * Defines the gamepad the input is gathering event from.
  112863. */
  112864. gamepad: Nullable<Gamepad>;
  112865. /**
  112866. * Defines the gamepad rotation sensiblity.
  112867. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112868. */
  112869. gamepadRotationSensibility: number;
  112870. /**
  112871. * Defines the gamepad move sensiblity.
  112872. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112873. */
  112874. gamepadMoveSensibility: number;
  112875. private _yAxisScale;
  112876. /**
  112877. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112878. */
  112879. get invertYAxis(): boolean;
  112880. set invertYAxis(value: boolean);
  112881. private _onGamepadConnectedObserver;
  112882. private _onGamepadDisconnectedObserver;
  112883. /**
  112884. * Attach the input controls to a specific dom element to get the input from.
  112885. * @param element Defines the element the controls should be listened from
  112886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112887. */
  112888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112889. /**
  112890. * Detach the current controls from the specified dom element.
  112891. * @param element Defines the element to stop listening the inputs from
  112892. */
  112893. detachControl(element: Nullable<HTMLElement>): void;
  112894. /**
  112895. * Update the current camera state depending on the inputs that have been used this frame.
  112896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112897. */
  112898. checkInputs(): void;
  112899. /**
  112900. * Gets the class name of the current intput.
  112901. * @returns the class name
  112902. */
  112903. getClassName(): string;
  112904. /**
  112905. * Get the friendly name associated with the input class.
  112906. * @returns the input friendly name
  112907. */
  112908. getSimpleName(): string;
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. interface ArcRotateCameraInputsManager {
  112913. /**
  112914. * Add orientation input support to the input manager.
  112915. * @returns the current input manager
  112916. */
  112917. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112918. }
  112919. /**
  112920. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112922. */
  112923. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112924. /**
  112925. * Defines the camera the input is attached to.
  112926. */
  112927. camera: ArcRotateCamera;
  112928. /**
  112929. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112930. */
  112931. alphaCorrection: number;
  112932. /**
  112933. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112934. */
  112935. gammaCorrection: number;
  112936. private _alpha;
  112937. private _gamma;
  112938. private _dirty;
  112939. private _deviceOrientationHandler;
  112940. /**
  112941. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112942. */
  112943. constructor();
  112944. /**
  112945. * Attach the input controls to a specific dom element to get the input from.
  112946. * @param element Defines the element the controls should be listened from
  112947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112948. */
  112949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112950. /** @hidden */
  112951. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112952. /**
  112953. * Update the current camera state depending on the inputs that have been used this frame.
  112954. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112955. */
  112956. checkInputs(): void;
  112957. /**
  112958. * Detach the current controls from the specified dom element.
  112959. * @param element Defines the element to stop listening the inputs from
  112960. */
  112961. detachControl(element: Nullable<HTMLElement>): void;
  112962. /**
  112963. * Gets the class name of the current intput.
  112964. * @returns the class name
  112965. */
  112966. getClassName(): string;
  112967. /**
  112968. * Get the friendly name associated with the input class.
  112969. * @returns the input friendly name
  112970. */
  112971. getSimpleName(): string;
  112972. }
  112973. }
  112974. declare module BABYLON {
  112975. /**
  112976. * Listen to mouse events to control the camera.
  112977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112978. */
  112979. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112980. /**
  112981. * Defines the camera the input is attached to.
  112982. */
  112983. camera: FlyCamera;
  112984. /**
  112985. * Defines if touch is enabled. (Default is true.)
  112986. */
  112987. touchEnabled: boolean;
  112988. /**
  112989. * Defines the buttons associated with the input to handle camera rotation.
  112990. */
  112991. buttons: number[];
  112992. /**
  112993. * Assign buttons for Yaw control.
  112994. */
  112995. buttonsYaw: number[];
  112996. /**
  112997. * Assign buttons for Pitch control.
  112998. */
  112999. buttonsPitch: number[];
  113000. /**
  113001. * Assign buttons for Roll control.
  113002. */
  113003. buttonsRoll: number[];
  113004. /**
  113005. * Detect if any button is being pressed while mouse is moved.
  113006. * -1 = Mouse locked.
  113007. * 0 = Left button.
  113008. * 1 = Middle Button.
  113009. * 2 = Right Button.
  113010. */
  113011. activeButton: number;
  113012. /**
  113013. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113014. * Higher values reduce its sensitivity.
  113015. */
  113016. angularSensibility: number;
  113017. private _mousemoveCallback;
  113018. private _observer;
  113019. private _rollObserver;
  113020. private previousPosition;
  113021. private noPreventDefault;
  113022. private element;
  113023. /**
  113024. * Listen to mouse events to control the camera.
  113025. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113027. */
  113028. constructor(touchEnabled?: boolean);
  113029. /**
  113030. * Attach the mouse control to the HTML DOM element.
  113031. * @param element Defines the element that listens to the input events.
  113032. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113033. */
  113034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113035. /**
  113036. * Detach the current controls from the specified dom element.
  113037. * @param element Defines the element to stop listening the inputs from
  113038. */
  113039. detachControl(element: Nullable<HTMLElement>): void;
  113040. /**
  113041. * Gets the class name of the current input.
  113042. * @returns the class name.
  113043. */
  113044. getClassName(): string;
  113045. /**
  113046. * Get the friendly name associated with the input class.
  113047. * @returns the input's friendly name.
  113048. */
  113049. getSimpleName(): string;
  113050. private _pointerInput;
  113051. private _onMouseMove;
  113052. /**
  113053. * Rotate camera by mouse offset.
  113054. */
  113055. private rotateCamera;
  113056. }
  113057. }
  113058. declare module BABYLON {
  113059. /**
  113060. * Default Inputs manager for the FlyCamera.
  113061. * It groups all the default supported inputs for ease of use.
  113062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113063. */
  113064. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113065. /**
  113066. * Instantiates a new FlyCameraInputsManager.
  113067. * @param camera Defines the camera the inputs belong to.
  113068. */
  113069. constructor(camera: FlyCamera);
  113070. /**
  113071. * Add keyboard input support to the input manager.
  113072. * @returns the new FlyCameraKeyboardMoveInput().
  113073. */
  113074. addKeyboard(): FlyCameraInputsManager;
  113075. /**
  113076. * Add mouse input support to the input manager.
  113077. * @param touchEnabled Enable touch screen support.
  113078. * @returns the new FlyCameraMouseInput().
  113079. */
  113080. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113081. }
  113082. }
  113083. declare module BABYLON {
  113084. /**
  113085. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113086. * such as in a 3D Space Shooter or a Flight Simulator.
  113087. */
  113088. export class FlyCamera extends TargetCamera {
  113089. /**
  113090. * Define the collision ellipsoid of the camera.
  113091. * This is helpful for simulating a camera body, like a player's body.
  113092. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113093. */
  113094. ellipsoid: Vector3;
  113095. /**
  113096. * Define an offset for the position of the ellipsoid around the camera.
  113097. * This can be helpful if the camera is attached away from the player's body center,
  113098. * such as at its head.
  113099. */
  113100. ellipsoidOffset: Vector3;
  113101. /**
  113102. * Enable or disable collisions of the camera with the rest of the scene objects.
  113103. */
  113104. checkCollisions: boolean;
  113105. /**
  113106. * Enable or disable gravity on the camera.
  113107. */
  113108. applyGravity: boolean;
  113109. /**
  113110. * Define the current direction the camera is moving to.
  113111. */
  113112. cameraDirection: Vector3;
  113113. /**
  113114. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113115. * This overrides and empties cameraRotation.
  113116. */
  113117. rotationQuaternion: Quaternion;
  113118. /**
  113119. * Track Roll to maintain the wanted Rolling when looking around.
  113120. */
  113121. _trackRoll: number;
  113122. /**
  113123. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113124. */
  113125. rollCorrect: number;
  113126. /**
  113127. * Mimic a banked turn, Rolling the camera when Yawing.
  113128. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113129. */
  113130. bankedTurn: boolean;
  113131. /**
  113132. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113133. */
  113134. bankedTurnLimit: number;
  113135. /**
  113136. * Value of 0 disables the banked Roll.
  113137. * Value of 1 is equal to the Yaw angle in radians.
  113138. */
  113139. bankedTurnMultiplier: number;
  113140. /**
  113141. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113142. */
  113143. inputs: FlyCameraInputsManager;
  113144. /**
  113145. * Gets the input sensibility for mouse input.
  113146. * Higher values reduce sensitivity.
  113147. */
  113148. get angularSensibility(): number;
  113149. /**
  113150. * Sets the input sensibility for a mouse input.
  113151. * Higher values reduce sensitivity.
  113152. */
  113153. set angularSensibility(value: number);
  113154. /**
  113155. * Get the keys for camera movement forward.
  113156. */
  113157. get keysForward(): number[];
  113158. /**
  113159. * Set the keys for camera movement forward.
  113160. */
  113161. set keysForward(value: number[]);
  113162. /**
  113163. * Get the keys for camera movement backward.
  113164. */
  113165. get keysBackward(): number[];
  113166. set keysBackward(value: number[]);
  113167. /**
  113168. * Get the keys for camera movement up.
  113169. */
  113170. get keysUp(): number[];
  113171. /**
  113172. * Set the keys for camera movement up.
  113173. */
  113174. set keysUp(value: number[]);
  113175. /**
  113176. * Get the keys for camera movement down.
  113177. */
  113178. get keysDown(): number[];
  113179. /**
  113180. * Set the keys for camera movement down.
  113181. */
  113182. set keysDown(value: number[]);
  113183. /**
  113184. * Get the keys for camera movement left.
  113185. */
  113186. get keysLeft(): number[];
  113187. /**
  113188. * Set the keys for camera movement left.
  113189. */
  113190. set keysLeft(value: number[]);
  113191. /**
  113192. * Set the keys for camera movement right.
  113193. */
  113194. get keysRight(): number[];
  113195. /**
  113196. * Set the keys for camera movement right.
  113197. */
  113198. set keysRight(value: number[]);
  113199. /**
  113200. * Event raised when the camera collides with a mesh in the scene.
  113201. */
  113202. onCollide: (collidedMesh: AbstractMesh) => void;
  113203. private _collider;
  113204. private _needMoveForGravity;
  113205. private _oldPosition;
  113206. private _diffPosition;
  113207. private _newPosition;
  113208. /** @hidden */
  113209. _localDirection: Vector3;
  113210. /** @hidden */
  113211. _transformedDirection: Vector3;
  113212. /**
  113213. * Instantiates a FlyCamera.
  113214. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113215. * such as in a 3D Space Shooter or a Flight Simulator.
  113216. * @param name Define the name of the camera in the scene.
  113217. * @param position Define the starting position of the camera in the scene.
  113218. * @param scene Define the scene the camera belongs to.
  113219. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113220. */
  113221. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113222. /**
  113223. * Attach a control to the HTML DOM element.
  113224. * @param element Defines the element that listens to the input events.
  113225. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113226. */
  113227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113228. /**
  113229. * Detach a control from the HTML DOM element.
  113230. * The camera will stop reacting to that input.
  113231. * @param element Defines the element that listens to the input events.
  113232. */
  113233. detachControl(element: HTMLElement): void;
  113234. private _collisionMask;
  113235. /**
  113236. * Get the mask that the camera ignores in collision events.
  113237. */
  113238. get collisionMask(): number;
  113239. /**
  113240. * Set the mask that the camera ignores in collision events.
  113241. */
  113242. set collisionMask(mask: number);
  113243. /** @hidden */
  113244. _collideWithWorld(displacement: Vector3): void;
  113245. /** @hidden */
  113246. private _onCollisionPositionChange;
  113247. /** @hidden */
  113248. _checkInputs(): void;
  113249. /** @hidden */
  113250. _decideIfNeedsToMove(): boolean;
  113251. /** @hidden */
  113252. _updatePosition(): void;
  113253. /**
  113254. * Restore the Roll to its target value at the rate specified.
  113255. * @param rate - Higher means slower restoring.
  113256. * @hidden
  113257. */
  113258. restoreRoll(rate: number): void;
  113259. /**
  113260. * Destroy the camera and release the current resources held by it.
  113261. */
  113262. dispose(): void;
  113263. /**
  113264. * Get the current object class name.
  113265. * @returns the class name.
  113266. */
  113267. getClassName(): string;
  113268. }
  113269. }
  113270. declare module BABYLON {
  113271. /**
  113272. * Listen to keyboard events to control the camera.
  113273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113274. */
  113275. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113276. /**
  113277. * Defines the camera the input is attached to.
  113278. */
  113279. camera: FlyCamera;
  113280. /**
  113281. * The list of keyboard keys used to control the forward move of the camera.
  113282. */
  113283. keysForward: number[];
  113284. /**
  113285. * The list of keyboard keys used to control the backward move of the camera.
  113286. */
  113287. keysBackward: number[];
  113288. /**
  113289. * The list of keyboard keys used to control the forward move of the camera.
  113290. */
  113291. keysUp: number[];
  113292. /**
  113293. * The list of keyboard keys used to control the backward move of the camera.
  113294. */
  113295. keysDown: number[];
  113296. /**
  113297. * The list of keyboard keys used to control the right strafe move of the camera.
  113298. */
  113299. keysRight: number[];
  113300. /**
  113301. * The list of keyboard keys used to control the left strafe move of the camera.
  113302. */
  113303. keysLeft: number[];
  113304. private _keys;
  113305. private _onCanvasBlurObserver;
  113306. private _onKeyboardObserver;
  113307. private _engine;
  113308. private _scene;
  113309. /**
  113310. * Attach the input controls to a specific dom element to get the input from.
  113311. * @param element Defines the element the controls should be listened from
  113312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113313. */
  113314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113315. /**
  113316. * Detach the current controls from the specified dom element.
  113317. * @param element Defines the element to stop listening the inputs from
  113318. */
  113319. detachControl(element: Nullable<HTMLElement>): void;
  113320. /**
  113321. * Gets the class name of the current intput.
  113322. * @returns the class name
  113323. */
  113324. getClassName(): string;
  113325. /** @hidden */
  113326. _onLostFocus(e: FocusEvent): void;
  113327. /**
  113328. * Get the friendly name associated with the input class.
  113329. * @returns the input friendly name
  113330. */
  113331. getSimpleName(): string;
  113332. /**
  113333. * Update the current camera state depending on the inputs that have been used this frame.
  113334. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113335. */
  113336. checkInputs(): void;
  113337. }
  113338. }
  113339. declare module BABYLON {
  113340. /**
  113341. * Manage the mouse wheel inputs to control a follow camera.
  113342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113343. */
  113344. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113345. /**
  113346. * Defines the camera the input is attached to.
  113347. */
  113348. camera: FollowCamera;
  113349. /**
  113350. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113351. */
  113352. axisControlRadius: boolean;
  113353. /**
  113354. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113355. */
  113356. axisControlHeight: boolean;
  113357. /**
  113358. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113359. */
  113360. axisControlRotation: boolean;
  113361. /**
  113362. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113363. * relation to mouseWheel events.
  113364. */
  113365. wheelPrecision: number;
  113366. /**
  113367. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113368. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113369. */
  113370. wheelDeltaPercentage: number;
  113371. private _wheel;
  113372. private _observer;
  113373. /**
  113374. * Attach the input controls to a specific dom element to get the input from.
  113375. * @param element Defines the element the controls should be listened from
  113376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113377. */
  113378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113379. /**
  113380. * Detach the current controls from the specified dom element.
  113381. * @param element Defines the element to stop listening the inputs from
  113382. */
  113383. detachControl(element: Nullable<HTMLElement>): void;
  113384. /**
  113385. * Gets the class name of the current intput.
  113386. * @returns the class name
  113387. */
  113388. getClassName(): string;
  113389. /**
  113390. * Get the friendly name associated with the input class.
  113391. * @returns the input friendly name
  113392. */
  113393. getSimpleName(): string;
  113394. }
  113395. }
  113396. declare module BABYLON {
  113397. /**
  113398. * Manage the pointers inputs to control an follow camera.
  113399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113400. */
  113401. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113402. /**
  113403. * Defines the camera the input is attached to.
  113404. */
  113405. camera: FollowCamera;
  113406. /**
  113407. * Gets the class name of the current input.
  113408. * @returns the class name
  113409. */
  113410. getClassName(): string;
  113411. /**
  113412. * Defines the pointer angular sensibility along the X axis or how fast is
  113413. * the camera rotating.
  113414. * A negative number will reverse the axis direction.
  113415. */
  113416. angularSensibilityX: number;
  113417. /**
  113418. * Defines the pointer angular sensibility along the Y axis or how fast is
  113419. * the camera rotating.
  113420. * A negative number will reverse the axis direction.
  113421. */
  113422. angularSensibilityY: number;
  113423. /**
  113424. * Defines the pointer pinch precision or how fast is the camera zooming.
  113425. * A negative number will reverse the axis direction.
  113426. */
  113427. pinchPrecision: number;
  113428. /**
  113429. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113430. * from 0.
  113431. * It defines the percentage of current camera.radius to use as delta when
  113432. * pinch zoom is used.
  113433. */
  113434. pinchDeltaPercentage: number;
  113435. /**
  113436. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113437. */
  113438. axisXControlRadius: boolean;
  113439. /**
  113440. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113441. */
  113442. axisXControlHeight: boolean;
  113443. /**
  113444. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113445. */
  113446. axisXControlRotation: boolean;
  113447. /**
  113448. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113449. */
  113450. axisYControlRadius: boolean;
  113451. /**
  113452. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113453. */
  113454. axisYControlHeight: boolean;
  113455. /**
  113456. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113457. */
  113458. axisYControlRotation: boolean;
  113459. /**
  113460. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113461. */
  113462. axisPinchControlRadius: boolean;
  113463. /**
  113464. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113465. */
  113466. axisPinchControlHeight: boolean;
  113467. /**
  113468. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113469. */
  113470. axisPinchControlRotation: boolean;
  113471. /**
  113472. * Log error messages if basic misconfiguration has occurred.
  113473. */
  113474. warningEnable: boolean;
  113475. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113476. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113477. private _warningCounter;
  113478. private _warning;
  113479. }
  113480. }
  113481. declare module BABYLON {
  113482. /**
  113483. * Default Inputs manager for the FollowCamera.
  113484. * It groups all the default supported inputs for ease of use.
  113485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113486. */
  113487. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113488. /**
  113489. * Instantiates a new FollowCameraInputsManager.
  113490. * @param camera Defines the camera the inputs belong to
  113491. */
  113492. constructor(camera: FollowCamera);
  113493. /**
  113494. * Add keyboard input support to the input manager.
  113495. * @returns the current input manager
  113496. */
  113497. addKeyboard(): FollowCameraInputsManager;
  113498. /**
  113499. * Add mouse wheel input support to the input manager.
  113500. * @returns the current input manager
  113501. */
  113502. addMouseWheel(): FollowCameraInputsManager;
  113503. /**
  113504. * Add pointers input support to the input manager.
  113505. * @returns the current input manager
  113506. */
  113507. addPointers(): FollowCameraInputsManager;
  113508. /**
  113509. * Add orientation input support to the input manager.
  113510. * @returns the current input manager
  113511. */
  113512. addVRDeviceOrientation(): FollowCameraInputsManager;
  113513. }
  113514. }
  113515. declare module BABYLON {
  113516. /**
  113517. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113518. * an arc rotate version arcFollowCamera are available.
  113519. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113520. */
  113521. export class FollowCamera extends TargetCamera {
  113522. /**
  113523. * Distance the follow camera should follow an object at
  113524. */
  113525. radius: number;
  113526. /**
  113527. * Minimum allowed distance of the camera to the axis of rotation
  113528. * (The camera can not get closer).
  113529. * This can help limiting how the Camera is able to move in the scene.
  113530. */
  113531. lowerRadiusLimit: Nullable<number>;
  113532. /**
  113533. * Maximum allowed distance of the camera to the axis of rotation
  113534. * (The camera can not get further).
  113535. * This can help limiting how the Camera is able to move in the scene.
  113536. */
  113537. upperRadiusLimit: Nullable<number>;
  113538. /**
  113539. * Define a rotation offset between the camera and the object it follows
  113540. */
  113541. rotationOffset: number;
  113542. /**
  113543. * Minimum allowed angle to camera position relative to target object.
  113544. * This can help limiting how the Camera is able to move in the scene.
  113545. */
  113546. lowerRotationOffsetLimit: Nullable<number>;
  113547. /**
  113548. * Maximum allowed angle to camera position relative to target object.
  113549. * This can help limiting how the Camera is able to move in the scene.
  113550. */
  113551. upperRotationOffsetLimit: Nullable<number>;
  113552. /**
  113553. * Define a height offset between the camera and the object it follows.
  113554. * It can help following an object from the top (like a car chaing a plane)
  113555. */
  113556. heightOffset: number;
  113557. /**
  113558. * Minimum allowed height of camera position relative to target object.
  113559. * This can help limiting how the Camera is able to move in the scene.
  113560. */
  113561. lowerHeightOffsetLimit: Nullable<number>;
  113562. /**
  113563. * Maximum allowed height of camera position relative to target object.
  113564. * This can help limiting how the Camera is able to move in the scene.
  113565. */
  113566. upperHeightOffsetLimit: Nullable<number>;
  113567. /**
  113568. * Define how fast the camera can accelerate to follow it s target.
  113569. */
  113570. cameraAcceleration: number;
  113571. /**
  113572. * Define the speed limit of the camera following an object.
  113573. */
  113574. maxCameraSpeed: number;
  113575. /**
  113576. * Define the target of the camera.
  113577. */
  113578. lockedTarget: Nullable<AbstractMesh>;
  113579. /**
  113580. * Defines the input associated with the camera.
  113581. */
  113582. inputs: FollowCameraInputsManager;
  113583. /**
  113584. * Instantiates the follow camera.
  113585. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113586. * @param name Define the name of the camera in the scene
  113587. * @param position Define the position of the camera
  113588. * @param scene Define the scene the camera belong to
  113589. * @param lockedTarget Define the target of the camera
  113590. */
  113591. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113592. private _follow;
  113593. /**
  113594. * Attached controls to the current camera.
  113595. * @param element Defines the element the controls should be listened from
  113596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113597. */
  113598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113599. /**
  113600. * Detach the current controls from the camera.
  113601. * The camera will stop reacting to inputs.
  113602. * @param element Defines the element to stop listening the inputs from
  113603. */
  113604. detachControl(element: HTMLElement): void;
  113605. /** @hidden */
  113606. _checkInputs(): void;
  113607. private _checkLimits;
  113608. /**
  113609. * Gets the camera class name.
  113610. * @returns the class name
  113611. */
  113612. getClassName(): string;
  113613. }
  113614. /**
  113615. * Arc Rotate version of the follow camera.
  113616. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113617. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113618. */
  113619. export class ArcFollowCamera extends TargetCamera {
  113620. /** The longitudinal angle of the camera */
  113621. alpha: number;
  113622. /** The latitudinal angle of the camera */
  113623. beta: number;
  113624. /** The radius of the camera from its target */
  113625. radius: number;
  113626. /** Define the camera target (the messh it should follow) */
  113627. target: Nullable<AbstractMesh>;
  113628. private _cartesianCoordinates;
  113629. /**
  113630. * Instantiates a new ArcFollowCamera
  113631. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113632. * @param name Define the name of the camera
  113633. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113634. * @param beta Define the rotation angle of the camera around the elevation axis
  113635. * @param radius Define the radius of the camera from its target point
  113636. * @param target Define the target of the camera
  113637. * @param scene Define the scene the camera belongs to
  113638. */
  113639. constructor(name: string,
  113640. /** The longitudinal angle of the camera */
  113641. alpha: number,
  113642. /** The latitudinal angle of the camera */
  113643. beta: number,
  113644. /** The radius of the camera from its target */
  113645. radius: number,
  113646. /** Define the camera target (the messh it should follow) */
  113647. target: Nullable<AbstractMesh>, scene: Scene);
  113648. private _follow;
  113649. /** @hidden */
  113650. _checkInputs(): void;
  113651. /**
  113652. * Returns the class name of the object.
  113653. * It is mostly used internally for serialization purposes.
  113654. */
  113655. getClassName(): string;
  113656. }
  113657. }
  113658. declare module BABYLON {
  113659. /**
  113660. * Manage the keyboard inputs to control the movement of a follow camera.
  113661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113662. */
  113663. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113664. /**
  113665. * Defines the camera the input is attached to.
  113666. */
  113667. camera: FollowCamera;
  113668. /**
  113669. * Defines the list of key codes associated with the up action (increase heightOffset)
  113670. */
  113671. keysHeightOffsetIncr: number[];
  113672. /**
  113673. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113674. */
  113675. keysHeightOffsetDecr: number[];
  113676. /**
  113677. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113678. */
  113679. keysHeightOffsetModifierAlt: boolean;
  113680. /**
  113681. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113682. */
  113683. keysHeightOffsetModifierCtrl: boolean;
  113684. /**
  113685. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113686. */
  113687. keysHeightOffsetModifierShift: boolean;
  113688. /**
  113689. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113690. */
  113691. keysRotationOffsetIncr: number[];
  113692. /**
  113693. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113694. */
  113695. keysRotationOffsetDecr: number[];
  113696. /**
  113697. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113698. */
  113699. keysRotationOffsetModifierAlt: boolean;
  113700. /**
  113701. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113702. */
  113703. keysRotationOffsetModifierCtrl: boolean;
  113704. /**
  113705. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113706. */
  113707. keysRotationOffsetModifierShift: boolean;
  113708. /**
  113709. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113710. */
  113711. keysRadiusIncr: number[];
  113712. /**
  113713. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113714. */
  113715. keysRadiusDecr: number[];
  113716. /**
  113717. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113718. */
  113719. keysRadiusModifierAlt: boolean;
  113720. /**
  113721. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113722. */
  113723. keysRadiusModifierCtrl: boolean;
  113724. /**
  113725. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113726. */
  113727. keysRadiusModifierShift: boolean;
  113728. /**
  113729. * Defines the rate of change of heightOffset.
  113730. */
  113731. heightSensibility: number;
  113732. /**
  113733. * Defines the rate of change of rotationOffset.
  113734. */
  113735. rotationSensibility: number;
  113736. /**
  113737. * Defines the rate of change of radius.
  113738. */
  113739. radiusSensibility: number;
  113740. private _keys;
  113741. private _ctrlPressed;
  113742. private _altPressed;
  113743. private _shiftPressed;
  113744. private _onCanvasBlurObserver;
  113745. private _onKeyboardObserver;
  113746. private _engine;
  113747. private _scene;
  113748. /**
  113749. * Attach the input controls to a specific dom element to get the input from.
  113750. * @param element Defines the element the controls should be listened from
  113751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113752. */
  113753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113754. /**
  113755. * Detach the current controls from the specified dom element.
  113756. * @param element Defines the element to stop listening the inputs from
  113757. */
  113758. detachControl(element: Nullable<HTMLElement>): void;
  113759. /**
  113760. * Update the current camera state depending on the inputs that have been used this frame.
  113761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113762. */
  113763. checkInputs(): void;
  113764. /**
  113765. * Gets the class name of the current input.
  113766. * @returns the class name
  113767. */
  113768. getClassName(): string;
  113769. /**
  113770. * Get the friendly name associated with the input class.
  113771. * @returns the input friendly name
  113772. */
  113773. getSimpleName(): string;
  113774. /**
  113775. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113776. * allow modification of the heightOffset value.
  113777. */
  113778. private _modifierHeightOffset;
  113779. /**
  113780. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113781. * allow modification of the rotationOffset value.
  113782. */
  113783. private _modifierRotationOffset;
  113784. /**
  113785. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113786. * allow modification of the radius value.
  113787. */
  113788. private _modifierRadius;
  113789. }
  113790. }
  113791. declare module BABYLON {
  113792. interface FreeCameraInputsManager {
  113793. /**
  113794. * @hidden
  113795. */
  113796. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113797. /**
  113798. * Add orientation input support to the input manager.
  113799. * @returns the current input manager
  113800. */
  113801. addDeviceOrientation(): FreeCameraInputsManager;
  113802. }
  113803. /**
  113804. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113805. * Screen rotation is taken into account.
  113806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113807. */
  113808. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113809. private _camera;
  113810. private _screenOrientationAngle;
  113811. private _constantTranform;
  113812. private _screenQuaternion;
  113813. private _alpha;
  113814. private _beta;
  113815. private _gamma;
  113816. /**
  113817. * Can be used to detect if a device orientation sensor is available on a device
  113818. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113819. * @returns a promise that will resolve on orientation change
  113820. */
  113821. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113822. /**
  113823. * @hidden
  113824. */
  113825. _onDeviceOrientationChangedObservable: Observable<void>;
  113826. /**
  113827. * Instantiates a new input
  113828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113829. */
  113830. constructor();
  113831. /**
  113832. * Define the camera controlled by the input.
  113833. */
  113834. get camera(): FreeCamera;
  113835. set camera(camera: FreeCamera);
  113836. /**
  113837. * Attach the input controls to a specific dom element to get the input from.
  113838. * @param element Defines the element the controls should be listened from
  113839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113840. */
  113841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113842. private _orientationChanged;
  113843. private _deviceOrientation;
  113844. /**
  113845. * Detach the current controls from the specified dom element.
  113846. * @param element Defines the element to stop listening the inputs from
  113847. */
  113848. detachControl(element: Nullable<HTMLElement>): void;
  113849. /**
  113850. * Update the current camera state depending on the inputs that have been used this frame.
  113851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113852. */
  113853. checkInputs(): void;
  113854. /**
  113855. * Gets the class name of the current intput.
  113856. * @returns the class name
  113857. */
  113858. getClassName(): string;
  113859. /**
  113860. * Get the friendly name associated with the input class.
  113861. * @returns the input friendly name
  113862. */
  113863. getSimpleName(): string;
  113864. }
  113865. }
  113866. declare module BABYLON {
  113867. /**
  113868. * Manage the gamepad inputs to control a free camera.
  113869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113870. */
  113871. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113872. /**
  113873. * Define the camera the input is attached to.
  113874. */
  113875. camera: FreeCamera;
  113876. /**
  113877. * Define the Gamepad controlling the input
  113878. */
  113879. gamepad: Nullable<Gamepad>;
  113880. /**
  113881. * Defines the gamepad rotation sensiblity.
  113882. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113883. */
  113884. gamepadAngularSensibility: number;
  113885. /**
  113886. * Defines the gamepad move sensiblity.
  113887. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113888. */
  113889. gamepadMoveSensibility: number;
  113890. private _yAxisScale;
  113891. /**
  113892. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113893. */
  113894. get invertYAxis(): boolean;
  113895. set invertYAxis(value: boolean);
  113896. private _onGamepadConnectedObserver;
  113897. private _onGamepadDisconnectedObserver;
  113898. private _cameraTransform;
  113899. private _deltaTransform;
  113900. private _vector3;
  113901. private _vector2;
  113902. /**
  113903. * Attach the input controls to a specific dom element to get the input from.
  113904. * @param element Defines the element the controls should be listened from
  113905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113906. */
  113907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113908. /**
  113909. * Detach the current controls from the specified dom element.
  113910. * @param element Defines the element to stop listening the inputs from
  113911. */
  113912. detachControl(element: Nullable<HTMLElement>): void;
  113913. /**
  113914. * Update the current camera state depending on the inputs that have been used this frame.
  113915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113916. */
  113917. checkInputs(): void;
  113918. /**
  113919. * Gets the class name of the current intput.
  113920. * @returns the class name
  113921. */
  113922. getClassName(): string;
  113923. /**
  113924. * Get the friendly name associated with the input class.
  113925. * @returns the input friendly name
  113926. */
  113927. getSimpleName(): string;
  113928. }
  113929. }
  113930. declare module BABYLON {
  113931. /**
  113932. * Defines the potential axis of a Joystick
  113933. */
  113934. export enum JoystickAxis {
  113935. /** X axis */
  113936. X = 0,
  113937. /** Y axis */
  113938. Y = 1,
  113939. /** Z axis */
  113940. Z = 2
  113941. }
  113942. /**
  113943. * Class used to define virtual joystick (used in touch mode)
  113944. */
  113945. export class VirtualJoystick {
  113946. /**
  113947. * Gets or sets a boolean indicating that left and right values must be inverted
  113948. */
  113949. reverseLeftRight: boolean;
  113950. /**
  113951. * Gets or sets a boolean indicating that up and down values must be inverted
  113952. */
  113953. reverseUpDown: boolean;
  113954. /**
  113955. * Gets the offset value for the position (ie. the change of the position value)
  113956. */
  113957. deltaPosition: Vector3;
  113958. /**
  113959. * Gets a boolean indicating if the virtual joystick was pressed
  113960. */
  113961. pressed: boolean;
  113962. /**
  113963. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113964. */
  113965. static Canvas: Nullable<HTMLCanvasElement>;
  113966. private static _globalJoystickIndex;
  113967. private static vjCanvasContext;
  113968. private static vjCanvasWidth;
  113969. private static vjCanvasHeight;
  113970. private static halfWidth;
  113971. private _action;
  113972. private _axisTargetedByLeftAndRight;
  113973. private _axisTargetedByUpAndDown;
  113974. private _joystickSensibility;
  113975. private _inversedSensibility;
  113976. private _joystickPointerID;
  113977. private _joystickColor;
  113978. private _joystickPointerPos;
  113979. private _joystickPreviousPointerPos;
  113980. private _joystickPointerStartPos;
  113981. private _deltaJoystickVector;
  113982. private _leftJoystick;
  113983. private _touches;
  113984. private _onPointerDownHandlerRef;
  113985. private _onPointerMoveHandlerRef;
  113986. private _onPointerUpHandlerRef;
  113987. private _onResize;
  113988. /**
  113989. * Creates a new virtual joystick
  113990. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113991. */
  113992. constructor(leftJoystick?: boolean);
  113993. /**
  113994. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113995. * @param newJoystickSensibility defines the new sensibility
  113996. */
  113997. setJoystickSensibility(newJoystickSensibility: number): void;
  113998. private _onPointerDown;
  113999. private _onPointerMove;
  114000. private _onPointerUp;
  114001. /**
  114002. * Change the color of the virtual joystick
  114003. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114004. */
  114005. setJoystickColor(newColor: string): void;
  114006. /**
  114007. * Defines a callback to call when the joystick is touched
  114008. * @param action defines the callback
  114009. */
  114010. setActionOnTouch(action: () => any): void;
  114011. /**
  114012. * Defines which axis you'd like to control for left & right
  114013. * @param axis defines the axis to use
  114014. */
  114015. setAxisForLeftRight(axis: JoystickAxis): void;
  114016. /**
  114017. * Defines which axis you'd like to control for up & down
  114018. * @param axis defines the axis to use
  114019. */
  114020. setAxisForUpDown(axis: JoystickAxis): void;
  114021. private _drawVirtualJoystick;
  114022. /**
  114023. * Release internal HTML canvas
  114024. */
  114025. releaseCanvas(): void;
  114026. }
  114027. }
  114028. declare module BABYLON {
  114029. interface FreeCameraInputsManager {
  114030. /**
  114031. * Add virtual joystick input support to the input manager.
  114032. * @returns the current input manager
  114033. */
  114034. addVirtualJoystick(): FreeCameraInputsManager;
  114035. }
  114036. /**
  114037. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114039. */
  114040. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114041. /**
  114042. * Defines the camera the input is attached to.
  114043. */
  114044. camera: FreeCamera;
  114045. private _leftjoystick;
  114046. private _rightjoystick;
  114047. /**
  114048. * Gets the left stick of the virtual joystick.
  114049. * @returns The virtual Joystick
  114050. */
  114051. getLeftJoystick(): VirtualJoystick;
  114052. /**
  114053. * Gets the right stick of the virtual joystick.
  114054. * @returns The virtual Joystick
  114055. */
  114056. getRightJoystick(): VirtualJoystick;
  114057. /**
  114058. * Update the current camera state depending on the inputs that have been used this frame.
  114059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114060. */
  114061. checkInputs(): void;
  114062. /**
  114063. * Attach the input controls to a specific dom element to get the input from.
  114064. * @param element Defines the element the controls should be listened from
  114065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114066. */
  114067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114068. /**
  114069. * Detach the current controls from the specified dom element.
  114070. * @param element Defines the element to stop listening the inputs from
  114071. */
  114072. detachControl(element: Nullable<HTMLElement>): void;
  114073. /**
  114074. * Gets the class name of the current intput.
  114075. * @returns the class name
  114076. */
  114077. getClassName(): string;
  114078. /**
  114079. * Get the friendly name associated with the input class.
  114080. * @returns the input friendly name
  114081. */
  114082. getSimpleName(): string;
  114083. }
  114084. }
  114085. declare module BABYLON {
  114086. /**
  114087. * This represents a FPS type of camera controlled by touch.
  114088. * This is like a universal camera minus the Gamepad controls.
  114089. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114090. */
  114091. export class TouchCamera extends FreeCamera {
  114092. /**
  114093. * Defines the touch sensibility for rotation.
  114094. * The higher the faster.
  114095. */
  114096. get touchAngularSensibility(): number;
  114097. set touchAngularSensibility(value: number);
  114098. /**
  114099. * Defines the touch sensibility for move.
  114100. * The higher the faster.
  114101. */
  114102. get touchMoveSensibility(): number;
  114103. set touchMoveSensibility(value: number);
  114104. /**
  114105. * Instantiates a new touch camera.
  114106. * This represents a FPS type of camera controlled by touch.
  114107. * This is like a universal camera minus the Gamepad controls.
  114108. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114109. * @param name Define the name of the camera in the scene
  114110. * @param position Define the start position of the camera in the scene
  114111. * @param scene Define the scene the camera belongs to
  114112. */
  114113. constructor(name: string, position: Vector3, scene: Scene);
  114114. /**
  114115. * Gets the current object class name.
  114116. * @return the class name
  114117. */
  114118. getClassName(): string;
  114119. /** @hidden */
  114120. _setupInputs(): void;
  114121. }
  114122. }
  114123. declare module BABYLON {
  114124. /**
  114125. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114126. * being tilted forward or back and left or right.
  114127. */
  114128. export class DeviceOrientationCamera extends FreeCamera {
  114129. private _initialQuaternion;
  114130. private _quaternionCache;
  114131. private _tmpDragQuaternion;
  114132. private _disablePointerInputWhenUsingDeviceOrientation;
  114133. /**
  114134. * Creates a new device orientation camera
  114135. * @param name The name of the camera
  114136. * @param position The start position camera
  114137. * @param scene The scene the camera belongs to
  114138. */
  114139. constructor(name: string, position: Vector3, scene: Scene);
  114140. /**
  114141. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114142. */
  114143. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114144. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114145. private _dragFactor;
  114146. /**
  114147. * Enabled turning on the y axis when the orientation sensor is active
  114148. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114149. */
  114150. enableHorizontalDragging(dragFactor?: number): void;
  114151. /**
  114152. * Gets the current instance class name ("DeviceOrientationCamera").
  114153. * This helps avoiding instanceof at run time.
  114154. * @returns the class name
  114155. */
  114156. getClassName(): string;
  114157. /**
  114158. * @hidden
  114159. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114160. */
  114161. _checkInputs(): void;
  114162. /**
  114163. * Reset the camera to its default orientation on the specified axis only.
  114164. * @param axis The axis to reset
  114165. */
  114166. resetToCurrentRotation(axis?: Axis): void;
  114167. }
  114168. }
  114169. declare module BABYLON {
  114170. /**
  114171. * Defines supported buttons for XBox360 compatible gamepads
  114172. */
  114173. export enum Xbox360Button {
  114174. /** A */
  114175. A = 0,
  114176. /** B */
  114177. B = 1,
  114178. /** X */
  114179. X = 2,
  114180. /** Y */
  114181. Y = 3,
  114182. /** Start */
  114183. Start = 4,
  114184. /** Back */
  114185. Back = 5,
  114186. /** Left button */
  114187. LB = 6,
  114188. /** Right button */
  114189. RB = 7,
  114190. /** Left stick */
  114191. LeftStick = 8,
  114192. /** Right stick */
  114193. RightStick = 9
  114194. }
  114195. /** Defines values for XBox360 DPad */
  114196. export enum Xbox360Dpad {
  114197. /** Up */
  114198. Up = 0,
  114199. /** Down */
  114200. Down = 1,
  114201. /** Left */
  114202. Left = 2,
  114203. /** Right */
  114204. Right = 3
  114205. }
  114206. /**
  114207. * Defines a XBox360 gamepad
  114208. */
  114209. export class Xbox360Pad extends Gamepad {
  114210. private _leftTrigger;
  114211. private _rightTrigger;
  114212. private _onlefttriggerchanged;
  114213. private _onrighttriggerchanged;
  114214. private _onbuttondown;
  114215. private _onbuttonup;
  114216. private _ondpaddown;
  114217. private _ondpadup;
  114218. /** Observable raised when a button is pressed */
  114219. onButtonDownObservable: Observable<Xbox360Button>;
  114220. /** Observable raised when a button is released */
  114221. onButtonUpObservable: Observable<Xbox360Button>;
  114222. /** Observable raised when a pad is pressed */
  114223. onPadDownObservable: Observable<Xbox360Dpad>;
  114224. /** Observable raised when a pad is released */
  114225. onPadUpObservable: Observable<Xbox360Dpad>;
  114226. private _buttonA;
  114227. private _buttonB;
  114228. private _buttonX;
  114229. private _buttonY;
  114230. private _buttonBack;
  114231. private _buttonStart;
  114232. private _buttonLB;
  114233. private _buttonRB;
  114234. private _buttonLeftStick;
  114235. private _buttonRightStick;
  114236. private _dPadUp;
  114237. private _dPadDown;
  114238. private _dPadLeft;
  114239. private _dPadRight;
  114240. private _isXboxOnePad;
  114241. /**
  114242. * Creates a new XBox360 gamepad object
  114243. * @param id defines the id of this gamepad
  114244. * @param index defines its index
  114245. * @param gamepad defines the internal HTML gamepad object
  114246. * @param xboxOne defines if it is a XBox One gamepad
  114247. */
  114248. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114249. /**
  114250. * Defines the callback to call when left trigger is pressed
  114251. * @param callback defines the callback to use
  114252. */
  114253. onlefttriggerchanged(callback: (value: number) => void): void;
  114254. /**
  114255. * Defines the callback to call when right trigger is pressed
  114256. * @param callback defines the callback to use
  114257. */
  114258. onrighttriggerchanged(callback: (value: number) => void): void;
  114259. /**
  114260. * Gets the left trigger value
  114261. */
  114262. get leftTrigger(): number;
  114263. /**
  114264. * Sets the left trigger value
  114265. */
  114266. set leftTrigger(newValue: number);
  114267. /**
  114268. * Gets the right trigger value
  114269. */
  114270. get rightTrigger(): number;
  114271. /**
  114272. * Sets the right trigger value
  114273. */
  114274. set rightTrigger(newValue: number);
  114275. /**
  114276. * Defines the callback to call when a button is pressed
  114277. * @param callback defines the callback to use
  114278. */
  114279. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114280. /**
  114281. * Defines the callback to call when a button is released
  114282. * @param callback defines the callback to use
  114283. */
  114284. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114285. /**
  114286. * Defines the callback to call when a pad is pressed
  114287. * @param callback defines the callback to use
  114288. */
  114289. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114290. /**
  114291. * Defines the callback to call when a pad is released
  114292. * @param callback defines the callback to use
  114293. */
  114294. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114295. private _setButtonValue;
  114296. private _setDPadValue;
  114297. /**
  114298. * Gets the value of the `A` button
  114299. */
  114300. get buttonA(): number;
  114301. /**
  114302. * Sets the value of the `A` button
  114303. */
  114304. set buttonA(value: number);
  114305. /**
  114306. * Gets the value of the `B` button
  114307. */
  114308. get buttonB(): number;
  114309. /**
  114310. * Sets the value of the `B` button
  114311. */
  114312. set buttonB(value: number);
  114313. /**
  114314. * Gets the value of the `X` button
  114315. */
  114316. get buttonX(): number;
  114317. /**
  114318. * Sets the value of the `X` button
  114319. */
  114320. set buttonX(value: number);
  114321. /**
  114322. * Gets the value of the `Y` button
  114323. */
  114324. get buttonY(): number;
  114325. /**
  114326. * Sets the value of the `Y` button
  114327. */
  114328. set buttonY(value: number);
  114329. /**
  114330. * Gets the value of the `Start` button
  114331. */
  114332. get buttonStart(): number;
  114333. /**
  114334. * Sets the value of the `Start` button
  114335. */
  114336. set buttonStart(value: number);
  114337. /**
  114338. * Gets the value of the `Back` button
  114339. */
  114340. get buttonBack(): number;
  114341. /**
  114342. * Sets the value of the `Back` button
  114343. */
  114344. set buttonBack(value: number);
  114345. /**
  114346. * Gets the value of the `Left` button
  114347. */
  114348. get buttonLB(): number;
  114349. /**
  114350. * Sets the value of the `Left` button
  114351. */
  114352. set buttonLB(value: number);
  114353. /**
  114354. * Gets the value of the `Right` button
  114355. */
  114356. get buttonRB(): number;
  114357. /**
  114358. * Sets the value of the `Right` button
  114359. */
  114360. set buttonRB(value: number);
  114361. /**
  114362. * Gets the value of the Left joystick
  114363. */
  114364. get buttonLeftStick(): number;
  114365. /**
  114366. * Sets the value of the Left joystick
  114367. */
  114368. set buttonLeftStick(value: number);
  114369. /**
  114370. * Gets the value of the Right joystick
  114371. */
  114372. get buttonRightStick(): number;
  114373. /**
  114374. * Sets the value of the Right joystick
  114375. */
  114376. set buttonRightStick(value: number);
  114377. /**
  114378. * Gets the value of D-pad up
  114379. */
  114380. get dPadUp(): number;
  114381. /**
  114382. * Sets the value of D-pad up
  114383. */
  114384. set dPadUp(value: number);
  114385. /**
  114386. * Gets the value of D-pad down
  114387. */
  114388. get dPadDown(): number;
  114389. /**
  114390. * Sets the value of D-pad down
  114391. */
  114392. set dPadDown(value: number);
  114393. /**
  114394. * Gets the value of D-pad left
  114395. */
  114396. get dPadLeft(): number;
  114397. /**
  114398. * Sets the value of D-pad left
  114399. */
  114400. set dPadLeft(value: number);
  114401. /**
  114402. * Gets the value of D-pad right
  114403. */
  114404. get dPadRight(): number;
  114405. /**
  114406. * Sets the value of D-pad right
  114407. */
  114408. set dPadRight(value: number);
  114409. /**
  114410. * Force the gamepad to synchronize with device values
  114411. */
  114412. update(): void;
  114413. /**
  114414. * Disposes the gamepad
  114415. */
  114416. dispose(): void;
  114417. }
  114418. }
  114419. declare module BABYLON {
  114420. /**
  114421. * Defines supported buttons for DualShock compatible gamepads
  114422. */
  114423. export enum DualShockButton {
  114424. /** Cross */
  114425. Cross = 0,
  114426. /** Circle */
  114427. Circle = 1,
  114428. /** Square */
  114429. Square = 2,
  114430. /** Triangle */
  114431. Triangle = 3,
  114432. /** Options */
  114433. Options = 4,
  114434. /** Share */
  114435. Share = 5,
  114436. /** L1 */
  114437. L1 = 6,
  114438. /** R1 */
  114439. R1 = 7,
  114440. /** Left stick */
  114441. LeftStick = 8,
  114442. /** Right stick */
  114443. RightStick = 9
  114444. }
  114445. /** Defines values for DualShock DPad */
  114446. export enum DualShockDpad {
  114447. /** Up */
  114448. Up = 0,
  114449. /** Down */
  114450. Down = 1,
  114451. /** Left */
  114452. Left = 2,
  114453. /** Right */
  114454. Right = 3
  114455. }
  114456. /**
  114457. * Defines a DualShock gamepad
  114458. */
  114459. export class DualShockPad extends Gamepad {
  114460. private _leftTrigger;
  114461. private _rightTrigger;
  114462. private _onlefttriggerchanged;
  114463. private _onrighttriggerchanged;
  114464. private _onbuttondown;
  114465. private _onbuttonup;
  114466. private _ondpaddown;
  114467. private _ondpadup;
  114468. /** Observable raised when a button is pressed */
  114469. onButtonDownObservable: Observable<DualShockButton>;
  114470. /** Observable raised when a button is released */
  114471. onButtonUpObservable: Observable<DualShockButton>;
  114472. /** Observable raised when a pad is pressed */
  114473. onPadDownObservable: Observable<DualShockDpad>;
  114474. /** Observable raised when a pad is released */
  114475. onPadUpObservable: Observable<DualShockDpad>;
  114476. private _buttonCross;
  114477. private _buttonCircle;
  114478. private _buttonSquare;
  114479. private _buttonTriangle;
  114480. private _buttonShare;
  114481. private _buttonOptions;
  114482. private _buttonL1;
  114483. private _buttonR1;
  114484. private _buttonLeftStick;
  114485. private _buttonRightStick;
  114486. private _dPadUp;
  114487. private _dPadDown;
  114488. private _dPadLeft;
  114489. private _dPadRight;
  114490. /**
  114491. * Creates a new DualShock gamepad object
  114492. * @param id defines the id of this gamepad
  114493. * @param index defines its index
  114494. * @param gamepad defines the internal HTML gamepad object
  114495. */
  114496. constructor(id: string, index: number, gamepad: any);
  114497. /**
  114498. * Defines the callback to call when left trigger is pressed
  114499. * @param callback defines the callback to use
  114500. */
  114501. onlefttriggerchanged(callback: (value: number) => void): void;
  114502. /**
  114503. * Defines the callback to call when right trigger is pressed
  114504. * @param callback defines the callback to use
  114505. */
  114506. onrighttriggerchanged(callback: (value: number) => void): void;
  114507. /**
  114508. * Gets the left trigger value
  114509. */
  114510. get leftTrigger(): number;
  114511. /**
  114512. * Sets the left trigger value
  114513. */
  114514. set leftTrigger(newValue: number);
  114515. /**
  114516. * Gets the right trigger value
  114517. */
  114518. get rightTrigger(): number;
  114519. /**
  114520. * Sets the right trigger value
  114521. */
  114522. set rightTrigger(newValue: number);
  114523. /**
  114524. * Defines the callback to call when a button is pressed
  114525. * @param callback defines the callback to use
  114526. */
  114527. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114528. /**
  114529. * Defines the callback to call when a button is released
  114530. * @param callback defines the callback to use
  114531. */
  114532. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114533. /**
  114534. * Defines the callback to call when a pad is pressed
  114535. * @param callback defines the callback to use
  114536. */
  114537. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114538. /**
  114539. * Defines the callback to call when a pad is released
  114540. * @param callback defines the callback to use
  114541. */
  114542. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114543. private _setButtonValue;
  114544. private _setDPadValue;
  114545. /**
  114546. * Gets the value of the `Cross` button
  114547. */
  114548. get buttonCross(): number;
  114549. /**
  114550. * Sets the value of the `Cross` button
  114551. */
  114552. set buttonCross(value: number);
  114553. /**
  114554. * Gets the value of the `Circle` button
  114555. */
  114556. get buttonCircle(): number;
  114557. /**
  114558. * Sets the value of the `Circle` button
  114559. */
  114560. set buttonCircle(value: number);
  114561. /**
  114562. * Gets the value of the `Square` button
  114563. */
  114564. get buttonSquare(): number;
  114565. /**
  114566. * Sets the value of the `Square` button
  114567. */
  114568. set buttonSquare(value: number);
  114569. /**
  114570. * Gets the value of the `Triangle` button
  114571. */
  114572. get buttonTriangle(): number;
  114573. /**
  114574. * Sets the value of the `Triangle` button
  114575. */
  114576. set buttonTriangle(value: number);
  114577. /**
  114578. * Gets the value of the `Options` button
  114579. */
  114580. get buttonOptions(): number;
  114581. /**
  114582. * Sets the value of the `Options` button
  114583. */
  114584. set buttonOptions(value: number);
  114585. /**
  114586. * Gets the value of the `Share` button
  114587. */
  114588. get buttonShare(): number;
  114589. /**
  114590. * Sets the value of the `Share` button
  114591. */
  114592. set buttonShare(value: number);
  114593. /**
  114594. * Gets the value of the `L1` button
  114595. */
  114596. get buttonL1(): number;
  114597. /**
  114598. * Sets the value of the `L1` button
  114599. */
  114600. set buttonL1(value: number);
  114601. /**
  114602. * Gets the value of the `R1` button
  114603. */
  114604. get buttonR1(): number;
  114605. /**
  114606. * Sets the value of the `R1` button
  114607. */
  114608. set buttonR1(value: number);
  114609. /**
  114610. * Gets the value of the Left joystick
  114611. */
  114612. get buttonLeftStick(): number;
  114613. /**
  114614. * Sets the value of the Left joystick
  114615. */
  114616. set buttonLeftStick(value: number);
  114617. /**
  114618. * Gets the value of the Right joystick
  114619. */
  114620. get buttonRightStick(): number;
  114621. /**
  114622. * Sets the value of the Right joystick
  114623. */
  114624. set buttonRightStick(value: number);
  114625. /**
  114626. * Gets the value of D-pad up
  114627. */
  114628. get dPadUp(): number;
  114629. /**
  114630. * Sets the value of D-pad up
  114631. */
  114632. set dPadUp(value: number);
  114633. /**
  114634. * Gets the value of D-pad down
  114635. */
  114636. get dPadDown(): number;
  114637. /**
  114638. * Sets the value of D-pad down
  114639. */
  114640. set dPadDown(value: number);
  114641. /**
  114642. * Gets the value of D-pad left
  114643. */
  114644. get dPadLeft(): number;
  114645. /**
  114646. * Sets the value of D-pad left
  114647. */
  114648. set dPadLeft(value: number);
  114649. /**
  114650. * Gets the value of D-pad right
  114651. */
  114652. get dPadRight(): number;
  114653. /**
  114654. * Sets the value of D-pad right
  114655. */
  114656. set dPadRight(value: number);
  114657. /**
  114658. * Force the gamepad to synchronize with device values
  114659. */
  114660. update(): void;
  114661. /**
  114662. * Disposes the gamepad
  114663. */
  114664. dispose(): void;
  114665. }
  114666. }
  114667. declare module BABYLON {
  114668. /**
  114669. * Manager for handling gamepads
  114670. */
  114671. export class GamepadManager {
  114672. private _scene?;
  114673. private _babylonGamepads;
  114674. private _oneGamepadConnected;
  114675. /** @hidden */
  114676. _isMonitoring: boolean;
  114677. private _gamepadEventSupported;
  114678. private _gamepadSupport?;
  114679. /**
  114680. * observable to be triggered when the gamepad controller has been connected
  114681. */
  114682. onGamepadConnectedObservable: Observable<Gamepad>;
  114683. /**
  114684. * observable to be triggered when the gamepad controller has been disconnected
  114685. */
  114686. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114687. private _onGamepadConnectedEvent;
  114688. private _onGamepadDisconnectedEvent;
  114689. /**
  114690. * Initializes the gamepad manager
  114691. * @param _scene BabylonJS scene
  114692. */
  114693. constructor(_scene?: Scene | undefined);
  114694. /**
  114695. * The gamepads in the game pad manager
  114696. */
  114697. get gamepads(): Gamepad[];
  114698. /**
  114699. * Get the gamepad controllers based on type
  114700. * @param type The type of gamepad controller
  114701. * @returns Nullable gamepad
  114702. */
  114703. getGamepadByType(type?: number): Nullable<Gamepad>;
  114704. /**
  114705. * Disposes the gamepad manager
  114706. */
  114707. dispose(): void;
  114708. private _addNewGamepad;
  114709. private _startMonitoringGamepads;
  114710. private _stopMonitoringGamepads;
  114711. /** @hidden */
  114712. _checkGamepadsStatus(): void;
  114713. private _updateGamepadObjects;
  114714. }
  114715. }
  114716. declare module BABYLON {
  114717. interface Scene {
  114718. /** @hidden */
  114719. _gamepadManager: Nullable<GamepadManager>;
  114720. /**
  114721. * Gets the gamepad manager associated with the scene
  114722. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114723. */
  114724. gamepadManager: GamepadManager;
  114725. }
  114726. /**
  114727. * Interface representing a free camera inputs manager
  114728. */
  114729. interface FreeCameraInputsManager {
  114730. /**
  114731. * Adds gamepad input support to the FreeCameraInputsManager.
  114732. * @returns the FreeCameraInputsManager
  114733. */
  114734. addGamepad(): FreeCameraInputsManager;
  114735. }
  114736. /**
  114737. * Interface representing an arc rotate camera inputs manager
  114738. */
  114739. interface ArcRotateCameraInputsManager {
  114740. /**
  114741. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114742. * @returns the camera inputs manager
  114743. */
  114744. addGamepad(): ArcRotateCameraInputsManager;
  114745. }
  114746. /**
  114747. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114748. */
  114749. export class GamepadSystemSceneComponent implements ISceneComponent {
  114750. /**
  114751. * The component name helpfull to identify the component in the list of scene components.
  114752. */
  114753. readonly name: string;
  114754. /**
  114755. * The scene the component belongs to.
  114756. */
  114757. scene: Scene;
  114758. /**
  114759. * Creates a new instance of the component for the given scene
  114760. * @param scene Defines the scene to register the component in
  114761. */
  114762. constructor(scene: Scene);
  114763. /**
  114764. * Registers the component in a given scene
  114765. */
  114766. register(): void;
  114767. /**
  114768. * Rebuilds the elements related to this component in case of
  114769. * context lost for instance.
  114770. */
  114771. rebuild(): void;
  114772. /**
  114773. * Disposes the component and the associated ressources
  114774. */
  114775. dispose(): void;
  114776. private _beforeCameraUpdate;
  114777. }
  114778. }
  114779. declare module BABYLON {
  114780. /**
  114781. * 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,
  114782. * which still works and will still be found in many Playgrounds.
  114783. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114784. */
  114785. export class UniversalCamera extends TouchCamera {
  114786. /**
  114787. * Defines the gamepad rotation sensiblity.
  114788. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114789. */
  114790. get gamepadAngularSensibility(): number;
  114791. set gamepadAngularSensibility(value: number);
  114792. /**
  114793. * Defines the gamepad move sensiblity.
  114794. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114795. */
  114796. get gamepadMoveSensibility(): number;
  114797. set gamepadMoveSensibility(value: number);
  114798. /**
  114799. * 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,
  114800. * which still works and will still be found in many Playgrounds.
  114801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114802. * @param name Define the name of the camera in the scene
  114803. * @param position Define the start position of the camera in the scene
  114804. * @param scene Define the scene the camera belongs to
  114805. */
  114806. constructor(name: string, position: Vector3, scene: Scene);
  114807. /**
  114808. * Gets the current object class name.
  114809. * @return the class name
  114810. */
  114811. getClassName(): string;
  114812. }
  114813. }
  114814. declare module BABYLON {
  114815. /**
  114816. * This represents a FPS type of camera. This is only here for back compat purpose.
  114817. * Please use the UniversalCamera instead as both are identical.
  114818. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114819. */
  114820. export class GamepadCamera extends UniversalCamera {
  114821. /**
  114822. * Instantiates a new Gamepad Camera
  114823. * This represents a FPS type of camera. This is only here for back compat purpose.
  114824. * Please use the UniversalCamera instead as both are identical.
  114825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114826. * @param name Define the name of the camera in the scene
  114827. * @param position Define the start position of the camera in the scene
  114828. * @param scene Define the scene the camera belongs to
  114829. */
  114830. constructor(name: string, position: Vector3, scene: Scene);
  114831. /**
  114832. * Gets the current object class name.
  114833. * @return the class name
  114834. */
  114835. getClassName(): string;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /** @hidden */
  114840. export var passPixelShader: {
  114841. name: string;
  114842. shader: string;
  114843. };
  114844. }
  114845. declare module BABYLON {
  114846. /** @hidden */
  114847. export var passCubePixelShader: {
  114848. name: string;
  114849. shader: string;
  114850. };
  114851. }
  114852. declare module BABYLON {
  114853. /**
  114854. * PassPostProcess which produces an output the same as it's input
  114855. */
  114856. export class PassPostProcess extends PostProcess {
  114857. /**
  114858. * Creates the PassPostProcess
  114859. * @param name The name of the effect.
  114860. * @param options The required width/height ratio to downsize to before computing the render pass.
  114861. * @param camera The camera to apply the render pass to.
  114862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114863. * @param engine The engine which the post process will be applied. (default: current engine)
  114864. * @param reusable If the post process can be reused on the same frame. (default: false)
  114865. * @param textureType The type of texture to be used when performing the post processing.
  114866. * @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)
  114867. */
  114868. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114869. }
  114870. /**
  114871. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114872. */
  114873. export class PassCubePostProcess extends PostProcess {
  114874. private _face;
  114875. /**
  114876. * Gets or sets the cube face to display.
  114877. * * 0 is +X
  114878. * * 1 is -X
  114879. * * 2 is +Y
  114880. * * 3 is -Y
  114881. * * 4 is +Z
  114882. * * 5 is -Z
  114883. */
  114884. get face(): number;
  114885. set face(value: number);
  114886. /**
  114887. * Creates the PassCubePostProcess
  114888. * @param name The name of the effect.
  114889. * @param options The required width/height ratio to downsize to before computing the render pass.
  114890. * @param camera The camera to apply the render pass to.
  114891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114892. * @param engine The engine which the post process will be applied. (default: current engine)
  114893. * @param reusable If the post process can be reused on the same frame. (default: false)
  114894. * @param textureType The type of texture to be used when performing the post processing.
  114895. * @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)
  114896. */
  114897. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114898. }
  114899. }
  114900. declare module BABYLON {
  114901. /** @hidden */
  114902. export var anaglyphPixelShader: {
  114903. name: string;
  114904. shader: string;
  114905. };
  114906. }
  114907. declare module BABYLON {
  114908. /**
  114909. * Postprocess used to generate anaglyphic rendering
  114910. */
  114911. export class AnaglyphPostProcess extends PostProcess {
  114912. private _passedProcess;
  114913. /**
  114914. * Creates a new AnaglyphPostProcess
  114915. * @param name defines postprocess name
  114916. * @param options defines creation options or target ratio scale
  114917. * @param rigCameras defines cameras using this postprocess
  114918. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114919. * @param engine defines hosting engine
  114920. * @param reusable defines if the postprocess will be reused multiple times per frame
  114921. */
  114922. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114923. }
  114924. }
  114925. declare module BABYLON {
  114926. /**
  114927. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114928. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114929. */
  114930. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114931. /**
  114932. * Creates a new AnaglyphArcRotateCamera
  114933. * @param name defines camera name
  114934. * @param alpha defines alpha angle (in radians)
  114935. * @param beta defines beta angle (in radians)
  114936. * @param radius defines radius
  114937. * @param target defines camera target
  114938. * @param interaxialDistance defines distance between each color axis
  114939. * @param scene defines the hosting scene
  114940. */
  114941. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114942. /**
  114943. * Gets camera class name
  114944. * @returns AnaglyphArcRotateCamera
  114945. */
  114946. getClassName(): string;
  114947. }
  114948. }
  114949. declare module BABYLON {
  114950. /**
  114951. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114952. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114953. */
  114954. export class AnaglyphFreeCamera extends FreeCamera {
  114955. /**
  114956. * Creates a new AnaglyphFreeCamera
  114957. * @param name defines camera name
  114958. * @param position defines initial position
  114959. * @param interaxialDistance defines distance between each color axis
  114960. * @param scene defines the hosting scene
  114961. */
  114962. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114963. /**
  114964. * Gets camera class name
  114965. * @returns AnaglyphFreeCamera
  114966. */
  114967. getClassName(): string;
  114968. }
  114969. }
  114970. declare module BABYLON {
  114971. /**
  114972. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114973. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114974. */
  114975. export class AnaglyphGamepadCamera extends GamepadCamera {
  114976. /**
  114977. * Creates a new AnaglyphGamepadCamera
  114978. * @param name defines camera name
  114979. * @param position defines initial position
  114980. * @param interaxialDistance defines distance between each color axis
  114981. * @param scene defines the hosting scene
  114982. */
  114983. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114984. /**
  114985. * Gets camera class name
  114986. * @returns AnaglyphGamepadCamera
  114987. */
  114988. getClassName(): string;
  114989. }
  114990. }
  114991. declare module BABYLON {
  114992. /**
  114993. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114994. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114995. */
  114996. export class AnaglyphUniversalCamera extends UniversalCamera {
  114997. /**
  114998. * Creates a new AnaglyphUniversalCamera
  114999. * @param name defines camera name
  115000. * @param position defines initial position
  115001. * @param interaxialDistance defines distance between each color axis
  115002. * @param scene defines the hosting scene
  115003. */
  115004. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115005. /**
  115006. * Gets camera class name
  115007. * @returns AnaglyphUniversalCamera
  115008. */
  115009. getClassName(): string;
  115010. }
  115011. }
  115012. declare module BABYLON {
  115013. /** @hidden */
  115014. export var stereoscopicInterlacePixelShader: {
  115015. name: string;
  115016. shader: string;
  115017. };
  115018. }
  115019. declare module BABYLON {
  115020. /**
  115021. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115022. */
  115023. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115024. private _stepSize;
  115025. private _passedProcess;
  115026. /**
  115027. * Initializes a StereoscopicInterlacePostProcessI
  115028. * @param name The name of the effect.
  115029. * @param rigCameras The rig cameras to be appled to the post process
  115030. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115031. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115033. * @param engine The engine which the post process will be applied. (default: current engine)
  115034. * @param reusable If the post process can be reused on the same frame. (default: false)
  115035. */
  115036. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115037. }
  115038. /**
  115039. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115040. */
  115041. export class StereoscopicInterlacePostProcess extends PostProcess {
  115042. private _stepSize;
  115043. private _passedProcess;
  115044. /**
  115045. * Initializes a StereoscopicInterlacePostProcess
  115046. * @param name The name of the effect.
  115047. * @param rigCameras The rig cameras to be appled to the post process
  115048. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115050. * @param engine The engine which the post process will be applied. (default: current engine)
  115051. * @param reusable If the post process can be reused on the same frame. (default: false)
  115052. */
  115053. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115059. * @see http://doc.babylonjs.com/features/cameras
  115060. */
  115061. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115062. /**
  115063. * Creates a new StereoscopicArcRotateCamera
  115064. * @param name defines camera name
  115065. * @param alpha defines alpha angle (in radians)
  115066. * @param beta defines beta angle (in radians)
  115067. * @param radius defines radius
  115068. * @param target defines camera target
  115069. * @param interaxialDistance defines distance between each color axis
  115070. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115071. * @param scene defines the hosting scene
  115072. */
  115073. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115074. /**
  115075. * Gets camera class name
  115076. * @returns StereoscopicArcRotateCamera
  115077. */
  115078. getClassName(): string;
  115079. }
  115080. }
  115081. declare module BABYLON {
  115082. /**
  115083. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115084. * @see http://doc.babylonjs.com/features/cameras
  115085. */
  115086. export class StereoscopicFreeCamera extends FreeCamera {
  115087. /**
  115088. * Creates a new StereoscopicFreeCamera
  115089. * @param name defines camera name
  115090. * @param position defines initial position
  115091. * @param interaxialDistance defines distance between each color axis
  115092. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115093. * @param scene defines the hosting scene
  115094. */
  115095. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115096. /**
  115097. * Gets camera class name
  115098. * @returns StereoscopicFreeCamera
  115099. */
  115100. getClassName(): string;
  115101. }
  115102. }
  115103. declare module BABYLON {
  115104. /**
  115105. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115106. * @see http://doc.babylonjs.com/features/cameras
  115107. */
  115108. export class StereoscopicGamepadCamera extends GamepadCamera {
  115109. /**
  115110. * Creates a new StereoscopicGamepadCamera
  115111. * @param name defines camera name
  115112. * @param position defines initial position
  115113. * @param interaxialDistance defines distance between each color axis
  115114. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115115. * @param scene defines the hosting scene
  115116. */
  115117. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115118. /**
  115119. * Gets camera class name
  115120. * @returns StereoscopicGamepadCamera
  115121. */
  115122. getClassName(): string;
  115123. }
  115124. }
  115125. declare module BABYLON {
  115126. /**
  115127. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115128. * @see http://doc.babylonjs.com/features/cameras
  115129. */
  115130. export class StereoscopicUniversalCamera extends UniversalCamera {
  115131. /**
  115132. * Creates a new StereoscopicUniversalCamera
  115133. * @param name defines camera name
  115134. * @param position defines initial position
  115135. * @param interaxialDistance defines distance between each color axis
  115136. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115137. * @param scene defines the hosting scene
  115138. */
  115139. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115140. /**
  115141. * Gets camera class name
  115142. * @returns StereoscopicUniversalCamera
  115143. */
  115144. getClassName(): string;
  115145. }
  115146. }
  115147. declare module BABYLON {
  115148. /**
  115149. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115150. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115151. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115152. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115153. */
  115154. export class VirtualJoysticksCamera extends FreeCamera {
  115155. /**
  115156. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115159. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115160. * @param name Define the name of the camera in the scene
  115161. * @param position Define the start position of the camera in the scene
  115162. * @param scene Define the scene the camera belongs to
  115163. */
  115164. constructor(name: string, position: Vector3, scene: Scene);
  115165. /**
  115166. * Gets the current object class name.
  115167. * @return the class name
  115168. */
  115169. getClassName(): string;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /**
  115174. * This represents all the required metrics to create a VR camera.
  115175. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115176. */
  115177. export class VRCameraMetrics {
  115178. /**
  115179. * Define the horizontal resolution off the screen.
  115180. */
  115181. hResolution: number;
  115182. /**
  115183. * Define the vertical resolution off the screen.
  115184. */
  115185. vResolution: number;
  115186. /**
  115187. * Define the horizontal screen size.
  115188. */
  115189. hScreenSize: number;
  115190. /**
  115191. * Define the vertical screen size.
  115192. */
  115193. vScreenSize: number;
  115194. /**
  115195. * Define the vertical screen center position.
  115196. */
  115197. vScreenCenter: number;
  115198. /**
  115199. * Define the distance of the eyes to the screen.
  115200. */
  115201. eyeToScreenDistance: number;
  115202. /**
  115203. * Define the distance between both lenses
  115204. */
  115205. lensSeparationDistance: number;
  115206. /**
  115207. * Define the distance between both viewer's eyes.
  115208. */
  115209. interpupillaryDistance: number;
  115210. /**
  115211. * Define the distortion factor of the VR postprocess.
  115212. * Please, touch with care.
  115213. */
  115214. distortionK: number[];
  115215. /**
  115216. * Define the chromatic aberration correction factors for the VR post process.
  115217. */
  115218. chromaAbCorrection: number[];
  115219. /**
  115220. * Define the scale factor of the post process.
  115221. * The smaller the better but the slower.
  115222. */
  115223. postProcessScaleFactor: number;
  115224. /**
  115225. * Define an offset for the lens center.
  115226. */
  115227. lensCenterOffset: number;
  115228. /**
  115229. * Define if the current vr camera should compensate the distortion of the lense or not.
  115230. */
  115231. compensateDistortion: boolean;
  115232. /**
  115233. * Defines if multiview should be enabled when rendering (Default: false)
  115234. */
  115235. multiviewEnabled: boolean;
  115236. /**
  115237. * Gets the rendering aspect ratio based on the provided resolutions.
  115238. */
  115239. get aspectRatio(): number;
  115240. /**
  115241. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115242. */
  115243. get aspectRatioFov(): number;
  115244. /**
  115245. * @hidden
  115246. */
  115247. get leftHMatrix(): Matrix;
  115248. /**
  115249. * @hidden
  115250. */
  115251. get rightHMatrix(): Matrix;
  115252. /**
  115253. * @hidden
  115254. */
  115255. get leftPreViewMatrix(): Matrix;
  115256. /**
  115257. * @hidden
  115258. */
  115259. get rightPreViewMatrix(): Matrix;
  115260. /**
  115261. * Get the default VRMetrics based on the most generic setup.
  115262. * @returns the default vr metrics
  115263. */
  115264. static GetDefault(): VRCameraMetrics;
  115265. }
  115266. }
  115267. declare module BABYLON {
  115268. /** @hidden */
  115269. export var vrDistortionCorrectionPixelShader: {
  115270. name: string;
  115271. shader: string;
  115272. };
  115273. }
  115274. declare module BABYLON {
  115275. /**
  115276. * VRDistortionCorrectionPostProcess used for mobile VR
  115277. */
  115278. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115279. private _isRightEye;
  115280. private _distortionFactors;
  115281. private _postProcessScaleFactor;
  115282. private _lensCenterOffset;
  115283. private _scaleIn;
  115284. private _scaleFactor;
  115285. private _lensCenter;
  115286. /**
  115287. * Initializes the VRDistortionCorrectionPostProcess
  115288. * @param name The name of the effect.
  115289. * @param camera The camera to apply the render pass to.
  115290. * @param isRightEye If this is for the right eye distortion
  115291. * @param vrMetrics All the required metrics for the VR camera
  115292. */
  115293. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115294. }
  115295. }
  115296. declare module BABYLON {
  115297. /**
  115298. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115299. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115300. */
  115301. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115302. /**
  115303. * Creates a new VRDeviceOrientationArcRotateCamera
  115304. * @param name defines camera name
  115305. * @param alpha defines the camera rotation along the logitudinal axis
  115306. * @param beta defines the camera rotation along the latitudinal axis
  115307. * @param radius defines the camera distance from its target
  115308. * @param target defines the camera target
  115309. * @param scene defines the scene the camera belongs to
  115310. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115311. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115312. */
  115313. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115314. /**
  115315. * Gets camera class name
  115316. * @returns VRDeviceOrientationArcRotateCamera
  115317. */
  115318. getClassName(): string;
  115319. }
  115320. }
  115321. declare module BABYLON {
  115322. /**
  115323. * Camera used to simulate VR rendering (based on FreeCamera)
  115324. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115325. */
  115326. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115327. /**
  115328. * Creates a new VRDeviceOrientationFreeCamera
  115329. * @param name defines camera name
  115330. * @param position defines the start position of the camera
  115331. * @param scene defines the scene the camera belongs to
  115332. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115333. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115334. */
  115335. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115336. /**
  115337. * Gets camera class name
  115338. * @returns VRDeviceOrientationFreeCamera
  115339. */
  115340. getClassName(): string;
  115341. }
  115342. }
  115343. declare module BABYLON {
  115344. /**
  115345. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115346. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115347. */
  115348. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115349. /**
  115350. * Creates a new VRDeviceOrientationGamepadCamera
  115351. * @param name defines camera name
  115352. * @param position defines the start position of the camera
  115353. * @param scene defines the scene the camera belongs to
  115354. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115355. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115356. */
  115357. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115358. /**
  115359. * Gets camera class name
  115360. * @returns VRDeviceOrientationGamepadCamera
  115361. */
  115362. getClassName(): string;
  115363. }
  115364. }
  115365. declare module BABYLON {
  115366. /** @hidden */
  115367. export var imageProcessingPixelShader: {
  115368. name: string;
  115369. shader: string;
  115370. };
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * ImageProcessingPostProcess
  115375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115376. */
  115377. export class ImageProcessingPostProcess extends PostProcess {
  115378. /**
  115379. * Default configuration related to image processing available in the PBR Material.
  115380. */
  115381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115382. /**
  115383. * Gets the image processing configuration used either in this material.
  115384. */
  115385. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115386. /**
  115387. * Sets the Default image processing configuration used either in the this material.
  115388. *
  115389. * If sets to null, the scene one is in use.
  115390. */
  115391. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115392. /**
  115393. * Keep track of the image processing observer to allow dispose and replace.
  115394. */
  115395. private _imageProcessingObserver;
  115396. /**
  115397. * Attaches a new image processing configuration to the PBR Material.
  115398. * @param configuration
  115399. */
  115400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115401. /**
  115402. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115403. */
  115404. get colorCurves(): Nullable<ColorCurves>;
  115405. /**
  115406. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115407. */
  115408. set colorCurves(value: Nullable<ColorCurves>);
  115409. /**
  115410. * Gets wether the color curves effect is enabled.
  115411. */
  115412. get colorCurvesEnabled(): boolean;
  115413. /**
  115414. * Sets wether the color curves effect is enabled.
  115415. */
  115416. set colorCurvesEnabled(value: boolean);
  115417. /**
  115418. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115419. */
  115420. get colorGradingTexture(): Nullable<BaseTexture>;
  115421. /**
  115422. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115423. */
  115424. set colorGradingTexture(value: Nullable<BaseTexture>);
  115425. /**
  115426. * Gets wether the color grading effect is enabled.
  115427. */
  115428. get colorGradingEnabled(): boolean;
  115429. /**
  115430. * Gets wether the color grading effect is enabled.
  115431. */
  115432. set colorGradingEnabled(value: boolean);
  115433. /**
  115434. * Gets exposure used in the effect.
  115435. */
  115436. get exposure(): number;
  115437. /**
  115438. * Sets exposure used in the effect.
  115439. */
  115440. set exposure(value: number);
  115441. /**
  115442. * Gets wether tonemapping is enabled or not.
  115443. */
  115444. get toneMappingEnabled(): boolean;
  115445. /**
  115446. * Sets wether tonemapping is enabled or not
  115447. */
  115448. set toneMappingEnabled(value: boolean);
  115449. /**
  115450. * Gets the type of tone mapping effect.
  115451. */
  115452. get toneMappingType(): number;
  115453. /**
  115454. * Sets the type of tone mapping effect.
  115455. */
  115456. set toneMappingType(value: number);
  115457. /**
  115458. * Gets contrast used in the effect.
  115459. */
  115460. get contrast(): number;
  115461. /**
  115462. * Sets contrast used in the effect.
  115463. */
  115464. set contrast(value: number);
  115465. /**
  115466. * Gets Vignette stretch size.
  115467. */
  115468. get vignetteStretch(): number;
  115469. /**
  115470. * Sets Vignette stretch size.
  115471. */
  115472. set vignetteStretch(value: number);
  115473. /**
  115474. * Gets Vignette centre X Offset.
  115475. */
  115476. get vignetteCentreX(): number;
  115477. /**
  115478. * Sets Vignette centre X Offset.
  115479. */
  115480. set vignetteCentreX(value: number);
  115481. /**
  115482. * Gets Vignette centre Y Offset.
  115483. */
  115484. get vignetteCentreY(): number;
  115485. /**
  115486. * Sets Vignette centre Y Offset.
  115487. */
  115488. set vignetteCentreY(value: number);
  115489. /**
  115490. * Gets Vignette weight or intensity of the vignette effect.
  115491. */
  115492. get vignetteWeight(): number;
  115493. /**
  115494. * Sets Vignette weight or intensity of the vignette effect.
  115495. */
  115496. set vignetteWeight(value: number);
  115497. /**
  115498. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115499. * if vignetteEnabled is set to true.
  115500. */
  115501. get vignetteColor(): Color4;
  115502. /**
  115503. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115504. * if vignetteEnabled is set to true.
  115505. */
  115506. set vignetteColor(value: Color4);
  115507. /**
  115508. * Gets Camera field of view used by the Vignette effect.
  115509. */
  115510. get vignetteCameraFov(): number;
  115511. /**
  115512. * Sets Camera field of view used by the Vignette effect.
  115513. */
  115514. set vignetteCameraFov(value: number);
  115515. /**
  115516. * Gets the vignette blend mode allowing different kind of effect.
  115517. */
  115518. get vignetteBlendMode(): number;
  115519. /**
  115520. * Sets the vignette blend mode allowing different kind of effect.
  115521. */
  115522. set vignetteBlendMode(value: number);
  115523. /**
  115524. * Gets wether the vignette effect is enabled.
  115525. */
  115526. get vignetteEnabled(): boolean;
  115527. /**
  115528. * Sets wether the vignette effect is enabled.
  115529. */
  115530. set vignetteEnabled(value: boolean);
  115531. private _fromLinearSpace;
  115532. /**
  115533. * Gets wether the input of the processing is in Gamma or Linear Space.
  115534. */
  115535. get fromLinearSpace(): boolean;
  115536. /**
  115537. * Sets wether the input of the processing is in Gamma or Linear Space.
  115538. */
  115539. set fromLinearSpace(value: boolean);
  115540. /**
  115541. * Defines cache preventing GC.
  115542. */
  115543. private _defines;
  115544. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115545. /**
  115546. * "ImageProcessingPostProcess"
  115547. * @returns "ImageProcessingPostProcess"
  115548. */
  115549. getClassName(): string;
  115550. protected _updateParameters(): void;
  115551. dispose(camera?: Camera): void;
  115552. }
  115553. }
  115554. declare module BABYLON {
  115555. /**
  115556. * Class containing static functions to help procedurally build meshes
  115557. */
  115558. export class GroundBuilder {
  115559. /**
  115560. * Creates a ground mesh
  115561. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115562. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115564. * @param name defines the name of the mesh
  115565. * @param options defines the options used to create the mesh
  115566. * @param scene defines the hosting scene
  115567. * @returns the ground mesh
  115568. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115569. */
  115570. static CreateGround(name: string, options: {
  115571. width?: number;
  115572. height?: number;
  115573. subdivisions?: number;
  115574. subdivisionsX?: number;
  115575. subdivisionsY?: number;
  115576. updatable?: boolean;
  115577. }, scene: any): Mesh;
  115578. /**
  115579. * Creates a tiled ground mesh
  115580. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115581. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115582. * * 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
  115583. * * 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
  115584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115585. * @param name defines the name of the mesh
  115586. * @param options defines the options used to create the mesh
  115587. * @param scene defines the hosting scene
  115588. * @returns the tiled ground mesh
  115589. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115590. */
  115591. static CreateTiledGround(name: string, options: {
  115592. xmin: number;
  115593. zmin: number;
  115594. xmax: number;
  115595. zmax: number;
  115596. subdivisions?: {
  115597. w: number;
  115598. h: number;
  115599. };
  115600. precision?: {
  115601. w: number;
  115602. h: number;
  115603. };
  115604. updatable?: boolean;
  115605. }, scene?: Nullable<Scene>): Mesh;
  115606. /**
  115607. * Creates a ground mesh from a height map
  115608. * * The parameter `url` sets the URL of the height map image resource.
  115609. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115610. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115611. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115612. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115613. * * 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.
  115614. * * 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).
  115615. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115617. * @param name defines the name of the mesh
  115618. * @param url defines the url to the height map
  115619. * @param options defines the options used to create the mesh
  115620. * @param scene defines the hosting scene
  115621. * @returns the ground mesh
  115622. * @see https://doc.babylonjs.com/babylon101/height_map
  115623. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115624. */
  115625. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115626. width?: number;
  115627. height?: number;
  115628. subdivisions?: number;
  115629. minHeight?: number;
  115630. maxHeight?: number;
  115631. colorFilter?: Color3;
  115632. alphaFilter?: number;
  115633. updatable?: boolean;
  115634. onReady?: (mesh: GroundMesh) => void;
  115635. }, scene?: Nullable<Scene>): GroundMesh;
  115636. }
  115637. }
  115638. declare module BABYLON {
  115639. /**
  115640. * Class containing static functions to help procedurally build meshes
  115641. */
  115642. export class TorusBuilder {
  115643. /**
  115644. * Creates a torus mesh
  115645. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115646. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115647. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115651. * @param name defines the name of the mesh
  115652. * @param options defines the options used to create the mesh
  115653. * @param scene defines the hosting scene
  115654. * @returns the torus mesh
  115655. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115656. */
  115657. static CreateTorus(name: string, options: {
  115658. diameter?: number;
  115659. thickness?: number;
  115660. tessellation?: number;
  115661. updatable?: boolean;
  115662. sideOrientation?: number;
  115663. frontUVs?: Vector4;
  115664. backUVs?: Vector4;
  115665. }, scene: any): Mesh;
  115666. }
  115667. }
  115668. declare module BABYLON {
  115669. /**
  115670. * Class containing static functions to help procedurally build meshes
  115671. */
  115672. export class CylinderBuilder {
  115673. /**
  115674. * Creates a cylinder or a cone mesh
  115675. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115676. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115677. * * 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.
  115678. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115679. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115680. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115681. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115682. * * 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).
  115683. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115684. * * 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).
  115685. * * 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
  115686. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115687. * * 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
  115688. * * 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.
  115689. * * If `enclose` is false, a ring surface is one element.
  115690. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115691. * * 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
  115692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115695. * @param name defines the name of the mesh
  115696. * @param options defines the options used to create the mesh
  115697. * @param scene defines the hosting scene
  115698. * @returns the cylinder mesh
  115699. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115700. */
  115701. static CreateCylinder(name: string, options: {
  115702. height?: number;
  115703. diameterTop?: number;
  115704. diameterBottom?: number;
  115705. diameter?: number;
  115706. tessellation?: number;
  115707. subdivisions?: number;
  115708. arc?: number;
  115709. faceColors?: Color4[];
  115710. faceUV?: Vector4[];
  115711. updatable?: boolean;
  115712. hasRings?: boolean;
  115713. enclose?: boolean;
  115714. cap?: number;
  115715. sideOrientation?: number;
  115716. frontUVs?: Vector4;
  115717. backUVs?: Vector4;
  115718. }, scene: any): Mesh;
  115719. }
  115720. }
  115721. declare module BABYLON {
  115722. /**
  115723. * States of the webXR experience
  115724. */
  115725. export enum WebXRState {
  115726. /**
  115727. * Transitioning to being in XR mode
  115728. */
  115729. ENTERING_XR = 0,
  115730. /**
  115731. * Transitioning to non XR mode
  115732. */
  115733. EXITING_XR = 1,
  115734. /**
  115735. * In XR mode and presenting
  115736. */
  115737. IN_XR = 2,
  115738. /**
  115739. * Not entered XR mode
  115740. */
  115741. NOT_IN_XR = 3
  115742. }
  115743. /**
  115744. * Abstraction of the XR render target
  115745. */
  115746. export interface WebXRRenderTarget extends IDisposable {
  115747. /**
  115748. * xrpresent context of the canvas which can be used to display/mirror xr content
  115749. */
  115750. canvasContext: WebGLRenderingContext;
  115751. /**
  115752. * xr layer for the canvas
  115753. */
  115754. xrLayer: Nullable<XRWebGLLayer>;
  115755. /**
  115756. * Initializes the xr layer for the session
  115757. * @param xrSession xr session
  115758. * @returns a promise that will resolve once the XR Layer has been created
  115759. */
  115760. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115761. }
  115762. }
  115763. declare module BABYLON {
  115764. /**
  115765. * COnfiguration object for WebXR output canvas
  115766. */
  115767. export class WebXRManagedOutputCanvasOptions {
  115768. /**
  115769. * Options for this XR Layer output
  115770. */
  115771. canvasOptions?: XRWebGLLayerOptions;
  115772. /**
  115773. * CSS styling for a newly created canvas (if not provided)
  115774. */
  115775. newCanvasCssStyle?: string;
  115776. /**
  115777. * An optional canvas in case you wish to create it yourself and provide it here.
  115778. * If not provided, a new canvas will be created
  115779. */
  115780. canvasElement?: HTMLCanvasElement;
  115781. /**
  115782. * Get the default values of the configuration object
  115783. * @returns default values of this configuration object
  115784. */
  115785. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115786. }
  115787. /**
  115788. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115789. */
  115790. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115791. private _options;
  115792. private _engine;
  115793. private _canvas;
  115794. /**
  115795. * Rendering context of the canvas which can be used to display/mirror xr content
  115796. */
  115797. canvasContext: WebGLRenderingContext;
  115798. /**
  115799. * xr layer for the canvas
  115800. */
  115801. xrLayer: Nullable<XRWebGLLayer>;
  115802. /**
  115803. * Initializes the xr layer for the session
  115804. * @param xrSession xr session
  115805. * @returns a promise that will resolve once the XR Layer has been created
  115806. */
  115807. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115808. /**
  115809. * Initializes the canvas to be added/removed upon entering/exiting xr
  115810. * @param _xrSessionManager The XR Session manager
  115811. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115812. */
  115813. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115814. /**
  115815. * Disposes of the object
  115816. */
  115817. dispose(): void;
  115818. private _setManagedOutputCanvas;
  115819. private _addCanvas;
  115820. private _removeCanvas;
  115821. }
  115822. }
  115823. declare module BABYLON {
  115824. /**
  115825. * Manages an XRSession to work with Babylon's engine
  115826. * @see https://doc.babylonjs.com/how_to/webxr
  115827. */
  115828. export class WebXRSessionManager implements IDisposable {
  115829. /** The scene which the session should be created for */
  115830. scene: Scene;
  115831. /**
  115832. * Fires every time a new xrFrame arrives which can be used to update the camera
  115833. */
  115834. onXRFrameObservable: Observable<XRFrame>;
  115835. /**
  115836. * Fires when the xr session is ended either by the device or manually done
  115837. */
  115838. onXRSessionEnded: Observable<any>;
  115839. /**
  115840. * Fires when the xr session is ended either by the device or manually done
  115841. */
  115842. onXRSessionInit: Observable<XRSession>;
  115843. /**
  115844. * Fires when the reference space changed
  115845. */
  115846. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115847. /**
  115848. * Underlying xr session
  115849. */
  115850. session: XRSession;
  115851. /**
  115852. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115853. * or get the offset the player is currently at.
  115854. */
  115855. viewerReferenceSpace: XRReferenceSpace;
  115856. private _referenceSpace;
  115857. /**
  115858. * The current reference space used in this session. This reference space can constantly change!
  115859. * It is mainly used to offset the camera's position.
  115860. */
  115861. get referenceSpace(): XRReferenceSpace;
  115862. /**
  115863. * Set a new reference space and triggers the observable
  115864. */
  115865. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115866. /**
  115867. * The base reference space from which the session started. good if you want to reset your
  115868. * reference space
  115869. */
  115870. baseReferenceSpace: XRReferenceSpace;
  115871. /**
  115872. * Used just in case of a failure to initialize an immersive session.
  115873. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115874. */
  115875. defaultHeightCompensation: number;
  115876. /**
  115877. * Current XR frame
  115878. */
  115879. currentFrame: Nullable<XRFrame>;
  115880. /** WebXR timestamp updated every frame */
  115881. currentTimestamp: number;
  115882. private _xrNavigator;
  115883. private baseLayer;
  115884. private _rttProvider;
  115885. private _sessionEnded;
  115886. /**
  115887. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115888. * @param scene The scene which the session should be created for
  115889. */
  115890. constructor(
  115891. /** The scene which the session should be created for */
  115892. scene: Scene);
  115893. /**
  115894. * Initializes the manager
  115895. * After initialization enterXR can be called to start an XR session
  115896. * @returns Promise which resolves after it is initialized
  115897. */
  115898. initializeAsync(): Promise<void>;
  115899. /**
  115900. * Initializes an xr session
  115901. * @param xrSessionMode mode to initialize
  115902. * @param xrSessionInit defines optional and required values to pass to the session builder
  115903. * @returns a promise which will resolve once the session has been initialized
  115904. */
  115905. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115906. /**
  115907. * Sets the reference space on the xr session
  115908. * @param referenceSpaceType space to set
  115909. * @returns a promise that will resolve once the reference space has been set
  115910. */
  115911. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115912. /**
  115913. * Resets the reference space to the one started the session
  115914. */
  115915. resetReferenceSpace(): void;
  115916. /**
  115917. * Updates the render state of the session
  115918. * @param state state to set
  115919. * @returns a promise that resolves once the render state has been updated
  115920. */
  115921. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115922. /**
  115923. * Starts rendering to the xr layer
  115924. */
  115925. runXRRenderLoop(): void;
  115926. /**
  115927. * Gets the correct render target texture to be rendered this frame for this eye
  115928. * @param eye the eye for which to get the render target
  115929. * @returns the render target for the specified eye
  115930. */
  115931. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115932. /**
  115933. * Stops the xrSession and restores the renderloop
  115934. * @returns Promise which resolves after it exits XR
  115935. */
  115936. exitXRAsync(): Promise<void>;
  115937. /**
  115938. * Checks if a session would be supported for the creation options specified
  115939. * @param sessionMode session mode to check if supported eg. immersive-vr
  115940. * @returns A Promise that resolves to true if supported and false if not
  115941. */
  115942. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115943. /**
  115944. * Creates a WebXRRenderTarget object for the XR session
  115945. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115946. * @param options optional options to provide when creating a new render target
  115947. * @returns a WebXR render target to which the session can render
  115948. */
  115949. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115950. /**
  115951. * @hidden
  115952. * Converts the render layer of xrSession to a render target
  115953. * @param session session to create render target for
  115954. * @param scene scene the new render target should be created for
  115955. * @param baseLayer the webgl layer to create the render target for
  115956. */
  115957. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115958. /**
  115959. * Disposes of the session manager
  115960. */
  115961. dispose(): void;
  115962. /**
  115963. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115964. * @param sessionMode defines the session to test
  115965. * @returns a promise with boolean as final value
  115966. */
  115967. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115968. }
  115969. }
  115970. declare module BABYLON {
  115971. /**
  115972. * WebXR Camera which holds the views for the xrSession
  115973. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115974. */
  115975. export class WebXRCamera extends FreeCamera {
  115976. private _xrSessionManager;
  115977. private _firstFrame;
  115978. private _referenceQuaternion;
  115979. private _referencedPosition;
  115980. private _xrInvPositionCache;
  115981. private _xrInvQuaternionCache;
  115982. /**
  115983. * Should position compensation execute on first frame.
  115984. * This is used when copying the position from a native (non XR) camera
  115985. */
  115986. compensateOnFirstFrame: boolean;
  115987. /**
  115988. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115989. * @param name the name of the camera
  115990. * @param scene the scene to add the camera to
  115991. * @param _xrSessionManager a constructed xr session manager
  115992. */
  115993. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115994. /**
  115995. * Return the user's height, unrelated to the current ground.
  115996. * This will be the y position of this camera, when ground level is 0.
  115997. */
  115998. get realWorldHeight(): number;
  115999. /** @hidden */
  116000. _updateForDualEyeDebugging(): void;
  116001. /**
  116002. * Sets this camera's transformation based on a non-vr camera
  116003. * @param otherCamera the non-vr camera to copy the transformation from
  116004. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116005. */
  116006. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116007. private _updateFromXRSession;
  116008. private _updateNumberOfRigCameras;
  116009. private _updateReferenceSpace;
  116010. private _updateReferenceSpaceOffset;
  116011. }
  116012. }
  116013. declare module BABYLON {
  116014. /**
  116015. * Defining the interface required for a (webxr) feature
  116016. */
  116017. export interface IWebXRFeature extends IDisposable {
  116018. /**
  116019. * Is this feature attached
  116020. */
  116021. attached: boolean;
  116022. /**
  116023. * Should auto-attach be disabled?
  116024. */
  116025. disableAutoAttach: boolean;
  116026. /**
  116027. * Attach the feature to the session
  116028. * Will usually be called by the features manager
  116029. *
  116030. * @param force should attachment be forced (even when already attached)
  116031. * @returns true if successful.
  116032. */
  116033. attach(force?: boolean): boolean;
  116034. /**
  116035. * Detach the feature from the session
  116036. * Will usually be called by the features manager
  116037. *
  116038. * @returns true if successful.
  116039. */
  116040. detach(): boolean;
  116041. }
  116042. /**
  116043. * A list of the currently available features without referencing them
  116044. */
  116045. export class WebXRFeatureName {
  116046. /**
  116047. * The name of the hit test feature
  116048. */
  116049. static HIT_TEST: string;
  116050. /**
  116051. * The name of the anchor system feature
  116052. */
  116053. static ANCHOR_SYSTEM: string;
  116054. /**
  116055. * The name of the background remover feature
  116056. */
  116057. static BACKGROUND_REMOVER: string;
  116058. /**
  116059. * The name of the pointer selection feature
  116060. */
  116061. static POINTER_SELECTION: string;
  116062. /**
  116063. * The name of the teleportation feature
  116064. */
  116065. static TELEPORTATION: string;
  116066. /**
  116067. * The name of the plane detection feature
  116068. */
  116069. static PLANE_DETECTION: string;
  116070. /**
  116071. * physics impostors for xr controllers feature
  116072. */
  116073. static PHYSICS_CONTROLLERS: string;
  116074. }
  116075. /**
  116076. * Defining the constructor of a feature. Used to register the modules.
  116077. */
  116078. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116079. /**
  116080. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116081. * It is mainly used in AR sessions.
  116082. *
  116083. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116084. */
  116085. export class WebXRFeaturesManager implements IDisposable {
  116086. private _xrSessionManager;
  116087. private static readonly _AvailableFeatures;
  116088. /**
  116089. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116090. * Mainly used internally.
  116091. *
  116092. * @param featureName the name of the feature to register
  116093. * @param constructorFunction the function used to construct the module
  116094. * @param version the (babylon) version of the module
  116095. * @param stable is that a stable version of this module
  116096. */
  116097. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116098. /**
  116099. * Returns a constructor of a specific feature.
  116100. *
  116101. * @param featureName the name of the feature to construct
  116102. * @param version the version of the feature to load
  116103. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116104. * @param options optional options provided to the module.
  116105. * @returns a function that, when called, will return a new instance of this feature
  116106. */
  116107. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116108. /**
  116109. * Return the latest unstable version of this feature
  116110. * @param featureName the name of the feature to search
  116111. * @returns the version number. if not found will return -1
  116112. */
  116113. static GetLatestVersionOfFeature(featureName: string): number;
  116114. /**
  116115. * Return the latest stable version of this feature
  116116. * @param featureName the name of the feature to search
  116117. * @returns the version number. if not found will return -1
  116118. */
  116119. static GetStableVersionOfFeature(featureName: string): number;
  116120. /**
  116121. * Can be used to return the list of features currently registered
  116122. *
  116123. * @returns an Array of available features
  116124. */
  116125. static GetAvailableFeatures(): string[];
  116126. /**
  116127. * Gets the versions available for a specific feature
  116128. * @param featureName the name of the feature
  116129. * @returns an array with the available versions
  116130. */
  116131. static GetAvailableVersions(featureName: string): string[];
  116132. private _features;
  116133. /**
  116134. * constructs a new features manages.
  116135. *
  116136. * @param _xrSessionManager an instance of WebXRSessionManager
  116137. */
  116138. constructor(_xrSessionManager: WebXRSessionManager);
  116139. /**
  116140. * 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.
  116141. * 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.
  116142. *
  116143. * @param featureName the name of the feature to load or the class of the feature
  116144. * @param version optional version to load. if not provided the latest version will be enabled
  116145. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116146. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116147. * @returns a new constructed feature or throws an error if feature not found.
  116148. */
  116149. enableFeature(featureName: string | {
  116150. Name: string;
  116151. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116152. /**
  116153. * Used to disable an already-enabled feature
  116154. * The feature will be disposed and will be recreated once enabled.
  116155. * @param featureName the feature to disable
  116156. * @returns true if disable was successful
  116157. */
  116158. disableFeature(featureName: string | {
  116159. Name: string;
  116160. }): boolean;
  116161. /**
  116162. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116163. * Can be used during a session to start a feature
  116164. * @param featureName the name of feature to attach
  116165. */
  116166. attachFeature(featureName: string): void;
  116167. /**
  116168. * Can be used inside a session or when the session ends to detach a specific feature
  116169. * @param featureName the name of the feature to detach
  116170. */
  116171. detachFeature(featureName: string): void;
  116172. /**
  116173. * Get the list of enabled features
  116174. * @returns an array of enabled features
  116175. */
  116176. getEnabledFeatures(): string[];
  116177. /**
  116178. * get the implementation of an enabled feature.
  116179. * @param featureName the name of the feature to load
  116180. * @returns the feature class, if found
  116181. */
  116182. getEnabledFeature(featureName: string): IWebXRFeature;
  116183. /**
  116184. * dispose this features manager
  116185. */
  116186. dispose(): void;
  116187. }
  116188. }
  116189. declare module BABYLON {
  116190. /**
  116191. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116192. * @see https://doc.babylonjs.com/how_to/webxr
  116193. */
  116194. export class WebXRExperienceHelper implements IDisposable {
  116195. private scene;
  116196. /**
  116197. * Camera used to render xr content
  116198. */
  116199. camera: WebXRCamera;
  116200. /**
  116201. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116202. */
  116203. state: WebXRState;
  116204. private _setState;
  116205. /**
  116206. * Fires when the state of the experience helper has changed
  116207. */
  116208. onStateChangedObservable: Observable<WebXRState>;
  116209. /**
  116210. * Observers registered here will be triggered after the camera's initial transformation is set
  116211. * This can be used to set a different ground level or an extra rotation.
  116212. *
  116213. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116214. * to the position set after this observable is done executing.
  116215. */
  116216. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116217. /** Session manager used to keep track of xr session */
  116218. sessionManager: WebXRSessionManager;
  116219. /** A features manager for this xr session */
  116220. featuresManager: WebXRFeaturesManager;
  116221. private _nonVRCamera;
  116222. private _originalSceneAutoClear;
  116223. private _supported;
  116224. /**
  116225. * Creates the experience helper
  116226. * @param scene the scene to attach the experience helper to
  116227. * @returns a promise for the experience helper
  116228. */
  116229. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116230. /**
  116231. * Creates a WebXRExperienceHelper
  116232. * @param scene The scene the helper should be created in
  116233. */
  116234. private constructor();
  116235. /**
  116236. * Exits XR mode and returns the scene to its original state
  116237. * @returns promise that resolves after xr mode has exited
  116238. */
  116239. exitXRAsync(): Promise<void>;
  116240. /**
  116241. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116242. * @param sessionMode options for the XR session
  116243. * @param referenceSpaceType frame of reference of the XR session
  116244. * @param renderTarget the output canvas that will be used to enter XR mode
  116245. * @returns promise that resolves after xr mode has entered
  116246. */
  116247. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116248. /**
  116249. * Disposes of the experience helper
  116250. */
  116251. dispose(): void;
  116252. private _nonXRToXRCamera;
  116253. }
  116254. }
  116255. declare module BABYLON {
  116256. /**
  116257. * X-Y values for axes in WebXR
  116258. */
  116259. export interface IWebXRMotionControllerAxesValue {
  116260. /**
  116261. * The value of the x axis
  116262. */
  116263. x: number;
  116264. /**
  116265. * The value of the y-axis
  116266. */
  116267. y: number;
  116268. }
  116269. /**
  116270. * changed / previous values for the values of this component
  116271. */
  116272. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116273. /**
  116274. * current (this frame) value
  116275. */
  116276. current: T;
  116277. /**
  116278. * previous (last change) value
  116279. */
  116280. previous: T;
  116281. }
  116282. /**
  116283. * Represents changes in the component between current frame and last values recorded
  116284. */
  116285. export interface IWebXRMotionControllerComponentChanges {
  116286. /**
  116287. * will be populated with previous and current values if touched changed
  116288. */
  116289. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116290. /**
  116291. * will be populated with previous and current values if pressed changed
  116292. */
  116293. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116294. /**
  116295. * will be populated with previous and current values if value changed
  116296. */
  116297. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116298. /**
  116299. * will be populated with previous and current values if axes changed
  116300. */
  116301. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116302. }
  116303. /**
  116304. * This class represents a single component (for example button or thumbstick) of a motion controller
  116305. */
  116306. export class WebXRControllerComponent implements IDisposable {
  116307. /**
  116308. * the id of this component
  116309. */
  116310. id: string;
  116311. /**
  116312. * the type of the component
  116313. */
  116314. type: MotionControllerComponentType;
  116315. private _buttonIndex;
  116316. private _axesIndices;
  116317. /**
  116318. * Thumbstick component type
  116319. */
  116320. static THUMBSTICK: MotionControllerComponentType;
  116321. /**
  116322. * Touchpad component type
  116323. */
  116324. static TOUCHPAD: MotionControllerComponentType;
  116325. /**
  116326. * trigger component type
  116327. */
  116328. static TRIGGER: MotionControllerComponentType;
  116329. /**
  116330. * squeeze component type
  116331. */
  116332. static SQUEEZE: MotionControllerComponentType;
  116333. /**
  116334. * button component type
  116335. */
  116336. static BUTTON: MotionControllerComponentType;
  116337. /**
  116338. * Observers registered here will be triggered when the state of a button changes
  116339. * State change is either pressed / touched / value
  116340. */
  116341. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116342. /**
  116343. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116344. * the axes data changes
  116345. */
  116346. onAxisValueChangedObservable: Observable<{
  116347. x: number;
  116348. y: number;
  116349. }>;
  116350. private _currentValue;
  116351. private _touched;
  116352. private _pressed;
  116353. private _axes;
  116354. private _changes;
  116355. private _hasChanges;
  116356. /**
  116357. * Return whether or not the component changed the last frame
  116358. */
  116359. get hasChanges(): boolean;
  116360. /**
  116361. * Creates a new component for a motion controller.
  116362. * It is created by the motion controller itself
  116363. *
  116364. * @param id the id of this component
  116365. * @param type the type of the component
  116366. * @param _buttonIndex index in the buttons array of the gamepad
  116367. * @param _axesIndices indices of the values in the axes array of the gamepad
  116368. */
  116369. constructor(
  116370. /**
  116371. * the id of this component
  116372. */
  116373. id: string,
  116374. /**
  116375. * the type of the component
  116376. */
  116377. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116378. /**
  116379. * Get the current value of this component
  116380. */
  116381. get value(): number;
  116382. /**
  116383. * is the button currently pressed
  116384. */
  116385. get pressed(): boolean;
  116386. /**
  116387. * is the button currently touched
  116388. */
  116389. get touched(): boolean;
  116390. /**
  116391. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116392. */
  116393. get axes(): IWebXRMotionControllerAxesValue;
  116394. /**
  116395. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116396. */
  116397. get changes(): IWebXRMotionControllerComponentChanges;
  116398. /**
  116399. * Is this component a button (hence - pressable)
  116400. * @returns true if can be pressed
  116401. */
  116402. isButton(): boolean;
  116403. /**
  116404. * Are there axes correlating to this component
  116405. * @return true is axes data is available
  116406. */
  116407. isAxes(): boolean;
  116408. /**
  116409. * update this component using the gamepad object it is in. Called on every frame
  116410. * @param nativeController the native gamepad controller object
  116411. */
  116412. update(nativeController: IMinimalMotionControllerObject): void;
  116413. /**
  116414. * Dispose this component
  116415. */
  116416. dispose(): void;
  116417. }
  116418. }
  116419. declare module BABYLON {
  116420. /**
  116421. * Class used to represent data loading progression
  116422. */
  116423. export class SceneLoaderProgressEvent {
  116424. /** defines if data length to load can be evaluated */
  116425. readonly lengthComputable: boolean;
  116426. /** defines the loaded data length */
  116427. readonly loaded: number;
  116428. /** defines the data length to load */
  116429. readonly total: number;
  116430. /**
  116431. * Create a new progress event
  116432. * @param lengthComputable defines if data length to load can be evaluated
  116433. * @param loaded defines the loaded data length
  116434. * @param total defines the data length to load
  116435. */
  116436. constructor(
  116437. /** defines if data length to load can be evaluated */
  116438. lengthComputable: boolean,
  116439. /** defines the loaded data length */
  116440. loaded: number,
  116441. /** defines the data length to load */
  116442. total: number);
  116443. /**
  116444. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116445. * @param event defines the source event
  116446. * @returns a new SceneLoaderProgressEvent
  116447. */
  116448. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116449. }
  116450. /**
  116451. * Interface used by SceneLoader plugins to define supported file extensions
  116452. */
  116453. export interface ISceneLoaderPluginExtensions {
  116454. /**
  116455. * Defines the list of supported extensions
  116456. */
  116457. [extension: string]: {
  116458. isBinary: boolean;
  116459. };
  116460. }
  116461. /**
  116462. * Interface used by SceneLoader plugin factory
  116463. */
  116464. export interface ISceneLoaderPluginFactory {
  116465. /**
  116466. * Defines the name of the factory
  116467. */
  116468. name: string;
  116469. /**
  116470. * Function called to create a new plugin
  116471. * @return the new plugin
  116472. */
  116473. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116474. /**
  116475. * The callback that returns true if the data can be directly loaded.
  116476. * @param data string containing the file data
  116477. * @returns if the data can be loaded directly
  116478. */
  116479. canDirectLoad?(data: string): boolean;
  116480. }
  116481. /**
  116482. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116483. */
  116484. export interface ISceneLoaderPluginBase {
  116485. /**
  116486. * The friendly name of this plugin.
  116487. */
  116488. name: string;
  116489. /**
  116490. * The file extensions supported by this plugin.
  116491. */
  116492. extensions: string | ISceneLoaderPluginExtensions;
  116493. /**
  116494. * The callback called when loading from a url.
  116495. * @param scene scene loading this url
  116496. * @param url url to load
  116497. * @param onSuccess callback called when the file successfully loads
  116498. * @param onProgress callback called while file is loading (if the server supports this mode)
  116499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116500. * @param onError callback called when the file fails to load
  116501. * @returns a file request object
  116502. */
  116503. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116504. /**
  116505. * The callback called when loading from a file object.
  116506. * @param scene scene loading this file
  116507. * @param file defines the file to load
  116508. * @param onSuccess defines the callback to call when data is loaded
  116509. * @param onProgress defines the callback to call during loading process
  116510. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116511. * @param onError defines the callback to call when an error occurs
  116512. * @returns a file request object
  116513. */
  116514. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116515. /**
  116516. * The callback that returns true if the data can be directly loaded.
  116517. * @param data string containing the file data
  116518. * @returns if the data can be loaded directly
  116519. */
  116520. canDirectLoad?(data: string): boolean;
  116521. /**
  116522. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116523. * @param scene scene loading this data
  116524. * @param data string containing the data
  116525. * @returns data to pass to the plugin
  116526. */
  116527. directLoad?(scene: Scene, data: string): any;
  116528. /**
  116529. * The callback that allows custom handling of the root url based on the response url.
  116530. * @param rootUrl the original root url
  116531. * @param responseURL the response url if available
  116532. * @returns the new root url
  116533. */
  116534. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116535. }
  116536. /**
  116537. * Interface used to define a SceneLoader plugin
  116538. */
  116539. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116540. /**
  116541. * Import meshes into a scene.
  116542. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116543. * @param scene The scene to import into
  116544. * @param data The data to import
  116545. * @param rootUrl The root url for scene and resources
  116546. * @param meshes The meshes array to import into
  116547. * @param particleSystems The particle systems array to import into
  116548. * @param skeletons The skeletons array to import into
  116549. * @param onError The callback when import fails
  116550. * @returns True if successful or false otherwise
  116551. */
  116552. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116553. /**
  116554. * Load into a scene.
  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 True if successful or false otherwise
  116560. */
  116561. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116562. /**
  116563. * Load into an asset container.
  116564. * @param scene The scene to load into
  116565. * @param data The data to import
  116566. * @param rootUrl The root url for scene and resources
  116567. * @param onError The callback when import fails
  116568. * @returns The loaded asset container
  116569. */
  116570. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116571. }
  116572. /**
  116573. * Interface used to define an async SceneLoader plugin
  116574. */
  116575. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116576. /**
  116577. * Import meshes into a scene.
  116578. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116579. * @param scene The scene to import into
  116580. * @param data The data to import
  116581. * @param rootUrl The root url for scene and resources
  116582. * @param onProgress The callback when the load progresses
  116583. * @param fileName Defines the name of the file to load
  116584. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116585. */
  116586. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116587. meshes: AbstractMesh[];
  116588. particleSystems: IParticleSystem[];
  116589. skeletons: Skeleton[];
  116590. animationGroups: AnimationGroup[];
  116591. }>;
  116592. /**
  116593. * Load into a scene.
  116594. * @param scene The scene to load into
  116595. * @param data The data to import
  116596. * @param rootUrl The root url for scene and resources
  116597. * @param onProgress The callback when the load progresses
  116598. * @param fileName Defines the name of the file to load
  116599. * @returns Nothing
  116600. */
  116601. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116602. /**
  116603. * Load into an asset container.
  116604. * @param scene The scene to load into
  116605. * @param data The data to import
  116606. * @param rootUrl The root url for scene and resources
  116607. * @param onProgress The callback when the load progresses
  116608. * @param fileName Defines the name of the file to load
  116609. * @returns The loaded asset container
  116610. */
  116611. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116612. }
  116613. /**
  116614. * Mode that determines how to handle old animation groups before loading new ones.
  116615. */
  116616. export enum SceneLoaderAnimationGroupLoadingMode {
  116617. /**
  116618. * Reset all old animations to initial state then dispose them.
  116619. */
  116620. Clean = 0,
  116621. /**
  116622. * Stop all old animations.
  116623. */
  116624. Stop = 1,
  116625. /**
  116626. * Restart old animations from first frame.
  116627. */
  116628. Sync = 2,
  116629. /**
  116630. * Old animations remains untouched.
  116631. */
  116632. NoSync = 3
  116633. }
  116634. /**
  116635. * Class used to load scene from various file formats using registered plugins
  116636. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116637. */
  116638. export class SceneLoader {
  116639. /**
  116640. * No logging while loading
  116641. */
  116642. static readonly NO_LOGGING: number;
  116643. /**
  116644. * Minimal logging while loading
  116645. */
  116646. static readonly MINIMAL_LOGGING: number;
  116647. /**
  116648. * Summary logging while loading
  116649. */
  116650. static readonly SUMMARY_LOGGING: number;
  116651. /**
  116652. * Detailled logging while loading
  116653. */
  116654. static readonly DETAILED_LOGGING: number;
  116655. /**
  116656. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116657. */
  116658. static get ForceFullSceneLoadingForIncremental(): boolean;
  116659. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116660. /**
  116661. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116662. */
  116663. static get ShowLoadingScreen(): boolean;
  116664. static set ShowLoadingScreen(value: boolean);
  116665. /**
  116666. * Defines the current logging level (while loading the scene)
  116667. * @ignorenaming
  116668. */
  116669. static get loggingLevel(): number;
  116670. static set loggingLevel(value: number);
  116671. /**
  116672. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116673. */
  116674. static get CleanBoneMatrixWeights(): boolean;
  116675. static set CleanBoneMatrixWeights(value: boolean);
  116676. /**
  116677. * Event raised when a plugin is used to load a scene
  116678. */
  116679. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116680. private static _registeredPlugins;
  116681. private static _getDefaultPlugin;
  116682. private static _getPluginForExtension;
  116683. private static _getPluginForDirectLoad;
  116684. private static _getPluginForFilename;
  116685. private static _getDirectLoad;
  116686. private static _loadData;
  116687. private static _getFileInfo;
  116688. /**
  116689. * Gets a plugin that can load the given extension
  116690. * @param extension defines the extension to load
  116691. * @returns a plugin or null if none works
  116692. */
  116693. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116694. /**
  116695. * Gets a boolean indicating that the given extension can be loaded
  116696. * @param extension defines the extension to load
  116697. * @returns true if the extension is supported
  116698. */
  116699. static IsPluginForExtensionAvailable(extension: string): boolean;
  116700. /**
  116701. * Adds a new plugin to the list of registered plugins
  116702. * @param plugin defines the plugin to add
  116703. */
  116704. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116705. /**
  116706. * Import meshes into a scene
  116707. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116708. * @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)
  116709. * @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)
  116710. * @param scene the instance of BABYLON.Scene to append to
  116711. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116712. * @param onProgress a callback with a progress event for each file being loaded
  116713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116714. * @param pluginExtension the extension used to determine the plugin
  116715. * @returns The loaded plugin
  116716. */
  116717. 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>;
  116718. /**
  116719. * Import meshes into a scene
  116720. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116721. * @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)
  116722. * @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)
  116723. * @param scene the instance of BABYLON.Scene to append to
  116724. * @param onProgress a callback with a progress event for each file being loaded
  116725. * @param pluginExtension the extension used to determine the plugin
  116726. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116727. */
  116728. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116729. meshes: AbstractMesh[];
  116730. particleSystems: IParticleSystem[];
  116731. skeletons: Skeleton[];
  116732. animationGroups: AnimationGroup[];
  116733. }>;
  116734. /**
  116735. * Load a scene
  116736. * @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)
  116737. * @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)
  116738. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116739. * @param onSuccess a callback with the scene when import succeeds
  116740. * @param onProgress a callback with a progress event for each file being loaded
  116741. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116742. * @param pluginExtension the extension used to determine the plugin
  116743. * @returns The loaded plugin
  116744. */
  116745. 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>;
  116746. /**
  116747. * Load a scene
  116748. * @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)
  116749. * @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)
  116750. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116751. * @param onProgress a callback with a progress event for each file being loaded
  116752. * @param pluginExtension the extension used to determine the plugin
  116753. * @returns The loaded scene
  116754. */
  116755. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116756. /**
  116757. * Append a scene
  116758. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116759. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116760. * @param scene is the instance of BABYLON.Scene to append to
  116761. * @param onSuccess a callback with the scene when import succeeds
  116762. * @param onProgress a callback with a progress event for each file being loaded
  116763. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116764. * @param pluginExtension the extension used to determine the plugin
  116765. * @returns The loaded plugin
  116766. */
  116767. static 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>;
  116768. /**
  116769. * Append a scene
  116770. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116771. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116772. * @param scene is the instance of BABYLON.Scene to append to
  116773. * @param onProgress a callback with a progress event for each file being loaded
  116774. * @param pluginExtension the extension used to determine the plugin
  116775. * @returns The given scene
  116776. */
  116777. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116778. /**
  116779. * Load a scene into an asset container
  116780. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116781. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116782. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116783. * @param onSuccess a callback with the scene when import succeeds
  116784. * @param onProgress a callback with a progress event for each file being loaded
  116785. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116786. * @param pluginExtension the extension used to determine the plugin
  116787. * @returns The loaded plugin
  116788. */
  116789. static 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>;
  116790. /**
  116791. * Load a scene into an asset container
  116792. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116793. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  116794. * @param scene is the instance of Scene to append to
  116795. * @param onProgress a callback with a progress event for each file being loaded
  116796. * @param pluginExtension the extension used to determine the plugin
  116797. * @returns The loaded asset container
  116798. */
  116799. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116800. /**
  116801. * Import animations from a file into a scene
  116802. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116803. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116804. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116805. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116806. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116807. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116808. * @param onSuccess a callback with the scene when import succeeds
  116809. * @param onProgress a callback with a progress event for each file being loaded
  116810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116811. */
  116812. 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;
  116813. /**
  116814. * Import animations from a file into a scene
  116815. * @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)
  116816. * @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)
  116817. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116818. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116819. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116820. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116821. * @param onSuccess a callback with the scene when import succeeds
  116822. * @param onProgress a callback with a progress event for each file being loaded
  116823. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116824. * @returns the updated scene with imported animations
  116825. */
  116826. 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>;
  116827. }
  116828. }
  116829. declare module BABYLON {
  116830. /**
  116831. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116832. */
  116833. export type MotionControllerHandness = "none" | "left" | "right";
  116834. /**
  116835. * The type of components available in motion controllers.
  116836. * This is not the name of the component.
  116837. */
  116838. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116839. /**
  116840. * The state of a controller component
  116841. */
  116842. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116843. /**
  116844. * The schema of motion controller layout.
  116845. * No object will be initialized using this interface
  116846. * This is used just to define the profile.
  116847. */
  116848. export interface IMotionControllerLayout {
  116849. /**
  116850. * Defines the main button component id
  116851. */
  116852. selectComponentId: string;
  116853. /**
  116854. * Available components (unsorted)
  116855. */
  116856. components: {
  116857. /**
  116858. * A map of component Ids
  116859. */
  116860. [componentId: string]: {
  116861. /**
  116862. * The type of input the component outputs
  116863. */
  116864. type: MotionControllerComponentType;
  116865. /**
  116866. * The indices of this component in the gamepad object
  116867. */
  116868. gamepadIndices: {
  116869. /**
  116870. * Index of button
  116871. */
  116872. button?: number;
  116873. /**
  116874. * If available, index of x-axis
  116875. */
  116876. xAxis?: number;
  116877. /**
  116878. * If available, index of y-axis
  116879. */
  116880. yAxis?: number;
  116881. };
  116882. /**
  116883. * The mesh's root node name
  116884. */
  116885. rootNodeName: string;
  116886. /**
  116887. * Animation definitions for this model
  116888. */
  116889. visualResponses: {
  116890. [stateKey: string]: {
  116891. /**
  116892. * What property will be animated
  116893. */
  116894. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116895. /**
  116896. * What states influence this visual reponse
  116897. */
  116898. states: MotionControllerComponentStateType[];
  116899. /**
  116900. * Type of animation - movement or visibility
  116901. */
  116902. valueNodeProperty: "transform" | "visibility";
  116903. /**
  116904. * Base node name to move. Its position will be calculated according to the min and max nodes
  116905. */
  116906. valueNodeName?: string;
  116907. /**
  116908. * Minimum movement node
  116909. */
  116910. minNodeName?: string;
  116911. /**
  116912. * Max movement node
  116913. */
  116914. maxNodeName?: string;
  116915. };
  116916. };
  116917. /**
  116918. * If touch enabled, what is the name of node to display user feedback
  116919. */
  116920. touchPointNodeName?: string;
  116921. };
  116922. };
  116923. /**
  116924. * Is it xr standard mapping or not
  116925. */
  116926. gamepadMapping: "" | "xr-standard";
  116927. /**
  116928. * Base root node of this entire model
  116929. */
  116930. rootNodeName: string;
  116931. /**
  116932. * Path to load the assets. Usually relative to the base path
  116933. */
  116934. assetPath: string;
  116935. }
  116936. /**
  116937. * A definition for the layout map in the input profile
  116938. */
  116939. export interface IMotionControllerLayoutMap {
  116940. /**
  116941. * Layouts with handness type as a key
  116942. */
  116943. [handness: string]: IMotionControllerLayout;
  116944. }
  116945. /**
  116946. * The XR Input profile schema
  116947. * Profiles can be found here:
  116948. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116949. */
  116950. export interface IMotionControllerProfile {
  116951. /**
  116952. * The id of this profile
  116953. * correlates to the profile(s) in the xrInput.profiles array
  116954. */
  116955. profileId: string;
  116956. /**
  116957. * fallback profiles for this profileId
  116958. */
  116959. fallbackProfileIds: string[];
  116960. /**
  116961. * The layout map, with handness as key
  116962. */
  116963. layouts: IMotionControllerLayoutMap;
  116964. }
  116965. /**
  116966. * A helper-interface for the 3 meshes needed for controller button animation
  116967. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116968. */
  116969. export interface IMotionControllerButtonMeshMap {
  116970. /**
  116971. * The mesh that will be changed when value changes
  116972. */
  116973. valueMesh: AbstractMesh;
  116974. /**
  116975. * the mesh that defines the pressed value mesh position.
  116976. * This is used to find the max-position of this button
  116977. */
  116978. pressedMesh: AbstractMesh;
  116979. /**
  116980. * the mesh that defines the unpressed value mesh position.
  116981. * This is used to find the min (or initial) position of this button
  116982. */
  116983. unpressedMesh: AbstractMesh;
  116984. }
  116985. /**
  116986. * A helper-interface for the 3 meshes needed for controller axis animation.
  116987. * This will be expanded when touchpad animations are fully supported
  116988. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116989. */
  116990. export interface IMotionControllerMeshMap {
  116991. /**
  116992. * The mesh that will be changed when axis value changes
  116993. */
  116994. valueMesh: AbstractMesh;
  116995. /**
  116996. * the mesh that defines the minimum value mesh position.
  116997. */
  116998. minMesh?: AbstractMesh;
  116999. /**
  117000. * the mesh that defines the maximum value mesh position.
  117001. */
  117002. maxMesh?: AbstractMesh;
  117003. }
  117004. /**
  117005. * The elements needed for change-detection of the gamepad objects in motion controllers
  117006. */
  117007. export interface IMinimalMotionControllerObject {
  117008. /**
  117009. * An array of available buttons
  117010. */
  117011. buttons: Array<{
  117012. /**
  117013. * Value of the button/trigger
  117014. */
  117015. value: number;
  117016. /**
  117017. * If the button/trigger is currently touched
  117018. */
  117019. touched: boolean;
  117020. /**
  117021. * If the button/trigger is currently pressed
  117022. */
  117023. pressed: boolean;
  117024. }>;
  117025. /**
  117026. * Available axes of this controller
  117027. */
  117028. axes: number[];
  117029. }
  117030. /**
  117031. * An Abstract Motion controller
  117032. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117033. * Each component has an observable to check for changes in value and state
  117034. */
  117035. export abstract class WebXRAbstractMotionController implements IDisposable {
  117036. protected scene: Scene;
  117037. protected layout: IMotionControllerLayout;
  117038. /**
  117039. * The gamepad object correlating to this controller
  117040. */
  117041. gamepadObject: IMinimalMotionControllerObject;
  117042. /**
  117043. * handness (left/right/none) of this controller
  117044. */
  117045. handness: MotionControllerHandness;
  117046. /**
  117047. * The profile id of this motion controller
  117048. */
  117049. abstract profileId: string;
  117050. /**
  117051. * A map of components (WebXRControllerComponent) in this motion controller
  117052. * Components have a ComponentType and can also have both button and axis definitions
  117053. */
  117054. readonly components: {
  117055. [id: string]: WebXRControllerComponent;
  117056. };
  117057. /**
  117058. * Observers registered here will be triggered when the model of this controller is done loading
  117059. */
  117060. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117061. /**
  117062. * The root mesh of the model. It is null if the model was not yet initialized
  117063. */
  117064. rootMesh: Nullable<AbstractMesh>;
  117065. /**
  117066. * Disable the model's animation. Can be set at any time.
  117067. */
  117068. disableAnimation: boolean;
  117069. private _modelReady;
  117070. /**
  117071. * constructs a new abstract motion controller
  117072. * @param scene the scene to which the model of the controller will be added
  117073. * @param layout The profile layout to load
  117074. * @param gamepadObject The gamepad object correlating to this controller
  117075. * @param handness handness (left/right/none) of this controller
  117076. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117077. */
  117078. constructor(scene: Scene, layout: IMotionControllerLayout,
  117079. /**
  117080. * The gamepad object correlating to this controller
  117081. */
  117082. gamepadObject: IMinimalMotionControllerObject,
  117083. /**
  117084. * handness (left/right/none) of this controller
  117085. */
  117086. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117087. private _initComponent;
  117088. /**
  117089. * Update this model using the current XRFrame
  117090. * @param xrFrame the current xr frame to use and update the model
  117091. */
  117092. updateFromXRFrame(xrFrame: XRFrame): void;
  117093. /**
  117094. * Get the list of components available in this motion controller
  117095. * @returns an array of strings correlating to available components
  117096. */
  117097. getComponentIds(): string[];
  117098. /**
  117099. * Get the main (Select) component of this controller as defined in the layout
  117100. * @returns the main component of this controller
  117101. */
  117102. getMainComponent(): WebXRControllerComponent;
  117103. /**
  117104. * get a component based an its component id as defined in layout.components
  117105. * @param id the id of the component
  117106. * @returns the component correlates to the id or undefined if not found
  117107. */
  117108. getComponent(id: string): WebXRControllerComponent;
  117109. /**
  117110. * Get the first component of specific type
  117111. * @param type type of component to find
  117112. * @return a controller component or null if not found
  117113. */
  117114. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117115. /**
  117116. * Returns all components of specific type
  117117. * @param type the type to search for
  117118. * @return an array of components with this type
  117119. */
  117120. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117121. /**
  117122. * Loads the model correlating to this controller
  117123. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117124. * @returns A promise fulfilled with the result of the model loading
  117125. */
  117126. loadModel(): Promise<boolean>;
  117127. /**
  117128. * Update the model itself with the current frame data
  117129. * @param xrFrame the frame to use for updating the model mesh
  117130. */
  117131. protected updateModel(xrFrame: XRFrame): void;
  117132. /**
  117133. * Moves the axis on the controller mesh based on its current state
  117134. * @param axis the index of the axis
  117135. * @param axisValue the value of the axis which determines the meshes new position
  117136. * @hidden
  117137. */
  117138. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117139. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117140. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117141. private _getGenericFilenameAndPath;
  117142. private _getGenericParentMesh;
  117143. /**
  117144. * Get the filename and path for this controller's model
  117145. * @returns a map of filename and path
  117146. */
  117147. protected abstract _getFilenameAndPath(): {
  117148. filename: string;
  117149. path: string;
  117150. };
  117151. /**
  117152. * This function will be called after the model was successfully loaded and can be used
  117153. * for mesh transformations before it is available for the user
  117154. * @param meshes the loaded meshes
  117155. */
  117156. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117157. /**
  117158. * Set the root mesh for this controller. Important for the WebXR controller class
  117159. * @param meshes the loaded meshes
  117160. */
  117161. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117162. /**
  117163. * A function executed each frame that updates the mesh (if needed)
  117164. * @param xrFrame the current xrFrame
  117165. */
  117166. protected abstract _updateModel(xrFrame: XRFrame): void;
  117167. /**
  117168. * This function is called before the mesh is loaded. It checks for loading constraints.
  117169. * For example, this function can check if the GLB loader is available
  117170. * If this function returns false, the generic controller will be loaded instead
  117171. * @returns Is the client ready to load the mesh
  117172. */
  117173. protected abstract _getModelLoadingConstraints(): boolean;
  117174. /**
  117175. * Dispose this controller, the model mesh and all its components
  117176. */
  117177. dispose(): void;
  117178. }
  117179. }
  117180. declare module BABYLON {
  117181. /**
  117182. * A generic trigger-only motion controller for WebXR
  117183. */
  117184. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117185. /**
  117186. * Static version of the profile id of this controller
  117187. */
  117188. static ProfileId: string;
  117189. profileId: string;
  117190. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117191. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117192. protected _updateModel(): void;
  117193. protected _getFilenameAndPath(): {
  117194. filename: string;
  117195. path: string;
  117196. };
  117197. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117198. protected _getModelLoadingConstraints(): boolean;
  117199. }
  117200. }
  117201. declare module BABYLON {
  117202. /**
  117203. * Class containing static functions to help procedurally build meshes
  117204. */
  117205. export class SphereBuilder {
  117206. /**
  117207. * Creates a sphere mesh
  117208. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117209. * * 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`)
  117210. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117211. * * 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
  117212. * * 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)
  117213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117216. * @param name defines the name of the mesh
  117217. * @param options defines the options used to create the mesh
  117218. * @param scene defines the hosting scene
  117219. * @returns the sphere mesh
  117220. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117221. */
  117222. static CreateSphere(name: string, options: {
  117223. segments?: number;
  117224. diameter?: number;
  117225. diameterX?: number;
  117226. diameterY?: number;
  117227. diameterZ?: number;
  117228. arc?: number;
  117229. slice?: number;
  117230. sideOrientation?: number;
  117231. frontUVs?: Vector4;
  117232. backUVs?: Vector4;
  117233. updatable?: boolean;
  117234. }, scene?: Nullable<Scene>): Mesh;
  117235. }
  117236. }
  117237. declare module BABYLON {
  117238. /**
  117239. * A profiled motion controller has its profile loaded from an online repository.
  117240. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117241. */
  117242. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117243. private _repositoryUrl;
  117244. /**
  117245. * The profile ID of this controller. Will be populated when the controller initializes.
  117246. */
  117247. profileId: string;
  117248. private _buttonMeshMapping;
  117249. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117250. protected _getFilenameAndPath(): {
  117251. filename: string;
  117252. path: string;
  117253. };
  117254. private _touchDots;
  117255. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117256. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117257. protected _updateModel(_xrFrame: XRFrame): void;
  117258. protected _getModelLoadingConstraints(): boolean;
  117259. dispose(): void;
  117260. }
  117261. }
  117262. declare module BABYLON {
  117263. /**
  117264. * A construction function type to create a new controller based on an xrInput object
  117265. */
  117266. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117267. /**
  117268. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117269. *
  117270. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117271. * it should be replaced with auto-loaded controllers.
  117272. *
  117273. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117274. */
  117275. export class WebXRMotionControllerManager {
  117276. /**
  117277. * The base URL of the online controller repository. Can be changed at any time.
  117278. */
  117279. static BaseRepositoryUrl: string;
  117280. /**
  117281. * Use the online repository, or use only locally-defined controllers
  117282. */
  117283. static UseOnlineRepository: boolean;
  117284. /**
  117285. * Which repository gets priority - local or online
  117286. */
  117287. static PrioritizeOnlineRepository: boolean;
  117288. private static _AvailableControllers;
  117289. private static _Fallbacks;
  117290. /**
  117291. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117292. *
  117293. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117294. *
  117295. * @param type the profile type to register
  117296. * @param constructFunction the function to be called when loading this profile
  117297. */
  117298. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117299. /**
  117300. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117301. * The order of search:
  117302. *
  117303. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117304. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117305. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117306. * 4) return the generic trigger controller if none were found
  117307. *
  117308. * @param xrInput the xrInput to which a new controller is initialized
  117309. * @param scene the scene to which the model will be added
  117310. * @param forceProfile force a certain profile for this controller
  117311. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117312. */
  117313. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117314. private static _LoadProfilesFromAvailableControllers;
  117315. private static _ProfilesList;
  117316. private static _ProfileLoadingPromises;
  117317. private static _LoadProfileFromRepository;
  117318. /**
  117319. * Clear the cache used for profile loading and reload when requested again
  117320. */
  117321. static ClearProfilesCache(): void;
  117322. /**
  117323. * Will update the list of profiles available in the repository
  117324. * @return a promise that resolves to a map of profiles available online
  117325. */
  117326. static UpdateProfilesList(): Promise<{
  117327. [profile: string]: string;
  117328. }>;
  117329. /**
  117330. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117331. * @param profileId the profile to which a fallback needs to be found
  117332. * @return an array with corresponding fallback profiles
  117333. */
  117334. static FindFallbackWithProfileId(profileId: string): string[];
  117335. /**
  117336. * Register a fallback to a specific profile.
  117337. * @param profileId the profileId that will receive the fallbacks
  117338. * @param fallbacks A list of fallback profiles
  117339. */
  117340. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117341. /**
  117342. * Register the default fallbacks.
  117343. * This function is called automatically when this file is imported.
  117344. */
  117345. static DefaultFallbacks(): void;
  117346. }
  117347. }
  117348. declare module BABYLON {
  117349. /**
  117350. * Configuration options for the WebXR controller creation
  117351. */
  117352. export interface IWebXRControllerOptions {
  117353. /**
  117354. * Force a specific controller type for this controller.
  117355. * This can be used when creating your own profile or when testing different controllers
  117356. */
  117357. forceControllerProfile?: string;
  117358. /**
  117359. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117360. */
  117361. doNotLoadControllerMesh?: boolean;
  117362. /**
  117363. * Should the controller mesh be animated when a user interacts with it
  117364. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117365. */
  117366. disableMotionControllerAnimation?: boolean;
  117367. }
  117368. /**
  117369. * Represents an XR controller
  117370. */
  117371. export class WebXRInputSource {
  117372. private _scene;
  117373. /** The underlying input source for the controller */
  117374. inputSource: XRInputSource;
  117375. private _options;
  117376. /**
  117377. * 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
  117378. */
  117379. grip?: AbstractMesh;
  117380. /**
  117381. * Pointer which can be used to select objects or attach a visible laser to
  117382. */
  117383. pointer: AbstractMesh;
  117384. /**
  117385. * If available, this is the gamepad object related to this controller.
  117386. * Using this object it is possible to get click events and trackpad changes of the
  117387. * webxr controller that is currently being used.
  117388. */
  117389. motionController?: WebXRAbstractMotionController;
  117390. /**
  117391. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117392. */
  117393. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117394. /**
  117395. * Will be triggered when the mesh associated with the motion controller is done loading.
  117396. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117397. * A shortened version of controller -> motion controller -> on mesh loaded.
  117398. */
  117399. onMeshLoadedObservable: Observable<AbstractMesh>;
  117400. /**
  117401. * Event that fires when the controller is removed/disposed.
  117402. * The object provided as event data is this controller, after associated assets were disposed.
  117403. * uniqueId is still available.
  117404. */
  117405. onDisposeObservable: Observable<WebXRInputSource>;
  117406. private _tmpQuaternion;
  117407. private _tmpVector;
  117408. private _uniqueId;
  117409. /**
  117410. * Creates the controller
  117411. * @see https://doc.babylonjs.com/how_to/webxr
  117412. * @param _scene the scene which the controller should be associated to
  117413. * @param inputSource the underlying input source for the controller
  117414. * @param _options options for this controller creation
  117415. */
  117416. constructor(_scene: Scene,
  117417. /** The underlying input source for the controller */
  117418. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117419. /**
  117420. * Get this controllers unique id
  117421. */
  117422. get uniqueId(): string;
  117423. /**
  117424. * Updates the controller pose based on the given XRFrame
  117425. * @param xrFrame xr frame to update the pose with
  117426. * @param referenceSpace reference space to use
  117427. */
  117428. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117429. /**
  117430. * Gets a world space ray coming from the pointer or grip
  117431. * @param result the resulting ray
  117432. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117433. */
  117434. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117435. /**
  117436. * Disposes of the object
  117437. */
  117438. dispose(): void;
  117439. }
  117440. }
  117441. declare module BABYLON {
  117442. /**
  117443. * The schema for initialization options of the XR Input class
  117444. */
  117445. export interface IWebXRInputOptions {
  117446. /**
  117447. * If set to true no model will be automatically loaded
  117448. */
  117449. doNotLoadControllerMeshes?: boolean;
  117450. /**
  117451. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117452. * If not found, the xr input profile data will be used.
  117453. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117454. */
  117455. forceInputProfile?: string;
  117456. /**
  117457. * Do not send a request to the controlle repository to load the profile.
  117458. *
  117459. * Instead, use the controllers available in babylon itself.
  117460. */
  117461. disableOnlineControllerRepository?: boolean;
  117462. /**
  117463. * A custom URL for the controllers repository
  117464. */
  117465. customControllersRepositoryURL?: string;
  117466. /**
  117467. * Should the controller model's components not move according to the user input
  117468. */
  117469. disableControllerAnimation?: boolean;
  117470. }
  117471. /**
  117472. * XR input used to track XR inputs such as controllers/rays
  117473. */
  117474. export class WebXRInput implements IDisposable {
  117475. /**
  117476. * the xr session manager for this session
  117477. */
  117478. xrSessionManager: WebXRSessionManager;
  117479. /**
  117480. * the WebXR camera for this session. Mainly used for teleportation
  117481. */
  117482. xrCamera: WebXRCamera;
  117483. private readonly options;
  117484. /**
  117485. * XR controllers being tracked
  117486. */
  117487. controllers: Array<WebXRInputSource>;
  117488. private _frameObserver;
  117489. private _sessionEndedObserver;
  117490. private _sessionInitObserver;
  117491. /**
  117492. * Event when a controller has been connected/added
  117493. */
  117494. onControllerAddedObservable: Observable<WebXRInputSource>;
  117495. /**
  117496. * Event when a controller has been removed/disconnected
  117497. */
  117498. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117499. /**
  117500. * Initializes the WebXRInput
  117501. * @param xrSessionManager the xr session manager for this session
  117502. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117503. * @param options = initialization options for this xr input
  117504. */
  117505. constructor(
  117506. /**
  117507. * the xr session manager for this session
  117508. */
  117509. xrSessionManager: WebXRSessionManager,
  117510. /**
  117511. * the WebXR camera for this session. Mainly used for teleportation
  117512. */
  117513. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117514. private _onInputSourcesChange;
  117515. private _addAndRemoveControllers;
  117516. /**
  117517. * Disposes of the object
  117518. */
  117519. dispose(): void;
  117520. }
  117521. }
  117522. declare module BABYLON {
  117523. /**
  117524. * This is the base class for all WebXR features.
  117525. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117526. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117527. */
  117528. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117529. protected _xrSessionManager: WebXRSessionManager;
  117530. /**
  117531. * Construct a new (abstract) webxr feature
  117532. * @param _xrSessionManager the xr session manager for this feature
  117533. */
  117534. constructor(_xrSessionManager: WebXRSessionManager);
  117535. private _attached;
  117536. private _removeOnDetach;
  117537. /**
  117538. * Is this feature attached
  117539. */
  117540. get attached(): boolean;
  117541. /**
  117542. * Should auto-attach be disabled?
  117543. */
  117544. disableAutoAttach: boolean;
  117545. /**
  117546. * attach this feature
  117547. *
  117548. * @param force should attachment be forced (even when already attached)
  117549. * @returns true if successful, false is failed or already attached
  117550. */
  117551. attach(force?: boolean): boolean;
  117552. /**
  117553. * detach this feature.
  117554. *
  117555. * @returns true if successful, false if failed or already detached
  117556. */
  117557. detach(): boolean;
  117558. /**
  117559. * Dispose this feature and all of the resources attached
  117560. */
  117561. dispose(): void;
  117562. /**
  117563. * Code in this function will be executed on each xrFrame received from the browser.
  117564. * This function will not execute after the feature is detached.
  117565. * @param _xrFrame the current frame
  117566. */
  117567. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117568. /**
  117569. * This is used to register callbacks that will automatically be removed when detach is called.
  117570. * @param observable the observable to which the observer will be attached
  117571. * @param callback the callback to register
  117572. */
  117573. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117574. }
  117575. }
  117576. declare module BABYLON {
  117577. /**
  117578. * Renders a layer on top of an existing scene
  117579. */
  117580. export class UtilityLayerRenderer implements IDisposable {
  117581. /** the original scene that will be rendered on top of */
  117582. originalScene: Scene;
  117583. private _pointerCaptures;
  117584. private _lastPointerEvents;
  117585. private static _DefaultUtilityLayer;
  117586. private static _DefaultKeepDepthUtilityLayer;
  117587. private _sharedGizmoLight;
  117588. private _renderCamera;
  117589. /**
  117590. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117591. * @returns the camera that is used when rendering the utility layer
  117592. */
  117593. getRenderCamera(): Camera;
  117594. /**
  117595. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117596. * @param cam the camera that should be used when rendering the utility layer
  117597. */
  117598. setRenderCamera(cam: Nullable<Camera>): void;
  117599. /**
  117600. * @hidden
  117601. * Light which used by gizmos to get light shading
  117602. */
  117603. _getSharedGizmoLight(): HemisphericLight;
  117604. /**
  117605. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117606. */
  117607. pickUtilitySceneFirst: boolean;
  117608. /**
  117609. * 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)
  117610. */
  117611. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117612. /**
  117613. * 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)
  117614. */
  117615. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117616. /**
  117617. * The scene that is rendered on top of the original scene
  117618. */
  117619. utilityLayerScene: Scene;
  117620. /**
  117621. * If the utility layer should automatically be rendered on top of existing scene
  117622. */
  117623. shouldRender: boolean;
  117624. /**
  117625. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117626. */
  117627. onlyCheckPointerDownEvents: boolean;
  117628. /**
  117629. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117630. */
  117631. processAllEvents: boolean;
  117632. /**
  117633. * Observable raised when the pointer move from the utility layer scene to the main scene
  117634. */
  117635. onPointerOutObservable: Observable<number>;
  117636. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117637. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117638. private _afterRenderObserver;
  117639. private _sceneDisposeObserver;
  117640. private _originalPointerObserver;
  117641. /**
  117642. * Instantiates a UtilityLayerRenderer
  117643. * @param originalScene the original scene that will be rendered on top of
  117644. * @param handleEvents boolean indicating if the utility layer should handle events
  117645. */
  117646. constructor(
  117647. /** the original scene that will be rendered on top of */
  117648. originalScene: Scene, handleEvents?: boolean);
  117649. private _notifyObservers;
  117650. /**
  117651. * Renders the utility layers scene on top of the original scene
  117652. */
  117653. render(): void;
  117654. /**
  117655. * Disposes of the renderer
  117656. */
  117657. dispose(): void;
  117658. private _updateCamera;
  117659. }
  117660. }
  117661. declare module BABYLON {
  117662. /**
  117663. * Options interface for the pointer selection module
  117664. */
  117665. export interface IWebXRControllerPointerSelectionOptions {
  117666. /**
  117667. * the xr input to use with this pointer selection
  117668. */
  117669. xrInput: WebXRInput;
  117670. /**
  117671. * Different button type to use instead of the main component
  117672. */
  117673. overrideButtonId?: string;
  117674. /**
  117675. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117676. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117677. * 3000 means 3 seconds between pointing at something and selecting it
  117678. */
  117679. timeToSelect?: number;
  117680. /**
  117681. * 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)
  117682. * If not disabled, the last picked point will be used to execute a pointer up event
  117683. * If disabled, pointer up event will be triggered right after the pointer down event.
  117684. * Used in screen and gaze target ray mode only
  117685. */
  117686. disablePointerUpOnTouchOut: boolean;
  117687. /**
  117688. * For gaze mode (time to select instead of press)
  117689. */
  117690. forceGazeMode: boolean;
  117691. /**
  117692. * 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
  117693. * to start a new countdown to the pointer down event.
  117694. * Defaults to 1.
  117695. */
  117696. gazeModePointerMovedFactor?: number;
  117697. /**
  117698. * Should meshes created here be added to a utility layer or the main scene
  117699. */
  117700. useUtilityLayer?: boolean;
  117701. /**
  117702. * if provided, this scene will be used to render meshes.
  117703. */
  117704. customUtilityLayerScene?: Scene;
  117705. }
  117706. /**
  117707. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117708. */
  117709. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117710. private readonly _options;
  117711. /**
  117712. * The module's name
  117713. */
  117714. static readonly Name: string;
  117715. /**
  117716. * The (Babylon) version of this module.
  117717. * This is an integer representing the implementation version.
  117718. * This number does not correspond to the webxr specs version
  117719. */
  117720. static readonly Version: number;
  117721. /**
  117722. * This color will be set to the laser pointer when selection is triggered
  117723. */
  117724. laserPointerPickedColor: Color3;
  117725. /**
  117726. * This color will be applied to the selection ring when selection is triggered
  117727. */
  117728. selectionMeshPickedColor: Color3;
  117729. /**
  117730. * default color of the selection ring
  117731. */
  117732. selectionMeshDefaultColor: Color3;
  117733. /**
  117734. * Default color of the laser pointer
  117735. */
  117736. lasterPointerDefaultColor: Color3;
  117737. /**
  117738. * Should the laser pointer be displayed
  117739. */
  117740. displayLaserPointer: boolean;
  117741. /**
  117742. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117743. */
  117744. displaySelectionMesh: boolean;
  117745. /**
  117746. * Disable lighting on the laser pointer (so it will always be visible)
  117747. */
  117748. disablePointerLighting: boolean;
  117749. /**
  117750. * Disable lighting on the selection mesh (so it will always be visible)
  117751. */
  117752. disableSelectionMeshLighting: boolean;
  117753. private static _idCounter;
  117754. private _tmpRay;
  117755. private _controllers;
  117756. private _scene;
  117757. /**
  117758. * constructs a new background remover module
  117759. * @param _xrSessionManager the session manager for this module
  117760. * @param _options read-only options to be used in this module
  117761. */
  117762. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117763. /**
  117764. * attach this feature
  117765. * Will usually be called by the features manager
  117766. *
  117767. * @returns true if successful.
  117768. */
  117769. attach(): boolean;
  117770. /**
  117771. * detach this feature.
  117772. * Will usually be called by the features manager
  117773. *
  117774. * @returns true if successful.
  117775. */
  117776. detach(): boolean;
  117777. /**
  117778. * Get the xr controller that correlates to the pointer id in the pointer event
  117779. *
  117780. * @param id the pointer id to search for
  117781. * @returns the controller that correlates to this id or null if not found
  117782. */
  117783. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117784. protected _onXRFrame(_xrFrame: XRFrame): void;
  117785. private _attachController;
  117786. private _attachScreenRayMode;
  117787. private _attachGazeMode;
  117788. private _tmpVectorForPickCompare;
  117789. private _pickingMoved;
  117790. private _attachTrackedPointerRayMode;
  117791. private _detachController;
  117792. private _generateNewMeshPair;
  117793. private _convertNormalToDirectionOfRay;
  117794. private _updatePointerDistance;
  117795. }
  117796. }
  117797. declare module BABYLON {
  117798. /**
  117799. * Button which can be used to enter a different mode of XR
  117800. */
  117801. export class WebXREnterExitUIButton {
  117802. /** button element */
  117803. element: HTMLElement;
  117804. /** XR initialization options for the button */
  117805. sessionMode: XRSessionMode;
  117806. /** Reference space type */
  117807. referenceSpaceType: XRReferenceSpaceType;
  117808. /**
  117809. * Creates a WebXREnterExitUIButton
  117810. * @param element button element
  117811. * @param sessionMode XR initialization session mode
  117812. * @param referenceSpaceType the type of reference space to be used
  117813. */
  117814. constructor(
  117815. /** button element */
  117816. element: HTMLElement,
  117817. /** XR initialization options for the button */
  117818. sessionMode: XRSessionMode,
  117819. /** Reference space type */
  117820. referenceSpaceType: XRReferenceSpaceType);
  117821. /**
  117822. * Overwritable function which can be used to update the button's visuals when the state changes
  117823. * @param activeButton the current active button in the UI
  117824. */
  117825. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117826. }
  117827. /**
  117828. * Options to create the webXR UI
  117829. */
  117830. export class WebXREnterExitUIOptions {
  117831. /**
  117832. * Context to enter xr with
  117833. */
  117834. renderTarget?: Nullable<WebXRRenderTarget>;
  117835. /**
  117836. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117837. */
  117838. customButtons?: Array<WebXREnterExitUIButton>;
  117839. /**
  117840. * A session mode to use when creating the default button.
  117841. * Default is immersive-vr
  117842. */
  117843. sessionMode?: XRSessionMode;
  117844. /**
  117845. * A reference space type to use when creating the default button.
  117846. * Default is local-floor
  117847. */
  117848. referenceSpaceType?: XRReferenceSpaceType;
  117849. }
  117850. /**
  117851. * UI to allow the user to enter/exit XR mode
  117852. */
  117853. export class WebXREnterExitUI implements IDisposable {
  117854. private scene;
  117855. /** version of the options passed to this UI */
  117856. options: WebXREnterExitUIOptions;
  117857. private _overlay;
  117858. private _buttons;
  117859. private _activeButton;
  117860. /**
  117861. * Fired every time the active button is changed.
  117862. *
  117863. * When xr is entered via a button that launches xr that button will be the callback parameter
  117864. *
  117865. * When exiting xr the callback parameter will be null)
  117866. */
  117867. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117868. /**
  117869. * Creates UI to allow the user to enter/exit XR mode
  117870. * @param scene the scene to add the ui to
  117871. * @param helper the xr experience helper to enter/exit xr with
  117872. * @param options options to configure the UI
  117873. * @returns the created ui
  117874. */
  117875. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117876. /**
  117877. *
  117878. * @param scene babylon scene object to use
  117879. * @param options (read-only) version of the options passed to this UI
  117880. */
  117881. private constructor();
  117882. private _updateButtons;
  117883. /**
  117884. * Disposes of the object
  117885. */
  117886. dispose(): void;
  117887. }
  117888. }
  117889. declare module BABYLON {
  117890. /**
  117891. * Class containing static functions to help procedurally build meshes
  117892. */
  117893. export class LinesBuilder {
  117894. /**
  117895. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117896. * * 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
  117897. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117898. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117899. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117900. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117901. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117902. * * 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
  117903. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117906. * @param name defines the name of the new line system
  117907. * @param options defines the options used to create the line system
  117908. * @param scene defines the hosting scene
  117909. * @returns a new line system mesh
  117910. */
  117911. static CreateLineSystem(name: string, options: {
  117912. lines: Vector3[][];
  117913. updatable?: boolean;
  117914. instance?: Nullable<LinesMesh>;
  117915. colors?: Nullable<Color4[][]>;
  117916. useVertexAlpha?: boolean;
  117917. }, scene: Nullable<Scene>): LinesMesh;
  117918. /**
  117919. * Creates a line mesh
  117920. * 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
  117921. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117922. * * The parameter `points` is an array successive Vector3
  117923. * * 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
  117924. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117925. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117926. * * When updating an instance, remember that only point positions can change, not the number of points
  117927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117929. * @param name defines the name of the new line system
  117930. * @param options defines the options used to create the line system
  117931. * @param scene defines the hosting scene
  117932. * @returns a new line mesh
  117933. */
  117934. static CreateLines(name: string, options: {
  117935. points: Vector3[];
  117936. updatable?: boolean;
  117937. instance?: Nullable<LinesMesh>;
  117938. colors?: Color4[];
  117939. useVertexAlpha?: boolean;
  117940. }, scene?: Nullable<Scene>): LinesMesh;
  117941. /**
  117942. * Creates a dashed line mesh
  117943. * * 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
  117944. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117945. * * The parameter `points` is an array successive Vector3
  117946. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117947. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117948. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117949. * * 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
  117950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117951. * * When updating an instance, remember that only point positions can change, not the number of points
  117952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117953. * @param name defines the name of the mesh
  117954. * @param options defines the options used to create the mesh
  117955. * @param scene defines the hosting scene
  117956. * @returns the dashed line mesh
  117957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117958. */
  117959. static CreateDashedLines(name: string, options: {
  117960. points: Vector3[];
  117961. dashSize?: number;
  117962. gapSize?: number;
  117963. dashNb?: number;
  117964. updatable?: boolean;
  117965. instance?: LinesMesh;
  117966. useVertexAlpha?: boolean;
  117967. }, scene?: Nullable<Scene>): LinesMesh;
  117968. }
  117969. }
  117970. declare module BABYLON {
  117971. /**
  117972. * The options container for the teleportation module
  117973. */
  117974. export interface IWebXRTeleportationOptions {
  117975. /**
  117976. * Babylon XR Input class for controller
  117977. */
  117978. xrInput: WebXRInput;
  117979. /**
  117980. * A list of meshes to use as floor meshes.
  117981. * Meshes can be added and removed after initializing the feature using the
  117982. * addFloorMesh and removeFloorMesh functions
  117983. * If empty, rotation will still work
  117984. */
  117985. floorMeshes?: AbstractMesh[];
  117986. /**
  117987. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117988. * If you want to support rotation, make sure your mesh has a direction indicator.
  117989. *
  117990. * When left untouched, the default mesh will be initialized.
  117991. */
  117992. teleportationTargetMesh?: AbstractMesh;
  117993. /**
  117994. * Values to configure the default target mesh
  117995. */
  117996. defaultTargetMeshOptions?: {
  117997. /**
  117998. * Fill color of the teleportation area
  117999. */
  118000. teleportationFillColor?: string;
  118001. /**
  118002. * Border color for the teleportation area
  118003. */
  118004. teleportationBorderColor?: string;
  118005. /**
  118006. * Disable the mesh's animation sequence
  118007. */
  118008. disableAnimation?: boolean;
  118009. /**
  118010. * Disable lighting on the material or the ring and arrow
  118011. */
  118012. disableLighting?: boolean;
  118013. /**
  118014. * Override the default material of the torus and arrow
  118015. */
  118016. torusArrowMaterial?: Material;
  118017. };
  118018. /**
  118019. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118020. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118021. */
  118022. useMainComponentOnly?: boolean;
  118023. /**
  118024. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118025. */
  118026. timeToTeleport?: number;
  118027. /**
  118028. * Should meshes created here be added to a utility layer or the main scene
  118029. */
  118030. useUtilityLayer?: boolean;
  118031. /**
  118032. * if provided, this scene will be used to render meshes.
  118033. */
  118034. customUtilityLayerScene?: Scene;
  118035. }
  118036. /**
  118037. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118038. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  118039. * the input of the attached controllers.
  118040. */
  118041. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118042. private _options;
  118043. /**
  118044. * The module's name
  118045. */
  118046. static readonly Name: string;
  118047. /**
  118048. * The (Babylon) version of this module.
  118049. * This is an integer representing the implementation version.
  118050. * This number does not correspond to the webxr specs version
  118051. */
  118052. static readonly Version: number;
  118053. /**
  118054. * Is rotation enabled when moving forward?
  118055. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118056. */
  118057. rotationEnabled: boolean;
  118058. /**
  118059. * Should the module support parabolic ray on top of direct ray
  118060. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118061. * Very helpful when moving between floors / different heights
  118062. */
  118063. parabolicRayEnabled: boolean;
  118064. /**
  118065. * The distance from the user to the inspection point in the direction of the controller
  118066. * A higher number will allow the user to move further
  118067. * defaults to 5 (meters, in xr units)
  118068. */
  118069. parabolicCheckRadius: number;
  118070. /**
  118071. * How much rotation should be applied when rotating right and left
  118072. */
  118073. rotationAngle: number;
  118074. /**
  118075. * Is movement backwards enabled
  118076. */
  118077. backwardsMovementEnabled: boolean;
  118078. /**
  118079. * Distance to travel when moving backwards
  118080. */
  118081. backwardsTeleportationDistance: number;
  118082. /**
  118083. * Add a new mesh to the floor meshes array
  118084. * @param mesh the mesh to use as floor mesh
  118085. */
  118086. addFloorMesh(mesh: AbstractMesh): void;
  118087. /**
  118088. * Remove a mesh from the floor meshes array
  118089. * @param mesh the mesh to remove
  118090. */
  118091. removeFloorMesh(mesh: AbstractMesh): void;
  118092. /**
  118093. * Remove a mesh from the floor meshes array using its name
  118094. * @param name the mesh name to remove
  118095. */
  118096. removeFloorMeshByName(name: string): void;
  118097. private _tmpRay;
  118098. private _tmpVector;
  118099. private _floorMeshes;
  118100. private _controllers;
  118101. /**
  118102. * constructs a new anchor system
  118103. * @param _xrSessionManager an instance of WebXRSessionManager
  118104. * @param _options configuration object for this feature
  118105. */
  118106. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118107. private _selectionFeature;
  118108. /**
  118109. * This function sets a selection feature that will be disabled when
  118110. * the forward ray is shown and will be reattached when hidden.
  118111. * This is used to remove the selection rays when moving.
  118112. * @param selectionFeature the feature to disable when forward movement is enabled
  118113. */
  118114. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118115. attach(): boolean;
  118116. detach(): boolean;
  118117. dispose(): void;
  118118. protected _onXRFrame(_xrFrame: XRFrame): void;
  118119. private _currentTeleportationControllerId;
  118120. private _attachController;
  118121. private _teleportForward;
  118122. private _detachController;
  118123. private createDefaultTargetMesh;
  118124. private setTargetMeshVisibility;
  118125. private setTargetMeshPosition;
  118126. private _quadraticBezierCurve;
  118127. private _showParabolicPath;
  118128. }
  118129. }
  118130. declare module BABYLON {
  118131. /**
  118132. * Options for the default xr helper
  118133. */
  118134. export class WebXRDefaultExperienceOptions {
  118135. /**
  118136. * Floor meshes that will be used for teleporting
  118137. */
  118138. floorMeshes?: Array<AbstractMesh>;
  118139. /**
  118140. * Enable or disable default UI to enter XR
  118141. */
  118142. disableDefaultUI?: boolean;
  118143. /**
  118144. * optional configuration for the output canvas
  118145. */
  118146. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118147. /**
  118148. * optional UI options. This can be used among other to change session mode and reference space type
  118149. */
  118150. uiOptions?: WebXREnterExitUIOptions;
  118151. /**
  118152. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118153. */
  118154. inputOptions?: IWebXRInputOptions;
  118155. /**
  118156. * Should teleportation not initialize. defaults to false.
  118157. */
  118158. disableTeleportation?: boolean;
  118159. /**
  118160. * If set to true, the first frame will not be used to reset position
  118161. * The first frame is mainly used when copying transformation from the old camera
  118162. * Mainly used in AR
  118163. */
  118164. ignoreNativeCameraTransformation?: boolean;
  118165. /**
  118166. * When loading teleportation and pointer select, use stable versions instead of latest.
  118167. */
  118168. useStablePlugins?: boolean;
  118169. }
  118170. /**
  118171. * Default experience which provides a similar setup to the previous webVRExperience
  118172. */
  118173. export class WebXRDefaultExperience {
  118174. /**
  118175. * Base experience
  118176. */
  118177. baseExperience: WebXRExperienceHelper;
  118178. /**
  118179. * Input experience extension
  118180. */
  118181. input: WebXRInput;
  118182. /**
  118183. * Enables laser pointer and selection
  118184. */
  118185. pointerSelection: WebXRControllerPointerSelection;
  118186. /**
  118187. * Enables teleportation
  118188. */
  118189. teleportation: WebXRMotionControllerTeleportation;
  118190. /**
  118191. * Enables ui for entering/exiting xr
  118192. */
  118193. enterExitUI: WebXREnterExitUI;
  118194. /**
  118195. * Default target xr should render to
  118196. */
  118197. renderTarget: WebXRRenderTarget;
  118198. /**
  118199. * Creates the default xr experience
  118200. * @param scene scene
  118201. * @param options options for basic configuration
  118202. * @returns resulting WebXRDefaultExperience
  118203. */
  118204. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118205. private constructor();
  118206. /**
  118207. * DIsposes of the experience helper
  118208. */
  118209. dispose(): void;
  118210. }
  118211. }
  118212. declare module BABYLON {
  118213. /**
  118214. * Options to modify the vr teleportation behavior.
  118215. */
  118216. export interface VRTeleportationOptions {
  118217. /**
  118218. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118219. */
  118220. floorMeshName?: string;
  118221. /**
  118222. * A list of meshes to be used as the teleportation floor. (default: empty)
  118223. */
  118224. floorMeshes?: Mesh[];
  118225. /**
  118226. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118227. */
  118228. teleportationMode?: number;
  118229. /**
  118230. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118231. */
  118232. teleportationTime?: number;
  118233. /**
  118234. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118235. */
  118236. teleportationSpeed?: number;
  118237. /**
  118238. * The easing function used in the animation or null for Linear. (default CircleEase)
  118239. */
  118240. easingFunction?: EasingFunction;
  118241. }
  118242. /**
  118243. * Options to modify the vr experience helper's behavior.
  118244. */
  118245. export interface VRExperienceHelperOptions extends WebVROptions {
  118246. /**
  118247. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118248. */
  118249. createDeviceOrientationCamera?: boolean;
  118250. /**
  118251. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118252. */
  118253. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118254. /**
  118255. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118256. */
  118257. laserToggle?: boolean;
  118258. /**
  118259. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118260. */
  118261. floorMeshes?: Mesh[];
  118262. /**
  118263. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118264. */
  118265. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118266. /**
  118267. * Defines if WebXR should be used instead of WebVR (if available)
  118268. */
  118269. useXR?: boolean;
  118270. }
  118271. /**
  118272. * Event containing information after VR has been entered
  118273. */
  118274. export class OnAfterEnteringVRObservableEvent {
  118275. /**
  118276. * If entering vr was successful
  118277. */
  118278. success: boolean;
  118279. }
  118280. /**
  118281. * Helps to quickly add VR support to an existing scene.
  118282. * See http://doc.babylonjs.com/how_to/webvr_helper
  118283. */
  118284. export class VRExperienceHelper {
  118285. /** Options to modify the vr experience helper's behavior. */
  118286. webVROptions: VRExperienceHelperOptions;
  118287. private _scene;
  118288. private _position;
  118289. private _btnVR;
  118290. private _btnVRDisplayed;
  118291. private _webVRsupported;
  118292. private _webVRready;
  118293. private _webVRrequesting;
  118294. private _webVRpresenting;
  118295. private _hasEnteredVR;
  118296. private _fullscreenVRpresenting;
  118297. private _inputElement;
  118298. private _webVRCamera;
  118299. private _vrDeviceOrientationCamera;
  118300. private _deviceOrientationCamera;
  118301. private _existingCamera;
  118302. private _onKeyDown;
  118303. private _onVrDisplayPresentChange;
  118304. private _onVRDisplayChanged;
  118305. private _onVRRequestPresentStart;
  118306. private _onVRRequestPresentComplete;
  118307. /**
  118308. * 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)
  118309. */
  118310. enableGazeEvenWhenNoPointerLock: boolean;
  118311. /**
  118312. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118313. */
  118314. exitVROnDoubleTap: boolean;
  118315. /**
  118316. * Observable raised right before entering VR.
  118317. */
  118318. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118319. /**
  118320. * Observable raised when entering VR has completed.
  118321. */
  118322. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118323. /**
  118324. * Observable raised when exiting VR.
  118325. */
  118326. onExitingVRObservable: Observable<VRExperienceHelper>;
  118327. /**
  118328. * Observable raised when controller mesh is loaded.
  118329. */
  118330. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118331. /** Return this.onEnteringVRObservable
  118332. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118333. */
  118334. get onEnteringVR(): Observable<VRExperienceHelper>;
  118335. /** Return this.onExitingVRObservable
  118336. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118337. */
  118338. get onExitingVR(): Observable<VRExperienceHelper>;
  118339. /** Return this.onControllerMeshLoadedObservable
  118340. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118341. */
  118342. get onControllerMeshLoaded(): Observable<WebVRController>;
  118343. private _rayLength;
  118344. private _useCustomVRButton;
  118345. private _teleportationRequested;
  118346. private _teleportActive;
  118347. private _floorMeshName;
  118348. private _floorMeshesCollection;
  118349. private _teleportationMode;
  118350. private _teleportationTime;
  118351. private _teleportationSpeed;
  118352. private _teleportationEasing;
  118353. private _rotationAllowed;
  118354. private _teleportBackwardsVector;
  118355. private _teleportationTarget;
  118356. private _isDefaultTeleportationTarget;
  118357. private _postProcessMove;
  118358. private _teleportationFillColor;
  118359. private _teleportationBorderColor;
  118360. private _rotationAngle;
  118361. private _haloCenter;
  118362. private _cameraGazer;
  118363. private _padSensibilityUp;
  118364. private _padSensibilityDown;
  118365. private _leftController;
  118366. private _rightController;
  118367. private _gazeColor;
  118368. private _laserColor;
  118369. private _pickedLaserColor;
  118370. private _pickedGazeColor;
  118371. /**
  118372. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118373. */
  118374. onNewMeshSelected: Observable<AbstractMesh>;
  118375. /**
  118376. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118377. * This observable will provide the mesh and the controller used to select the mesh
  118378. */
  118379. onMeshSelectedWithController: Observable<{
  118380. mesh: AbstractMesh;
  118381. controller: WebVRController;
  118382. }>;
  118383. /**
  118384. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118385. */
  118386. onNewMeshPicked: Observable<PickingInfo>;
  118387. private _circleEase;
  118388. /**
  118389. * Observable raised before camera teleportation
  118390. */
  118391. onBeforeCameraTeleport: Observable<Vector3>;
  118392. /**
  118393. * Observable raised after camera teleportation
  118394. */
  118395. onAfterCameraTeleport: Observable<Vector3>;
  118396. /**
  118397. * Observable raised when current selected mesh gets unselected
  118398. */
  118399. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118400. private _raySelectionPredicate;
  118401. /**
  118402. * To be optionaly changed by user to define custom ray selection
  118403. */
  118404. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118405. /**
  118406. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118407. */
  118408. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118409. /**
  118410. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118411. */
  118412. teleportationEnabled: boolean;
  118413. private _defaultHeight;
  118414. private _teleportationInitialized;
  118415. private _interactionsEnabled;
  118416. private _interactionsRequested;
  118417. private _displayGaze;
  118418. private _displayLaserPointer;
  118419. /**
  118420. * The mesh used to display where the user is going to teleport.
  118421. */
  118422. get teleportationTarget(): Mesh;
  118423. /**
  118424. * Sets the mesh to be used to display where the user is going to teleport.
  118425. */
  118426. set teleportationTarget(value: Mesh);
  118427. /**
  118428. * 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
  118429. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118430. * See http://doc.babylonjs.com/resources/baking_transformations
  118431. */
  118432. get gazeTrackerMesh(): Mesh;
  118433. set gazeTrackerMesh(value: Mesh);
  118434. /**
  118435. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118436. */
  118437. updateGazeTrackerScale: boolean;
  118438. /**
  118439. * If the gaze trackers color should be updated when selecting meshes
  118440. */
  118441. updateGazeTrackerColor: boolean;
  118442. /**
  118443. * If the controller laser color should be updated when selecting meshes
  118444. */
  118445. updateControllerLaserColor: boolean;
  118446. /**
  118447. * The gaze tracking mesh corresponding to the left controller
  118448. */
  118449. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118450. /**
  118451. * The gaze tracking mesh corresponding to the right controller
  118452. */
  118453. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118454. /**
  118455. * If the ray of the gaze should be displayed.
  118456. */
  118457. get displayGaze(): boolean;
  118458. /**
  118459. * Sets if the ray of the gaze should be displayed.
  118460. */
  118461. set displayGaze(value: boolean);
  118462. /**
  118463. * If the ray of the LaserPointer should be displayed.
  118464. */
  118465. get displayLaserPointer(): boolean;
  118466. /**
  118467. * Sets if the ray of the LaserPointer should be displayed.
  118468. */
  118469. set displayLaserPointer(value: boolean);
  118470. /**
  118471. * The deviceOrientationCamera used as the camera when not in VR.
  118472. */
  118473. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118474. /**
  118475. * Based on the current WebVR support, returns the current VR camera used.
  118476. */
  118477. get currentVRCamera(): Nullable<Camera>;
  118478. /**
  118479. * The webVRCamera which is used when in VR.
  118480. */
  118481. get webVRCamera(): WebVRFreeCamera;
  118482. /**
  118483. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118484. */
  118485. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118486. /**
  118487. * The html button that is used to trigger entering into VR.
  118488. */
  118489. get vrButton(): Nullable<HTMLButtonElement>;
  118490. private get _teleportationRequestInitiated();
  118491. /**
  118492. * Defines whether or not Pointer lock should be requested when switching to
  118493. * full screen.
  118494. */
  118495. requestPointerLockOnFullScreen: boolean;
  118496. /**
  118497. * If asking to force XR, this will be populated with the default xr experience
  118498. */
  118499. xr: WebXRDefaultExperience;
  118500. /**
  118501. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118502. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118503. */
  118504. xrTestDone: boolean;
  118505. /**
  118506. * Instantiates a VRExperienceHelper.
  118507. * Helps to quickly add VR support to an existing scene.
  118508. * @param scene The scene the VRExperienceHelper belongs to.
  118509. * @param webVROptions Options to modify the vr experience helper's behavior.
  118510. */
  118511. constructor(scene: Scene,
  118512. /** Options to modify the vr experience helper's behavior. */
  118513. webVROptions?: VRExperienceHelperOptions);
  118514. private completeVRInit;
  118515. private _onDefaultMeshLoaded;
  118516. private _onResize;
  118517. private _onFullscreenChange;
  118518. /**
  118519. * Gets a value indicating if we are currently in VR mode.
  118520. */
  118521. get isInVRMode(): boolean;
  118522. private onVrDisplayPresentChange;
  118523. private onVRDisplayChanged;
  118524. private moveButtonToBottomRight;
  118525. private displayVRButton;
  118526. private updateButtonVisibility;
  118527. private _cachedAngularSensibility;
  118528. /**
  118529. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118530. * Otherwise, will use the fullscreen API.
  118531. */
  118532. enterVR(): void;
  118533. /**
  118534. * Attempt to exit VR, or fullscreen.
  118535. */
  118536. exitVR(): void;
  118537. /**
  118538. * The position of the vr experience helper.
  118539. */
  118540. get position(): Vector3;
  118541. /**
  118542. * Sets the position of the vr experience helper.
  118543. */
  118544. set position(value: Vector3);
  118545. /**
  118546. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118547. */
  118548. enableInteractions(): void;
  118549. private get _noControllerIsActive();
  118550. private beforeRender;
  118551. private _isTeleportationFloor;
  118552. /**
  118553. * Adds a floor mesh to be used for teleportation.
  118554. * @param floorMesh the mesh to be used for teleportation.
  118555. */
  118556. addFloorMesh(floorMesh: Mesh): void;
  118557. /**
  118558. * Removes a floor mesh from being used for teleportation.
  118559. * @param floorMesh the mesh to be removed.
  118560. */
  118561. removeFloorMesh(floorMesh: Mesh): void;
  118562. /**
  118563. * Enables interactions and teleportation using the VR controllers and gaze.
  118564. * @param vrTeleportationOptions options to modify teleportation behavior.
  118565. */
  118566. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118567. private _onNewGamepadConnected;
  118568. private _tryEnableInteractionOnController;
  118569. private _onNewGamepadDisconnected;
  118570. private _enableInteractionOnController;
  118571. private _checkTeleportWithRay;
  118572. private _checkRotate;
  118573. private _checkTeleportBackwards;
  118574. private _enableTeleportationOnController;
  118575. private _createTeleportationCircles;
  118576. private _displayTeleportationTarget;
  118577. private _hideTeleportationTarget;
  118578. private _rotateCamera;
  118579. private _moveTeleportationSelectorTo;
  118580. private _workingVector;
  118581. private _workingQuaternion;
  118582. private _workingMatrix;
  118583. /**
  118584. * Time Constant Teleportation Mode
  118585. */
  118586. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118587. /**
  118588. * Speed Constant Teleportation Mode
  118589. */
  118590. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118591. /**
  118592. * Teleports the users feet to the desired location
  118593. * @param location The location where the user's feet should be placed
  118594. */
  118595. teleportCamera(location: Vector3): void;
  118596. private _convertNormalToDirectionOfRay;
  118597. private _castRayAndSelectObject;
  118598. private _notifySelectedMeshUnselected;
  118599. /**
  118600. * Permanently set new colors for the laser pointer
  118601. * @param color the new laser color
  118602. * @param pickedColor the new laser color when picked mesh detected
  118603. */
  118604. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118605. /**
  118606. * Set lighting enabled / disabled on the laser pointer of both controllers
  118607. * @param enabled should the lighting be enabled on the laser pointer
  118608. */
  118609. setLaserLightingState(enabled?: boolean): void;
  118610. /**
  118611. * Permanently set new colors for the gaze pointer
  118612. * @param color the new gaze color
  118613. * @param pickedColor the new gaze color when picked mesh detected
  118614. */
  118615. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118616. /**
  118617. * Sets the color of the laser ray from the vr controllers.
  118618. * @param color new color for the ray.
  118619. */
  118620. changeLaserColor(color: Color3): void;
  118621. /**
  118622. * Sets the color of the ray from the vr headsets gaze.
  118623. * @param color new color for the ray.
  118624. */
  118625. changeGazeColor(color: Color3): void;
  118626. /**
  118627. * Exits VR and disposes of the vr experience helper
  118628. */
  118629. dispose(): void;
  118630. /**
  118631. * Gets the name of the VRExperienceHelper class
  118632. * @returns "VRExperienceHelper"
  118633. */
  118634. getClassName(): string;
  118635. }
  118636. }
  118637. declare module BABYLON {
  118638. /**
  118639. * Contains an array of blocks representing the octree
  118640. */
  118641. export interface IOctreeContainer<T> {
  118642. /**
  118643. * Blocks within the octree
  118644. */
  118645. blocks: Array<OctreeBlock<T>>;
  118646. }
  118647. /**
  118648. * Class used to store a cell in an octree
  118649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118650. */
  118651. export class OctreeBlock<T> {
  118652. /**
  118653. * Gets the content of the current block
  118654. */
  118655. entries: T[];
  118656. /**
  118657. * Gets the list of block children
  118658. */
  118659. blocks: Array<OctreeBlock<T>>;
  118660. private _depth;
  118661. private _maxDepth;
  118662. private _capacity;
  118663. private _minPoint;
  118664. private _maxPoint;
  118665. private _boundingVectors;
  118666. private _creationFunc;
  118667. /**
  118668. * Creates a new block
  118669. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118670. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118671. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118672. * @param depth defines the current depth of this block in the octree
  118673. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118674. * @param creationFunc defines a callback to call when an element is added to the block
  118675. */
  118676. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118677. /**
  118678. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118679. */
  118680. get capacity(): number;
  118681. /**
  118682. * Gets the minimum vector (in world space) of the block's bounding box
  118683. */
  118684. get minPoint(): Vector3;
  118685. /**
  118686. * Gets the maximum vector (in world space) of the block's bounding box
  118687. */
  118688. get maxPoint(): Vector3;
  118689. /**
  118690. * Add a new element to this block
  118691. * @param entry defines the element to add
  118692. */
  118693. addEntry(entry: T): void;
  118694. /**
  118695. * Remove an element from this block
  118696. * @param entry defines the element to remove
  118697. */
  118698. removeEntry(entry: T): void;
  118699. /**
  118700. * Add an array of elements to this block
  118701. * @param entries defines the array of elements to add
  118702. */
  118703. addEntries(entries: T[]): void;
  118704. /**
  118705. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118706. * @param frustumPlanes defines the frustum planes to test
  118707. * @param selection defines the array to store current content if selection is positive
  118708. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118709. */
  118710. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118711. /**
  118712. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118713. * @param sphereCenter defines the bounding sphere center
  118714. * @param sphereRadius defines the bounding sphere radius
  118715. * @param selection defines the array to store current content if selection is positive
  118716. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118717. */
  118718. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118719. /**
  118720. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118721. * @param ray defines the ray to test with
  118722. * @param selection defines the array to store current content if selection is positive
  118723. */
  118724. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118725. /**
  118726. * Subdivide the content into child blocks (this block will then be empty)
  118727. */
  118728. createInnerBlocks(): void;
  118729. /**
  118730. * @hidden
  118731. */
  118732. 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;
  118733. }
  118734. }
  118735. declare module BABYLON {
  118736. /**
  118737. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118739. */
  118740. export class Octree<T> {
  118741. /** 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.) */
  118742. maxDepth: number;
  118743. /**
  118744. * Blocks within the octree containing objects
  118745. */
  118746. blocks: Array<OctreeBlock<T>>;
  118747. /**
  118748. * Content stored in the octree
  118749. */
  118750. dynamicContent: T[];
  118751. private _maxBlockCapacity;
  118752. private _selectionContent;
  118753. private _creationFunc;
  118754. /**
  118755. * Creates a octree
  118756. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118757. * @param creationFunc function to be used to instatiate the octree
  118758. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118759. * @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.)
  118760. */
  118761. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118762. /** 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.) */
  118763. maxDepth?: number);
  118764. /**
  118765. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118766. * @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);
  118767. * @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);
  118768. * @param entries meshes to be added to the octree blocks
  118769. */
  118770. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118771. /**
  118772. * Adds a mesh to the octree
  118773. * @param entry Mesh to add to the octree
  118774. */
  118775. addMesh(entry: T): void;
  118776. /**
  118777. * Remove an element from the octree
  118778. * @param entry defines the element to remove
  118779. */
  118780. removeMesh(entry: T): void;
  118781. /**
  118782. * Selects an array of meshes within the frustum
  118783. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118784. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118785. * @returns array of meshes within the frustum
  118786. */
  118787. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118788. /**
  118789. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118790. * @param sphereCenter defines the bounding sphere center
  118791. * @param sphereRadius defines the bounding sphere radius
  118792. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118793. * @returns an array of objects that intersect the sphere
  118794. */
  118795. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118796. /**
  118797. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118798. * @param ray defines the ray to test with
  118799. * @returns array of intersected objects
  118800. */
  118801. intersectsRay(ray: Ray): SmartArray<T>;
  118802. /**
  118803. * Adds a mesh into the octree block if it intersects the block
  118804. */
  118805. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118806. /**
  118807. * Adds a submesh into the octree block if it intersects the block
  118808. */
  118809. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118810. }
  118811. }
  118812. declare module BABYLON {
  118813. interface Scene {
  118814. /**
  118815. * @hidden
  118816. * Backing Filed
  118817. */
  118818. _selectionOctree: Octree<AbstractMesh>;
  118819. /**
  118820. * Gets the octree used to boost mesh selection (picking)
  118821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118822. */
  118823. selectionOctree: Octree<AbstractMesh>;
  118824. /**
  118825. * Creates or updates the octree used to boost selection (picking)
  118826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118827. * @param maxCapacity defines the maximum capacity per leaf
  118828. * @param maxDepth defines the maximum depth of the octree
  118829. * @returns an octree of AbstractMesh
  118830. */
  118831. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118832. }
  118833. interface AbstractMesh {
  118834. /**
  118835. * @hidden
  118836. * Backing Field
  118837. */
  118838. _submeshesOctree: Octree<SubMesh>;
  118839. /**
  118840. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118841. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118842. * @param maxCapacity defines the maximum size of each block (64 by default)
  118843. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118844. * @returns the new octree
  118845. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118847. */
  118848. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118849. }
  118850. /**
  118851. * Defines the octree scene component responsible to manage any octrees
  118852. * in a given scene.
  118853. */
  118854. export class OctreeSceneComponent {
  118855. /**
  118856. * The component name help to identify the component in the list of scene components.
  118857. */
  118858. readonly name: string;
  118859. /**
  118860. * The scene the component belongs to.
  118861. */
  118862. scene: Scene;
  118863. /**
  118864. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118865. */
  118866. readonly checksIsEnabled: boolean;
  118867. /**
  118868. * Creates a new instance of the component for the given scene
  118869. * @param scene Defines the scene to register the component in
  118870. */
  118871. constructor(scene: Scene);
  118872. /**
  118873. * Registers the component in a given scene
  118874. */
  118875. register(): void;
  118876. /**
  118877. * Return the list of active meshes
  118878. * @returns the list of active meshes
  118879. */
  118880. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118881. /**
  118882. * Return the list of active sub meshes
  118883. * @param mesh The mesh to get the candidates sub meshes from
  118884. * @returns the list of active sub meshes
  118885. */
  118886. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118887. private _tempRay;
  118888. /**
  118889. * Return the list of sub meshes intersecting with a given local ray
  118890. * @param mesh defines the mesh to find the submesh for
  118891. * @param localRay defines the ray in local space
  118892. * @returns the list of intersecting sub meshes
  118893. */
  118894. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118895. /**
  118896. * Return the list of sub meshes colliding with a collider
  118897. * @param mesh defines the mesh to find the submesh for
  118898. * @param collider defines the collider to evaluate the collision against
  118899. * @returns the list of colliding sub meshes
  118900. */
  118901. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118902. /**
  118903. * Rebuilds the elements related to this component in case of
  118904. * context lost for instance.
  118905. */
  118906. rebuild(): void;
  118907. /**
  118908. * Disposes the component and the associated ressources.
  118909. */
  118910. dispose(): void;
  118911. }
  118912. }
  118913. declare module BABYLON {
  118914. /**
  118915. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118916. */
  118917. export class Gizmo implements IDisposable {
  118918. /** The utility layer the gizmo will be added to */
  118919. gizmoLayer: UtilityLayerRenderer;
  118920. /**
  118921. * The root mesh of the gizmo
  118922. */
  118923. _rootMesh: Mesh;
  118924. private _attachedMesh;
  118925. /**
  118926. * Ratio for the scale of the gizmo (Default: 1)
  118927. */
  118928. scaleRatio: number;
  118929. /**
  118930. * If a custom mesh has been set (Default: false)
  118931. */
  118932. protected _customMeshSet: boolean;
  118933. /**
  118934. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118935. * * When set, interactions will be enabled
  118936. */
  118937. get attachedMesh(): Nullable<AbstractMesh>;
  118938. set attachedMesh(value: Nullable<AbstractMesh>);
  118939. /**
  118940. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118941. * @param mesh The mesh to replace the default mesh of the gizmo
  118942. */
  118943. setCustomMesh(mesh: Mesh): void;
  118944. /**
  118945. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118946. */
  118947. updateGizmoRotationToMatchAttachedMesh: boolean;
  118948. /**
  118949. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118950. */
  118951. updateGizmoPositionToMatchAttachedMesh: boolean;
  118952. /**
  118953. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118954. */
  118955. updateScale: boolean;
  118956. protected _interactionsEnabled: boolean;
  118957. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118958. private _beforeRenderObserver;
  118959. private _tempVector;
  118960. /**
  118961. * Creates a gizmo
  118962. * @param gizmoLayer The utility layer the gizmo will be added to
  118963. */
  118964. constructor(
  118965. /** The utility layer the gizmo will be added to */
  118966. gizmoLayer?: UtilityLayerRenderer);
  118967. /**
  118968. * Updates the gizmo to match the attached mesh's position/rotation
  118969. */
  118970. protected _update(): void;
  118971. /**
  118972. * Disposes of the gizmo
  118973. */
  118974. dispose(): void;
  118975. }
  118976. }
  118977. declare module BABYLON {
  118978. /**
  118979. * Single plane drag gizmo
  118980. */
  118981. export class PlaneDragGizmo extends Gizmo {
  118982. /**
  118983. * Drag behavior responsible for the gizmos dragging interactions
  118984. */
  118985. dragBehavior: PointerDragBehavior;
  118986. private _pointerObserver;
  118987. /**
  118988. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118989. */
  118990. snapDistance: number;
  118991. /**
  118992. * Event that fires each time the gizmo snaps to a new location.
  118993. * * snapDistance is the the change in distance
  118994. */
  118995. onSnapObservable: Observable<{
  118996. snapDistance: number;
  118997. }>;
  118998. private _plane;
  118999. private _coloredMaterial;
  119000. private _hoverMaterial;
  119001. private _isEnabled;
  119002. private _parent;
  119003. /** @hidden */
  119004. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119005. /** @hidden */
  119006. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119007. /**
  119008. * Creates a PlaneDragGizmo
  119009. * @param gizmoLayer The utility layer the gizmo will be added to
  119010. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119011. * @param color The color of the gizmo
  119012. */
  119013. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119014. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119015. /**
  119016. * If the gizmo is enabled
  119017. */
  119018. set isEnabled(value: boolean);
  119019. get isEnabled(): boolean;
  119020. /**
  119021. * Disposes of the gizmo
  119022. */
  119023. dispose(): void;
  119024. }
  119025. }
  119026. declare module BABYLON {
  119027. /**
  119028. * Gizmo that enables dragging a mesh along 3 axis
  119029. */
  119030. export class PositionGizmo extends Gizmo {
  119031. /**
  119032. * Internal gizmo used for interactions on the x axis
  119033. */
  119034. xGizmo: AxisDragGizmo;
  119035. /**
  119036. * Internal gizmo used for interactions on the y axis
  119037. */
  119038. yGizmo: AxisDragGizmo;
  119039. /**
  119040. * Internal gizmo used for interactions on the z axis
  119041. */
  119042. zGizmo: AxisDragGizmo;
  119043. /**
  119044. * Internal gizmo used for interactions on the yz plane
  119045. */
  119046. xPlaneGizmo: PlaneDragGizmo;
  119047. /**
  119048. * Internal gizmo used for interactions on the xz plane
  119049. */
  119050. yPlaneGizmo: PlaneDragGizmo;
  119051. /**
  119052. * Internal gizmo used for interactions on the xy plane
  119053. */
  119054. zPlaneGizmo: PlaneDragGizmo;
  119055. /**
  119056. * private variables
  119057. */
  119058. private _meshAttached;
  119059. private _updateGizmoRotationToMatchAttachedMesh;
  119060. private _snapDistance;
  119061. private _scaleRatio;
  119062. /** Fires an event when any of it's sub gizmos are dragged */
  119063. onDragStartObservable: Observable<unknown>;
  119064. /** Fires an event when any of it's sub gizmos are released from dragging */
  119065. onDragEndObservable: Observable<unknown>;
  119066. /**
  119067. * If set to true, planar drag is enabled
  119068. */
  119069. private _planarGizmoEnabled;
  119070. get attachedMesh(): Nullable<AbstractMesh>;
  119071. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119072. /**
  119073. * Creates a PositionGizmo
  119074. * @param gizmoLayer The utility layer the gizmo will be added to
  119075. */
  119076. constructor(gizmoLayer?: UtilityLayerRenderer);
  119077. /**
  119078. * If the planar drag gizmo is enabled
  119079. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119080. */
  119081. set planarGizmoEnabled(value: boolean);
  119082. get planarGizmoEnabled(): boolean;
  119083. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119084. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119085. /**
  119086. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119087. */
  119088. set snapDistance(value: number);
  119089. get snapDistance(): number;
  119090. /**
  119091. * Ratio for the scale of the gizmo (Default: 1)
  119092. */
  119093. set scaleRatio(value: number);
  119094. get scaleRatio(): number;
  119095. /**
  119096. * Disposes of the gizmo
  119097. */
  119098. dispose(): void;
  119099. /**
  119100. * CustomMeshes are not supported by this gizmo
  119101. * @param mesh The mesh to replace the default mesh of the gizmo
  119102. */
  119103. setCustomMesh(mesh: Mesh): void;
  119104. }
  119105. }
  119106. declare module BABYLON {
  119107. /**
  119108. * Single axis drag gizmo
  119109. */
  119110. export class AxisDragGizmo extends Gizmo {
  119111. /**
  119112. * Drag behavior responsible for the gizmos dragging interactions
  119113. */
  119114. dragBehavior: PointerDragBehavior;
  119115. private _pointerObserver;
  119116. /**
  119117. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119118. */
  119119. snapDistance: number;
  119120. /**
  119121. * Event that fires each time the gizmo snaps to a new location.
  119122. * * snapDistance is the the change in distance
  119123. */
  119124. onSnapObservable: Observable<{
  119125. snapDistance: number;
  119126. }>;
  119127. private _isEnabled;
  119128. private _parent;
  119129. private _arrow;
  119130. private _coloredMaterial;
  119131. private _hoverMaterial;
  119132. /** @hidden */
  119133. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119134. /** @hidden */
  119135. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119136. /**
  119137. * Creates an AxisDragGizmo
  119138. * @param gizmoLayer The utility layer the gizmo will be added to
  119139. * @param dragAxis The axis which the gizmo will be able to drag on
  119140. * @param color The color of the gizmo
  119141. */
  119142. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119143. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119144. /**
  119145. * If the gizmo is enabled
  119146. */
  119147. set isEnabled(value: boolean);
  119148. get isEnabled(): boolean;
  119149. /**
  119150. * Disposes of the gizmo
  119151. */
  119152. dispose(): void;
  119153. }
  119154. }
  119155. declare module BABYLON.Debug {
  119156. /**
  119157. * The Axes viewer will show 3 axes in a specific point in space
  119158. */
  119159. export class AxesViewer {
  119160. private _xAxis;
  119161. private _yAxis;
  119162. private _zAxis;
  119163. private _scaleLinesFactor;
  119164. private _instanced;
  119165. /**
  119166. * Gets the hosting scene
  119167. */
  119168. scene: Scene;
  119169. /**
  119170. * Gets or sets a number used to scale line length
  119171. */
  119172. scaleLines: number;
  119173. /** Gets the node hierarchy used to render x-axis */
  119174. get xAxis(): TransformNode;
  119175. /** Gets the node hierarchy used to render y-axis */
  119176. get yAxis(): TransformNode;
  119177. /** Gets the node hierarchy used to render z-axis */
  119178. get zAxis(): TransformNode;
  119179. /**
  119180. * Creates a new AxesViewer
  119181. * @param scene defines the hosting scene
  119182. * @param scaleLines defines a number used to scale line length (1 by default)
  119183. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119184. * @param xAxis defines the node hierarchy used to render the x-axis
  119185. * @param yAxis defines the node hierarchy used to render the y-axis
  119186. * @param zAxis defines the node hierarchy used to render the z-axis
  119187. */
  119188. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119189. /**
  119190. * Force the viewer to update
  119191. * @param position defines the position of the viewer
  119192. * @param xaxis defines the x axis of the viewer
  119193. * @param yaxis defines the y axis of the viewer
  119194. * @param zaxis defines the z axis of the viewer
  119195. */
  119196. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119197. /**
  119198. * Creates an instance of this axes viewer.
  119199. * @returns a new axes viewer with instanced meshes
  119200. */
  119201. createInstance(): AxesViewer;
  119202. /** Releases resources */
  119203. dispose(): void;
  119204. private static _SetRenderingGroupId;
  119205. }
  119206. }
  119207. declare module BABYLON.Debug {
  119208. /**
  119209. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119210. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119211. */
  119212. export class BoneAxesViewer extends AxesViewer {
  119213. /**
  119214. * Gets or sets the target mesh where to display the axes viewer
  119215. */
  119216. mesh: Nullable<Mesh>;
  119217. /**
  119218. * Gets or sets the target bone where to display the axes viewer
  119219. */
  119220. bone: Nullable<Bone>;
  119221. /** Gets current position */
  119222. pos: Vector3;
  119223. /** Gets direction of X axis */
  119224. xaxis: Vector3;
  119225. /** Gets direction of Y axis */
  119226. yaxis: Vector3;
  119227. /** Gets direction of Z axis */
  119228. zaxis: Vector3;
  119229. /**
  119230. * Creates a new BoneAxesViewer
  119231. * @param scene defines the hosting scene
  119232. * @param bone defines the target bone
  119233. * @param mesh defines the target mesh
  119234. * @param scaleLines defines a scaling factor for line length (1 by default)
  119235. */
  119236. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119237. /**
  119238. * Force the viewer to update
  119239. */
  119240. update(): void;
  119241. /** Releases resources */
  119242. dispose(): void;
  119243. }
  119244. }
  119245. declare module BABYLON {
  119246. /**
  119247. * Interface used to define scene explorer extensibility option
  119248. */
  119249. export interface IExplorerExtensibilityOption {
  119250. /**
  119251. * Define the option label
  119252. */
  119253. label: string;
  119254. /**
  119255. * Defines the action to execute on click
  119256. */
  119257. action: (entity: any) => void;
  119258. }
  119259. /**
  119260. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119261. */
  119262. export interface IExplorerExtensibilityGroup {
  119263. /**
  119264. * Defines a predicate to test if a given type mut be extended
  119265. */
  119266. predicate: (entity: any) => boolean;
  119267. /**
  119268. * Gets the list of options added to a type
  119269. */
  119270. entries: IExplorerExtensibilityOption[];
  119271. }
  119272. /**
  119273. * Interface used to define the options to use to create the Inspector
  119274. */
  119275. export interface IInspectorOptions {
  119276. /**
  119277. * Display in overlay mode (default: false)
  119278. */
  119279. overlay?: boolean;
  119280. /**
  119281. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119282. */
  119283. globalRoot?: HTMLElement;
  119284. /**
  119285. * Display the Scene explorer
  119286. */
  119287. showExplorer?: boolean;
  119288. /**
  119289. * Display the property inspector
  119290. */
  119291. showInspector?: boolean;
  119292. /**
  119293. * Display in embed mode (both panes on the right)
  119294. */
  119295. embedMode?: boolean;
  119296. /**
  119297. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119298. */
  119299. handleResize?: boolean;
  119300. /**
  119301. * Allow the panes to popup (default: true)
  119302. */
  119303. enablePopup?: boolean;
  119304. /**
  119305. * Allow the panes to be closed by users (default: true)
  119306. */
  119307. enableClose?: boolean;
  119308. /**
  119309. * Optional list of extensibility entries
  119310. */
  119311. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119312. /**
  119313. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119314. */
  119315. inspectorURL?: string;
  119316. /**
  119317. * Optional initial tab (default to DebugLayerTab.Properties)
  119318. */
  119319. initialTab?: DebugLayerTab;
  119320. }
  119321. interface Scene {
  119322. /**
  119323. * @hidden
  119324. * Backing field
  119325. */
  119326. _debugLayer: DebugLayer;
  119327. /**
  119328. * Gets the debug layer (aka Inspector) associated with the scene
  119329. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119330. */
  119331. debugLayer: DebugLayer;
  119332. }
  119333. /**
  119334. * Enum of inspector action tab
  119335. */
  119336. export enum DebugLayerTab {
  119337. /**
  119338. * Properties tag (default)
  119339. */
  119340. Properties = 0,
  119341. /**
  119342. * Debug tab
  119343. */
  119344. Debug = 1,
  119345. /**
  119346. * Statistics tab
  119347. */
  119348. Statistics = 2,
  119349. /**
  119350. * Tools tab
  119351. */
  119352. Tools = 3,
  119353. /**
  119354. * Settings tab
  119355. */
  119356. Settings = 4
  119357. }
  119358. /**
  119359. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119360. * what is happening in your scene
  119361. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119362. */
  119363. export class DebugLayer {
  119364. /**
  119365. * Define the url to get the inspector script from.
  119366. * By default it uses the babylonjs CDN.
  119367. * @ignoreNaming
  119368. */
  119369. static InspectorURL: string;
  119370. private _scene;
  119371. private BJSINSPECTOR;
  119372. private _onPropertyChangedObservable?;
  119373. /**
  119374. * Observable triggered when a property is changed through the inspector.
  119375. */
  119376. get onPropertyChangedObservable(): any;
  119377. /**
  119378. * Instantiates a new debug layer.
  119379. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119380. * what is happening in your scene
  119381. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119382. * @param scene Defines the scene to inspect
  119383. */
  119384. constructor(scene: Scene);
  119385. /** Creates the inspector window. */
  119386. private _createInspector;
  119387. /**
  119388. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119389. * @param entity defines the entity to select
  119390. * @param lineContainerTitle defines the specific block to highlight
  119391. */
  119392. select(entity: any, lineContainerTitle?: string): void;
  119393. /** Get the inspector from bundle or global */
  119394. private _getGlobalInspector;
  119395. /**
  119396. * Get if the inspector is visible or not.
  119397. * @returns true if visible otherwise, false
  119398. */
  119399. isVisible(): boolean;
  119400. /**
  119401. * Hide the inspector and close its window.
  119402. */
  119403. hide(): void;
  119404. /**
  119405. * Launch the debugLayer.
  119406. * @param config Define the configuration of the inspector
  119407. * @return a promise fulfilled when the debug layer is visible
  119408. */
  119409. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119410. }
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * Class containing static functions to help procedurally build meshes
  119415. */
  119416. export class BoxBuilder {
  119417. /**
  119418. * Creates a box mesh
  119419. * * The parameter `size` sets the size (float) of each box side (default 1)
  119420. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119421. * * 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)
  119422. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119426. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119427. * @param name defines the name of the mesh
  119428. * @param options defines the options used to create the mesh
  119429. * @param scene defines the hosting scene
  119430. * @returns the box mesh
  119431. */
  119432. static CreateBox(name: string, options: {
  119433. size?: number;
  119434. width?: number;
  119435. height?: number;
  119436. depth?: number;
  119437. faceUV?: Vector4[];
  119438. faceColors?: Color4[];
  119439. sideOrientation?: number;
  119440. frontUVs?: Vector4;
  119441. backUVs?: Vector4;
  119442. wrap?: boolean;
  119443. topBaseAt?: number;
  119444. bottomBaseAt?: number;
  119445. updatable?: boolean;
  119446. }, scene?: Nullable<Scene>): Mesh;
  119447. }
  119448. }
  119449. declare module BABYLON.Debug {
  119450. /**
  119451. * Used to show the physics impostor around the specific mesh
  119452. */
  119453. export class PhysicsViewer {
  119454. /** @hidden */
  119455. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119456. /** @hidden */
  119457. protected _meshes: Array<Nullable<AbstractMesh>>;
  119458. /** @hidden */
  119459. protected _scene: Nullable<Scene>;
  119460. /** @hidden */
  119461. protected _numMeshes: number;
  119462. /** @hidden */
  119463. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119464. private _renderFunction;
  119465. private _utilityLayer;
  119466. private _debugBoxMesh;
  119467. private _debugSphereMesh;
  119468. private _debugCylinderMesh;
  119469. private _debugMaterial;
  119470. private _debugMeshMeshes;
  119471. /**
  119472. * Creates a new PhysicsViewer
  119473. * @param scene defines the hosting scene
  119474. */
  119475. constructor(scene: Scene);
  119476. /** @hidden */
  119477. protected _updateDebugMeshes(): void;
  119478. /**
  119479. * Renders a specified physic impostor
  119480. * @param impostor defines the impostor to render
  119481. * @param targetMesh defines the mesh represented by the impostor
  119482. * @returns the new debug mesh used to render the impostor
  119483. */
  119484. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119485. /**
  119486. * Hides a specified physic impostor
  119487. * @param impostor defines the impostor to hide
  119488. */
  119489. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119490. private _getDebugMaterial;
  119491. private _getDebugBoxMesh;
  119492. private _getDebugSphereMesh;
  119493. private _getDebugCylinderMesh;
  119494. private _getDebugMeshMesh;
  119495. private _getDebugMesh;
  119496. /** Releases all resources */
  119497. dispose(): void;
  119498. }
  119499. }
  119500. declare module BABYLON {
  119501. /**
  119502. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119503. * in order to better appreciate the issue one might have.
  119504. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119505. */
  119506. export class RayHelper {
  119507. /**
  119508. * Defines the ray we are currently tryin to visualize.
  119509. */
  119510. ray: Nullable<Ray>;
  119511. private _renderPoints;
  119512. private _renderLine;
  119513. private _renderFunction;
  119514. private _scene;
  119515. private _updateToMeshFunction;
  119516. private _attachedToMesh;
  119517. private _meshSpaceDirection;
  119518. private _meshSpaceOrigin;
  119519. /**
  119520. * Helper function to create a colored helper in a scene in one line.
  119521. * @param ray Defines the ray we are currently tryin to visualize
  119522. * @param scene Defines the scene the ray is used in
  119523. * @param color Defines the color we want to see the ray in
  119524. * @returns The newly created ray helper.
  119525. */
  119526. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119527. /**
  119528. * Instantiate a new ray helper.
  119529. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119530. * in order to better appreciate the issue one might have.
  119531. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119532. * @param ray Defines the ray we are currently tryin to visualize
  119533. */
  119534. constructor(ray: Ray);
  119535. /**
  119536. * Shows the ray we are willing to debug.
  119537. * @param scene Defines the scene the ray needs to be rendered in
  119538. * @param color Defines the color the ray needs to be rendered in
  119539. */
  119540. show(scene: Scene, color?: Color3): void;
  119541. /**
  119542. * Hides the ray we are debugging.
  119543. */
  119544. hide(): void;
  119545. private _render;
  119546. /**
  119547. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119548. * @param mesh Defines the mesh we want the helper attached to
  119549. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119550. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119551. * @param length Defines the length of the ray
  119552. */
  119553. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119554. /**
  119555. * Detach the ray helper from the mesh it has previously been attached to.
  119556. */
  119557. detachFromMesh(): void;
  119558. private _updateToMesh;
  119559. /**
  119560. * Dispose the helper and release its associated resources.
  119561. */
  119562. dispose(): void;
  119563. }
  119564. }
  119565. declare module BABYLON.Debug {
  119566. /**
  119567. * Class used to render a debug view of a given skeleton
  119568. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119569. */
  119570. export class SkeletonViewer {
  119571. /** defines the skeleton to render */
  119572. skeleton: Skeleton;
  119573. /** defines the mesh attached to the skeleton */
  119574. mesh: AbstractMesh;
  119575. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119576. autoUpdateBonesMatrices: boolean;
  119577. /** defines the rendering group id to use with the viewer */
  119578. renderingGroupId: number;
  119579. /** Gets or sets the color used to render the skeleton */
  119580. color: Color3;
  119581. private _scene;
  119582. private _debugLines;
  119583. private _debugMesh;
  119584. private _isEnabled;
  119585. private _renderFunction;
  119586. private _utilityLayer;
  119587. /**
  119588. * Returns the mesh used to render the bones
  119589. */
  119590. get debugMesh(): Nullable<LinesMesh>;
  119591. /**
  119592. * Creates a new SkeletonViewer
  119593. * @param skeleton defines the skeleton to render
  119594. * @param mesh defines the mesh attached to the skeleton
  119595. * @param scene defines the hosting scene
  119596. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119597. * @param renderingGroupId defines the rendering group id to use with the viewer
  119598. */
  119599. constructor(
  119600. /** defines the skeleton to render */
  119601. skeleton: Skeleton,
  119602. /** defines the mesh attached to the skeleton */
  119603. mesh: AbstractMesh, scene: Scene,
  119604. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119605. autoUpdateBonesMatrices?: boolean,
  119606. /** defines the rendering group id to use with the viewer */
  119607. renderingGroupId?: number);
  119608. /** Gets or sets a boolean indicating if the viewer is enabled */
  119609. set isEnabled(value: boolean);
  119610. get isEnabled(): boolean;
  119611. private _getBonePosition;
  119612. private _getLinesForBonesWithLength;
  119613. private _getLinesForBonesNoLength;
  119614. /** Update the viewer to sync with current skeleton state */
  119615. update(): void;
  119616. /** Release associated resources */
  119617. dispose(): void;
  119618. }
  119619. }
  119620. declare module BABYLON {
  119621. /**
  119622. * Options to create the null engine
  119623. */
  119624. export class NullEngineOptions {
  119625. /**
  119626. * Render width (Default: 512)
  119627. */
  119628. renderWidth: number;
  119629. /**
  119630. * Render height (Default: 256)
  119631. */
  119632. renderHeight: number;
  119633. /**
  119634. * Texture size (Default: 512)
  119635. */
  119636. textureSize: number;
  119637. /**
  119638. * If delta time between frames should be constant
  119639. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119640. */
  119641. deterministicLockstep: boolean;
  119642. /**
  119643. * Maximum about of steps between frames (Default: 4)
  119644. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119645. */
  119646. lockstepMaxSteps: number;
  119647. }
  119648. /**
  119649. * The null engine class provides support for headless version of babylon.js.
  119650. * This can be used in server side scenario or for testing purposes
  119651. */
  119652. export class NullEngine extends Engine {
  119653. private _options;
  119654. /**
  119655. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119656. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119657. * @returns true if engine is in deterministic lock step mode
  119658. */
  119659. isDeterministicLockStep(): boolean;
  119660. /**
  119661. * Gets the max steps when engine is running in deterministic lock step
  119662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119663. * @returns the max steps
  119664. */
  119665. getLockstepMaxSteps(): number;
  119666. /**
  119667. * Gets the current hardware scaling level.
  119668. * By default the hardware scaling level is computed from the window device ratio.
  119669. * 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.
  119670. * @returns a number indicating the current hardware scaling level
  119671. */
  119672. getHardwareScalingLevel(): number;
  119673. constructor(options?: NullEngineOptions);
  119674. /**
  119675. * Creates a vertex buffer
  119676. * @param vertices the data for the vertex buffer
  119677. * @returns the new WebGL static buffer
  119678. */
  119679. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119680. /**
  119681. * Creates a new index buffer
  119682. * @param indices defines the content of the index buffer
  119683. * @param updatable defines if the index buffer must be updatable
  119684. * @returns a new webGL buffer
  119685. */
  119686. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119687. /**
  119688. * Clear the current render buffer or the current render target (if any is set up)
  119689. * @param color defines the color to use
  119690. * @param backBuffer defines if the back buffer must be cleared
  119691. * @param depth defines if the depth buffer must be cleared
  119692. * @param stencil defines if the stencil buffer must be cleared
  119693. */
  119694. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119695. /**
  119696. * Gets the current render width
  119697. * @param useScreen defines if screen size must be used (or the current render target if any)
  119698. * @returns a number defining the current render width
  119699. */
  119700. getRenderWidth(useScreen?: boolean): number;
  119701. /**
  119702. * Gets the current render height
  119703. * @param useScreen defines if screen size must be used (or the current render target if any)
  119704. * @returns a number defining the current render height
  119705. */
  119706. getRenderHeight(useScreen?: boolean): number;
  119707. /**
  119708. * Set the WebGL's viewport
  119709. * @param viewport defines the viewport element to be used
  119710. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119711. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119712. */
  119713. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119714. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119715. /**
  119716. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119717. * @param pipelineContext defines the pipeline context to use
  119718. * @param uniformsNames defines the list of uniform names
  119719. * @returns an array of webGL uniform locations
  119720. */
  119721. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119722. /**
  119723. * Gets the lsit of active attributes for a given webGL program
  119724. * @param pipelineContext defines the pipeline context to use
  119725. * @param attributesNames defines the list of attribute names to get
  119726. * @returns an array of indices indicating the offset of each attribute
  119727. */
  119728. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119729. /**
  119730. * Binds an effect to the webGL context
  119731. * @param effect defines the effect to bind
  119732. */
  119733. bindSamplers(effect: Effect): void;
  119734. /**
  119735. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119736. * @param effect defines the effect to activate
  119737. */
  119738. enableEffect(effect: Effect): void;
  119739. /**
  119740. * Set various states to the webGL context
  119741. * @param culling defines backface culling state
  119742. * @param zOffset defines the value to apply to zOffset (0 by default)
  119743. * @param force defines if states must be applied even if cache is up to date
  119744. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119745. */
  119746. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119747. /**
  119748. * Set the value of an uniform to an array of int32
  119749. * @param uniform defines the webGL uniform location where to store the value
  119750. * @param array defines the array of int32 to store
  119751. */
  119752. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119753. /**
  119754. * Set the value of an uniform to an array of int32 (stored as vec2)
  119755. * @param uniform defines the webGL uniform location where to store the value
  119756. * @param array defines the array of int32 to store
  119757. */
  119758. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119759. /**
  119760. * Set the value of an uniform to an array of int32 (stored as vec3)
  119761. * @param uniform defines the webGL uniform location where to store the value
  119762. * @param array defines the array of int32 to store
  119763. */
  119764. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119765. /**
  119766. * Set the value of an uniform to an array of int32 (stored as vec4)
  119767. * @param uniform defines the webGL uniform location where to store the value
  119768. * @param array defines the array of int32 to store
  119769. */
  119770. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119771. /**
  119772. * Set the value of an uniform to an array of float32
  119773. * @param uniform defines the webGL uniform location where to store the value
  119774. * @param array defines the array of float32 to store
  119775. */
  119776. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119777. /**
  119778. * Set the value of an uniform to an array of float32 (stored as vec2)
  119779. * @param uniform defines the webGL uniform location where to store the value
  119780. * @param array defines the array of float32 to store
  119781. */
  119782. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119783. /**
  119784. * Set the value of an uniform to an array of float32 (stored as vec3)
  119785. * @param uniform defines the webGL uniform location where to store the value
  119786. * @param array defines the array of float32 to store
  119787. */
  119788. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119789. /**
  119790. * Set the value of an uniform to an array of float32 (stored as vec4)
  119791. * @param uniform defines the webGL uniform location where to store the value
  119792. * @param array defines the array of float32 to store
  119793. */
  119794. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119795. /**
  119796. * Set the value of an uniform to an array of number
  119797. * @param uniform defines the webGL uniform location where to store the value
  119798. * @param array defines the array of number to store
  119799. */
  119800. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119801. /**
  119802. * Set the value of an uniform to an array of number (stored as vec2)
  119803. * @param uniform defines the webGL uniform location where to store the value
  119804. * @param array defines the array of number to store
  119805. */
  119806. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119807. /**
  119808. * Set the value of an uniform to an array of number (stored as vec3)
  119809. * @param uniform defines the webGL uniform location where to store the value
  119810. * @param array defines the array of number to store
  119811. */
  119812. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119813. /**
  119814. * Set the value of an uniform to an array of number (stored as vec4)
  119815. * @param uniform defines the webGL uniform location where to store the value
  119816. * @param array defines the array of number to store
  119817. */
  119818. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119819. /**
  119820. * Set the value of an uniform to an array of float32 (stored as matrices)
  119821. * @param uniform defines the webGL uniform location where to store the value
  119822. * @param matrices defines the array of float32 to store
  119823. */
  119824. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119825. /**
  119826. * Set the value of an uniform to a matrix (3x3)
  119827. * @param uniform defines the webGL uniform location where to store the value
  119828. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119829. */
  119830. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119831. /**
  119832. * Set the value of an uniform to a matrix (2x2)
  119833. * @param uniform defines the webGL uniform location where to store the value
  119834. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119835. */
  119836. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119837. /**
  119838. * Set the value of an uniform to a number (float)
  119839. * @param uniform defines the webGL uniform location where to store the value
  119840. * @param value defines the float number to store
  119841. */
  119842. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119843. /**
  119844. * Set the value of an uniform to a vec2
  119845. * @param uniform defines the webGL uniform location where to store the value
  119846. * @param x defines the 1st component of the value
  119847. * @param y defines the 2nd component of the value
  119848. */
  119849. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119850. /**
  119851. * Set the value of an uniform to a vec3
  119852. * @param uniform defines the webGL uniform location where to store the value
  119853. * @param x defines the 1st component of the value
  119854. * @param y defines the 2nd component of the value
  119855. * @param z defines the 3rd component of the value
  119856. */
  119857. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119858. /**
  119859. * Set the value of an uniform to a boolean
  119860. * @param uniform defines the webGL uniform location where to store the value
  119861. * @param bool defines the boolean to store
  119862. */
  119863. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119864. /**
  119865. * Set the value of an uniform to a vec4
  119866. * @param uniform defines the webGL uniform location where to store the value
  119867. * @param x defines the 1st component of the value
  119868. * @param y defines the 2nd component of the value
  119869. * @param z defines the 3rd component of the value
  119870. * @param w defines the 4th component of the value
  119871. */
  119872. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119873. /**
  119874. * Sets the current alpha mode
  119875. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119876. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119877. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119878. */
  119879. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119880. /**
  119881. * Bind webGl buffers directly to the webGL context
  119882. * @param vertexBuffers defines the vertex buffer to bind
  119883. * @param indexBuffer defines the index buffer to bind
  119884. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119885. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119886. * @param effect defines the effect associated with the vertex buffer
  119887. */
  119888. bindBuffers(vertexBuffers: {
  119889. [key: string]: VertexBuffer;
  119890. }, indexBuffer: DataBuffer, effect: Effect): void;
  119891. /**
  119892. * Force the entire cache to be cleared
  119893. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119894. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119895. */
  119896. wipeCaches(bruteForce?: boolean): void;
  119897. /**
  119898. * Send a draw order
  119899. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119900. * @param indexStart defines the starting index
  119901. * @param indexCount defines the number of index to draw
  119902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119903. */
  119904. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119905. /**
  119906. * Draw a list of indexed primitives
  119907. * @param fillMode defines the primitive to use
  119908. * @param indexStart defines the starting index
  119909. * @param indexCount defines the number of index to draw
  119910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119911. */
  119912. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119913. /**
  119914. * Draw a list of unindexed primitives
  119915. * @param fillMode defines the primitive to use
  119916. * @param verticesStart defines the index of first vertex to draw
  119917. * @param verticesCount defines the count of vertices to draw
  119918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119919. */
  119920. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119921. /** @hidden */
  119922. _createTexture(): WebGLTexture;
  119923. /** @hidden */
  119924. _releaseTexture(texture: InternalTexture): void;
  119925. /**
  119926. * Usually called from Texture.ts.
  119927. * Passed information to create a WebGLTexture
  119928. * @param urlArg defines a value which contains one of the following:
  119929. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119930. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119931. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119933. * @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)
  119934. * @param scene needed for loading to the correct scene
  119935. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119936. * @param onLoad optional callback to be called upon successful completion
  119937. * @param onError optional callback to be called upon failure
  119938. * @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
  119939. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119940. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119941. * @param forcedExtension defines the extension to use to pick the right loader
  119942. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119943. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119944. */
  119945. 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;
  119946. /**
  119947. * Creates a new render target texture
  119948. * @param size defines the size of the texture
  119949. * @param options defines the options used to create the texture
  119950. * @returns a new render target texture stored in an InternalTexture
  119951. */
  119952. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119953. /**
  119954. * Update the sampling mode of a given texture
  119955. * @param samplingMode defines the required sampling mode
  119956. * @param texture defines the texture to update
  119957. */
  119958. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119959. /**
  119960. * Binds the frame buffer to the specified texture.
  119961. * @param texture The texture to render to or null for the default canvas
  119962. * @param faceIndex The face of the texture to render to in case of cube texture
  119963. * @param requiredWidth The width of the target to render to
  119964. * @param requiredHeight The height of the target to render to
  119965. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119966. * @param lodLevel defines le lod level to bind to the frame buffer
  119967. */
  119968. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119969. /**
  119970. * Unbind the current render target texture from the webGL context
  119971. * @param texture defines the render target texture to unbind
  119972. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119973. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119974. */
  119975. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119976. /**
  119977. * Creates a dynamic vertex buffer
  119978. * @param vertices the data for the dynamic vertex buffer
  119979. * @returns the new WebGL dynamic buffer
  119980. */
  119981. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119982. /**
  119983. * Update the content of a dynamic texture
  119984. * @param texture defines the texture to update
  119985. * @param canvas defines the canvas containing the source
  119986. * @param invertY defines if data must be stored with Y axis inverted
  119987. * @param premulAlpha defines if alpha is stored as premultiplied
  119988. * @param format defines the format of the data
  119989. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119990. */
  119991. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119992. /**
  119993. * Gets a boolean indicating if all created effects are ready
  119994. * @returns true if all effects are ready
  119995. */
  119996. areAllEffectsReady(): boolean;
  119997. /**
  119998. * @hidden
  119999. * Get the current error code of the webGL context
  120000. * @returns the error code
  120001. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120002. */
  120003. getError(): number;
  120004. /** @hidden */
  120005. _getUnpackAlignement(): number;
  120006. /** @hidden */
  120007. _unpackFlipY(value: boolean): void;
  120008. /**
  120009. * Update a dynamic index buffer
  120010. * @param indexBuffer defines the target index buffer
  120011. * @param indices defines the data to update
  120012. * @param offset defines the offset in the target index buffer where update should start
  120013. */
  120014. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120015. /**
  120016. * Updates a dynamic vertex buffer.
  120017. * @param vertexBuffer the vertex buffer to update
  120018. * @param vertices the data used to update the vertex buffer
  120019. * @param byteOffset the byte offset of the data (optional)
  120020. * @param byteLength the byte length of the data (optional)
  120021. */
  120022. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120023. /** @hidden */
  120024. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120025. /** @hidden */
  120026. _bindTexture(channel: number, texture: InternalTexture): void;
  120027. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120028. /**
  120029. * 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
  120030. */
  120031. releaseEffects(): void;
  120032. displayLoadingUI(): void;
  120033. hideLoadingUI(): void;
  120034. /** @hidden */
  120035. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120036. /** @hidden */
  120037. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120038. /** @hidden */
  120039. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120040. /** @hidden */
  120041. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120042. }
  120043. }
  120044. declare module BABYLON {
  120045. /**
  120046. * @hidden
  120047. **/
  120048. export class _TimeToken {
  120049. _startTimeQuery: Nullable<WebGLQuery>;
  120050. _endTimeQuery: Nullable<WebGLQuery>;
  120051. _timeElapsedQuery: Nullable<WebGLQuery>;
  120052. _timeElapsedQueryEnded: boolean;
  120053. }
  120054. }
  120055. declare module BABYLON {
  120056. /** @hidden */
  120057. export class _OcclusionDataStorage {
  120058. /** @hidden */
  120059. occlusionInternalRetryCounter: number;
  120060. /** @hidden */
  120061. isOcclusionQueryInProgress: boolean;
  120062. /** @hidden */
  120063. isOccluded: boolean;
  120064. /** @hidden */
  120065. occlusionRetryCount: number;
  120066. /** @hidden */
  120067. occlusionType: number;
  120068. /** @hidden */
  120069. occlusionQueryAlgorithmType: number;
  120070. }
  120071. interface Engine {
  120072. /**
  120073. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120074. * @return the new query
  120075. */
  120076. createQuery(): WebGLQuery;
  120077. /**
  120078. * Delete and release a webGL query
  120079. * @param query defines the query to delete
  120080. * @return the current engine
  120081. */
  120082. deleteQuery(query: WebGLQuery): Engine;
  120083. /**
  120084. * Check if a given query has resolved and got its value
  120085. * @param query defines the query to check
  120086. * @returns true if the query got its value
  120087. */
  120088. isQueryResultAvailable(query: WebGLQuery): boolean;
  120089. /**
  120090. * Gets the value of a given query
  120091. * @param query defines the query to check
  120092. * @returns the value of the query
  120093. */
  120094. getQueryResult(query: WebGLQuery): number;
  120095. /**
  120096. * Initiates an occlusion query
  120097. * @param algorithmType defines the algorithm to use
  120098. * @param query defines the query to use
  120099. * @returns the current engine
  120100. * @see http://doc.babylonjs.com/features/occlusionquery
  120101. */
  120102. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120103. /**
  120104. * Ends an occlusion query
  120105. * @see http://doc.babylonjs.com/features/occlusionquery
  120106. * @param algorithmType defines the algorithm to use
  120107. * @returns the current engine
  120108. */
  120109. endOcclusionQuery(algorithmType: number): Engine;
  120110. /**
  120111. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120112. * Please note that only one query can be issued at a time
  120113. * @returns a time token used to track the time span
  120114. */
  120115. startTimeQuery(): Nullable<_TimeToken>;
  120116. /**
  120117. * Ends a time query
  120118. * @param token defines the token used to measure the time span
  120119. * @returns the time spent (in ns)
  120120. */
  120121. endTimeQuery(token: _TimeToken): int;
  120122. /** @hidden */
  120123. _currentNonTimestampToken: Nullable<_TimeToken>;
  120124. /** @hidden */
  120125. _createTimeQuery(): WebGLQuery;
  120126. /** @hidden */
  120127. _deleteTimeQuery(query: WebGLQuery): void;
  120128. /** @hidden */
  120129. _getGlAlgorithmType(algorithmType: number): number;
  120130. /** @hidden */
  120131. _getTimeQueryResult(query: WebGLQuery): any;
  120132. /** @hidden */
  120133. _getTimeQueryAvailability(query: WebGLQuery): any;
  120134. }
  120135. interface AbstractMesh {
  120136. /**
  120137. * Backing filed
  120138. * @hidden
  120139. */
  120140. __occlusionDataStorage: _OcclusionDataStorage;
  120141. /**
  120142. * Access property
  120143. * @hidden
  120144. */
  120145. _occlusionDataStorage: _OcclusionDataStorage;
  120146. /**
  120147. * 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.
  120148. * The default value is -1 which means don't break the query and wait till the result
  120149. * @see http://doc.babylonjs.com/features/occlusionquery
  120150. */
  120151. occlusionRetryCount: number;
  120152. /**
  120153. * 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:
  120154. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120155. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120156. * * 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.
  120157. * @see http://doc.babylonjs.com/features/occlusionquery
  120158. */
  120159. occlusionType: number;
  120160. /**
  120161. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120162. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120163. * * 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.
  120164. * @see http://doc.babylonjs.com/features/occlusionquery
  120165. */
  120166. occlusionQueryAlgorithmType: number;
  120167. /**
  120168. * 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
  120169. * @see http://doc.babylonjs.com/features/occlusionquery
  120170. */
  120171. isOccluded: boolean;
  120172. /**
  120173. * Flag to check the progress status of the query
  120174. * @see http://doc.babylonjs.com/features/occlusionquery
  120175. */
  120176. isOcclusionQueryInProgress: boolean;
  120177. }
  120178. }
  120179. declare module BABYLON {
  120180. /** @hidden */
  120181. export var _forceTransformFeedbackToBundle: boolean;
  120182. interface Engine {
  120183. /**
  120184. * Creates a webGL transform feedback object
  120185. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120186. * @returns the webGL transform feedback object
  120187. */
  120188. createTransformFeedback(): WebGLTransformFeedback;
  120189. /**
  120190. * Delete a webGL transform feedback object
  120191. * @param value defines the webGL transform feedback object to delete
  120192. */
  120193. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120194. /**
  120195. * Bind a webGL transform feedback object to the webgl context
  120196. * @param value defines the webGL transform feedback object to bind
  120197. */
  120198. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120199. /**
  120200. * Begins a transform feedback operation
  120201. * @param usePoints defines if points or triangles must be used
  120202. */
  120203. beginTransformFeedback(usePoints: boolean): void;
  120204. /**
  120205. * Ends a transform feedback operation
  120206. */
  120207. endTransformFeedback(): void;
  120208. /**
  120209. * Specify the varyings to use with transform feedback
  120210. * @param program defines the associated webGL program
  120211. * @param value defines the list of strings representing the varying names
  120212. */
  120213. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120214. /**
  120215. * Bind a webGL buffer for a transform feedback operation
  120216. * @param value defines the webGL buffer to bind
  120217. */
  120218. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120219. }
  120220. }
  120221. declare module BABYLON {
  120222. /**
  120223. * Creation options of the multi render target texture.
  120224. */
  120225. export interface IMultiRenderTargetOptions {
  120226. /**
  120227. * Define if the texture needs to create mip maps after render.
  120228. */
  120229. generateMipMaps?: boolean;
  120230. /**
  120231. * Define the types of all the draw buffers we want to create
  120232. */
  120233. types?: number[];
  120234. /**
  120235. * Define the sampling modes of all the draw buffers we want to create
  120236. */
  120237. samplingModes?: number[];
  120238. /**
  120239. * Define if a depth buffer is required
  120240. */
  120241. generateDepthBuffer?: boolean;
  120242. /**
  120243. * Define if a stencil buffer is required
  120244. */
  120245. generateStencilBuffer?: boolean;
  120246. /**
  120247. * Define if a depth texture is required instead of a depth buffer
  120248. */
  120249. generateDepthTexture?: boolean;
  120250. /**
  120251. * Define the number of desired draw buffers
  120252. */
  120253. textureCount?: number;
  120254. /**
  120255. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120256. */
  120257. doNotChangeAspectRatio?: boolean;
  120258. /**
  120259. * Define the default type of the buffers we are creating
  120260. */
  120261. defaultType?: number;
  120262. }
  120263. /**
  120264. * A multi render target, like a render target provides the ability to render to a texture.
  120265. * Unlike the render target, it can render to several draw buffers in one draw.
  120266. * This is specially interesting in deferred rendering or for any effects requiring more than
  120267. * just one color from a single pass.
  120268. */
  120269. export class MultiRenderTarget extends RenderTargetTexture {
  120270. private _internalTextures;
  120271. private _textures;
  120272. private _multiRenderTargetOptions;
  120273. /**
  120274. * Get if draw buffers are currently supported by the used hardware and browser.
  120275. */
  120276. get isSupported(): boolean;
  120277. /**
  120278. * Get the list of textures generated by the multi render target.
  120279. */
  120280. get textures(): Texture[];
  120281. /**
  120282. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120283. */
  120284. get depthTexture(): Texture;
  120285. /**
  120286. * Set the wrapping mode on U of all the textures we are rendering to.
  120287. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120288. */
  120289. set wrapU(wrap: number);
  120290. /**
  120291. * Set the wrapping mode on V of all the textures we are rendering to.
  120292. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120293. */
  120294. set wrapV(wrap: number);
  120295. /**
  120296. * Instantiate a new multi render target texture.
  120297. * A multi render target, like a render target provides the ability to render to a texture.
  120298. * Unlike the render target, it can render to several draw buffers in one draw.
  120299. * This is specially interesting in deferred rendering or for any effects requiring more than
  120300. * just one color from a single pass.
  120301. * @param name Define the name of the texture
  120302. * @param size Define the size of the buffers to render to
  120303. * @param count Define the number of target we are rendering into
  120304. * @param scene Define the scene the texture belongs to
  120305. * @param options Define the options used to create the multi render target
  120306. */
  120307. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120308. /** @hidden */
  120309. _rebuild(): void;
  120310. private _createInternalTextures;
  120311. private _createTextures;
  120312. /**
  120313. * Define the number of samples used if MSAA is enabled.
  120314. */
  120315. get samples(): number;
  120316. set samples(value: number);
  120317. /**
  120318. * Resize all the textures in the multi render target.
  120319. * Be carrefull as it will recreate all the data in the new texture.
  120320. * @param size Define the new size
  120321. */
  120322. resize(size: any): void;
  120323. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120324. /**
  120325. * Dispose the render targets and their associated resources
  120326. */
  120327. dispose(): void;
  120328. /**
  120329. * Release all the underlying texture used as draw buffers.
  120330. */
  120331. releaseInternalTextures(): void;
  120332. }
  120333. }
  120334. declare module BABYLON {
  120335. interface ThinEngine {
  120336. /**
  120337. * Unbind a list of render target textures from the webGL context
  120338. * This is used only when drawBuffer extension or webGL2 are active
  120339. * @param textures defines the render target textures to unbind
  120340. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120341. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120342. */
  120343. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120344. /**
  120345. * Create a multi render target texture
  120346. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120347. * @param size defines the size of the texture
  120348. * @param options defines the creation options
  120349. * @returns the cube texture as an InternalTexture
  120350. */
  120351. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120352. /**
  120353. * Update the sample count for a given multiple render target texture
  120354. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120355. * @param textures defines the textures to update
  120356. * @param samples defines the sample count to set
  120357. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120358. */
  120359. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120360. }
  120361. }
  120362. declare module BABYLON {
  120363. /**
  120364. * Class used to define an additional view for the engine
  120365. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120366. */
  120367. export class EngineView {
  120368. /** Defines the canvas where to render the view */
  120369. target: HTMLCanvasElement;
  120370. /** Defines an optional camera used to render the view (will use active camera else) */
  120371. camera?: Camera;
  120372. }
  120373. interface Engine {
  120374. /**
  120375. * Gets or sets the HTML element to use for attaching events
  120376. */
  120377. inputElement: Nullable<HTMLElement>;
  120378. /**
  120379. * Gets the current engine view
  120380. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120381. */
  120382. activeView: Nullable<EngineView>;
  120383. /** Gets or sets the list of views */
  120384. views: EngineView[];
  120385. /**
  120386. * Register a new child canvas
  120387. * @param canvas defines the canvas to register
  120388. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120389. * @returns the associated view
  120390. */
  120391. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120392. /**
  120393. * Remove a registered child canvas
  120394. * @param canvas defines the canvas to remove
  120395. * @returns the current engine
  120396. */
  120397. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120398. }
  120399. }
  120400. declare module BABYLON {
  120401. /**
  120402. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120403. */
  120404. export interface CubeMapInfo {
  120405. /**
  120406. * The pixel array for the front face.
  120407. * This is stored in format, left to right, up to down format.
  120408. */
  120409. front: Nullable<ArrayBufferView>;
  120410. /**
  120411. * The pixel array for the back face.
  120412. * This is stored in format, left to right, up to down format.
  120413. */
  120414. back: Nullable<ArrayBufferView>;
  120415. /**
  120416. * The pixel array for the left face.
  120417. * This is stored in format, left to right, up to down format.
  120418. */
  120419. left: Nullable<ArrayBufferView>;
  120420. /**
  120421. * The pixel array for the right face.
  120422. * This is stored in format, left to right, up to down format.
  120423. */
  120424. right: Nullable<ArrayBufferView>;
  120425. /**
  120426. * The pixel array for the up face.
  120427. * This is stored in format, left to right, up to down format.
  120428. */
  120429. up: Nullable<ArrayBufferView>;
  120430. /**
  120431. * The pixel array for the down face.
  120432. * This is stored in format, left to right, up to down format.
  120433. */
  120434. down: Nullable<ArrayBufferView>;
  120435. /**
  120436. * The size of the cubemap stored.
  120437. *
  120438. * Each faces will be size * size pixels.
  120439. */
  120440. size: number;
  120441. /**
  120442. * The format of the texture.
  120443. *
  120444. * RGBA, RGB.
  120445. */
  120446. format: number;
  120447. /**
  120448. * The type of the texture data.
  120449. *
  120450. * UNSIGNED_INT, FLOAT.
  120451. */
  120452. type: number;
  120453. /**
  120454. * Specifies whether the texture is in gamma space.
  120455. */
  120456. gammaSpace: boolean;
  120457. }
  120458. /**
  120459. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120460. */
  120461. export class PanoramaToCubeMapTools {
  120462. private static FACE_FRONT;
  120463. private static FACE_BACK;
  120464. private static FACE_RIGHT;
  120465. private static FACE_LEFT;
  120466. private static FACE_DOWN;
  120467. private static FACE_UP;
  120468. /**
  120469. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120470. *
  120471. * @param float32Array The source data.
  120472. * @param inputWidth The width of the input panorama.
  120473. * @param inputHeight The height of the input panorama.
  120474. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120475. * @return The cubemap data
  120476. */
  120477. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120478. private static CreateCubemapTexture;
  120479. private static CalcProjectionSpherical;
  120480. }
  120481. }
  120482. declare module BABYLON {
  120483. /**
  120484. * Helper class dealing with the extraction of spherical polynomial dataArray
  120485. * from a cube map.
  120486. */
  120487. export class CubeMapToSphericalPolynomialTools {
  120488. private static FileFaces;
  120489. /**
  120490. * Converts a texture to the according Spherical Polynomial data.
  120491. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120492. *
  120493. * @param texture The texture to extract the information from.
  120494. * @return The Spherical Polynomial data.
  120495. */
  120496. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120497. /**
  120498. * Converts a cubemap to the according Spherical Polynomial data.
  120499. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120500. *
  120501. * @param cubeInfo The Cube map to extract the information from.
  120502. * @return The Spherical Polynomial data.
  120503. */
  120504. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120505. }
  120506. }
  120507. declare module BABYLON {
  120508. interface BaseTexture {
  120509. /**
  120510. * Get the polynomial representation of the texture data.
  120511. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120512. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120513. */
  120514. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120515. }
  120516. }
  120517. declare module BABYLON {
  120518. /** @hidden */
  120519. export var rgbdEncodePixelShader: {
  120520. name: string;
  120521. shader: string;
  120522. };
  120523. }
  120524. declare module BABYLON {
  120525. /** @hidden */
  120526. export var rgbdDecodePixelShader: {
  120527. name: string;
  120528. shader: string;
  120529. };
  120530. }
  120531. declare module BABYLON {
  120532. /**
  120533. * Raw texture data and descriptor sufficient for WebGL texture upload
  120534. */
  120535. export interface EnvironmentTextureInfo {
  120536. /**
  120537. * Version of the environment map
  120538. */
  120539. version: number;
  120540. /**
  120541. * Width of image
  120542. */
  120543. width: number;
  120544. /**
  120545. * Irradiance information stored in the file.
  120546. */
  120547. irradiance: any;
  120548. /**
  120549. * Specular information stored in the file.
  120550. */
  120551. specular: any;
  120552. }
  120553. /**
  120554. * Defines One Image in the file. It requires only the position in the file
  120555. * as well as the length.
  120556. */
  120557. interface BufferImageData {
  120558. /**
  120559. * Length of the image data.
  120560. */
  120561. length: number;
  120562. /**
  120563. * Position of the data from the null terminator delimiting the end of the JSON.
  120564. */
  120565. position: number;
  120566. }
  120567. /**
  120568. * Defines the specular data enclosed in the file.
  120569. * This corresponds to the version 1 of the data.
  120570. */
  120571. export interface EnvironmentTextureSpecularInfoV1 {
  120572. /**
  120573. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120574. */
  120575. specularDataPosition?: number;
  120576. /**
  120577. * This contains all the images data needed to reconstruct the cubemap.
  120578. */
  120579. mipmaps: Array<BufferImageData>;
  120580. /**
  120581. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120582. */
  120583. lodGenerationScale: number;
  120584. }
  120585. /**
  120586. * Sets of helpers addressing the serialization and deserialization of environment texture
  120587. * stored in a BabylonJS env file.
  120588. * Those files are usually stored as .env files.
  120589. */
  120590. export class EnvironmentTextureTools {
  120591. /**
  120592. * Magic number identifying the env file.
  120593. */
  120594. private static _MagicBytes;
  120595. /**
  120596. * Gets the environment info from an env file.
  120597. * @param data The array buffer containing the .env bytes.
  120598. * @returns the environment file info (the json header) if successfully parsed.
  120599. */
  120600. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120601. /**
  120602. * Creates an environment texture from a loaded cube texture.
  120603. * @param texture defines the cube texture to convert in env file
  120604. * @return a promise containing the environment data if succesfull.
  120605. */
  120606. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120607. /**
  120608. * Creates a JSON representation of the spherical data.
  120609. * @param texture defines the texture containing the polynomials
  120610. * @return the JSON representation of the spherical info
  120611. */
  120612. private static _CreateEnvTextureIrradiance;
  120613. /**
  120614. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120615. * @param data the image data
  120616. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120617. * @return the views described by info providing access to the underlying buffer
  120618. */
  120619. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120620. /**
  120621. * Uploads the texture info contained in the env file to the GPU.
  120622. * @param texture defines the internal texture to upload to
  120623. * @param data defines the data to load
  120624. * @param info defines the texture info retrieved through the GetEnvInfo method
  120625. * @returns a promise
  120626. */
  120627. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120628. private static _OnImageReadyAsync;
  120629. /**
  120630. * Uploads the levels of image data to the GPU.
  120631. * @param texture defines the internal texture to upload to
  120632. * @param imageData defines the array buffer views of image data [mipmap][face]
  120633. * @returns a promise
  120634. */
  120635. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120636. /**
  120637. * Uploads spherical polynomials information to the texture.
  120638. * @param texture defines the texture we are trying to upload the information to
  120639. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120640. */
  120641. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120642. /** @hidden */
  120643. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120644. }
  120645. }
  120646. declare module BABYLON {
  120647. /**
  120648. * Contains position and normal vectors for a vertex
  120649. */
  120650. export class PositionNormalVertex {
  120651. /** the position of the vertex (defaut: 0,0,0) */
  120652. position: Vector3;
  120653. /** the normal of the vertex (defaut: 0,1,0) */
  120654. normal: Vector3;
  120655. /**
  120656. * Creates a PositionNormalVertex
  120657. * @param position the position of the vertex (defaut: 0,0,0)
  120658. * @param normal the normal of the vertex (defaut: 0,1,0)
  120659. */
  120660. constructor(
  120661. /** the position of the vertex (defaut: 0,0,0) */
  120662. position?: Vector3,
  120663. /** the normal of the vertex (defaut: 0,1,0) */
  120664. normal?: Vector3);
  120665. /**
  120666. * Clones the PositionNormalVertex
  120667. * @returns the cloned PositionNormalVertex
  120668. */
  120669. clone(): PositionNormalVertex;
  120670. }
  120671. /**
  120672. * Contains position, normal and uv vectors for a vertex
  120673. */
  120674. export class PositionNormalTextureVertex {
  120675. /** the position of the vertex (defaut: 0,0,0) */
  120676. position: Vector3;
  120677. /** the normal of the vertex (defaut: 0,1,0) */
  120678. normal: Vector3;
  120679. /** the uv of the vertex (default: 0,0) */
  120680. uv: Vector2;
  120681. /**
  120682. * Creates a PositionNormalTextureVertex
  120683. * @param position the position of the vertex (defaut: 0,0,0)
  120684. * @param normal the normal of the vertex (defaut: 0,1,0)
  120685. * @param uv the uv of the vertex (default: 0,0)
  120686. */
  120687. constructor(
  120688. /** the position of the vertex (defaut: 0,0,0) */
  120689. position?: Vector3,
  120690. /** the normal of the vertex (defaut: 0,1,0) */
  120691. normal?: Vector3,
  120692. /** the uv of the vertex (default: 0,0) */
  120693. uv?: Vector2);
  120694. /**
  120695. * Clones the PositionNormalTextureVertex
  120696. * @returns the cloned PositionNormalTextureVertex
  120697. */
  120698. clone(): PositionNormalTextureVertex;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /** @hidden */
  120703. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120704. private _genericAttributeLocation;
  120705. private _varyingLocationCount;
  120706. private _varyingLocationMap;
  120707. private _replacements;
  120708. private _textureCount;
  120709. private _uniforms;
  120710. lineProcessor(line: string): string;
  120711. attributeProcessor(attribute: string): string;
  120712. varyingProcessor(varying: string, isFragment: boolean): string;
  120713. uniformProcessor(uniform: string): string;
  120714. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120715. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120716. }
  120717. }
  120718. declare module BABYLON {
  120719. /**
  120720. * Container for accessors for natively-stored mesh data buffers.
  120721. */
  120722. class NativeDataBuffer extends DataBuffer {
  120723. /**
  120724. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120725. */
  120726. nativeIndexBuffer?: any;
  120727. /**
  120728. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120729. */
  120730. nativeVertexBuffer?: any;
  120731. }
  120732. /** @hidden */
  120733. class NativeTexture extends InternalTexture {
  120734. getInternalTexture(): InternalTexture;
  120735. getViewCount(): number;
  120736. }
  120737. /** @hidden */
  120738. export class NativeEngine extends Engine {
  120739. private readonly _native;
  120740. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120741. private readonly INVALID_HANDLE;
  120742. getHardwareScalingLevel(): number;
  120743. constructor();
  120744. /**
  120745. * Can be used to override the current requestAnimationFrame requester.
  120746. * @hidden
  120747. */
  120748. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120749. /**
  120750. * Override default engine behavior.
  120751. * @param color
  120752. * @param backBuffer
  120753. * @param depth
  120754. * @param stencil
  120755. */
  120756. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120757. /**
  120758. * Gets host document
  120759. * @returns the host document object
  120760. */
  120761. getHostDocument(): Nullable<Document>;
  120762. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120763. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120764. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120765. recordVertexArrayObject(vertexBuffers: {
  120766. [key: string]: VertexBuffer;
  120767. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120768. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120769. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120770. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120771. /**
  120772. * Draw a list of indexed primitives
  120773. * @param fillMode defines the primitive to use
  120774. * @param indexStart defines the starting index
  120775. * @param indexCount defines the number of index to draw
  120776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120777. */
  120778. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120779. /**
  120780. * Draw a list of unindexed primitives
  120781. * @param fillMode defines the primitive to use
  120782. * @param verticesStart defines the index of first vertex to draw
  120783. * @param verticesCount defines the count of vertices to draw
  120784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120785. */
  120786. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120787. createPipelineContext(): IPipelineContext;
  120788. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120789. /** @hidden */
  120790. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120791. /** @hidden */
  120792. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120793. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120794. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120795. protected _setProgram(program: WebGLProgram): void;
  120796. _releaseEffect(effect: Effect): void;
  120797. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120798. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120799. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120800. bindSamplers(effect: Effect): void;
  120801. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120802. getRenderWidth(useScreen?: boolean): number;
  120803. getRenderHeight(useScreen?: boolean): number;
  120804. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120805. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120806. /**
  120807. * Set the z offset to apply to current rendering
  120808. * @param value defines the offset to apply
  120809. */
  120810. setZOffset(value: number): void;
  120811. /**
  120812. * Gets the current value of the zOffset
  120813. * @returns the current zOffset state
  120814. */
  120815. getZOffset(): number;
  120816. /**
  120817. * Enable or disable depth buffering
  120818. * @param enable defines the state to set
  120819. */
  120820. setDepthBuffer(enable: boolean): void;
  120821. /**
  120822. * Gets a boolean indicating if depth writing is enabled
  120823. * @returns the current depth writing state
  120824. */
  120825. getDepthWrite(): boolean;
  120826. /**
  120827. * Enable or disable depth writing
  120828. * @param enable defines the state to set
  120829. */
  120830. setDepthWrite(enable: boolean): void;
  120831. /**
  120832. * Enable or disable color writing
  120833. * @param enable defines the state to set
  120834. */
  120835. setColorWrite(enable: boolean): void;
  120836. /**
  120837. * Gets a boolean indicating if color writing is enabled
  120838. * @returns the current color writing state
  120839. */
  120840. getColorWrite(): boolean;
  120841. /**
  120842. * Sets alpha constants used by some alpha blending modes
  120843. * @param r defines the red component
  120844. * @param g defines the green component
  120845. * @param b defines the blue component
  120846. * @param a defines the alpha component
  120847. */
  120848. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120849. /**
  120850. * Sets the current alpha mode
  120851. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120852. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120853. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120854. */
  120855. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120856. /**
  120857. * Gets the current alpha mode
  120858. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120859. * @returns the current alpha mode
  120860. */
  120861. getAlphaMode(): number;
  120862. setInt(uniform: WebGLUniformLocation, int: number): void;
  120863. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120864. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120865. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120866. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120867. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120868. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120869. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120870. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120871. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120872. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120873. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120874. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120875. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120876. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120877. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120878. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120879. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120880. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120881. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120882. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120883. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120884. wipeCaches(bruteForce?: boolean): void;
  120885. _createTexture(): WebGLTexture;
  120886. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120887. /**
  120888. * Usually called from BABYLON.Texture.ts.
  120889. * Passed information to create a WebGLTexture
  120890. * @param urlArg defines a value which contains one of the following:
  120891. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120892. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120893. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120894. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120895. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120896. * @param scene needed for loading to the correct scene
  120897. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120898. * @param onLoad optional callback to be called upon successful completion
  120899. * @param onError optional callback to be called upon failure
  120900. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120901. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120902. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120903. * @param forcedExtension defines the extension to use to pick the right loader
  120904. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120905. */
  120906. 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;
  120907. /**
  120908. * Creates a cube texture
  120909. * @param rootUrl defines the url where the files to load is located
  120910. * @param scene defines the current scene
  120911. * @param files defines the list of files to load (1 per face)
  120912. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120913. * @param onLoad defines an optional callback raised when the texture is loaded
  120914. * @param onError defines an optional callback raised if there is an issue to load the texture
  120915. * @param format defines the format of the data
  120916. * @param forcedExtension defines the extension to use to pick the right loader
  120917. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120918. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120919. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120920. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120921. * @returns the cube texture as an InternalTexture
  120922. */
  120923. 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;
  120924. private _getSamplingFilter;
  120925. private static _GetNativeTextureFormat;
  120926. createRenderTargetTexture(size: number | {
  120927. width: number;
  120928. height: number;
  120929. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120930. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120931. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120932. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120933. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120934. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120935. /**
  120936. * Updates a dynamic vertex buffer.
  120937. * @param vertexBuffer the vertex buffer to update
  120938. * @param data the data used to update the vertex buffer
  120939. * @param byteOffset the byte offset of the data (optional)
  120940. * @param byteLength the byte length of the data (optional)
  120941. */
  120942. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120943. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120944. private _updateAnisotropicLevel;
  120945. private _getAddressMode;
  120946. /** @hidden */
  120947. _bindTexture(channel: number, texture: InternalTexture): void;
  120948. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120949. releaseEffects(): void;
  120950. /** @hidden */
  120951. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120952. /** @hidden */
  120953. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120954. /** @hidden */
  120955. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120956. /** @hidden */
  120957. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120958. }
  120959. }
  120960. declare module BABYLON {
  120961. /**
  120962. * Gather the list of clipboard event types as constants.
  120963. */
  120964. export class ClipboardEventTypes {
  120965. /**
  120966. * The clipboard event is fired when a copy command is active (pressed).
  120967. */
  120968. static readonly COPY: number;
  120969. /**
  120970. * The clipboard event is fired when a cut command is active (pressed).
  120971. */
  120972. static readonly CUT: number;
  120973. /**
  120974. * The clipboard event is fired when a paste command is active (pressed).
  120975. */
  120976. static readonly PASTE: number;
  120977. }
  120978. /**
  120979. * This class is used to store clipboard related info for the onClipboardObservable event.
  120980. */
  120981. export class ClipboardInfo {
  120982. /**
  120983. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120984. */
  120985. type: number;
  120986. /**
  120987. * Defines the related dom event
  120988. */
  120989. event: ClipboardEvent;
  120990. /**
  120991. *Creates an instance of ClipboardInfo.
  120992. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120993. * @param event Defines the related dom event
  120994. */
  120995. constructor(
  120996. /**
  120997. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120998. */
  120999. type: number,
  121000. /**
  121001. * Defines the related dom event
  121002. */
  121003. event: ClipboardEvent);
  121004. /**
  121005. * Get the clipboard event's type from the keycode.
  121006. * @param keyCode Defines the keyCode for the current keyboard event.
  121007. * @return {number}
  121008. */
  121009. static GetTypeFromCharacter(keyCode: number): number;
  121010. }
  121011. }
  121012. declare module BABYLON {
  121013. /**
  121014. * Google Daydream controller
  121015. */
  121016. export class DaydreamController extends WebVRController {
  121017. /**
  121018. * Base Url for the controller model.
  121019. */
  121020. static MODEL_BASE_URL: string;
  121021. /**
  121022. * File name for the controller model.
  121023. */
  121024. static MODEL_FILENAME: string;
  121025. /**
  121026. * Gamepad Id prefix used to identify Daydream Controller.
  121027. */
  121028. static readonly GAMEPAD_ID_PREFIX: string;
  121029. /**
  121030. * Creates a new DaydreamController from a gamepad
  121031. * @param vrGamepad the gamepad that the controller should be created from
  121032. */
  121033. constructor(vrGamepad: any);
  121034. /**
  121035. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121036. * @param scene scene in which to add meshes
  121037. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121038. */
  121039. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121040. /**
  121041. * Called once for each button that changed state since the last frame
  121042. * @param buttonIdx Which button index changed
  121043. * @param state New state of the button
  121044. * @param changes Which properties on the state changed since last frame
  121045. */
  121046. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121047. }
  121048. }
  121049. declare module BABYLON {
  121050. /**
  121051. * Gear VR Controller
  121052. */
  121053. export class GearVRController extends WebVRController {
  121054. /**
  121055. * Base Url for the controller model.
  121056. */
  121057. static MODEL_BASE_URL: string;
  121058. /**
  121059. * File name for the controller model.
  121060. */
  121061. static MODEL_FILENAME: string;
  121062. /**
  121063. * Gamepad Id prefix used to identify this controller.
  121064. */
  121065. static readonly GAMEPAD_ID_PREFIX: string;
  121066. private readonly _buttonIndexToObservableNameMap;
  121067. /**
  121068. * Creates a new GearVRController from a gamepad
  121069. * @param vrGamepad the gamepad that the controller should be created from
  121070. */
  121071. constructor(vrGamepad: any);
  121072. /**
  121073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121074. * @param scene scene in which to add meshes
  121075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121076. */
  121077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121078. /**
  121079. * Called once for each button that changed state since the last frame
  121080. * @param buttonIdx Which button index changed
  121081. * @param state New state of the button
  121082. * @param changes Which properties on the state changed since last frame
  121083. */
  121084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121085. }
  121086. }
  121087. declare module BABYLON {
  121088. /**
  121089. * Generic Controller
  121090. */
  121091. export class GenericController extends WebVRController {
  121092. /**
  121093. * Base Url for the controller model.
  121094. */
  121095. static readonly MODEL_BASE_URL: string;
  121096. /**
  121097. * File name for the controller model.
  121098. */
  121099. static readonly MODEL_FILENAME: string;
  121100. /**
  121101. * Creates a new GenericController from a gamepad
  121102. * @param vrGamepad the gamepad that the controller should be created from
  121103. */
  121104. constructor(vrGamepad: any);
  121105. /**
  121106. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121107. * @param scene scene in which to add meshes
  121108. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121109. */
  121110. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121111. /**
  121112. * Called once for each button that changed state since the last frame
  121113. * @param buttonIdx Which button index changed
  121114. * @param state New state of the button
  121115. * @param changes Which properties on the state changed since last frame
  121116. */
  121117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121118. }
  121119. }
  121120. declare module BABYLON {
  121121. /**
  121122. * Oculus Touch Controller
  121123. */
  121124. export class OculusTouchController extends WebVRController {
  121125. /**
  121126. * Base Url for the controller model.
  121127. */
  121128. static MODEL_BASE_URL: string;
  121129. /**
  121130. * File name for the left controller model.
  121131. */
  121132. static MODEL_LEFT_FILENAME: string;
  121133. /**
  121134. * File name for the right controller model.
  121135. */
  121136. static MODEL_RIGHT_FILENAME: string;
  121137. /**
  121138. * Base Url for the Quest controller model.
  121139. */
  121140. static QUEST_MODEL_BASE_URL: string;
  121141. /**
  121142. * @hidden
  121143. * If the controllers are running on a device that needs the updated Quest controller models
  121144. */
  121145. static _IsQuest: boolean;
  121146. /**
  121147. * Fired when the secondary trigger on this controller is modified
  121148. */
  121149. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121150. /**
  121151. * Fired when the thumb rest on this controller is modified
  121152. */
  121153. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121154. /**
  121155. * Creates a new OculusTouchController from a gamepad
  121156. * @param vrGamepad the gamepad that the controller should be created from
  121157. */
  121158. constructor(vrGamepad: any);
  121159. /**
  121160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121161. * @param scene scene in which to add meshes
  121162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121163. */
  121164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121165. /**
  121166. * Fired when the A button on this controller is modified
  121167. */
  121168. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121169. /**
  121170. * Fired when the B button on this controller is modified
  121171. */
  121172. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121173. /**
  121174. * Fired when the X button on this controller is modified
  121175. */
  121176. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121177. /**
  121178. * Fired when the Y button on this controller is modified
  121179. */
  121180. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121181. /**
  121182. * Called once for each button that changed state since the last frame
  121183. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121184. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121185. * 2) secondary trigger (same)
  121186. * 3) A (right) X (left), touch, pressed = value
  121187. * 4) B / Y
  121188. * 5) thumb rest
  121189. * @param buttonIdx Which button index changed
  121190. * @param state New state of the button
  121191. * @param changes Which properties on the state changed since last frame
  121192. */
  121193. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121194. }
  121195. }
  121196. declare module BABYLON {
  121197. /**
  121198. * Vive Controller
  121199. */
  121200. export class ViveController extends WebVRController {
  121201. /**
  121202. * Base Url for the controller model.
  121203. */
  121204. static MODEL_BASE_URL: string;
  121205. /**
  121206. * File name for the controller model.
  121207. */
  121208. static MODEL_FILENAME: string;
  121209. /**
  121210. * Creates a new ViveController from a gamepad
  121211. * @param vrGamepad the gamepad that the controller should be created from
  121212. */
  121213. constructor(vrGamepad: any);
  121214. /**
  121215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121216. * @param scene scene in which to add meshes
  121217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121218. */
  121219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121220. /**
  121221. * Fired when the left button on this controller is modified
  121222. */
  121223. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121224. /**
  121225. * Fired when the right button on this controller is modified
  121226. */
  121227. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121228. /**
  121229. * Fired when the menu button on this controller is modified
  121230. */
  121231. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121232. /**
  121233. * Called once for each button that changed state since the last frame
  121234. * Vive mapping:
  121235. * 0: touchpad
  121236. * 1: trigger
  121237. * 2: left AND right buttons
  121238. * 3: menu button
  121239. * @param buttonIdx Which button index changed
  121240. * @param state New state of the button
  121241. * @param changes Which properties on the state changed since last frame
  121242. */
  121243. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121244. }
  121245. }
  121246. declare module BABYLON {
  121247. /**
  121248. * Defines the WindowsMotionController object that the state of the windows motion controller
  121249. */
  121250. export class WindowsMotionController extends WebVRController {
  121251. /**
  121252. * The base url used to load the left and right controller models
  121253. */
  121254. static MODEL_BASE_URL: string;
  121255. /**
  121256. * The name of the left controller model file
  121257. */
  121258. static MODEL_LEFT_FILENAME: string;
  121259. /**
  121260. * The name of the right controller model file
  121261. */
  121262. static MODEL_RIGHT_FILENAME: string;
  121263. /**
  121264. * The controller name prefix for this controller type
  121265. */
  121266. static readonly GAMEPAD_ID_PREFIX: string;
  121267. /**
  121268. * The controller id pattern for this controller type
  121269. */
  121270. private static readonly GAMEPAD_ID_PATTERN;
  121271. private _loadedMeshInfo;
  121272. protected readonly _mapping: {
  121273. buttons: string[];
  121274. buttonMeshNames: {
  121275. 'trigger': string;
  121276. 'menu': string;
  121277. 'grip': string;
  121278. 'thumbstick': string;
  121279. 'trackpad': string;
  121280. };
  121281. buttonObservableNames: {
  121282. 'trigger': string;
  121283. 'menu': string;
  121284. 'grip': string;
  121285. 'thumbstick': string;
  121286. 'trackpad': string;
  121287. };
  121288. axisMeshNames: string[];
  121289. pointingPoseMeshName: string;
  121290. };
  121291. /**
  121292. * Fired when the trackpad on this controller is clicked
  121293. */
  121294. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121295. /**
  121296. * Fired when the trackpad on this controller is modified
  121297. */
  121298. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121299. /**
  121300. * The current x and y values of this controller's trackpad
  121301. */
  121302. trackpad: StickValues;
  121303. /**
  121304. * Creates a new WindowsMotionController from a gamepad
  121305. * @param vrGamepad the gamepad that the controller should be created from
  121306. */
  121307. constructor(vrGamepad: any);
  121308. /**
  121309. * Fired when the trigger on this controller is modified
  121310. */
  121311. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121312. /**
  121313. * Fired when the menu button on this controller is modified
  121314. */
  121315. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121316. /**
  121317. * Fired when the grip button on this controller is modified
  121318. */
  121319. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121320. /**
  121321. * Fired when the thumbstick button on this controller is modified
  121322. */
  121323. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121324. /**
  121325. * Fired when the touchpad button on this controller is modified
  121326. */
  121327. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121328. /**
  121329. * Fired when the touchpad values on this controller are modified
  121330. */
  121331. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121332. protected _updateTrackpad(): void;
  121333. /**
  121334. * Called once per frame by the engine.
  121335. */
  121336. update(): void;
  121337. /**
  121338. * Called once for each button that changed state since the last frame
  121339. * @param buttonIdx Which button index changed
  121340. * @param state New state of the button
  121341. * @param changes Which properties on the state changed since last frame
  121342. */
  121343. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121344. /**
  121345. * Moves the buttons on the controller mesh based on their current state
  121346. * @param buttonName the name of the button to move
  121347. * @param buttonValue the value of the button which determines the buttons new position
  121348. */
  121349. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121350. /**
  121351. * Moves the axis on the controller mesh based on its current state
  121352. * @param axis the index of the axis
  121353. * @param axisValue the value of the axis which determines the meshes new position
  121354. * @hidden
  121355. */
  121356. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121357. /**
  121358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121359. * @param scene scene in which to add meshes
  121360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121361. */
  121362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121363. /**
  121364. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121365. * can be transformed by button presses and axes values, based on this._mapping.
  121366. *
  121367. * @param scene scene in which the meshes exist
  121368. * @param meshes list of meshes that make up the controller model to process
  121369. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121370. */
  121371. private processModel;
  121372. private createMeshInfo;
  121373. /**
  121374. * Gets the ray of the controller in the direction the controller is pointing
  121375. * @param length the length the resulting ray should be
  121376. * @returns a ray in the direction the controller is pointing
  121377. */
  121378. getForwardRay(length?: number): Ray;
  121379. /**
  121380. * Disposes of the controller
  121381. */
  121382. dispose(): void;
  121383. }
  121384. /**
  121385. * This class represents a new windows motion controller in XR.
  121386. */
  121387. export class XRWindowsMotionController extends WindowsMotionController {
  121388. /**
  121389. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121390. */
  121391. protected readonly _mapping: {
  121392. buttons: string[];
  121393. buttonMeshNames: {
  121394. 'trigger': string;
  121395. 'menu': string;
  121396. 'grip': string;
  121397. 'thumbstick': string;
  121398. 'trackpad': string;
  121399. };
  121400. buttonObservableNames: {
  121401. 'trigger': string;
  121402. 'menu': string;
  121403. 'grip': string;
  121404. 'thumbstick': string;
  121405. 'trackpad': string;
  121406. };
  121407. axisMeshNames: string[];
  121408. pointingPoseMeshName: string;
  121409. };
  121410. /**
  121411. * Construct a new XR-Based windows motion controller
  121412. *
  121413. * @param gamepadInfo the gamepad object from the browser
  121414. */
  121415. constructor(gamepadInfo: any);
  121416. /**
  121417. * holds the thumbstick values (X,Y)
  121418. */
  121419. thumbstickValues: StickValues;
  121420. /**
  121421. * Fired when the thumbstick on this controller is clicked
  121422. */
  121423. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121424. /**
  121425. * Fired when the thumbstick on this controller is modified
  121426. */
  121427. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121428. /**
  121429. * Fired when the touchpad button on this controller is modified
  121430. */
  121431. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121432. /**
  121433. * Fired when the touchpad values on this controller are modified
  121434. */
  121435. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121436. /**
  121437. * Fired when the thumbstick button on this controller is modified
  121438. * here to prevent breaking changes
  121439. */
  121440. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121441. /**
  121442. * updating the thumbstick(!) and not the trackpad.
  121443. * This is named this way due to the difference between WebVR and XR and to avoid
  121444. * changing the parent class.
  121445. */
  121446. protected _updateTrackpad(): void;
  121447. /**
  121448. * Disposes the class with joy
  121449. */
  121450. dispose(): void;
  121451. }
  121452. }
  121453. declare module BABYLON {
  121454. /**
  121455. * Class containing static functions to help procedurally build meshes
  121456. */
  121457. export class PolyhedronBuilder {
  121458. /**
  121459. * Creates a polyhedron mesh
  121460. * * 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
  121461. * * The parameter `size` (positive float, default 1) sets the polygon size
  121462. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121463. * * 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`
  121464. * * 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
  121465. * * 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)`)
  121466. * * 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
  121467. * * 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
  121468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121471. * @param name defines the name of the mesh
  121472. * @param options defines the options used to create the mesh
  121473. * @param scene defines the hosting scene
  121474. * @returns the polyhedron mesh
  121475. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121476. */
  121477. static CreatePolyhedron(name: string, options: {
  121478. type?: number;
  121479. size?: number;
  121480. sizeX?: number;
  121481. sizeY?: number;
  121482. sizeZ?: number;
  121483. custom?: any;
  121484. faceUV?: Vector4[];
  121485. faceColors?: Color4[];
  121486. flat?: boolean;
  121487. updatable?: boolean;
  121488. sideOrientation?: number;
  121489. frontUVs?: Vector4;
  121490. backUVs?: Vector4;
  121491. }, scene?: Nullable<Scene>): Mesh;
  121492. }
  121493. }
  121494. declare module BABYLON {
  121495. /**
  121496. * Gizmo that enables scaling a mesh along 3 axis
  121497. */
  121498. export class ScaleGizmo extends Gizmo {
  121499. /**
  121500. * Internal gizmo used for interactions on the x axis
  121501. */
  121502. xGizmo: AxisScaleGizmo;
  121503. /**
  121504. * Internal gizmo used for interactions on the y axis
  121505. */
  121506. yGizmo: AxisScaleGizmo;
  121507. /**
  121508. * Internal gizmo used for interactions on the z axis
  121509. */
  121510. zGizmo: AxisScaleGizmo;
  121511. /**
  121512. * Internal gizmo used to scale all axis equally
  121513. */
  121514. uniformScaleGizmo: AxisScaleGizmo;
  121515. private _meshAttached;
  121516. private _updateGizmoRotationToMatchAttachedMesh;
  121517. private _snapDistance;
  121518. private _scaleRatio;
  121519. private _uniformScalingMesh;
  121520. private _octahedron;
  121521. private _sensitivity;
  121522. /** Fires an event when any of it's sub gizmos are dragged */
  121523. onDragStartObservable: Observable<unknown>;
  121524. /** Fires an event when any of it's sub gizmos are released from dragging */
  121525. onDragEndObservable: Observable<unknown>;
  121526. get attachedMesh(): Nullable<AbstractMesh>;
  121527. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121528. /**
  121529. * Creates a ScaleGizmo
  121530. * @param gizmoLayer The utility layer the gizmo will be added to
  121531. */
  121532. constructor(gizmoLayer?: UtilityLayerRenderer);
  121533. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121534. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121535. /**
  121536. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121537. */
  121538. set snapDistance(value: number);
  121539. get snapDistance(): number;
  121540. /**
  121541. * Ratio for the scale of the gizmo (Default: 1)
  121542. */
  121543. set scaleRatio(value: number);
  121544. get scaleRatio(): number;
  121545. /**
  121546. * Sensitivity factor for dragging (Default: 1)
  121547. */
  121548. set sensitivity(value: number);
  121549. get sensitivity(): number;
  121550. /**
  121551. * Disposes of the gizmo
  121552. */
  121553. dispose(): void;
  121554. }
  121555. }
  121556. declare module BABYLON {
  121557. /**
  121558. * Single axis scale gizmo
  121559. */
  121560. export class AxisScaleGizmo extends Gizmo {
  121561. /**
  121562. * Drag behavior responsible for the gizmos dragging interactions
  121563. */
  121564. dragBehavior: PointerDragBehavior;
  121565. private _pointerObserver;
  121566. /**
  121567. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121568. */
  121569. snapDistance: number;
  121570. /**
  121571. * Event that fires each time the gizmo snaps to a new location.
  121572. * * snapDistance is the the change in distance
  121573. */
  121574. onSnapObservable: Observable<{
  121575. snapDistance: number;
  121576. }>;
  121577. /**
  121578. * If the scaling operation should be done on all axis (default: false)
  121579. */
  121580. uniformScaling: boolean;
  121581. /**
  121582. * Custom sensitivity value for the drag strength
  121583. */
  121584. sensitivity: number;
  121585. private _isEnabled;
  121586. private _parent;
  121587. private _arrow;
  121588. private _coloredMaterial;
  121589. private _hoverMaterial;
  121590. /**
  121591. * Creates an AxisScaleGizmo
  121592. * @param gizmoLayer The utility layer the gizmo will be added to
  121593. * @param dragAxis The axis which the gizmo will be able to scale on
  121594. * @param color The color of the gizmo
  121595. */
  121596. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121597. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121598. /**
  121599. * If the gizmo is enabled
  121600. */
  121601. set isEnabled(value: boolean);
  121602. get isEnabled(): boolean;
  121603. /**
  121604. * Disposes of the gizmo
  121605. */
  121606. dispose(): void;
  121607. /**
  121608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121609. * @param mesh The mesh to replace the default mesh of the gizmo
  121610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121611. */
  121612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121613. }
  121614. }
  121615. declare module BABYLON {
  121616. /**
  121617. * Bounding box gizmo
  121618. */
  121619. export class BoundingBoxGizmo extends Gizmo {
  121620. private _lineBoundingBox;
  121621. private _rotateSpheresParent;
  121622. private _scaleBoxesParent;
  121623. private _boundingDimensions;
  121624. private _renderObserver;
  121625. private _pointerObserver;
  121626. private _scaleDragSpeed;
  121627. private _tmpQuaternion;
  121628. private _tmpVector;
  121629. private _tmpRotationMatrix;
  121630. /**
  121631. * 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)
  121632. */
  121633. ignoreChildren: boolean;
  121634. /**
  121635. * 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)
  121636. */
  121637. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121638. /**
  121639. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121640. */
  121641. rotationSphereSize: number;
  121642. /**
  121643. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121644. */
  121645. scaleBoxSize: number;
  121646. /**
  121647. * 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)
  121648. */
  121649. fixedDragMeshScreenSize: boolean;
  121650. /**
  121651. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121652. */
  121653. fixedDragMeshScreenSizeDistanceFactor: number;
  121654. /**
  121655. * Fired when a rotation sphere or scale box is dragged
  121656. */
  121657. onDragStartObservable: Observable<{}>;
  121658. /**
  121659. * Fired when a scale box is dragged
  121660. */
  121661. onScaleBoxDragObservable: Observable<{}>;
  121662. /**
  121663. * Fired when a scale box drag is ended
  121664. */
  121665. onScaleBoxDragEndObservable: Observable<{}>;
  121666. /**
  121667. * Fired when a rotation sphere is dragged
  121668. */
  121669. onRotationSphereDragObservable: Observable<{}>;
  121670. /**
  121671. * Fired when a rotation sphere drag is ended
  121672. */
  121673. onRotationSphereDragEndObservable: Observable<{}>;
  121674. /**
  121675. * 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)
  121676. */
  121677. scalePivot: Nullable<Vector3>;
  121678. /**
  121679. * Mesh used as a pivot to rotate the attached mesh
  121680. */
  121681. private _anchorMesh;
  121682. private _existingMeshScale;
  121683. private _dragMesh;
  121684. private pointerDragBehavior;
  121685. private coloredMaterial;
  121686. private hoverColoredMaterial;
  121687. /**
  121688. * Sets the color of the bounding box gizmo
  121689. * @param color the color to set
  121690. */
  121691. setColor(color: Color3): void;
  121692. /**
  121693. * Creates an BoundingBoxGizmo
  121694. * @param gizmoLayer The utility layer the gizmo will be added to
  121695. * @param color The color of the gizmo
  121696. */
  121697. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121699. private _selectNode;
  121700. /**
  121701. * Updates the bounding box information for the Gizmo
  121702. */
  121703. updateBoundingBox(): void;
  121704. private _updateRotationSpheres;
  121705. private _updateScaleBoxes;
  121706. /**
  121707. * Enables rotation on the specified axis and disables rotation on the others
  121708. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121709. */
  121710. setEnabledRotationAxis(axis: string): void;
  121711. /**
  121712. * Enables/disables scaling
  121713. * @param enable if scaling should be enabled
  121714. */
  121715. setEnabledScaling(enable: boolean): void;
  121716. private _updateDummy;
  121717. /**
  121718. * Enables a pointer drag behavior on the bounding box of the gizmo
  121719. */
  121720. enableDragBehavior(): void;
  121721. /**
  121722. * Disposes of the gizmo
  121723. */
  121724. dispose(): void;
  121725. /**
  121726. * 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)
  121727. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121728. * @returns the bounding box mesh with the passed in mesh as a child
  121729. */
  121730. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121731. /**
  121732. * CustomMeshes are not supported by this gizmo
  121733. * @param mesh The mesh to replace the default mesh of the gizmo
  121734. */
  121735. setCustomMesh(mesh: Mesh): void;
  121736. }
  121737. }
  121738. declare module BABYLON {
  121739. /**
  121740. * Single plane rotation gizmo
  121741. */
  121742. export class PlaneRotationGizmo extends Gizmo {
  121743. /**
  121744. * Drag behavior responsible for the gizmos dragging interactions
  121745. */
  121746. dragBehavior: PointerDragBehavior;
  121747. private _pointerObserver;
  121748. /**
  121749. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121750. */
  121751. snapDistance: number;
  121752. /**
  121753. * Event that fires each time the gizmo snaps to a new location.
  121754. * * snapDistance is the the change in distance
  121755. */
  121756. onSnapObservable: Observable<{
  121757. snapDistance: number;
  121758. }>;
  121759. private _isEnabled;
  121760. private _parent;
  121761. /**
  121762. * Creates a PlaneRotationGizmo
  121763. * @param gizmoLayer The utility layer the gizmo will be added to
  121764. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121765. * @param color The color of the gizmo
  121766. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121767. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121768. */
  121769. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121770. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121771. /**
  121772. * If the gizmo is enabled
  121773. */
  121774. set isEnabled(value: boolean);
  121775. get isEnabled(): boolean;
  121776. /**
  121777. * Disposes of the gizmo
  121778. */
  121779. dispose(): void;
  121780. }
  121781. }
  121782. declare module BABYLON {
  121783. /**
  121784. * Gizmo that enables rotating a mesh along 3 axis
  121785. */
  121786. export class RotationGizmo extends Gizmo {
  121787. /**
  121788. * Internal gizmo used for interactions on the x axis
  121789. */
  121790. xGizmo: PlaneRotationGizmo;
  121791. /**
  121792. * Internal gizmo used for interactions on the y axis
  121793. */
  121794. yGizmo: PlaneRotationGizmo;
  121795. /**
  121796. * Internal gizmo used for interactions on the z axis
  121797. */
  121798. zGizmo: PlaneRotationGizmo;
  121799. /** Fires an event when any of it's sub gizmos are dragged */
  121800. onDragStartObservable: Observable<unknown>;
  121801. /** Fires an event when any of it's sub gizmos are released from dragging */
  121802. onDragEndObservable: Observable<unknown>;
  121803. private _meshAttached;
  121804. get attachedMesh(): Nullable<AbstractMesh>;
  121805. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121806. /**
  121807. * Creates a RotationGizmo
  121808. * @param gizmoLayer The utility layer the gizmo will be added to
  121809. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121810. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121811. */
  121812. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121813. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121814. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121815. /**
  121816. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121817. */
  121818. set snapDistance(value: number);
  121819. get snapDistance(): number;
  121820. /**
  121821. * Ratio for the scale of the gizmo (Default: 1)
  121822. */
  121823. set scaleRatio(value: number);
  121824. get scaleRatio(): number;
  121825. /**
  121826. * Disposes of the gizmo
  121827. */
  121828. dispose(): void;
  121829. /**
  121830. * CustomMeshes are not supported by this gizmo
  121831. * @param mesh The mesh to replace the default mesh of the gizmo
  121832. */
  121833. setCustomMesh(mesh: Mesh): void;
  121834. }
  121835. }
  121836. declare module BABYLON {
  121837. /**
  121838. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121839. */
  121840. export class GizmoManager implements IDisposable {
  121841. private scene;
  121842. /**
  121843. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121844. */
  121845. gizmos: {
  121846. positionGizmo: Nullable<PositionGizmo>;
  121847. rotationGizmo: Nullable<RotationGizmo>;
  121848. scaleGizmo: Nullable<ScaleGizmo>;
  121849. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121850. };
  121851. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121852. clearGizmoOnEmptyPointerEvent: boolean;
  121853. /** Fires an event when the manager is attached to a mesh */
  121854. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121855. private _gizmosEnabled;
  121856. private _pointerObserver;
  121857. private _attachedMesh;
  121858. private _boundingBoxColor;
  121859. private _defaultUtilityLayer;
  121860. private _defaultKeepDepthUtilityLayer;
  121861. /**
  121862. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121863. */
  121864. boundingBoxDragBehavior: SixDofDragBehavior;
  121865. /**
  121866. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121867. */
  121868. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121869. /**
  121870. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121871. */
  121872. usePointerToAttachGizmos: boolean;
  121873. /**
  121874. * Utility layer that the bounding box gizmo belongs to
  121875. */
  121876. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121877. /**
  121878. * Utility layer that all gizmos besides bounding box belong to
  121879. */
  121880. get utilityLayer(): UtilityLayerRenderer;
  121881. /**
  121882. * Instatiates a gizmo manager
  121883. * @param scene the scene to overlay the gizmos on top of
  121884. */
  121885. constructor(scene: Scene);
  121886. /**
  121887. * Attaches a set of gizmos to the specified mesh
  121888. * @param mesh The mesh the gizmo's should be attached to
  121889. */
  121890. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121891. /**
  121892. * If the position gizmo is enabled
  121893. */
  121894. set positionGizmoEnabled(value: boolean);
  121895. get positionGizmoEnabled(): boolean;
  121896. /**
  121897. * If the rotation gizmo is enabled
  121898. */
  121899. set rotationGizmoEnabled(value: boolean);
  121900. get rotationGizmoEnabled(): boolean;
  121901. /**
  121902. * If the scale gizmo is enabled
  121903. */
  121904. set scaleGizmoEnabled(value: boolean);
  121905. get scaleGizmoEnabled(): boolean;
  121906. /**
  121907. * If the boundingBox gizmo is enabled
  121908. */
  121909. set boundingBoxGizmoEnabled(value: boolean);
  121910. get boundingBoxGizmoEnabled(): boolean;
  121911. /**
  121912. * Disposes of the gizmo manager
  121913. */
  121914. dispose(): void;
  121915. }
  121916. }
  121917. declare module BABYLON {
  121918. /**
  121919. * A directional light is defined by a direction (what a surprise!).
  121920. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121921. * 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.
  121922. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121923. */
  121924. export class DirectionalLight extends ShadowLight {
  121925. private _shadowFrustumSize;
  121926. /**
  121927. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121928. */
  121929. get shadowFrustumSize(): number;
  121930. /**
  121931. * Specifies a fix frustum size for the shadow generation.
  121932. */
  121933. set shadowFrustumSize(value: number);
  121934. private _shadowOrthoScale;
  121935. /**
  121936. * Gets the shadow projection scale against the optimal computed one.
  121937. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121938. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121939. */
  121940. get shadowOrthoScale(): number;
  121941. /**
  121942. * Sets the shadow projection scale against the optimal computed one.
  121943. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121944. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121945. */
  121946. set shadowOrthoScale(value: number);
  121947. /**
  121948. * Automatically compute the projection matrix to best fit (including all the casters)
  121949. * on each frame.
  121950. */
  121951. autoUpdateExtends: boolean;
  121952. /**
  121953. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121954. * on each frame. autoUpdateExtends must be set to true for this to work
  121955. */
  121956. autoCalcShadowZBounds: boolean;
  121957. private _orthoLeft;
  121958. private _orthoRight;
  121959. private _orthoTop;
  121960. private _orthoBottom;
  121961. /**
  121962. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121963. * The directional light is emitted from everywhere in the given direction.
  121964. * It can cast shadows.
  121965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121966. * @param name The friendly name of the light
  121967. * @param direction The direction of the light
  121968. * @param scene The scene the light belongs to
  121969. */
  121970. constructor(name: string, direction: Vector3, scene: Scene);
  121971. /**
  121972. * Returns the string "DirectionalLight".
  121973. * @return The class name
  121974. */
  121975. getClassName(): string;
  121976. /**
  121977. * Returns the integer 1.
  121978. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121979. */
  121980. getTypeID(): number;
  121981. /**
  121982. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121983. * Returns the DirectionalLight Shadow projection matrix.
  121984. */
  121985. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121986. /**
  121987. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121988. * Returns the DirectionalLight Shadow projection matrix.
  121989. */
  121990. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121991. /**
  121992. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121993. * Returns the DirectionalLight Shadow projection matrix.
  121994. */
  121995. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121996. protected _buildUniformLayout(): void;
  121997. /**
  121998. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121999. * @param effect The effect to update
  122000. * @param lightIndex The index of the light in the effect to update
  122001. * @returns The directional light
  122002. */
  122003. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122004. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122005. /**
  122006. * Gets the minZ 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 min for
  122011. * @returns the depth min z
  122012. */
  122013. getDepthMinZ(activeCamera: Camera): number;
  122014. /**
  122015. * Gets the maxZ used for shadow according to both the scene and the light.
  122016. *
  122017. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122018. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122019. * @param activeCamera The camera we are returning the max for
  122020. * @returns the depth max z
  122021. */
  122022. getDepthMaxZ(activeCamera: Camera): number;
  122023. /**
  122024. * Prepares the list of defines specific to the light type.
  122025. * @param defines the list of defines
  122026. * @param lightIndex defines the index of the light for the effect
  122027. */
  122028. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122029. }
  122030. }
  122031. declare module BABYLON {
  122032. /**
  122033. * Class containing static functions to help procedurally build meshes
  122034. */
  122035. export class HemisphereBuilder {
  122036. /**
  122037. * Creates a hemisphere mesh
  122038. * @param name defines the name of the mesh
  122039. * @param options defines the options used to create the mesh
  122040. * @param scene defines the hosting scene
  122041. * @returns the hemisphere mesh
  122042. */
  122043. static CreateHemisphere(name: string, options: {
  122044. segments?: number;
  122045. diameter?: number;
  122046. sideOrientation?: number;
  122047. }, scene: any): Mesh;
  122048. }
  122049. }
  122050. declare module BABYLON {
  122051. /**
  122052. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122053. * These values define a cone of light starting from the position, emitting toward the direction.
  122054. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122055. * and the exponent defines the speed of the decay of the light with distance (reach).
  122056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122057. */
  122058. export class SpotLight extends ShadowLight {
  122059. private _angle;
  122060. private _innerAngle;
  122061. private _cosHalfAngle;
  122062. private _lightAngleScale;
  122063. private _lightAngleOffset;
  122064. /**
  122065. * Gets the cone angle of the spot light in Radians.
  122066. */
  122067. get angle(): number;
  122068. /**
  122069. * Sets the cone angle of the spot light in Radians.
  122070. */
  122071. set angle(value: number);
  122072. /**
  122073. * Only used in gltf falloff mode, this defines the angle where
  122074. * the directional falloff will start before cutting at angle which could be seen
  122075. * as outer angle.
  122076. */
  122077. get innerAngle(): number;
  122078. /**
  122079. * Only used in gltf falloff mode, this defines the angle where
  122080. * the directional falloff will start before cutting at angle which could be seen
  122081. * as outer angle.
  122082. */
  122083. set innerAngle(value: number);
  122084. private _shadowAngleScale;
  122085. /**
  122086. * Allows scaling the angle of the light for shadow generation only.
  122087. */
  122088. get shadowAngleScale(): number;
  122089. /**
  122090. * Allows scaling the angle of the light for shadow generation only.
  122091. */
  122092. set shadowAngleScale(value: number);
  122093. /**
  122094. * The light decay speed with the distance from the emission spot.
  122095. */
  122096. exponent: number;
  122097. private _projectionTextureMatrix;
  122098. /**
  122099. * Allows reading the projecton texture
  122100. */
  122101. get projectionTextureMatrix(): Matrix;
  122102. protected _projectionTextureLightNear: number;
  122103. /**
  122104. * Gets the near clip of the Spotlight for texture projection.
  122105. */
  122106. get projectionTextureLightNear(): number;
  122107. /**
  122108. * Sets the near clip of the Spotlight for texture projection.
  122109. */
  122110. set projectionTextureLightNear(value: number);
  122111. protected _projectionTextureLightFar: number;
  122112. /**
  122113. * Gets the far clip of the Spotlight for texture projection.
  122114. */
  122115. get projectionTextureLightFar(): number;
  122116. /**
  122117. * Sets the far clip of the Spotlight for texture projection.
  122118. */
  122119. set projectionTextureLightFar(value: number);
  122120. protected _projectionTextureUpDirection: Vector3;
  122121. /**
  122122. * Gets the Up vector of the Spotlight for texture projection.
  122123. */
  122124. get projectionTextureUpDirection(): Vector3;
  122125. /**
  122126. * Sets the Up vector of the Spotlight for texture projection.
  122127. */
  122128. set projectionTextureUpDirection(value: Vector3);
  122129. private _projectionTexture;
  122130. /**
  122131. * Gets the projection texture of the light.
  122132. */
  122133. get projectionTexture(): Nullable<BaseTexture>;
  122134. /**
  122135. * Sets the projection texture of the light.
  122136. */
  122137. set projectionTexture(value: Nullable<BaseTexture>);
  122138. private _projectionTextureViewLightDirty;
  122139. private _projectionTextureProjectionLightDirty;
  122140. private _projectionTextureDirty;
  122141. private _projectionTextureViewTargetVector;
  122142. private _projectionTextureViewLightMatrix;
  122143. private _projectionTextureProjectionLightMatrix;
  122144. private _projectionTextureScalingMatrix;
  122145. /**
  122146. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122147. * It can cast shadows.
  122148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122149. * @param name The light friendly name
  122150. * @param position The position of the spot light in the scene
  122151. * @param direction The direction of the light in the scene
  122152. * @param angle The cone angle of the light in Radians
  122153. * @param exponent The light decay speed with the distance from the emission spot
  122154. * @param scene The scene the lights belongs to
  122155. */
  122156. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122157. /**
  122158. * Returns the string "SpotLight".
  122159. * @returns the class name
  122160. */
  122161. getClassName(): string;
  122162. /**
  122163. * Returns the integer 2.
  122164. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122165. */
  122166. getTypeID(): number;
  122167. /**
  122168. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122169. */
  122170. protected _setDirection(value: Vector3): void;
  122171. /**
  122172. * Overrides the position setter to recompute the projection texture view light Matrix.
  122173. */
  122174. protected _setPosition(value: Vector3): void;
  122175. /**
  122176. * 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.
  122177. * Returns the SpotLight.
  122178. */
  122179. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122180. protected _computeProjectionTextureViewLightMatrix(): void;
  122181. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122182. /**
  122183. * Main function for light texture projection matrix computing.
  122184. */
  122185. protected _computeProjectionTextureMatrix(): void;
  122186. protected _buildUniformLayout(): void;
  122187. private _computeAngleValues;
  122188. /**
  122189. * Sets the passed Effect "effect" with the Light textures.
  122190. * @param effect The effect to update
  122191. * @param lightIndex The index of the light in the effect to update
  122192. * @returns The light
  122193. */
  122194. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122195. /**
  122196. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122197. * @param effect The effect to update
  122198. * @param lightIndex The index of the light in the effect to update
  122199. * @returns The spot light
  122200. */
  122201. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122202. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122203. /**
  122204. * Disposes the light and the associated resources.
  122205. */
  122206. dispose(): void;
  122207. /**
  122208. * Prepares the list of defines specific to the light type.
  122209. * @param defines the list of defines
  122210. * @param lightIndex defines the index of the light for the effect
  122211. */
  122212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122213. }
  122214. }
  122215. declare module BABYLON {
  122216. /**
  122217. * Gizmo that enables viewing a light
  122218. */
  122219. export class LightGizmo extends Gizmo {
  122220. private _lightMesh;
  122221. private _material;
  122222. private _cachedPosition;
  122223. private _cachedForward;
  122224. private _attachedMeshParent;
  122225. /**
  122226. * Creates a LightGizmo
  122227. * @param gizmoLayer The utility layer the gizmo will be added to
  122228. */
  122229. constructor(gizmoLayer?: UtilityLayerRenderer);
  122230. private _light;
  122231. /**
  122232. * The light that the gizmo is attached to
  122233. */
  122234. set light(light: Nullable<Light>);
  122235. get light(): Nullable<Light>;
  122236. /**
  122237. * Gets the material used to render the light gizmo
  122238. */
  122239. get material(): StandardMaterial;
  122240. /**
  122241. * @hidden
  122242. * Updates the gizmo to match the attached mesh's position/rotation
  122243. */
  122244. protected _update(): void;
  122245. private static _Scale;
  122246. /**
  122247. * Creates the lines for a light mesh
  122248. */
  122249. private static _CreateLightLines;
  122250. /**
  122251. * Disposes of the light gizmo
  122252. */
  122253. dispose(): void;
  122254. private static _CreateHemisphericLightMesh;
  122255. private static _CreatePointLightMesh;
  122256. private static _CreateSpotLightMesh;
  122257. private static _CreateDirectionalLightMesh;
  122258. }
  122259. }
  122260. declare module BABYLON {
  122261. /** @hidden */
  122262. export var backgroundFragmentDeclaration: {
  122263. name: string;
  122264. shader: string;
  122265. };
  122266. }
  122267. declare module BABYLON {
  122268. /** @hidden */
  122269. export var backgroundUboDeclaration: {
  122270. name: string;
  122271. shader: string;
  122272. };
  122273. }
  122274. declare module BABYLON {
  122275. /** @hidden */
  122276. export var backgroundPixelShader: {
  122277. name: string;
  122278. shader: string;
  122279. };
  122280. }
  122281. declare module BABYLON {
  122282. /** @hidden */
  122283. export var backgroundVertexDeclaration: {
  122284. name: string;
  122285. shader: string;
  122286. };
  122287. }
  122288. declare module BABYLON {
  122289. /** @hidden */
  122290. export var backgroundVertexShader: {
  122291. name: string;
  122292. shader: string;
  122293. };
  122294. }
  122295. declare module BABYLON {
  122296. /**
  122297. * Background material used to create an efficient environement around your scene.
  122298. */
  122299. export class BackgroundMaterial extends PushMaterial {
  122300. /**
  122301. * Standard reflectance value at parallel view angle.
  122302. */
  122303. static StandardReflectance0: number;
  122304. /**
  122305. * Standard reflectance value at grazing angle.
  122306. */
  122307. static StandardReflectance90: number;
  122308. protected _primaryColor: Color3;
  122309. /**
  122310. * Key light Color (multiply against the environement texture)
  122311. */
  122312. primaryColor: Color3;
  122313. protected __perceptualColor: Nullable<Color3>;
  122314. /**
  122315. * Experimental Internal Use Only.
  122316. *
  122317. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122318. * This acts as a helper to set the primary color to a more "human friendly" value.
  122319. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122320. * output color as close as possible from the chosen value.
  122321. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122322. * part of lighting setup.)
  122323. */
  122324. get _perceptualColor(): Nullable<Color3>;
  122325. set _perceptualColor(value: Nullable<Color3>);
  122326. protected _primaryColorShadowLevel: float;
  122327. /**
  122328. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122329. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122330. */
  122331. get primaryColorShadowLevel(): float;
  122332. set primaryColorShadowLevel(value: float);
  122333. protected _primaryColorHighlightLevel: float;
  122334. /**
  122335. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122336. * The primary color is used at the level chosen to define what the white area would look.
  122337. */
  122338. get primaryColorHighlightLevel(): float;
  122339. set primaryColorHighlightLevel(value: float);
  122340. protected _reflectionTexture: Nullable<BaseTexture>;
  122341. /**
  122342. * Reflection Texture used in the material.
  122343. * Should be author in a specific way for the best result (refer to the documentation).
  122344. */
  122345. reflectionTexture: Nullable<BaseTexture>;
  122346. protected _reflectionBlur: float;
  122347. /**
  122348. * Reflection Texture level of blur.
  122349. *
  122350. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122351. * texture twice.
  122352. */
  122353. reflectionBlur: float;
  122354. protected _diffuseTexture: Nullable<BaseTexture>;
  122355. /**
  122356. * Diffuse Texture used in the material.
  122357. * Should be author in a specific way for the best result (refer to the documentation).
  122358. */
  122359. diffuseTexture: Nullable<BaseTexture>;
  122360. protected _shadowLights: Nullable<IShadowLight[]>;
  122361. /**
  122362. * Specify the list of lights casting shadow on the material.
  122363. * All scene shadow lights will be included if null.
  122364. */
  122365. shadowLights: Nullable<IShadowLight[]>;
  122366. protected _shadowLevel: float;
  122367. /**
  122368. * Helps adjusting the shadow to a softer level if required.
  122369. * 0 means black shadows and 1 means no shadows.
  122370. */
  122371. shadowLevel: float;
  122372. protected _sceneCenter: Vector3;
  122373. /**
  122374. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122375. * It is usually zero but might be interesting to modify according to your setup.
  122376. */
  122377. sceneCenter: Vector3;
  122378. protected _opacityFresnel: boolean;
  122379. /**
  122380. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122381. * This helps ensuring a nice transition when the camera goes under the ground.
  122382. */
  122383. opacityFresnel: boolean;
  122384. protected _reflectionFresnel: boolean;
  122385. /**
  122386. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122387. * This helps adding a mirror texture on the ground.
  122388. */
  122389. reflectionFresnel: boolean;
  122390. protected _reflectionFalloffDistance: number;
  122391. /**
  122392. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122393. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122394. */
  122395. reflectionFalloffDistance: number;
  122396. protected _reflectionAmount: number;
  122397. /**
  122398. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122399. */
  122400. reflectionAmount: number;
  122401. protected _reflectionReflectance0: number;
  122402. /**
  122403. * This specifies the weight of the reflection at grazing angle.
  122404. */
  122405. reflectionReflectance0: number;
  122406. protected _reflectionReflectance90: number;
  122407. /**
  122408. * This specifies the weight of the reflection at a perpendicular point of view.
  122409. */
  122410. reflectionReflectance90: number;
  122411. /**
  122412. * Sets the reflection reflectance fresnel values according to the default standard
  122413. * empirically know to work well :-)
  122414. */
  122415. set reflectionStandardFresnelWeight(value: number);
  122416. protected _useRGBColor: boolean;
  122417. /**
  122418. * Helps to directly use the maps channels instead of their level.
  122419. */
  122420. useRGBColor: boolean;
  122421. protected _enableNoise: boolean;
  122422. /**
  122423. * This helps reducing the banding effect that could occur on the background.
  122424. */
  122425. enableNoise: boolean;
  122426. /**
  122427. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122428. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122429. * Recommended to be keep at 1.0 except for special cases.
  122430. */
  122431. get fovMultiplier(): number;
  122432. set fovMultiplier(value: number);
  122433. private _fovMultiplier;
  122434. /**
  122435. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122436. */
  122437. useEquirectangularFOV: boolean;
  122438. private _maxSimultaneousLights;
  122439. /**
  122440. * Number of Simultaneous lights allowed on the material.
  122441. */
  122442. maxSimultaneousLights: int;
  122443. /**
  122444. * Default configuration related to image processing available in the Background Material.
  122445. */
  122446. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122447. /**
  122448. * Keep track of the image processing observer to allow dispose and replace.
  122449. */
  122450. private _imageProcessingObserver;
  122451. /**
  122452. * Attaches a new image processing configuration to the PBR Material.
  122453. * @param configuration (if null the scene configuration will be use)
  122454. */
  122455. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122456. /**
  122457. * Gets the image processing configuration used either in this material.
  122458. */
  122459. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122460. /**
  122461. * Sets the Default image processing configuration used either in the this material.
  122462. *
  122463. * If sets to null, the scene one is in use.
  122464. */
  122465. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122466. /**
  122467. * Gets wether the color curves effect is enabled.
  122468. */
  122469. get cameraColorCurvesEnabled(): boolean;
  122470. /**
  122471. * Sets wether the color curves effect is enabled.
  122472. */
  122473. set cameraColorCurvesEnabled(value: boolean);
  122474. /**
  122475. * Gets wether the color grading effect is enabled.
  122476. */
  122477. get cameraColorGradingEnabled(): boolean;
  122478. /**
  122479. * Gets wether the color grading effect is enabled.
  122480. */
  122481. set cameraColorGradingEnabled(value: boolean);
  122482. /**
  122483. * Gets wether tonemapping is enabled or not.
  122484. */
  122485. get cameraToneMappingEnabled(): boolean;
  122486. /**
  122487. * Sets wether tonemapping is enabled or not
  122488. */
  122489. set cameraToneMappingEnabled(value: boolean);
  122490. /**
  122491. * The camera exposure used on this material.
  122492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122493. * This corresponds to a photographic exposure.
  122494. */
  122495. get cameraExposure(): float;
  122496. /**
  122497. * The camera exposure used on this material.
  122498. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122499. * This corresponds to a photographic exposure.
  122500. */
  122501. set cameraExposure(value: float);
  122502. /**
  122503. * Gets The camera contrast used on this material.
  122504. */
  122505. get cameraContrast(): float;
  122506. /**
  122507. * Sets The camera contrast used on this material.
  122508. */
  122509. set cameraContrast(value: float);
  122510. /**
  122511. * Gets the Color Grading 2D Lookup Texture.
  122512. */
  122513. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122514. /**
  122515. * Sets the Color Grading 2D Lookup Texture.
  122516. */
  122517. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122518. /**
  122519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122521. * 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;
  122522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122523. */
  122524. get cameraColorCurves(): Nullable<ColorCurves>;
  122525. /**
  122526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122528. * 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;
  122529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122530. */
  122531. set cameraColorCurves(value: Nullable<ColorCurves>);
  122532. /**
  122533. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122534. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122535. */
  122536. switchToBGR: boolean;
  122537. private _renderTargets;
  122538. private _reflectionControls;
  122539. private _white;
  122540. private _primaryShadowColor;
  122541. private _primaryHighlightColor;
  122542. /**
  122543. * Instantiates a Background Material in the given scene
  122544. * @param name The friendly name of the material
  122545. * @param scene The scene to add the material to
  122546. */
  122547. constructor(name: string, scene: Scene);
  122548. /**
  122549. * Gets a boolean indicating that current material needs to register RTT
  122550. */
  122551. get hasRenderTargetTextures(): boolean;
  122552. /**
  122553. * The entire material has been created in order to prevent overdraw.
  122554. * @returns false
  122555. */
  122556. needAlphaTesting(): boolean;
  122557. /**
  122558. * The entire material has been created in order to prevent overdraw.
  122559. * @returns true if blending is enable
  122560. */
  122561. needAlphaBlending(): boolean;
  122562. /**
  122563. * Checks wether the material is ready to be rendered for a given mesh.
  122564. * @param mesh The mesh to render
  122565. * @param subMesh The submesh to check against
  122566. * @param useInstances Specify wether or not the material is used with instances
  122567. * @returns true if all the dependencies are ready (Textures, Effects...)
  122568. */
  122569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122570. /**
  122571. * Compute the primary color according to the chosen perceptual color.
  122572. */
  122573. private _computePrimaryColorFromPerceptualColor;
  122574. /**
  122575. * Compute the highlights and shadow colors according to their chosen levels.
  122576. */
  122577. private _computePrimaryColors;
  122578. /**
  122579. * Build the uniform buffer used in the material.
  122580. */
  122581. buildUniformLayout(): void;
  122582. /**
  122583. * Unbind the material.
  122584. */
  122585. unbind(): void;
  122586. /**
  122587. * Bind only the world matrix to the material.
  122588. * @param world The world matrix to bind.
  122589. */
  122590. bindOnlyWorldMatrix(world: Matrix): void;
  122591. /**
  122592. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122593. * @param world The world matrix to bind.
  122594. * @param subMesh The submesh to bind for.
  122595. */
  122596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122597. /**
  122598. * Checks to see if a texture is used in the material.
  122599. * @param texture - Base texture to use.
  122600. * @returns - Boolean specifying if a texture is used in the material.
  122601. */
  122602. hasTexture(texture: BaseTexture): boolean;
  122603. /**
  122604. * Dispose the material.
  122605. * @param forceDisposeEffect Force disposal of the associated effect.
  122606. * @param forceDisposeTextures Force disposal of the associated textures.
  122607. */
  122608. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122609. /**
  122610. * Clones the material.
  122611. * @param name The cloned name.
  122612. * @returns The cloned material.
  122613. */
  122614. clone(name: string): BackgroundMaterial;
  122615. /**
  122616. * Serializes the current material to its JSON representation.
  122617. * @returns The JSON representation.
  122618. */
  122619. serialize(): any;
  122620. /**
  122621. * Gets the class name of the material
  122622. * @returns "BackgroundMaterial"
  122623. */
  122624. getClassName(): string;
  122625. /**
  122626. * Parse a JSON input to create back a background material.
  122627. * @param source The JSON data to parse
  122628. * @param scene The scene to create the parsed material in
  122629. * @param rootUrl The root url of the assets the material depends upon
  122630. * @returns the instantiated BackgroundMaterial.
  122631. */
  122632. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122633. }
  122634. }
  122635. declare module BABYLON {
  122636. /**
  122637. * Represents the different options available during the creation of
  122638. * a Environment helper.
  122639. *
  122640. * This can control the default ground, skybox and image processing setup of your scene.
  122641. */
  122642. export interface IEnvironmentHelperOptions {
  122643. /**
  122644. * Specifies whether or not to create a ground.
  122645. * True by default.
  122646. */
  122647. createGround: boolean;
  122648. /**
  122649. * Specifies the ground size.
  122650. * 15 by default.
  122651. */
  122652. groundSize: number;
  122653. /**
  122654. * The texture used on the ground for the main color.
  122655. * Comes from the BabylonJS CDN by default.
  122656. *
  122657. * Remarks: Can be either a texture or a url.
  122658. */
  122659. groundTexture: string | BaseTexture;
  122660. /**
  122661. * The color mixed in the ground texture by default.
  122662. * BabylonJS clearColor by default.
  122663. */
  122664. groundColor: Color3;
  122665. /**
  122666. * Specifies the ground opacity.
  122667. * 1 by default.
  122668. */
  122669. groundOpacity: number;
  122670. /**
  122671. * Enables the ground to receive shadows.
  122672. * True by default.
  122673. */
  122674. enableGroundShadow: boolean;
  122675. /**
  122676. * Helps preventing the shadow to be fully black on the ground.
  122677. * 0.5 by default.
  122678. */
  122679. groundShadowLevel: number;
  122680. /**
  122681. * Creates a mirror texture attach to the ground.
  122682. * false by default.
  122683. */
  122684. enableGroundMirror: boolean;
  122685. /**
  122686. * Specifies the ground mirror size ratio.
  122687. * 0.3 by default as the default kernel is 64.
  122688. */
  122689. groundMirrorSizeRatio: number;
  122690. /**
  122691. * Specifies the ground mirror blur kernel size.
  122692. * 64 by default.
  122693. */
  122694. groundMirrorBlurKernel: number;
  122695. /**
  122696. * Specifies the ground mirror visibility amount.
  122697. * 1 by default
  122698. */
  122699. groundMirrorAmount: number;
  122700. /**
  122701. * Specifies the ground mirror reflectance weight.
  122702. * This uses the standard weight of the background material to setup the fresnel effect
  122703. * of the mirror.
  122704. * 1 by default.
  122705. */
  122706. groundMirrorFresnelWeight: number;
  122707. /**
  122708. * Specifies the ground mirror Falloff distance.
  122709. * This can helps reducing the size of the reflection.
  122710. * 0 by Default.
  122711. */
  122712. groundMirrorFallOffDistance: number;
  122713. /**
  122714. * Specifies the ground mirror texture type.
  122715. * Unsigned Int by Default.
  122716. */
  122717. groundMirrorTextureType: number;
  122718. /**
  122719. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122720. * the shown objects.
  122721. */
  122722. groundYBias: number;
  122723. /**
  122724. * Specifies whether or not to create a skybox.
  122725. * True by default.
  122726. */
  122727. createSkybox: boolean;
  122728. /**
  122729. * Specifies the skybox size.
  122730. * 20 by default.
  122731. */
  122732. skyboxSize: number;
  122733. /**
  122734. * The texture used on the skybox for the main color.
  122735. * Comes from the BabylonJS CDN by default.
  122736. *
  122737. * Remarks: Can be either a texture or a url.
  122738. */
  122739. skyboxTexture: string | BaseTexture;
  122740. /**
  122741. * The color mixed in the skybox texture by default.
  122742. * BabylonJS clearColor by default.
  122743. */
  122744. skyboxColor: Color3;
  122745. /**
  122746. * The background rotation around the Y axis of the scene.
  122747. * This helps aligning the key lights of your scene with the background.
  122748. * 0 by default.
  122749. */
  122750. backgroundYRotation: number;
  122751. /**
  122752. * Compute automatically the size of the elements to best fit with the scene.
  122753. */
  122754. sizeAuto: boolean;
  122755. /**
  122756. * Default position of the rootMesh if autoSize is not true.
  122757. */
  122758. rootPosition: Vector3;
  122759. /**
  122760. * Sets up the image processing in the scene.
  122761. * true by default.
  122762. */
  122763. setupImageProcessing: boolean;
  122764. /**
  122765. * The texture used as your environment texture in the scene.
  122766. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122767. *
  122768. * Remarks: Can be either a texture or a url.
  122769. */
  122770. environmentTexture: string | BaseTexture;
  122771. /**
  122772. * The value of the exposure to apply to the scene.
  122773. * 0.6 by default if setupImageProcessing is true.
  122774. */
  122775. cameraExposure: number;
  122776. /**
  122777. * The value of the contrast to apply to the scene.
  122778. * 1.6 by default if setupImageProcessing is true.
  122779. */
  122780. cameraContrast: number;
  122781. /**
  122782. * Specifies whether or not tonemapping should be enabled in the scene.
  122783. * true by default if setupImageProcessing is true.
  122784. */
  122785. toneMappingEnabled: boolean;
  122786. }
  122787. /**
  122788. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122789. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122790. * It also helps with the default setup of your imageProcessing configuration.
  122791. */
  122792. export class EnvironmentHelper {
  122793. /**
  122794. * Default ground texture URL.
  122795. */
  122796. private static _groundTextureCDNUrl;
  122797. /**
  122798. * Default skybox texture URL.
  122799. */
  122800. private static _skyboxTextureCDNUrl;
  122801. /**
  122802. * Default environment texture URL.
  122803. */
  122804. private static _environmentTextureCDNUrl;
  122805. /**
  122806. * Creates the default options for the helper.
  122807. */
  122808. private static _getDefaultOptions;
  122809. private _rootMesh;
  122810. /**
  122811. * Gets the root mesh created by the helper.
  122812. */
  122813. get rootMesh(): Mesh;
  122814. private _skybox;
  122815. /**
  122816. * Gets the skybox created by the helper.
  122817. */
  122818. get skybox(): Nullable<Mesh>;
  122819. private _skyboxTexture;
  122820. /**
  122821. * Gets the skybox texture created by the helper.
  122822. */
  122823. get skyboxTexture(): Nullable<BaseTexture>;
  122824. private _skyboxMaterial;
  122825. /**
  122826. * Gets the skybox material created by the helper.
  122827. */
  122828. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122829. private _ground;
  122830. /**
  122831. * Gets the ground mesh created by the helper.
  122832. */
  122833. get ground(): Nullable<Mesh>;
  122834. private _groundTexture;
  122835. /**
  122836. * Gets the ground texture created by the helper.
  122837. */
  122838. get groundTexture(): Nullable<BaseTexture>;
  122839. private _groundMirror;
  122840. /**
  122841. * Gets the ground mirror created by the helper.
  122842. */
  122843. get groundMirror(): Nullable<MirrorTexture>;
  122844. /**
  122845. * Gets the ground mirror render list to helps pushing the meshes
  122846. * you wish in the ground reflection.
  122847. */
  122848. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122849. private _groundMaterial;
  122850. /**
  122851. * Gets the ground material created by the helper.
  122852. */
  122853. get groundMaterial(): Nullable<BackgroundMaterial>;
  122854. /**
  122855. * Stores the creation options.
  122856. */
  122857. private readonly _scene;
  122858. private _options;
  122859. /**
  122860. * This observable will be notified with any error during the creation of the environment,
  122861. * mainly texture creation errors.
  122862. */
  122863. onErrorObservable: Observable<{
  122864. message?: string;
  122865. exception?: any;
  122866. }>;
  122867. /**
  122868. * constructor
  122869. * @param options Defines the options we want to customize the helper
  122870. * @param scene The scene to add the material to
  122871. */
  122872. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122873. /**
  122874. * Updates the background according to the new options
  122875. * @param options
  122876. */
  122877. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122878. /**
  122879. * Sets the primary color of all the available elements.
  122880. * @param color the main color to affect to the ground and the background
  122881. */
  122882. setMainColor(color: Color3): void;
  122883. /**
  122884. * Setup the image processing according to the specified options.
  122885. */
  122886. private _setupImageProcessing;
  122887. /**
  122888. * Setup the environment texture according to the specified options.
  122889. */
  122890. private _setupEnvironmentTexture;
  122891. /**
  122892. * Setup the background according to the specified options.
  122893. */
  122894. private _setupBackground;
  122895. /**
  122896. * Get the scene sizes according to the setup.
  122897. */
  122898. private _getSceneSize;
  122899. /**
  122900. * Setup the ground according to the specified options.
  122901. */
  122902. private _setupGround;
  122903. /**
  122904. * Setup the ground material according to the specified options.
  122905. */
  122906. private _setupGroundMaterial;
  122907. /**
  122908. * Setup the ground diffuse texture according to the specified options.
  122909. */
  122910. private _setupGroundDiffuseTexture;
  122911. /**
  122912. * Setup the ground mirror texture according to the specified options.
  122913. */
  122914. private _setupGroundMirrorTexture;
  122915. /**
  122916. * Setup the ground to receive the mirror texture.
  122917. */
  122918. private _setupMirrorInGroundMaterial;
  122919. /**
  122920. * Setup the skybox according to the specified options.
  122921. */
  122922. private _setupSkybox;
  122923. /**
  122924. * Setup the skybox material according to the specified options.
  122925. */
  122926. private _setupSkyboxMaterial;
  122927. /**
  122928. * Setup the skybox reflection texture according to the specified options.
  122929. */
  122930. private _setupSkyboxReflectionTexture;
  122931. private _errorHandler;
  122932. /**
  122933. * Dispose all the elements created by the Helper.
  122934. */
  122935. dispose(): void;
  122936. }
  122937. }
  122938. declare module BABYLON {
  122939. /**
  122940. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122941. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122942. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122943. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122944. */
  122945. export class PhotoDome extends TransformNode {
  122946. /**
  122947. * Define the image as a Monoscopic panoramic 360 image.
  122948. */
  122949. static readonly MODE_MONOSCOPIC: number;
  122950. /**
  122951. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122952. */
  122953. static readonly MODE_TOPBOTTOM: number;
  122954. /**
  122955. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122956. */
  122957. static readonly MODE_SIDEBYSIDE: number;
  122958. private _useDirectMapping;
  122959. /**
  122960. * The texture being displayed on the sphere
  122961. */
  122962. protected _photoTexture: Texture;
  122963. /**
  122964. * Gets or sets the texture being displayed on the sphere
  122965. */
  122966. get photoTexture(): Texture;
  122967. set photoTexture(value: Texture);
  122968. /**
  122969. * Observable raised when an error occured while loading the 360 image
  122970. */
  122971. onLoadErrorObservable: Observable<string>;
  122972. /**
  122973. * The skybox material
  122974. */
  122975. protected _material: BackgroundMaterial;
  122976. /**
  122977. * The surface used for the skybox
  122978. */
  122979. protected _mesh: Mesh;
  122980. /**
  122981. * Gets the mesh used for the skybox.
  122982. */
  122983. get mesh(): Mesh;
  122984. /**
  122985. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122986. * Also see the options.resolution property.
  122987. */
  122988. get fovMultiplier(): number;
  122989. set fovMultiplier(value: number);
  122990. private _imageMode;
  122991. /**
  122992. * Gets or set the current video mode for the video. It can be:
  122993. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122994. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122995. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122996. */
  122997. get imageMode(): number;
  122998. set imageMode(value: number);
  122999. /**
  123000. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123001. * @param name Element's name, child elements will append suffixes for their own names.
  123002. * @param urlsOfPhoto defines the url of the photo to display
  123003. * @param options defines an object containing optional or exposed sub element properties
  123004. * @param onError defines a callback called when an error occured while loading the texture
  123005. */
  123006. constructor(name: string, urlOfPhoto: string, options: {
  123007. resolution?: number;
  123008. size?: number;
  123009. useDirectMapping?: boolean;
  123010. faceForward?: boolean;
  123011. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123012. private _onBeforeCameraRenderObserver;
  123013. private _changeImageMode;
  123014. /**
  123015. * Releases resources associated with this node.
  123016. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123017. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123018. */
  123019. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123020. }
  123021. }
  123022. declare module BABYLON {
  123023. /**
  123024. * Class used to host RGBD texture specific utilities
  123025. */
  123026. export class RGBDTextureTools {
  123027. /**
  123028. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123029. * @param texture the texture to expand.
  123030. */
  123031. static ExpandRGBDTexture(texture: Texture): void;
  123032. }
  123033. }
  123034. declare module BABYLON {
  123035. /**
  123036. * Class used to host texture specific utilities
  123037. */
  123038. export class BRDFTextureTools {
  123039. /**
  123040. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123041. * @param scene defines the hosting scene
  123042. * @returns the environment BRDF texture
  123043. */
  123044. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123045. private static _environmentBRDFBase64Texture;
  123046. }
  123047. }
  123048. declare module BABYLON {
  123049. /**
  123050. * @hidden
  123051. */
  123052. export interface IMaterialClearCoatDefines {
  123053. CLEARCOAT: boolean;
  123054. CLEARCOAT_DEFAULTIOR: boolean;
  123055. CLEARCOAT_TEXTURE: boolean;
  123056. CLEARCOAT_TEXTUREDIRECTUV: number;
  123057. CLEARCOAT_BUMP: boolean;
  123058. CLEARCOAT_BUMPDIRECTUV: number;
  123059. CLEARCOAT_TINT: boolean;
  123060. CLEARCOAT_TINT_TEXTURE: boolean;
  123061. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123062. /** @hidden */
  123063. _areTexturesDirty: boolean;
  123064. }
  123065. /**
  123066. * Define the code related to the clear coat parameters of the pbr material.
  123067. */
  123068. export class PBRClearCoatConfiguration {
  123069. /**
  123070. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123071. * The default fits with a polyurethane material.
  123072. */
  123073. private static readonly _DefaultIndexOfRefraction;
  123074. private _isEnabled;
  123075. /**
  123076. * Defines if the clear coat is enabled in the material.
  123077. */
  123078. isEnabled: boolean;
  123079. /**
  123080. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123081. */
  123082. intensity: number;
  123083. /**
  123084. * Defines the clear coat layer roughness.
  123085. */
  123086. roughness: number;
  123087. private _indexOfRefraction;
  123088. /**
  123089. * Defines the index of refraction of the clear coat.
  123090. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123091. * The default fits with a polyurethane material.
  123092. * Changing the default value is more performance intensive.
  123093. */
  123094. indexOfRefraction: number;
  123095. private _texture;
  123096. /**
  123097. * Stores the clear coat values in a texture.
  123098. */
  123099. texture: Nullable<BaseTexture>;
  123100. private _bumpTexture;
  123101. /**
  123102. * Define the clear coat specific bump texture.
  123103. */
  123104. bumpTexture: Nullable<BaseTexture>;
  123105. private _isTintEnabled;
  123106. /**
  123107. * Defines if the clear coat tint is enabled in the material.
  123108. */
  123109. isTintEnabled: boolean;
  123110. /**
  123111. * Defines the clear coat tint of the material.
  123112. * This is only use if tint is enabled
  123113. */
  123114. tintColor: Color3;
  123115. /**
  123116. * Defines the distance at which the tint color should be found in the
  123117. * clear coat media.
  123118. * This is only use if tint is enabled
  123119. */
  123120. tintColorAtDistance: number;
  123121. /**
  123122. * Defines the clear coat layer thickness.
  123123. * This is only use if tint is enabled
  123124. */
  123125. tintThickness: number;
  123126. private _tintTexture;
  123127. /**
  123128. * Stores the clear tint values in a texture.
  123129. * rgb is tint
  123130. * a is a thickness factor
  123131. */
  123132. tintTexture: Nullable<BaseTexture>;
  123133. /** @hidden */
  123134. private _internalMarkAllSubMeshesAsTexturesDirty;
  123135. /** @hidden */
  123136. _markAllSubMeshesAsTexturesDirty(): void;
  123137. /**
  123138. * Instantiate a new istance of clear coat configuration.
  123139. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123140. */
  123141. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123142. /**
  123143. * Gets wehter the submesh is ready to be used or not.
  123144. * @param defines the list of "defines" to update.
  123145. * @param scene defines the scene the material belongs to.
  123146. * @param engine defines the engine the material belongs to.
  123147. * @param disableBumpMap defines wether the material disables bump or not.
  123148. * @returns - boolean indicating that the submesh is ready or not.
  123149. */
  123150. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123151. /**
  123152. * Checks to see if a texture is used in the material.
  123153. * @param defines the list of "defines" to update.
  123154. * @param scene defines the scene to the material belongs to.
  123155. */
  123156. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123157. /**
  123158. * Binds the material data.
  123159. * @param uniformBuffer defines the Uniform buffer to fill in.
  123160. * @param scene defines the scene the material belongs to.
  123161. * @param engine defines the engine the material belongs to.
  123162. * @param disableBumpMap defines wether the material disables bump or not.
  123163. * @param isFrozen defines wether the material is frozen or not.
  123164. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123165. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123166. */
  123167. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123168. /**
  123169. * Checks to see if a texture is used in the material.
  123170. * @param texture - Base texture to use.
  123171. * @returns - Boolean specifying if a texture is used in the material.
  123172. */
  123173. hasTexture(texture: BaseTexture): boolean;
  123174. /**
  123175. * Returns an array of the actively used textures.
  123176. * @param activeTextures Array of BaseTextures
  123177. */
  123178. getActiveTextures(activeTextures: BaseTexture[]): void;
  123179. /**
  123180. * Returns the animatable textures.
  123181. * @param animatables Array of animatable textures.
  123182. */
  123183. getAnimatables(animatables: IAnimatable[]): void;
  123184. /**
  123185. * Disposes the resources of the material.
  123186. * @param forceDisposeTextures - Forces the disposal of all textures.
  123187. */
  123188. dispose(forceDisposeTextures?: boolean): void;
  123189. /**
  123190. * Get the current class name of the texture useful for serialization or dynamic coding.
  123191. * @returns "PBRClearCoatConfiguration"
  123192. */
  123193. getClassName(): string;
  123194. /**
  123195. * Add fallbacks to the effect fallbacks list.
  123196. * @param defines defines the Base texture to use.
  123197. * @param fallbacks defines the current fallback list.
  123198. * @param currentRank defines the current fallback rank.
  123199. * @returns the new fallback rank.
  123200. */
  123201. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123202. /**
  123203. * Add the required uniforms to the current list.
  123204. * @param uniforms defines the current uniform list.
  123205. */
  123206. static AddUniforms(uniforms: string[]): void;
  123207. /**
  123208. * Add the required samplers to the current list.
  123209. * @param samplers defines the current sampler list.
  123210. */
  123211. static AddSamplers(samplers: string[]): void;
  123212. /**
  123213. * Add the required uniforms to the current buffer.
  123214. * @param uniformBuffer defines the current uniform buffer.
  123215. */
  123216. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123217. /**
  123218. * Makes a duplicate of the current configuration into another one.
  123219. * @param clearCoatConfiguration define the config where to copy the info
  123220. */
  123221. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123222. /**
  123223. * Serializes this clear coat configuration.
  123224. * @returns - An object with the serialized config.
  123225. */
  123226. serialize(): any;
  123227. /**
  123228. * Parses a anisotropy Configuration from a serialized object.
  123229. * @param source - Serialized object.
  123230. * @param scene Defines the scene we are parsing for
  123231. * @param rootUrl Defines the rootUrl to load from
  123232. */
  123233. parse(source: any, scene: Scene, rootUrl: string): void;
  123234. }
  123235. }
  123236. declare module BABYLON {
  123237. /**
  123238. * @hidden
  123239. */
  123240. export interface IMaterialAnisotropicDefines {
  123241. ANISOTROPIC: boolean;
  123242. ANISOTROPIC_TEXTURE: boolean;
  123243. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123244. MAINUV1: boolean;
  123245. _areTexturesDirty: boolean;
  123246. _needUVs: boolean;
  123247. }
  123248. /**
  123249. * Define the code related to the anisotropic parameters of the pbr material.
  123250. */
  123251. export class PBRAnisotropicConfiguration {
  123252. private _isEnabled;
  123253. /**
  123254. * Defines if the anisotropy is enabled in the material.
  123255. */
  123256. isEnabled: boolean;
  123257. /**
  123258. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123259. */
  123260. intensity: number;
  123261. /**
  123262. * Defines if the effect is along the tangents, bitangents or in between.
  123263. * By default, the effect is "strectching" the highlights along the tangents.
  123264. */
  123265. direction: Vector2;
  123266. private _texture;
  123267. /**
  123268. * Stores the anisotropy values in a texture.
  123269. * rg is direction (like normal from -1 to 1)
  123270. * b is a intensity
  123271. */
  123272. texture: Nullable<BaseTexture>;
  123273. /** @hidden */
  123274. private _internalMarkAllSubMeshesAsTexturesDirty;
  123275. /** @hidden */
  123276. _markAllSubMeshesAsTexturesDirty(): void;
  123277. /**
  123278. * Instantiate a new istance of anisotropy configuration.
  123279. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123280. */
  123281. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123282. /**
  123283. * Specifies that the submesh is ready to be used.
  123284. * @param defines the list of "defines" to update.
  123285. * @param scene defines the scene the material belongs to.
  123286. * @returns - boolean indicating that the submesh is ready or not.
  123287. */
  123288. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123289. /**
  123290. * Checks to see if a texture is used in the material.
  123291. * @param defines the list of "defines" to update.
  123292. * @param mesh the mesh we are preparing the defines for.
  123293. * @param scene defines the scene the material belongs to.
  123294. */
  123295. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123296. /**
  123297. * Binds the material data.
  123298. * @param uniformBuffer defines the Uniform buffer to fill in.
  123299. * @param scene defines the scene the material belongs to.
  123300. * @param isFrozen defines wether the material is frozen or not.
  123301. */
  123302. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123303. /**
  123304. * Checks to see if a texture is used in the material.
  123305. * @param texture - Base texture to use.
  123306. * @returns - Boolean specifying if a texture is used in the material.
  123307. */
  123308. hasTexture(texture: BaseTexture): boolean;
  123309. /**
  123310. * Returns an array of the actively used textures.
  123311. * @param activeTextures Array of BaseTextures
  123312. */
  123313. getActiveTextures(activeTextures: BaseTexture[]): void;
  123314. /**
  123315. * Returns the animatable textures.
  123316. * @param animatables Array of animatable textures.
  123317. */
  123318. getAnimatables(animatables: IAnimatable[]): void;
  123319. /**
  123320. * Disposes the resources of the material.
  123321. * @param forceDisposeTextures - Forces the disposal of all textures.
  123322. */
  123323. dispose(forceDisposeTextures?: boolean): void;
  123324. /**
  123325. * Get the current class name of the texture useful for serialization or dynamic coding.
  123326. * @returns "PBRAnisotropicConfiguration"
  123327. */
  123328. getClassName(): string;
  123329. /**
  123330. * Add fallbacks to the effect fallbacks list.
  123331. * @param defines defines the Base texture to use.
  123332. * @param fallbacks defines the current fallback list.
  123333. * @param currentRank defines the current fallback rank.
  123334. * @returns the new fallback rank.
  123335. */
  123336. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123337. /**
  123338. * Add the required uniforms to the current list.
  123339. * @param uniforms defines the current uniform list.
  123340. */
  123341. static AddUniforms(uniforms: string[]): void;
  123342. /**
  123343. * Add the required uniforms to the current buffer.
  123344. * @param uniformBuffer defines the current uniform buffer.
  123345. */
  123346. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123347. /**
  123348. * Add the required samplers to the current list.
  123349. * @param samplers defines the current sampler list.
  123350. */
  123351. static AddSamplers(samplers: string[]): void;
  123352. /**
  123353. * Makes a duplicate of the current configuration into another one.
  123354. * @param anisotropicConfiguration define the config where to copy the info
  123355. */
  123356. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123357. /**
  123358. * Serializes this anisotropy configuration.
  123359. * @returns - An object with the serialized config.
  123360. */
  123361. serialize(): any;
  123362. /**
  123363. * Parses a anisotropy Configuration from a serialized object.
  123364. * @param source - Serialized object.
  123365. * @param scene Defines the scene we are parsing for
  123366. * @param rootUrl Defines the rootUrl to load from
  123367. */
  123368. parse(source: any, scene: Scene, rootUrl: string): void;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * @hidden
  123374. */
  123375. export interface IMaterialBRDFDefines {
  123376. BRDF_V_HEIGHT_CORRELATED: boolean;
  123377. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123378. SPHERICAL_HARMONICS: boolean;
  123379. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123380. /** @hidden */
  123381. _areMiscDirty: boolean;
  123382. }
  123383. /**
  123384. * Define the code related to the BRDF parameters of the pbr material.
  123385. */
  123386. export class PBRBRDFConfiguration {
  123387. /**
  123388. * Default value used for the energy conservation.
  123389. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123390. */
  123391. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123392. /**
  123393. * Default value used for the Smith Visibility Height Correlated mode.
  123394. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123395. */
  123396. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123397. /**
  123398. * Default value used for the IBL diffuse part.
  123399. * This can help switching back to the polynomials mode globally which is a tiny bit
  123400. * less GPU intensive at the drawback of a lower quality.
  123401. */
  123402. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123403. /**
  123404. * Default value used for activating energy conservation for the specular workflow.
  123405. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123406. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123407. */
  123408. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123409. private _useEnergyConservation;
  123410. /**
  123411. * Defines if the material uses energy conservation.
  123412. */
  123413. useEnergyConservation: boolean;
  123414. private _useSmithVisibilityHeightCorrelated;
  123415. /**
  123416. * LEGACY Mode set to false
  123417. * Defines if the material uses height smith correlated visibility term.
  123418. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123419. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123420. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123421. * Not relying on height correlated will also disable energy conservation.
  123422. */
  123423. useSmithVisibilityHeightCorrelated: boolean;
  123424. private _useSphericalHarmonics;
  123425. /**
  123426. * LEGACY Mode set to false
  123427. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123428. * diffuse part of the IBL.
  123429. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123430. * to the ground truth.
  123431. */
  123432. useSphericalHarmonics: boolean;
  123433. private _useSpecularGlossinessInputEnergyConservation;
  123434. /**
  123435. * Defines if the material uses energy conservation, when the specular workflow is active.
  123436. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123437. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123438. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123439. */
  123440. useSpecularGlossinessInputEnergyConservation: boolean;
  123441. /** @hidden */
  123442. private _internalMarkAllSubMeshesAsMiscDirty;
  123443. /** @hidden */
  123444. _markAllSubMeshesAsMiscDirty(): void;
  123445. /**
  123446. * Instantiate a new istance of clear coat configuration.
  123447. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123448. */
  123449. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123450. /**
  123451. * Checks to see if a texture is used in the material.
  123452. * @param defines the list of "defines" to update.
  123453. */
  123454. prepareDefines(defines: IMaterialBRDFDefines): void;
  123455. /**
  123456. * Get the current class name of the texture useful for serialization or dynamic coding.
  123457. * @returns "PBRClearCoatConfiguration"
  123458. */
  123459. getClassName(): string;
  123460. /**
  123461. * Makes a duplicate of the current configuration into another one.
  123462. * @param brdfConfiguration define the config where to copy the info
  123463. */
  123464. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123465. /**
  123466. * Serializes this BRDF configuration.
  123467. * @returns - An object with the serialized config.
  123468. */
  123469. serialize(): any;
  123470. /**
  123471. * Parses a anisotropy Configuration from a serialized object.
  123472. * @param source - Serialized object.
  123473. * @param scene Defines the scene we are parsing for
  123474. * @param rootUrl Defines the rootUrl to load from
  123475. */
  123476. parse(source: any, scene: Scene, rootUrl: string): void;
  123477. }
  123478. }
  123479. declare module BABYLON {
  123480. /**
  123481. * @hidden
  123482. */
  123483. export interface IMaterialSheenDefines {
  123484. SHEEN: boolean;
  123485. SHEEN_TEXTURE: boolean;
  123486. SHEEN_TEXTUREDIRECTUV: number;
  123487. SHEEN_LINKWITHALBEDO: boolean;
  123488. /** @hidden */
  123489. _areTexturesDirty: boolean;
  123490. }
  123491. /**
  123492. * Define the code related to the Sheen parameters of the pbr material.
  123493. */
  123494. export class PBRSheenConfiguration {
  123495. private _isEnabled;
  123496. /**
  123497. * Defines if the material uses sheen.
  123498. */
  123499. isEnabled: boolean;
  123500. private _linkSheenWithAlbedo;
  123501. /**
  123502. * Defines if the sheen is linked to the sheen color.
  123503. */
  123504. linkSheenWithAlbedo: boolean;
  123505. /**
  123506. * Defines the sheen intensity.
  123507. */
  123508. intensity: number;
  123509. /**
  123510. * Defines the sheen color.
  123511. */
  123512. color: Color3;
  123513. private _texture;
  123514. /**
  123515. * Stores the sheen tint values in a texture.
  123516. * rgb is tint
  123517. * a is a intensity
  123518. */
  123519. texture: Nullable<BaseTexture>;
  123520. /** @hidden */
  123521. private _internalMarkAllSubMeshesAsTexturesDirty;
  123522. /** @hidden */
  123523. _markAllSubMeshesAsTexturesDirty(): void;
  123524. /**
  123525. * Instantiate a new istance of clear coat configuration.
  123526. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123527. */
  123528. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123529. /**
  123530. * Specifies that the submesh is ready to be used.
  123531. * @param defines the list of "defines" to update.
  123532. * @param scene defines the scene the material belongs to.
  123533. * @returns - boolean indicating that the submesh is ready or not.
  123534. */
  123535. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123536. /**
  123537. * Checks to see if a texture is used in the material.
  123538. * @param defines the list of "defines" to update.
  123539. * @param scene defines the scene the material belongs to.
  123540. */
  123541. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123542. /**
  123543. * Binds the material data.
  123544. * @param uniformBuffer defines the Uniform buffer to fill in.
  123545. * @param scene defines the scene the material belongs to.
  123546. * @param isFrozen defines wether the material is frozen or not.
  123547. */
  123548. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123549. /**
  123550. * Checks to see if a texture is used in the material.
  123551. * @param texture - Base texture to use.
  123552. * @returns - Boolean specifying if a texture is used in the material.
  123553. */
  123554. hasTexture(texture: BaseTexture): boolean;
  123555. /**
  123556. * Returns an array of the actively used textures.
  123557. * @param activeTextures Array of BaseTextures
  123558. */
  123559. getActiveTextures(activeTextures: BaseTexture[]): void;
  123560. /**
  123561. * Returns the animatable textures.
  123562. * @param animatables Array of animatable textures.
  123563. */
  123564. getAnimatables(animatables: IAnimatable[]): void;
  123565. /**
  123566. * Disposes the resources of the material.
  123567. * @param forceDisposeTextures - Forces the disposal of all textures.
  123568. */
  123569. dispose(forceDisposeTextures?: boolean): void;
  123570. /**
  123571. * Get the current class name of the texture useful for serialization or dynamic coding.
  123572. * @returns "PBRSheenConfiguration"
  123573. */
  123574. getClassName(): string;
  123575. /**
  123576. * Add fallbacks to the effect fallbacks list.
  123577. * @param defines defines the Base texture to use.
  123578. * @param fallbacks defines the current fallback list.
  123579. * @param currentRank defines the current fallback rank.
  123580. * @returns the new fallback rank.
  123581. */
  123582. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123583. /**
  123584. * Add the required uniforms to the current list.
  123585. * @param uniforms defines the current uniform list.
  123586. */
  123587. static AddUniforms(uniforms: string[]): void;
  123588. /**
  123589. * Add the required uniforms to the current buffer.
  123590. * @param uniformBuffer defines the current uniform buffer.
  123591. */
  123592. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123593. /**
  123594. * Add the required samplers to the current list.
  123595. * @param samplers defines the current sampler list.
  123596. */
  123597. static AddSamplers(samplers: string[]): void;
  123598. /**
  123599. * Makes a duplicate of the current configuration into another one.
  123600. * @param sheenConfiguration define the config where to copy the info
  123601. */
  123602. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123603. /**
  123604. * Serializes this BRDF configuration.
  123605. * @returns - An object with the serialized config.
  123606. */
  123607. serialize(): any;
  123608. /**
  123609. * Parses a anisotropy Configuration from a serialized object.
  123610. * @param source - Serialized object.
  123611. * @param scene Defines the scene we are parsing for
  123612. * @param rootUrl Defines the rootUrl to load from
  123613. */
  123614. parse(source: any, scene: Scene, rootUrl: string): void;
  123615. }
  123616. }
  123617. declare module BABYLON {
  123618. /**
  123619. * @hidden
  123620. */
  123621. export interface IMaterialSubSurfaceDefines {
  123622. SUBSURFACE: boolean;
  123623. SS_REFRACTION: boolean;
  123624. SS_TRANSLUCENCY: boolean;
  123625. SS_SCATERRING: boolean;
  123626. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123627. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123628. SS_REFRACTIONMAP_3D: boolean;
  123629. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123630. SS_LODINREFRACTIONALPHA: boolean;
  123631. SS_GAMMAREFRACTION: boolean;
  123632. SS_RGBDREFRACTION: boolean;
  123633. SS_LINEARSPECULARREFRACTION: boolean;
  123634. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123635. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123636. /** @hidden */
  123637. _areTexturesDirty: boolean;
  123638. }
  123639. /**
  123640. * Define the code related to the sub surface parameters of the pbr material.
  123641. */
  123642. export class PBRSubSurfaceConfiguration {
  123643. private _isRefractionEnabled;
  123644. /**
  123645. * Defines if the refraction is enabled in the material.
  123646. */
  123647. isRefractionEnabled: boolean;
  123648. private _isTranslucencyEnabled;
  123649. /**
  123650. * Defines if the translucency is enabled in the material.
  123651. */
  123652. isTranslucencyEnabled: boolean;
  123653. private _isScatteringEnabled;
  123654. /**
  123655. * Defines the refraction intensity of the material.
  123656. * The refraction when enabled replaces the Diffuse part of the material.
  123657. * The intensity helps transitionning between diffuse and refraction.
  123658. */
  123659. refractionIntensity: number;
  123660. /**
  123661. * Defines the translucency intensity of the material.
  123662. * When translucency has been enabled, this defines how much of the "translucency"
  123663. * is addded to the diffuse part of the material.
  123664. */
  123665. translucencyIntensity: number;
  123666. /**
  123667. * Defines the scattering intensity of the material.
  123668. * When scattering has been enabled, this defines how much of the "scattered light"
  123669. * is addded to the diffuse part of the material.
  123670. */
  123671. scatteringIntensity: number;
  123672. private _thicknessTexture;
  123673. /**
  123674. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123675. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123676. * 0 would mean minimumThickness
  123677. * 1 would mean maximumThickness
  123678. * The other channels might be use as a mask to vary the different effects intensity.
  123679. */
  123680. thicknessTexture: Nullable<BaseTexture>;
  123681. private _refractionTexture;
  123682. /**
  123683. * Defines the texture to use for refraction.
  123684. */
  123685. refractionTexture: Nullable<BaseTexture>;
  123686. private _indexOfRefraction;
  123687. /**
  123688. * Defines the index of refraction used in the material.
  123689. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123690. */
  123691. indexOfRefraction: number;
  123692. private _invertRefractionY;
  123693. /**
  123694. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123695. */
  123696. invertRefractionY: boolean;
  123697. private _linkRefractionWithTransparency;
  123698. /**
  123699. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123700. * Materials half opaque for instance using refraction could benefit from this control.
  123701. */
  123702. linkRefractionWithTransparency: boolean;
  123703. /**
  123704. * Defines the minimum thickness stored in the thickness map.
  123705. * If no thickness map is defined, this value will be used to simulate thickness.
  123706. */
  123707. minimumThickness: number;
  123708. /**
  123709. * Defines the maximum thickness stored in the thickness map.
  123710. */
  123711. maximumThickness: number;
  123712. /**
  123713. * Defines the volume tint of the material.
  123714. * This is used for both translucency and scattering.
  123715. */
  123716. tintColor: Color3;
  123717. /**
  123718. * Defines the distance at which the tint color should be found in the media.
  123719. * This is used for refraction only.
  123720. */
  123721. tintColorAtDistance: number;
  123722. /**
  123723. * Defines how far each channel transmit through the media.
  123724. * It is defined as a color to simplify it selection.
  123725. */
  123726. diffusionDistance: Color3;
  123727. private _useMaskFromThicknessTexture;
  123728. /**
  123729. * Stores the intensity of the different subsurface effects in the thickness texture.
  123730. * * the green channel is the translucency intensity.
  123731. * * the blue channel is the scattering intensity.
  123732. * * the alpha channel is the refraction intensity.
  123733. */
  123734. useMaskFromThicknessTexture: boolean;
  123735. /** @hidden */
  123736. private _internalMarkAllSubMeshesAsTexturesDirty;
  123737. /** @hidden */
  123738. _markAllSubMeshesAsTexturesDirty(): void;
  123739. /**
  123740. * Instantiate a new istance of sub surface configuration.
  123741. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123742. */
  123743. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123744. /**
  123745. * Gets wehter the submesh is ready to be used or not.
  123746. * @param defines the list of "defines" to update.
  123747. * @param scene defines the scene the material belongs to.
  123748. * @returns - boolean indicating that the submesh is ready or not.
  123749. */
  123750. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123751. /**
  123752. * Checks to see if a texture is used in the material.
  123753. * @param defines the list of "defines" to update.
  123754. * @param scene defines the scene to the material belongs to.
  123755. */
  123756. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123757. /**
  123758. * Binds the material data.
  123759. * @param uniformBuffer defines the Uniform buffer to fill in.
  123760. * @param scene defines the scene the material belongs to.
  123761. * @param engine defines the engine the material belongs to.
  123762. * @param isFrozen defines wether the material is frozen or not.
  123763. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123764. */
  123765. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123766. /**
  123767. * Unbinds the material from the mesh.
  123768. * @param activeEffect defines the effect that should be unbound from.
  123769. * @returns true if unbound, otherwise false
  123770. */
  123771. unbind(activeEffect: Effect): boolean;
  123772. /**
  123773. * Returns the texture used for refraction or null if none is used.
  123774. * @param scene defines the scene the material belongs to.
  123775. * @returns - Refraction texture if present. If no refraction texture and refraction
  123776. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123777. */
  123778. private _getRefractionTexture;
  123779. /**
  123780. * Returns true if alpha blending should be disabled.
  123781. */
  123782. get disableAlphaBlending(): boolean;
  123783. /**
  123784. * Fills the list of render target textures.
  123785. * @param renderTargets the list of render targets to update
  123786. */
  123787. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123788. /**
  123789. * Checks to see if a texture is used in the material.
  123790. * @param texture - Base texture to use.
  123791. * @returns - Boolean specifying if a texture is used in the material.
  123792. */
  123793. hasTexture(texture: BaseTexture): boolean;
  123794. /**
  123795. * Gets a boolean indicating that current material needs to register RTT
  123796. * @returns true if this uses a render target otherwise false.
  123797. */
  123798. hasRenderTargetTextures(): boolean;
  123799. /**
  123800. * Returns an array of the actively used textures.
  123801. * @param activeTextures Array of BaseTextures
  123802. */
  123803. getActiveTextures(activeTextures: BaseTexture[]): void;
  123804. /**
  123805. * Returns the animatable textures.
  123806. * @param animatables Array of animatable textures.
  123807. */
  123808. getAnimatables(animatables: IAnimatable[]): void;
  123809. /**
  123810. * Disposes the resources of the material.
  123811. * @param forceDisposeTextures - Forces the disposal of all textures.
  123812. */
  123813. dispose(forceDisposeTextures?: boolean): void;
  123814. /**
  123815. * Get the current class name of the texture useful for serialization or dynamic coding.
  123816. * @returns "PBRSubSurfaceConfiguration"
  123817. */
  123818. getClassName(): string;
  123819. /**
  123820. * Add fallbacks to the effect fallbacks list.
  123821. * @param defines defines the Base texture to use.
  123822. * @param fallbacks defines the current fallback list.
  123823. * @param currentRank defines the current fallback rank.
  123824. * @returns the new fallback rank.
  123825. */
  123826. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123827. /**
  123828. * Add the required uniforms to the current list.
  123829. * @param uniforms defines the current uniform list.
  123830. */
  123831. static AddUniforms(uniforms: string[]): void;
  123832. /**
  123833. * Add the required samplers to the current list.
  123834. * @param samplers defines the current sampler list.
  123835. */
  123836. static AddSamplers(samplers: string[]): void;
  123837. /**
  123838. * Add the required uniforms to the current buffer.
  123839. * @param uniformBuffer defines the current uniform buffer.
  123840. */
  123841. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123842. /**
  123843. * Makes a duplicate of the current configuration into another one.
  123844. * @param configuration define the config where to copy the info
  123845. */
  123846. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123847. /**
  123848. * Serializes this Sub Surface configuration.
  123849. * @returns - An object with the serialized config.
  123850. */
  123851. serialize(): any;
  123852. /**
  123853. * Parses a anisotropy Configuration from a serialized object.
  123854. * @param source - Serialized object.
  123855. * @param scene Defines the scene we are parsing for
  123856. * @param rootUrl Defines the rootUrl to load from
  123857. */
  123858. parse(source: any, scene: Scene, rootUrl: string): void;
  123859. }
  123860. }
  123861. declare module BABYLON {
  123862. /** @hidden */
  123863. export var pbrFragmentDeclaration: {
  123864. name: string;
  123865. shader: string;
  123866. };
  123867. }
  123868. declare module BABYLON {
  123869. /** @hidden */
  123870. export var pbrUboDeclaration: {
  123871. name: string;
  123872. shader: string;
  123873. };
  123874. }
  123875. declare module BABYLON {
  123876. /** @hidden */
  123877. export var pbrFragmentExtraDeclaration: {
  123878. name: string;
  123879. shader: string;
  123880. };
  123881. }
  123882. declare module BABYLON {
  123883. /** @hidden */
  123884. export var pbrFragmentSamplersDeclaration: {
  123885. name: string;
  123886. shader: string;
  123887. };
  123888. }
  123889. declare module BABYLON {
  123890. /** @hidden */
  123891. export var pbrHelperFunctions: {
  123892. name: string;
  123893. shader: string;
  123894. };
  123895. }
  123896. declare module BABYLON {
  123897. /** @hidden */
  123898. export var harmonicsFunctions: {
  123899. name: string;
  123900. shader: string;
  123901. };
  123902. }
  123903. declare module BABYLON {
  123904. /** @hidden */
  123905. export var pbrDirectLightingSetupFunctions: {
  123906. name: string;
  123907. shader: string;
  123908. };
  123909. }
  123910. declare module BABYLON {
  123911. /** @hidden */
  123912. export var pbrDirectLightingFalloffFunctions: {
  123913. name: string;
  123914. shader: string;
  123915. };
  123916. }
  123917. declare module BABYLON {
  123918. /** @hidden */
  123919. export var pbrBRDFFunctions: {
  123920. name: string;
  123921. shader: string;
  123922. };
  123923. }
  123924. declare module BABYLON {
  123925. /** @hidden */
  123926. export var pbrDirectLightingFunctions: {
  123927. name: string;
  123928. shader: string;
  123929. };
  123930. }
  123931. declare module BABYLON {
  123932. /** @hidden */
  123933. export var pbrIBLFunctions: {
  123934. name: string;
  123935. shader: string;
  123936. };
  123937. }
  123938. declare module BABYLON {
  123939. /** @hidden */
  123940. export var pbrDebug: {
  123941. name: string;
  123942. shader: string;
  123943. };
  123944. }
  123945. declare module BABYLON {
  123946. /** @hidden */
  123947. export var pbrPixelShader: {
  123948. name: string;
  123949. shader: string;
  123950. };
  123951. }
  123952. declare module BABYLON {
  123953. /** @hidden */
  123954. export var pbrVertexDeclaration: {
  123955. name: string;
  123956. shader: string;
  123957. };
  123958. }
  123959. declare module BABYLON {
  123960. /** @hidden */
  123961. export var pbrVertexShader: {
  123962. name: string;
  123963. shader: string;
  123964. };
  123965. }
  123966. declare module BABYLON {
  123967. /**
  123968. * Manages the defines for the PBR Material.
  123969. * @hidden
  123970. */
  123971. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123972. PBR: boolean;
  123973. MAINUV1: boolean;
  123974. MAINUV2: boolean;
  123975. UV1: boolean;
  123976. UV2: boolean;
  123977. ALBEDO: boolean;
  123978. ALBEDODIRECTUV: number;
  123979. VERTEXCOLOR: boolean;
  123980. AMBIENT: boolean;
  123981. AMBIENTDIRECTUV: number;
  123982. AMBIENTINGRAYSCALE: boolean;
  123983. OPACITY: boolean;
  123984. VERTEXALPHA: boolean;
  123985. OPACITYDIRECTUV: number;
  123986. OPACITYRGB: boolean;
  123987. ALPHATEST: boolean;
  123988. DEPTHPREPASS: boolean;
  123989. ALPHABLEND: boolean;
  123990. ALPHAFROMALBEDO: boolean;
  123991. ALPHATESTVALUE: string;
  123992. SPECULAROVERALPHA: boolean;
  123993. RADIANCEOVERALPHA: boolean;
  123994. ALPHAFRESNEL: boolean;
  123995. LINEARALPHAFRESNEL: boolean;
  123996. PREMULTIPLYALPHA: boolean;
  123997. EMISSIVE: boolean;
  123998. EMISSIVEDIRECTUV: number;
  123999. REFLECTIVITY: boolean;
  124000. REFLECTIVITYDIRECTUV: number;
  124001. SPECULARTERM: boolean;
  124002. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124003. MICROSURFACEAUTOMATIC: boolean;
  124004. LODBASEDMICROSFURACE: boolean;
  124005. MICROSURFACEMAP: boolean;
  124006. MICROSURFACEMAPDIRECTUV: number;
  124007. METALLICWORKFLOW: boolean;
  124008. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124009. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124010. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124011. AOSTOREINMETALMAPRED: boolean;
  124012. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124013. ENVIRONMENTBRDF: boolean;
  124014. ENVIRONMENTBRDF_RGBD: boolean;
  124015. NORMAL: boolean;
  124016. TANGENT: boolean;
  124017. BUMP: boolean;
  124018. BUMPDIRECTUV: number;
  124019. OBJECTSPACE_NORMALMAP: boolean;
  124020. PARALLAX: boolean;
  124021. PARALLAXOCCLUSION: boolean;
  124022. NORMALXYSCALE: boolean;
  124023. LIGHTMAP: boolean;
  124024. LIGHTMAPDIRECTUV: number;
  124025. USELIGHTMAPASSHADOWMAP: boolean;
  124026. GAMMALIGHTMAP: boolean;
  124027. RGBDLIGHTMAP: boolean;
  124028. REFLECTION: boolean;
  124029. REFLECTIONMAP_3D: boolean;
  124030. REFLECTIONMAP_SPHERICAL: boolean;
  124031. REFLECTIONMAP_PLANAR: boolean;
  124032. REFLECTIONMAP_CUBIC: boolean;
  124033. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124034. REFLECTIONMAP_PROJECTION: boolean;
  124035. REFLECTIONMAP_SKYBOX: boolean;
  124036. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  124037. REFLECTIONMAP_EXPLICIT: boolean;
  124038. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124039. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124040. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124041. INVERTCUBICMAP: boolean;
  124042. USESPHERICALFROMREFLECTIONMAP: boolean;
  124043. USEIRRADIANCEMAP: boolean;
  124044. SPHERICAL_HARMONICS: boolean;
  124045. USESPHERICALINVERTEX: boolean;
  124046. REFLECTIONMAP_OPPOSITEZ: boolean;
  124047. LODINREFLECTIONALPHA: boolean;
  124048. GAMMAREFLECTION: boolean;
  124049. RGBDREFLECTION: boolean;
  124050. LINEARSPECULARREFLECTION: boolean;
  124051. RADIANCEOCCLUSION: boolean;
  124052. HORIZONOCCLUSION: boolean;
  124053. INSTANCES: boolean;
  124054. NUM_BONE_INFLUENCERS: number;
  124055. BonesPerMesh: number;
  124056. BONETEXTURE: boolean;
  124057. NONUNIFORMSCALING: boolean;
  124058. MORPHTARGETS: boolean;
  124059. MORPHTARGETS_NORMAL: boolean;
  124060. MORPHTARGETS_TANGENT: boolean;
  124061. MORPHTARGETS_UV: boolean;
  124062. NUM_MORPH_INFLUENCERS: number;
  124063. IMAGEPROCESSING: boolean;
  124064. VIGNETTE: boolean;
  124065. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124066. VIGNETTEBLENDMODEOPAQUE: boolean;
  124067. TONEMAPPING: boolean;
  124068. TONEMAPPING_ACES: boolean;
  124069. CONTRAST: boolean;
  124070. COLORCURVES: boolean;
  124071. COLORGRADING: boolean;
  124072. COLORGRADING3D: boolean;
  124073. SAMPLER3DGREENDEPTH: boolean;
  124074. SAMPLER3DBGRMAP: boolean;
  124075. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124076. EXPOSURE: boolean;
  124077. MULTIVIEW: boolean;
  124078. USEPHYSICALLIGHTFALLOFF: boolean;
  124079. USEGLTFLIGHTFALLOFF: boolean;
  124080. TWOSIDEDLIGHTING: boolean;
  124081. SHADOWFLOAT: boolean;
  124082. CLIPPLANE: boolean;
  124083. CLIPPLANE2: boolean;
  124084. CLIPPLANE3: boolean;
  124085. CLIPPLANE4: boolean;
  124086. CLIPPLANE5: boolean;
  124087. CLIPPLANE6: boolean;
  124088. POINTSIZE: boolean;
  124089. FOG: boolean;
  124090. LOGARITHMICDEPTH: boolean;
  124091. FORCENORMALFORWARD: boolean;
  124092. SPECULARAA: boolean;
  124093. CLEARCOAT: boolean;
  124094. CLEARCOAT_DEFAULTIOR: boolean;
  124095. CLEARCOAT_TEXTURE: boolean;
  124096. CLEARCOAT_TEXTUREDIRECTUV: number;
  124097. CLEARCOAT_BUMP: boolean;
  124098. CLEARCOAT_BUMPDIRECTUV: number;
  124099. CLEARCOAT_TINT: boolean;
  124100. CLEARCOAT_TINT_TEXTURE: boolean;
  124101. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124102. ANISOTROPIC: boolean;
  124103. ANISOTROPIC_TEXTURE: boolean;
  124104. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124105. BRDF_V_HEIGHT_CORRELATED: boolean;
  124106. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124107. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124108. SHEEN: boolean;
  124109. SHEEN_TEXTURE: boolean;
  124110. SHEEN_TEXTUREDIRECTUV: number;
  124111. SHEEN_LINKWITHALBEDO: boolean;
  124112. SUBSURFACE: boolean;
  124113. SS_REFRACTION: boolean;
  124114. SS_TRANSLUCENCY: boolean;
  124115. SS_SCATERRING: boolean;
  124116. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124117. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124118. SS_REFRACTIONMAP_3D: boolean;
  124119. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124120. SS_LODINREFRACTIONALPHA: boolean;
  124121. SS_GAMMAREFRACTION: boolean;
  124122. SS_RGBDREFRACTION: boolean;
  124123. SS_LINEARSPECULARREFRACTION: boolean;
  124124. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124125. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124126. UNLIT: boolean;
  124127. DEBUGMODE: number;
  124128. /**
  124129. * Initializes the PBR Material defines.
  124130. */
  124131. constructor();
  124132. /**
  124133. * Resets the PBR Material defines.
  124134. */
  124135. reset(): void;
  124136. }
  124137. /**
  124138. * The Physically based material base class of BJS.
  124139. *
  124140. * This offers the main features of a standard PBR material.
  124141. * For more information, please refer to the documentation :
  124142. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124143. */
  124144. export abstract class PBRBaseMaterial extends PushMaterial {
  124145. /**
  124146. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124147. */
  124148. static readonly PBRMATERIAL_OPAQUE: number;
  124149. /**
  124150. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124151. */
  124152. static readonly PBRMATERIAL_ALPHATEST: number;
  124153. /**
  124154. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124155. */
  124156. static readonly PBRMATERIAL_ALPHABLEND: number;
  124157. /**
  124158. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124159. * They are also discarded below the alpha cutoff threshold to improve performances.
  124160. */
  124161. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124162. /**
  124163. * Defines the default value of how much AO map is occluding the analytical lights
  124164. * (point spot...).
  124165. */
  124166. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124167. /**
  124168. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124169. */
  124170. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124171. /**
  124172. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124173. * to enhance interoperability with other engines.
  124174. */
  124175. static readonly LIGHTFALLOFF_GLTF: number;
  124176. /**
  124177. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124178. * to enhance interoperability with other materials.
  124179. */
  124180. static readonly LIGHTFALLOFF_STANDARD: number;
  124181. /**
  124182. * Intensity of the direct lights e.g. the four lights available in your scene.
  124183. * This impacts both the direct diffuse and specular highlights.
  124184. */
  124185. protected _directIntensity: number;
  124186. /**
  124187. * Intensity of the emissive part of the material.
  124188. * This helps controlling the emissive effect without modifying the emissive color.
  124189. */
  124190. protected _emissiveIntensity: number;
  124191. /**
  124192. * Intensity of the environment e.g. how much the environment will light the object
  124193. * either through harmonics for rough material or through the refelction for shiny ones.
  124194. */
  124195. protected _environmentIntensity: number;
  124196. /**
  124197. * This is a special control allowing the reduction of the specular highlights coming from the
  124198. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124199. */
  124200. protected _specularIntensity: number;
  124201. /**
  124202. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124203. */
  124204. private _lightingInfos;
  124205. /**
  124206. * Debug Control allowing disabling the bump map on this material.
  124207. */
  124208. protected _disableBumpMap: boolean;
  124209. /**
  124210. * AKA Diffuse Texture in standard nomenclature.
  124211. */
  124212. protected _albedoTexture: Nullable<BaseTexture>;
  124213. /**
  124214. * AKA Occlusion Texture in other nomenclature.
  124215. */
  124216. protected _ambientTexture: Nullable<BaseTexture>;
  124217. /**
  124218. * AKA Occlusion Texture Intensity in other nomenclature.
  124219. */
  124220. protected _ambientTextureStrength: number;
  124221. /**
  124222. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124223. * 1 means it completely occludes it
  124224. * 0 mean it has no impact
  124225. */
  124226. protected _ambientTextureImpactOnAnalyticalLights: number;
  124227. /**
  124228. * Stores the alpha values in a texture.
  124229. */
  124230. protected _opacityTexture: Nullable<BaseTexture>;
  124231. /**
  124232. * Stores the reflection values in a texture.
  124233. */
  124234. protected _reflectionTexture: Nullable<BaseTexture>;
  124235. /**
  124236. * Stores the emissive values in a texture.
  124237. */
  124238. protected _emissiveTexture: Nullable<BaseTexture>;
  124239. /**
  124240. * AKA Specular texture in other nomenclature.
  124241. */
  124242. protected _reflectivityTexture: Nullable<BaseTexture>;
  124243. /**
  124244. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124245. */
  124246. protected _metallicTexture: Nullable<BaseTexture>;
  124247. /**
  124248. * Specifies the metallic scalar of the metallic/roughness workflow.
  124249. * Can also be used to scale the metalness values of the metallic texture.
  124250. */
  124251. protected _metallic: Nullable<number>;
  124252. /**
  124253. * Specifies the roughness scalar of the metallic/roughness workflow.
  124254. * Can also be used to scale the roughness values of the metallic texture.
  124255. */
  124256. protected _roughness: Nullable<number>;
  124257. /**
  124258. * Specifies the an F0 factor to help configuring the material F0.
  124259. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124260. * to 0.5 the previously hard coded value stays the same.
  124261. * Can also be used to scale the F0 values of the metallic texture.
  124262. */
  124263. protected _metallicF0Factor: number;
  124264. /**
  124265. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124266. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124267. * your expectation as it multiplies with the texture data.
  124268. */
  124269. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124270. /**
  124271. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124272. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124273. */
  124274. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124275. /**
  124276. * Stores surface normal data used to displace a mesh in a texture.
  124277. */
  124278. protected _bumpTexture: Nullable<BaseTexture>;
  124279. /**
  124280. * Stores the pre-calculated light information of a mesh in a texture.
  124281. */
  124282. protected _lightmapTexture: Nullable<BaseTexture>;
  124283. /**
  124284. * The color of a material in ambient lighting.
  124285. */
  124286. protected _ambientColor: Color3;
  124287. /**
  124288. * AKA Diffuse Color in other nomenclature.
  124289. */
  124290. protected _albedoColor: Color3;
  124291. /**
  124292. * AKA Specular Color in other nomenclature.
  124293. */
  124294. protected _reflectivityColor: Color3;
  124295. /**
  124296. * The color applied when light is reflected from a material.
  124297. */
  124298. protected _reflectionColor: Color3;
  124299. /**
  124300. * The color applied when light is emitted from a material.
  124301. */
  124302. protected _emissiveColor: Color3;
  124303. /**
  124304. * AKA Glossiness in other nomenclature.
  124305. */
  124306. protected _microSurface: number;
  124307. /**
  124308. * Specifies that the material will use the light map as a show map.
  124309. */
  124310. protected _useLightmapAsShadowmap: boolean;
  124311. /**
  124312. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124313. * makes the reflect vector face the model (under horizon).
  124314. */
  124315. protected _useHorizonOcclusion: boolean;
  124316. /**
  124317. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124318. * too much the area relying on ambient texture to define their ambient occlusion.
  124319. */
  124320. protected _useRadianceOcclusion: boolean;
  124321. /**
  124322. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124323. */
  124324. protected _useAlphaFromAlbedoTexture: boolean;
  124325. /**
  124326. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124327. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124328. */
  124329. protected _useSpecularOverAlpha: boolean;
  124330. /**
  124331. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124332. */
  124333. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124334. /**
  124335. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124336. */
  124337. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124338. /**
  124339. * Specifies if the metallic texture contains the roughness information in its green channel.
  124340. */
  124341. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124342. /**
  124343. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124344. */
  124345. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124346. /**
  124347. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124348. */
  124349. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124350. /**
  124351. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124352. */
  124353. protected _useAmbientInGrayScale: boolean;
  124354. /**
  124355. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124356. * The material will try to infer what glossiness each pixel should be.
  124357. */
  124358. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124359. /**
  124360. * Defines the falloff type used in this material.
  124361. * It by default is Physical.
  124362. */
  124363. protected _lightFalloff: number;
  124364. /**
  124365. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124366. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124367. */
  124368. protected _useRadianceOverAlpha: boolean;
  124369. /**
  124370. * Allows using an object space normal map (instead of tangent space).
  124371. */
  124372. protected _useObjectSpaceNormalMap: boolean;
  124373. /**
  124374. * Allows using the bump map in parallax mode.
  124375. */
  124376. protected _useParallax: boolean;
  124377. /**
  124378. * Allows using the bump map in parallax occlusion mode.
  124379. */
  124380. protected _useParallaxOcclusion: boolean;
  124381. /**
  124382. * Controls the scale bias of the parallax mode.
  124383. */
  124384. protected _parallaxScaleBias: number;
  124385. /**
  124386. * If sets to true, disables all the lights affecting the material.
  124387. */
  124388. protected _disableLighting: boolean;
  124389. /**
  124390. * Number of Simultaneous lights allowed on the material.
  124391. */
  124392. protected _maxSimultaneousLights: number;
  124393. /**
  124394. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124395. */
  124396. protected _invertNormalMapX: boolean;
  124397. /**
  124398. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124399. */
  124400. protected _invertNormalMapY: boolean;
  124401. /**
  124402. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124403. */
  124404. protected _twoSidedLighting: boolean;
  124405. /**
  124406. * Defines the alpha limits in alpha test mode.
  124407. */
  124408. protected _alphaCutOff: number;
  124409. /**
  124410. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124411. */
  124412. protected _forceAlphaTest: boolean;
  124413. /**
  124414. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124415. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124416. */
  124417. protected _useAlphaFresnel: boolean;
  124418. /**
  124419. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124420. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124421. */
  124422. protected _useLinearAlphaFresnel: boolean;
  124423. /**
  124424. * The transparency mode of the material.
  124425. */
  124426. protected _transparencyMode: Nullable<number>;
  124427. /**
  124428. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124429. * from cos thetav and roughness:
  124430. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124431. */
  124432. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124433. /**
  124434. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124435. */
  124436. protected _forceIrradianceInFragment: boolean;
  124437. /**
  124438. * Force normal to face away from face.
  124439. */
  124440. protected _forceNormalForward: boolean;
  124441. /**
  124442. * Enables specular anti aliasing in the PBR shader.
  124443. * It will both interacts on the Geometry for analytical and IBL lighting.
  124444. * It also prefilter the roughness map based on the bump values.
  124445. */
  124446. protected _enableSpecularAntiAliasing: boolean;
  124447. /**
  124448. * Default configuration related to image processing available in the PBR Material.
  124449. */
  124450. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124451. /**
  124452. * Keep track of the image processing observer to allow dispose and replace.
  124453. */
  124454. private _imageProcessingObserver;
  124455. /**
  124456. * Attaches a new image processing configuration to the PBR Material.
  124457. * @param configuration
  124458. */
  124459. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124460. /**
  124461. * Stores the available render targets.
  124462. */
  124463. private _renderTargets;
  124464. /**
  124465. * Sets the global ambient color for the material used in lighting calculations.
  124466. */
  124467. private _globalAmbientColor;
  124468. /**
  124469. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124470. */
  124471. private _useLogarithmicDepth;
  124472. /**
  124473. * If set to true, no lighting calculations will be applied.
  124474. */
  124475. private _unlit;
  124476. private _debugMode;
  124477. /**
  124478. * @hidden
  124479. * This is reserved for the inspector.
  124480. * Defines the material debug mode.
  124481. * It helps seeing only some components of the material while troubleshooting.
  124482. */
  124483. debugMode: number;
  124484. /**
  124485. * @hidden
  124486. * This is reserved for the inspector.
  124487. * Specify from where on screen the debug mode should start.
  124488. * The value goes from -1 (full screen) to 1 (not visible)
  124489. * It helps with side by side comparison against the final render
  124490. * This defaults to -1
  124491. */
  124492. private debugLimit;
  124493. /**
  124494. * @hidden
  124495. * This is reserved for the inspector.
  124496. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124497. * You can use the factor to better multiply the final value.
  124498. */
  124499. private debugFactor;
  124500. /**
  124501. * Defines the clear coat layer parameters for the material.
  124502. */
  124503. readonly clearCoat: PBRClearCoatConfiguration;
  124504. /**
  124505. * Defines the anisotropic parameters for the material.
  124506. */
  124507. readonly anisotropy: PBRAnisotropicConfiguration;
  124508. /**
  124509. * Defines the BRDF parameters for the material.
  124510. */
  124511. readonly brdf: PBRBRDFConfiguration;
  124512. /**
  124513. * Defines the Sheen parameters for the material.
  124514. */
  124515. readonly sheen: PBRSheenConfiguration;
  124516. /**
  124517. * Defines the SubSurface parameters for the material.
  124518. */
  124519. readonly subSurface: PBRSubSurfaceConfiguration;
  124520. /**
  124521. * Custom callback helping to override the default shader used in the material.
  124522. */
  124523. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124524. protected _rebuildInParallel: boolean;
  124525. /**
  124526. * Instantiates a new PBRMaterial instance.
  124527. *
  124528. * @param name The material name
  124529. * @param scene The scene the material will be use in.
  124530. */
  124531. constructor(name: string, scene: Scene);
  124532. /**
  124533. * Gets a boolean indicating that current material needs to register RTT
  124534. */
  124535. get hasRenderTargetTextures(): boolean;
  124536. /**
  124537. * Gets the name of the material class.
  124538. */
  124539. getClassName(): string;
  124540. /**
  124541. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124542. */
  124543. get useLogarithmicDepth(): boolean;
  124544. /**
  124545. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124546. */
  124547. set useLogarithmicDepth(value: boolean);
  124548. /**
  124549. * Gets the current transparency mode.
  124550. */
  124551. get transparencyMode(): Nullable<number>;
  124552. /**
  124553. * Sets the transparency mode of the material.
  124554. *
  124555. * | Value | Type | Description |
  124556. * | ----- | ----------------------------------- | ----------- |
  124557. * | 0 | OPAQUE | |
  124558. * | 1 | ALPHATEST | |
  124559. * | 2 | ALPHABLEND | |
  124560. * | 3 | ALPHATESTANDBLEND | |
  124561. *
  124562. */
  124563. set transparencyMode(value: Nullable<number>);
  124564. /**
  124565. * Returns true if alpha blending should be disabled.
  124566. */
  124567. private get _disableAlphaBlending();
  124568. /**
  124569. * Specifies whether or not this material should be rendered in alpha blend mode.
  124570. */
  124571. needAlphaBlending(): boolean;
  124572. /**
  124573. * Specifies if the mesh will require alpha blending.
  124574. * @param mesh - BJS mesh.
  124575. */
  124576. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124577. /**
  124578. * Specifies whether or not this material should be rendered in alpha test mode.
  124579. */
  124580. needAlphaTesting(): boolean;
  124581. /**
  124582. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124583. */
  124584. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124585. /**
  124586. * Gets the texture used for the alpha test.
  124587. */
  124588. getAlphaTestTexture(): Nullable<BaseTexture>;
  124589. /**
  124590. * Specifies that the submesh is ready to be used.
  124591. * @param mesh - BJS mesh.
  124592. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124593. * @param useInstances - Specifies that instances should be used.
  124594. * @returns - boolean indicating that the submesh is ready or not.
  124595. */
  124596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124597. /**
  124598. * Specifies if the material uses metallic roughness workflow.
  124599. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124600. */
  124601. isMetallicWorkflow(): boolean;
  124602. private _prepareEffect;
  124603. private _prepareDefines;
  124604. /**
  124605. * Force shader compilation
  124606. */
  124607. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124608. /**
  124609. * Initializes the uniform buffer layout for the shader.
  124610. */
  124611. buildUniformLayout(): void;
  124612. /**
  124613. * Unbinds the material from the mesh
  124614. */
  124615. unbind(): void;
  124616. /**
  124617. * Binds the submesh data.
  124618. * @param world - The world matrix.
  124619. * @param mesh - The BJS mesh.
  124620. * @param subMesh - A submesh of the BJS mesh.
  124621. */
  124622. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124623. /**
  124624. * Returns the animatable textures.
  124625. * @returns - Array of animatable textures.
  124626. */
  124627. getAnimatables(): IAnimatable[];
  124628. /**
  124629. * Returns the texture used for reflections.
  124630. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124631. */
  124632. private _getReflectionTexture;
  124633. /**
  124634. * Returns an array of the actively used textures.
  124635. * @returns - Array of BaseTextures
  124636. */
  124637. getActiveTextures(): BaseTexture[];
  124638. /**
  124639. * Checks to see if a texture is used in the material.
  124640. * @param texture - Base texture to use.
  124641. * @returns - Boolean specifying if a texture is used in the material.
  124642. */
  124643. hasTexture(texture: BaseTexture): boolean;
  124644. /**
  124645. * Disposes the resources of the material.
  124646. * @param forceDisposeEffect - Forces the disposal of effects.
  124647. * @param forceDisposeTextures - Forces the disposal of all textures.
  124648. */
  124649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124650. }
  124651. }
  124652. declare module BABYLON {
  124653. /**
  124654. * The Physically based material of BJS.
  124655. *
  124656. * This offers the main features of a standard PBR material.
  124657. * For more information, please refer to the documentation :
  124658. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124659. */
  124660. export class PBRMaterial extends PBRBaseMaterial {
  124661. /**
  124662. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124663. */
  124664. static readonly PBRMATERIAL_OPAQUE: number;
  124665. /**
  124666. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124667. */
  124668. static readonly PBRMATERIAL_ALPHATEST: number;
  124669. /**
  124670. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124671. */
  124672. static readonly PBRMATERIAL_ALPHABLEND: number;
  124673. /**
  124674. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124675. * They are also discarded below the alpha cutoff threshold to improve performances.
  124676. */
  124677. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124678. /**
  124679. * Defines the default value of how much AO map is occluding the analytical lights
  124680. * (point spot...).
  124681. */
  124682. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124683. /**
  124684. * Intensity of the direct lights e.g. the four lights available in your scene.
  124685. * This impacts both the direct diffuse and specular highlights.
  124686. */
  124687. directIntensity: number;
  124688. /**
  124689. * Intensity of the emissive part of the material.
  124690. * This helps controlling the emissive effect without modifying the emissive color.
  124691. */
  124692. emissiveIntensity: number;
  124693. /**
  124694. * Intensity of the environment e.g. how much the environment will light the object
  124695. * either through harmonics for rough material or through the refelction for shiny ones.
  124696. */
  124697. environmentIntensity: number;
  124698. /**
  124699. * This is a special control allowing the reduction of the specular highlights coming from the
  124700. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124701. */
  124702. specularIntensity: number;
  124703. /**
  124704. * Debug Control allowing disabling the bump map on this material.
  124705. */
  124706. disableBumpMap: boolean;
  124707. /**
  124708. * AKA Diffuse Texture in standard nomenclature.
  124709. */
  124710. albedoTexture: BaseTexture;
  124711. /**
  124712. * AKA Occlusion Texture in other nomenclature.
  124713. */
  124714. ambientTexture: BaseTexture;
  124715. /**
  124716. * AKA Occlusion Texture Intensity in other nomenclature.
  124717. */
  124718. ambientTextureStrength: number;
  124719. /**
  124720. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124721. * 1 means it completely occludes it
  124722. * 0 mean it has no impact
  124723. */
  124724. ambientTextureImpactOnAnalyticalLights: number;
  124725. /**
  124726. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124727. */
  124728. opacityTexture: BaseTexture;
  124729. /**
  124730. * Stores the reflection values in a texture.
  124731. */
  124732. reflectionTexture: Nullable<BaseTexture>;
  124733. /**
  124734. * Stores the emissive values in a texture.
  124735. */
  124736. emissiveTexture: BaseTexture;
  124737. /**
  124738. * AKA Specular texture in other nomenclature.
  124739. */
  124740. reflectivityTexture: BaseTexture;
  124741. /**
  124742. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124743. */
  124744. metallicTexture: BaseTexture;
  124745. /**
  124746. * Specifies the metallic scalar of the metallic/roughness workflow.
  124747. * Can also be used to scale the metalness values of the metallic texture.
  124748. */
  124749. metallic: Nullable<number>;
  124750. /**
  124751. * Specifies the roughness scalar of the metallic/roughness workflow.
  124752. * Can also be used to scale the roughness values of the metallic texture.
  124753. */
  124754. roughness: Nullable<number>;
  124755. /**
  124756. * Specifies the an F0 factor to help configuring the material F0.
  124757. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124758. * to 0.5 the previously hard coded value stays the same.
  124759. * Can also be used to scale the F0 values of the metallic texture.
  124760. */
  124761. metallicF0Factor: number;
  124762. /**
  124763. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124764. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124765. * your expectation as it multiplies with the texture data.
  124766. */
  124767. useMetallicF0FactorFromMetallicTexture: boolean;
  124768. /**
  124769. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124770. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124771. */
  124772. microSurfaceTexture: BaseTexture;
  124773. /**
  124774. * Stores surface normal data used to displace a mesh in a texture.
  124775. */
  124776. bumpTexture: BaseTexture;
  124777. /**
  124778. * Stores the pre-calculated light information of a mesh in a texture.
  124779. */
  124780. lightmapTexture: BaseTexture;
  124781. /**
  124782. * Stores the refracted light information in a texture.
  124783. */
  124784. get refractionTexture(): Nullable<BaseTexture>;
  124785. set refractionTexture(value: Nullable<BaseTexture>);
  124786. /**
  124787. * The color of a material in ambient lighting.
  124788. */
  124789. ambientColor: Color3;
  124790. /**
  124791. * AKA Diffuse Color in other nomenclature.
  124792. */
  124793. albedoColor: Color3;
  124794. /**
  124795. * AKA Specular Color in other nomenclature.
  124796. */
  124797. reflectivityColor: Color3;
  124798. /**
  124799. * The color reflected from the material.
  124800. */
  124801. reflectionColor: Color3;
  124802. /**
  124803. * The color emitted from the material.
  124804. */
  124805. emissiveColor: Color3;
  124806. /**
  124807. * AKA Glossiness in other nomenclature.
  124808. */
  124809. microSurface: number;
  124810. /**
  124811. * source material index of refraction (IOR)' / 'destination material IOR.
  124812. */
  124813. get indexOfRefraction(): number;
  124814. set indexOfRefraction(value: number);
  124815. /**
  124816. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124817. */
  124818. get invertRefractionY(): boolean;
  124819. set invertRefractionY(value: boolean);
  124820. /**
  124821. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124822. * Materials half opaque for instance using refraction could benefit from this control.
  124823. */
  124824. get linkRefractionWithTransparency(): boolean;
  124825. set linkRefractionWithTransparency(value: boolean);
  124826. /**
  124827. * If true, the light map contains occlusion information instead of lighting info.
  124828. */
  124829. useLightmapAsShadowmap: boolean;
  124830. /**
  124831. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124832. */
  124833. useAlphaFromAlbedoTexture: boolean;
  124834. /**
  124835. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124836. */
  124837. forceAlphaTest: boolean;
  124838. /**
  124839. * Defines the alpha limits in alpha test mode.
  124840. */
  124841. alphaCutOff: number;
  124842. /**
  124843. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124844. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124845. */
  124846. useSpecularOverAlpha: boolean;
  124847. /**
  124848. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124849. */
  124850. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124851. /**
  124852. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124853. */
  124854. useRoughnessFromMetallicTextureAlpha: boolean;
  124855. /**
  124856. * Specifies if the metallic texture contains the roughness information in its green channel.
  124857. */
  124858. useRoughnessFromMetallicTextureGreen: boolean;
  124859. /**
  124860. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124861. */
  124862. useMetallnessFromMetallicTextureBlue: boolean;
  124863. /**
  124864. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124865. */
  124866. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124867. /**
  124868. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124869. */
  124870. useAmbientInGrayScale: boolean;
  124871. /**
  124872. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124873. * The material will try to infer what glossiness each pixel should be.
  124874. */
  124875. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124876. /**
  124877. * BJS is using an harcoded light falloff based on a manually sets up range.
  124878. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124879. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124880. */
  124881. get usePhysicalLightFalloff(): boolean;
  124882. /**
  124883. * BJS is using an harcoded light falloff based on a manually sets up range.
  124884. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124885. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124886. */
  124887. set usePhysicalLightFalloff(value: boolean);
  124888. /**
  124889. * In order to support the falloff compatibility with gltf, a special mode has been added
  124890. * to reproduce the gltf light falloff.
  124891. */
  124892. get useGLTFLightFalloff(): boolean;
  124893. /**
  124894. * In order to support the falloff compatibility with gltf, a special mode has been added
  124895. * to reproduce the gltf light falloff.
  124896. */
  124897. set useGLTFLightFalloff(value: boolean);
  124898. /**
  124899. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124900. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124901. */
  124902. useRadianceOverAlpha: boolean;
  124903. /**
  124904. * Allows using an object space normal map (instead of tangent space).
  124905. */
  124906. useObjectSpaceNormalMap: boolean;
  124907. /**
  124908. * Allows using the bump map in parallax mode.
  124909. */
  124910. useParallax: boolean;
  124911. /**
  124912. * Allows using the bump map in parallax occlusion mode.
  124913. */
  124914. useParallaxOcclusion: boolean;
  124915. /**
  124916. * Controls the scale bias of the parallax mode.
  124917. */
  124918. parallaxScaleBias: number;
  124919. /**
  124920. * If sets to true, disables all the lights affecting the material.
  124921. */
  124922. disableLighting: boolean;
  124923. /**
  124924. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124925. */
  124926. forceIrradianceInFragment: boolean;
  124927. /**
  124928. * Number of Simultaneous lights allowed on the material.
  124929. */
  124930. maxSimultaneousLights: number;
  124931. /**
  124932. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124933. */
  124934. invertNormalMapX: boolean;
  124935. /**
  124936. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124937. */
  124938. invertNormalMapY: boolean;
  124939. /**
  124940. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124941. */
  124942. twoSidedLighting: boolean;
  124943. /**
  124944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124945. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124946. */
  124947. useAlphaFresnel: boolean;
  124948. /**
  124949. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124950. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124951. */
  124952. useLinearAlphaFresnel: boolean;
  124953. /**
  124954. * Let user defines the brdf lookup texture used for IBL.
  124955. * A default 8bit version is embedded but you could point at :
  124956. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124957. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124958. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124959. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124960. */
  124961. environmentBRDFTexture: Nullable<BaseTexture>;
  124962. /**
  124963. * Force normal to face away from face.
  124964. */
  124965. forceNormalForward: boolean;
  124966. /**
  124967. * Enables specular anti aliasing in the PBR shader.
  124968. * It will both interacts on the Geometry for analytical and IBL lighting.
  124969. * It also prefilter the roughness map based on the bump values.
  124970. */
  124971. enableSpecularAntiAliasing: boolean;
  124972. /**
  124973. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124974. * makes the reflect vector face the model (under horizon).
  124975. */
  124976. useHorizonOcclusion: boolean;
  124977. /**
  124978. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124979. * too much the area relying on ambient texture to define their ambient occlusion.
  124980. */
  124981. useRadianceOcclusion: boolean;
  124982. /**
  124983. * If set to true, no lighting calculations will be applied.
  124984. */
  124985. unlit: boolean;
  124986. /**
  124987. * Gets the image processing configuration used either in this material.
  124988. */
  124989. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124990. /**
  124991. * Sets the Default image processing configuration used either in the this material.
  124992. *
  124993. * If sets to null, the scene one is in use.
  124994. */
  124995. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124996. /**
  124997. * Gets wether the color curves effect is enabled.
  124998. */
  124999. get cameraColorCurvesEnabled(): boolean;
  125000. /**
  125001. * Sets wether the color curves effect is enabled.
  125002. */
  125003. set cameraColorCurvesEnabled(value: boolean);
  125004. /**
  125005. * Gets wether the color grading effect is enabled.
  125006. */
  125007. get cameraColorGradingEnabled(): boolean;
  125008. /**
  125009. * Gets wether the color grading effect is enabled.
  125010. */
  125011. set cameraColorGradingEnabled(value: boolean);
  125012. /**
  125013. * Gets wether tonemapping is enabled or not.
  125014. */
  125015. get cameraToneMappingEnabled(): boolean;
  125016. /**
  125017. * Sets wether tonemapping is enabled or not
  125018. */
  125019. set cameraToneMappingEnabled(value: boolean);
  125020. /**
  125021. * The camera exposure used on this material.
  125022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125023. * This corresponds to a photographic exposure.
  125024. */
  125025. get cameraExposure(): number;
  125026. /**
  125027. * The camera exposure used on this material.
  125028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125029. * This corresponds to a photographic exposure.
  125030. */
  125031. set cameraExposure(value: number);
  125032. /**
  125033. * Gets The camera contrast used on this material.
  125034. */
  125035. get cameraContrast(): number;
  125036. /**
  125037. * Sets The camera contrast used on this material.
  125038. */
  125039. set cameraContrast(value: number);
  125040. /**
  125041. * Gets the Color Grading 2D Lookup Texture.
  125042. */
  125043. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125044. /**
  125045. * Sets the Color Grading 2D Lookup Texture.
  125046. */
  125047. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125048. /**
  125049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125051. * 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;
  125052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125053. */
  125054. get cameraColorCurves(): Nullable<ColorCurves>;
  125055. /**
  125056. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125057. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125058. * 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;
  125059. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125060. */
  125061. set cameraColorCurves(value: Nullable<ColorCurves>);
  125062. /**
  125063. * Instantiates a new PBRMaterial instance.
  125064. *
  125065. * @param name The material name
  125066. * @param scene The scene the material will be use in.
  125067. */
  125068. constructor(name: string, scene: Scene);
  125069. /**
  125070. * Returns the name of this material class.
  125071. */
  125072. getClassName(): string;
  125073. /**
  125074. * Makes a duplicate of the current material.
  125075. * @param name - name to use for the new material.
  125076. */
  125077. clone(name: string): PBRMaterial;
  125078. /**
  125079. * Serializes this PBR Material.
  125080. * @returns - An object with the serialized material.
  125081. */
  125082. serialize(): any;
  125083. /**
  125084. * Parses a PBR Material from a serialized object.
  125085. * @param source - Serialized object.
  125086. * @param scene - BJS scene instance.
  125087. * @param rootUrl - url for the scene object
  125088. * @returns - PBRMaterial
  125089. */
  125090. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125091. }
  125092. }
  125093. declare module BABYLON {
  125094. /**
  125095. * Direct draw surface info
  125096. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125097. */
  125098. export interface DDSInfo {
  125099. /**
  125100. * Width of the texture
  125101. */
  125102. width: number;
  125103. /**
  125104. * Width of the texture
  125105. */
  125106. height: number;
  125107. /**
  125108. * Number of Mipmaps for the texture
  125109. * @see https://en.wikipedia.org/wiki/Mipmap
  125110. */
  125111. mipmapCount: number;
  125112. /**
  125113. * If the textures format is a known fourCC format
  125114. * @see https://www.fourcc.org/
  125115. */
  125116. isFourCC: boolean;
  125117. /**
  125118. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125119. */
  125120. isRGB: boolean;
  125121. /**
  125122. * If the texture is a lumincance format
  125123. */
  125124. isLuminance: boolean;
  125125. /**
  125126. * If this is a cube texture
  125127. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125128. */
  125129. isCube: boolean;
  125130. /**
  125131. * If the texture is a compressed format eg. FOURCC_DXT1
  125132. */
  125133. isCompressed: boolean;
  125134. /**
  125135. * The dxgiFormat of the texture
  125136. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125137. */
  125138. dxgiFormat: number;
  125139. /**
  125140. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125141. */
  125142. textureType: number;
  125143. /**
  125144. * Sphericle polynomial created for the dds texture
  125145. */
  125146. sphericalPolynomial?: SphericalPolynomial;
  125147. }
  125148. /**
  125149. * Class used to provide DDS decompression tools
  125150. */
  125151. export class DDSTools {
  125152. /**
  125153. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125154. */
  125155. static StoreLODInAlphaChannel: boolean;
  125156. /**
  125157. * Gets DDS information from an array buffer
  125158. * @param data defines the array buffer view to read data from
  125159. * @returns the DDS information
  125160. */
  125161. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125162. private static _FloatView;
  125163. private static _Int32View;
  125164. private static _ToHalfFloat;
  125165. private static _FromHalfFloat;
  125166. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125167. private static _GetHalfFloatRGBAArrayBuffer;
  125168. private static _GetFloatRGBAArrayBuffer;
  125169. private static _GetFloatAsUIntRGBAArrayBuffer;
  125170. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125171. private static _GetRGBAArrayBuffer;
  125172. private static _ExtractLongWordOrder;
  125173. private static _GetRGBArrayBuffer;
  125174. private static _GetLuminanceArrayBuffer;
  125175. /**
  125176. * Uploads DDS Levels to a Babylon Texture
  125177. * @hidden
  125178. */
  125179. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125180. }
  125181. interface ThinEngine {
  125182. /**
  125183. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125184. * @param rootUrl defines the url where the file to load is located
  125185. * @param scene defines the current scene
  125186. * @param lodScale defines scale to apply to the mip map selection
  125187. * @param lodOffset defines offset to apply to the mip map selection
  125188. * @param onLoad defines an optional callback raised when the texture is loaded
  125189. * @param onError defines an optional callback raised if there is an issue to load the texture
  125190. * @param format defines the format of the data
  125191. * @param forcedExtension defines the extension to use to pick the right loader
  125192. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125193. * @returns the cube texture as an InternalTexture
  125194. */
  125195. 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;
  125196. }
  125197. }
  125198. declare module BABYLON {
  125199. /**
  125200. * Implementation of the DDS Texture Loader.
  125201. * @hidden
  125202. */
  125203. export class _DDSTextureLoader implements IInternalTextureLoader {
  125204. /**
  125205. * Defines wether the loader supports cascade loading the different faces.
  125206. */
  125207. readonly supportCascades: boolean;
  125208. /**
  125209. * This returns if the loader support the current file information.
  125210. * @param extension defines the file extension of the file being loaded
  125211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125212. * @param fallback defines the fallback internal texture if any
  125213. * @param isBase64 defines whether the texture is encoded as a base64
  125214. * @param isBuffer defines whether the texture data are stored as a buffer
  125215. * @returns true if the loader can load the specified file
  125216. */
  125217. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125218. /**
  125219. * Transform the url before loading if required.
  125220. * @param rootUrl the url of the texture
  125221. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125222. * @returns the transformed texture
  125223. */
  125224. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125225. /**
  125226. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125227. * @param rootUrl the url of the texture
  125228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125229. * @returns the fallback texture
  125230. */
  125231. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125232. /**
  125233. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125234. * @param data contains the texture data
  125235. * @param texture defines the BabylonJS internal texture
  125236. * @param createPolynomials will be true if polynomials have been requested
  125237. * @param onLoad defines the callback to trigger once the texture is ready
  125238. * @param onError defines the callback to trigger in case of error
  125239. */
  125240. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125241. /**
  125242. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125243. * @param data contains the texture data
  125244. * @param texture defines the BabylonJS internal texture
  125245. * @param callback defines the method to call once ready to upload
  125246. */
  125247. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125248. }
  125249. }
  125250. declare module BABYLON {
  125251. /**
  125252. * Implementation of the ENV Texture Loader.
  125253. * @hidden
  125254. */
  125255. export class _ENVTextureLoader implements IInternalTextureLoader {
  125256. /**
  125257. * Defines wether the loader supports cascade loading the different faces.
  125258. */
  125259. readonly supportCascades: boolean;
  125260. /**
  125261. * This returns if the loader support the current file information.
  125262. * @param extension defines the file extension of the file being loaded
  125263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125264. * @param fallback defines the fallback internal texture if any
  125265. * @param isBase64 defines whether the texture is encoded as a base64
  125266. * @param isBuffer defines whether the texture data are stored as a buffer
  125267. * @returns true if the loader can load the specified file
  125268. */
  125269. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125270. /**
  125271. * Transform the url before loading if required.
  125272. * @param rootUrl the url of the texture
  125273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125274. * @returns the transformed texture
  125275. */
  125276. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125277. /**
  125278. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125279. * @param rootUrl the url of the texture
  125280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125281. * @returns the fallback texture
  125282. */
  125283. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125284. /**
  125285. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125286. * @param data contains the texture data
  125287. * @param texture defines the BabylonJS internal texture
  125288. * @param createPolynomials will be true if polynomials have been requested
  125289. * @param onLoad defines the callback to trigger once the texture is ready
  125290. * @param onError defines the callback to trigger in case of error
  125291. */
  125292. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125293. /**
  125294. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125295. * @param data contains the texture data
  125296. * @param texture defines the BabylonJS internal texture
  125297. * @param callback defines the method to call once ready to upload
  125298. */
  125299. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125300. }
  125301. }
  125302. declare module BABYLON {
  125303. /**
  125304. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125305. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125306. */
  125307. export class KhronosTextureContainer {
  125308. /** contents of the KTX container file */
  125309. data: ArrayBufferView;
  125310. private static HEADER_LEN;
  125311. private static COMPRESSED_2D;
  125312. private static COMPRESSED_3D;
  125313. private static TEX_2D;
  125314. private static TEX_3D;
  125315. /**
  125316. * Gets the openGL type
  125317. */
  125318. glType: number;
  125319. /**
  125320. * Gets the openGL type size
  125321. */
  125322. glTypeSize: number;
  125323. /**
  125324. * Gets the openGL format
  125325. */
  125326. glFormat: number;
  125327. /**
  125328. * Gets the openGL internal format
  125329. */
  125330. glInternalFormat: number;
  125331. /**
  125332. * Gets the base internal format
  125333. */
  125334. glBaseInternalFormat: number;
  125335. /**
  125336. * Gets image width in pixel
  125337. */
  125338. pixelWidth: number;
  125339. /**
  125340. * Gets image height in pixel
  125341. */
  125342. pixelHeight: number;
  125343. /**
  125344. * Gets image depth in pixels
  125345. */
  125346. pixelDepth: number;
  125347. /**
  125348. * Gets the number of array elements
  125349. */
  125350. numberOfArrayElements: number;
  125351. /**
  125352. * Gets the number of faces
  125353. */
  125354. numberOfFaces: number;
  125355. /**
  125356. * Gets the number of mipmap levels
  125357. */
  125358. numberOfMipmapLevels: number;
  125359. /**
  125360. * Gets the bytes of key value data
  125361. */
  125362. bytesOfKeyValueData: number;
  125363. /**
  125364. * Gets the load type
  125365. */
  125366. loadType: number;
  125367. /**
  125368. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125369. */
  125370. isInvalid: boolean;
  125371. /**
  125372. * Creates a new KhronosTextureContainer
  125373. * @param data contents of the KTX container file
  125374. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125375. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125376. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125377. */
  125378. constructor(
  125379. /** contents of the KTX container file */
  125380. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125381. /**
  125382. * Uploads KTX content to a Babylon Texture.
  125383. * It is assumed that the texture has already been created & is currently bound
  125384. * @hidden
  125385. */
  125386. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125387. private _upload2DCompressedLevels;
  125388. }
  125389. }
  125390. declare module BABYLON {
  125391. /**
  125392. * Implementation of the KTX Texture Loader.
  125393. * @hidden
  125394. */
  125395. export class _KTXTextureLoader implements IInternalTextureLoader {
  125396. /**
  125397. * Defines wether the loader supports cascade loading the different faces.
  125398. */
  125399. readonly supportCascades: boolean;
  125400. /**
  125401. * This returns if the loader support the current file information.
  125402. * @param extension defines the file extension of the file being loaded
  125403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125404. * @param fallback defines the fallback internal texture if any
  125405. * @param isBase64 defines whether the texture is encoded as a base64
  125406. * @param isBuffer defines whether the texture data are stored as a buffer
  125407. * @returns true if the loader can load the specified file
  125408. */
  125409. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125410. /**
  125411. * Transform the url before loading if required.
  125412. * @param rootUrl the url of the texture
  125413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125414. * @returns the transformed texture
  125415. */
  125416. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125417. /**
  125418. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125419. * @param rootUrl the url of the texture
  125420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125421. * @returns the fallback texture
  125422. */
  125423. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125424. /**
  125425. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125426. * @param data contains the texture data
  125427. * @param texture defines the BabylonJS internal texture
  125428. * @param createPolynomials will be true if polynomials have been requested
  125429. * @param onLoad defines the callback to trigger once the texture is ready
  125430. * @param onError defines the callback to trigger in case of error
  125431. */
  125432. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125433. /**
  125434. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125435. * @param data contains the texture data
  125436. * @param texture defines the BabylonJS internal texture
  125437. * @param callback defines the method to call once ready to upload
  125438. */
  125439. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125440. }
  125441. }
  125442. declare module BABYLON {
  125443. /** @hidden */
  125444. export var _forceSceneHelpersToBundle: boolean;
  125445. interface Scene {
  125446. /**
  125447. * Creates a default light for the scene.
  125448. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125449. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125450. */
  125451. createDefaultLight(replace?: boolean): void;
  125452. /**
  125453. * Creates a default camera for the scene.
  125454. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125455. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125456. * @param replace has default false, when true replaces the active camera in the scene
  125457. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125458. */
  125459. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125460. /**
  125461. * Creates a default camera and a default light.
  125462. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125463. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125464. * @param replace has the default false, when true replaces the active camera/light in the scene
  125465. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125466. */
  125467. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125468. /**
  125469. * Creates a new sky box
  125470. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125471. * @param environmentTexture defines the texture to use as environment texture
  125472. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125473. * @param scale defines the overall scale of the skybox
  125474. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125475. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125476. * @returns a new mesh holding the sky box
  125477. */
  125478. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125479. /**
  125480. * Creates a new environment
  125481. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125482. * @param options defines the options you can use to configure the environment
  125483. * @returns the new EnvironmentHelper
  125484. */
  125485. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125486. /**
  125487. * Creates a new VREXperienceHelper
  125488. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125489. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125490. * @returns a new VREXperienceHelper
  125491. */
  125492. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125493. /**
  125494. * Creates a new WebXRDefaultExperience
  125495. * @see http://doc.babylonjs.com/how_to/webxr
  125496. * @param options experience options
  125497. * @returns a promise for a new WebXRDefaultExperience
  125498. */
  125499. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125500. }
  125501. }
  125502. declare module BABYLON {
  125503. /**
  125504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125508. */
  125509. export class VideoDome extends TransformNode {
  125510. /**
  125511. * Define the video source as a Monoscopic panoramic 360 video.
  125512. */
  125513. static readonly MODE_MONOSCOPIC: number;
  125514. /**
  125515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125516. */
  125517. static readonly MODE_TOPBOTTOM: number;
  125518. /**
  125519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125520. */
  125521. static readonly MODE_SIDEBYSIDE: number;
  125522. private _halfDome;
  125523. private _useDirectMapping;
  125524. /**
  125525. * The video texture being displayed on the sphere
  125526. */
  125527. protected _videoTexture: VideoTexture;
  125528. /**
  125529. * Gets the video texture being displayed on the sphere
  125530. */
  125531. get videoTexture(): VideoTexture;
  125532. /**
  125533. * The skybox material
  125534. */
  125535. protected _material: BackgroundMaterial;
  125536. /**
  125537. * The surface used for the skybox
  125538. */
  125539. protected _mesh: Mesh;
  125540. /**
  125541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125542. */
  125543. private _halfDomeMask;
  125544. /**
  125545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125546. * Also see the options.resolution property.
  125547. */
  125548. get fovMultiplier(): number;
  125549. set fovMultiplier(value: number);
  125550. private _videoMode;
  125551. /**
  125552. * Gets or set the current video mode for the video. It can be:
  125553. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125554. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125555. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125556. */
  125557. get videoMode(): number;
  125558. set videoMode(value: number);
  125559. /**
  125560. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125561. *
  125562. */
  125563. get halfDome(): boolean;
  125564. /**
  125565. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125566. */
  125567. set halfDome(enabled: boolean);
  125568. /**
  125569. * Oberserver used in Stereoscopic VR Mode.
  125570. */
  125571. private _onBeforeCameraRenderObserver;
  125572. /**
  125573. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125574. * @param name Element's name, child elements will append suffixes for their own names.
  125575. * @param urlsOrVideo defines the url(s) or the video element to use
  125576. * @param options An object containing optional or exposed sub element properties
  125577. */
  125578. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125579. resolution?: number;
  125580. clickToPlay?: boolean;
  125581. autoPlay?: boolean;
  125582. loop?: boolean;
  125583. size?: number;
  125584. poster?: string;
  125585. faceForward?: boolean;
  125586. useDirectMapping?: boolean;
  125587. halfDomeMode?: boolean;
  125588. }, scene: Scene);
  125589. private _changeVideoMode;
  125590. /**
  125591. * Releases resources associated with this node.
  125592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125594. */
  125595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125596. }
  125597. }
  125598. declare module BABYLON {
  125599. /**
  125600. * This class can be used to get instrumentation data from a Babylon engine
  125601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125602. */
  125603. export class EngineInstrumentation implements IDisposable {
  125604. /**
  125605. * Define the instrumented engine.
  125606. */
  125607. engine: Engine;
  125608. private _captureGPUFrameTime;
  125609. private _gpuFrameTimeToken;
  125610. private _gpuFrameTime;
  125611. private _captureShaderCompilationTime;
  125612. private _shaderCompilationTime;
  125613. private _onBeginFrameObserver;
  125614. private _onEndFrameObserver;
  125615. private _onBeforeShaderCompilationObserver;
  125616. private _onAfterShaderCompilationObserver;
  125617. /**
  125618. * Gets the perf counter used for GPU frame time
  125619. */
  125620. get gpuFrameTimeCounter(): PerfCounter;
  125621. /**
  125622. * Gets the GPU frame time capture status
  125623. */
  125624. get captureGPUFrameTime(): boolean;
  125625. /**
  125626. * Enable or disable the GPU frame time capture
  125627. */
  125628. set captureGPUFrameTime(value: boolean);
  125629. /**
  125630. * Gets the perf counter used for shader compilation time
  125631. */
  125632. get shaderCompilationTimeCounter(): PerfCounter;
  125633. /**
  125634. * Gets the shader compilation time capture status
  125635. */
  125636. get captureShaderCompilationTime(): boolean;
  125637. /**
  125638. * Enable or disable the shader compilation time capture
  125639. */
  125640. set captureShaderCompilationTime(value: boolean);
  125641. /**
  125642. * Instantiates a new engine instrumentation.
  125643. * This class can be used to get instrumentation data from a Babylon engine
  125644. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125645. * @param engine Defines the engine to instrument
  125646. */
  125647. constructor(
  125648. /**
  125649. * Define the instrumented engine.
  125650. */
  125651. engine: Engine);
  125652. /**
  125653. * Dispose and release associated resources.
  125654. */
  125655. dispose(): void;
  125656. }
  125657. }
  125658. declare module BABYLON {
  125659. /**
  125660. * This class can be used to get instrumentation data from a Babylon engine
  125661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125662. */
  125663. export class SceneInstrumentation implements IDisposable {
  125664. /**
  125665. * Defines the scene to instrument
  125666. */
  125667. scene: Scene;
  125668. private _captureActiveMeshesEvaluationTime;
  125669. private _activeMeshesEvaluationTime;
  125670. private _captureRenderTargetsRenderTime;
  125671. private _renderTargetsRenderTime;
  125672. private _captureFrameTime;
  125673. private _frameTime;
  125674. private _captureRenderTime;
  125675. private _renderTime;
  125676. private _captureInterFrameTime;
  125677. private _interFrameTime;
  125678. private _captureParticlesRenderTime;
  125679. private _particlesRenderTime;
  125680. private _captureSpritesRenderTime;
  125681. private _spritesRenderTime;
  125682. private _capturePhysicsTime;
  125683. private _physicsTime;
  125684. private _captureAnimationsTime;
  125685. private _animationsTime;
  125686. private _captureCameraRenderTime;
  125687. private _cameraRenderTime;
  125688. private _onBeforeActiveMeshesEvaluationObserver;
  125689. private _onAfterActiveMeshesEvaluationObserver;
  125690. private _onBeforeRenderTargetsRenderObserver;
  125691. private _onAfterRenderTargetsRenderObserver;
  125692. private _onAfterRenderObserver;
  125693. private _onBeforeDrawPhaseObserver;
  125694. private _onAfterDrawPhaseObserver;
  125695. private _onBeforeAnimationsObserver;
  125696. private _onBeforeParticlesRenderingObserver;
  125697. private _onAfterParticlesRenderingObserver;
  125698. private _onBeforeSpritesRenderingObserver;
  125699. private _onAfterSpritesRenderingObserver;
  125700. private _onBeforePhysicsObserver;
  125701. private _onAfterPhysicsObserver;
  125702. private _onAfterAnimationsObserver;
  125703. private _onBeforeCameraRenderObserver;
  125704. private _onAfterCameraRenderObserver;
  125705. /**
  125706. * Gets the perf counter used for active meshes evaluation time
  125707. */
  125708. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125709. /**
  125710. * Gets the active meshes evaluation time capture status
  125711. */
  125712. get captureActiveMeshesEvaluationTime(): boolean;
  125713. /**
  125714. * Enable or disable the active meshes evaluation time capture
  125715. */
  125716. set captureActiveMeshesEvaluationTime(value: boolean);
  125717. /**
  125718. * Gets the perf counter used for render targets render time
  125719. */
  125720. get renderTargetsRenderTimeCounter(): PerfCounter;
  125721. /**
  125722. * Gets the render targets render time capture status
  125723. */
  125724. get captureRenderTargetsRenderTime(): boolean;
  125725. /**
  125726. * Enable or disable the render targets render time capture
  125727. */
  125728. set captureRenderTargetsRenderTime(value: boolean);
  125729. /**
  125730. * Gets the perf counter used for particles render time
  125731. */
  125732. get particlesRenderTimeCounter(): PerfCounter;
  125733. /**
  125734. * Gets the particles render time capture status
  125735. */
  125736. get captureParticlesRenderTime(): boolean;
  125737. /**
  125738. * Enable or disable the particles render time capture
  125739. */
  125740. set captureParticlesRenderTime(value: boolean);
  125741. /**
  125742. * Gets the perf counter used for sprites render time
  125743. */
  125744. get spritesRenderTimeCounter(): PerfCounter;
  125745. /**
  125746. * Gets the sprites render time capture status
  125747. */
  125748. get captureSpritesRenderTime(): boolean;
  125749. /**
  125750. * Enable or disable the sprites render time capture
  125751. */
  125752. set captureSpritesRenderTime(value: boolean);
  125753. /**
  125754. * Gets the perf counter used for physics time
  125755. */
  125756. get physicsTimeCounter(): PerfCounter;
  125757. /**
  125758. * Gets the physics time capture status
  125759. */
  125760. get capturePhysicsTime(): boolean;
  125761. /**
  125762. * Enable or disable the physics time capture
  125763. */
  125764. set capturePhysicsTime(value: boolean);
  125765. /**
  125766. * Gets the perf counter used for animations time
  125767. */
  125768. get animationsTimeCounter(): PerfCounter;
  125769. /**
  125770. * Gets the animations time capture status
  125771. */
  125772. get captureAnimationsTime(): boolean;
  125773. /**
  125774. * Enable or disable the animations time capture
  125775. */
  125776. set captureAnimationsTime(value: boolean);
  125777. /**
  125778. * Gets the perf counter used for frame time capture
  125779. */
  125780. get frameTimeCounter(): PerfCounter;
  125781. /**
  125782. * Gets the frame time capture status
  125783. */
  125784. get captureFrameTime(): boolean;
  125785. /**
  125786. * Enable or disable the frame time capture
  125787. */
  125788. set captureFrameTime(value: boolean);
  125789. /**
  125790. * Gets the perf counter used for inter-frames time capture
  125791. */
  125792. get interFrameTimeCounter(): PerfCounter;
  125793. /**
  125794. * Gets the inter-frames time capture status
  125795. */
  125796. get captureInterFrameTime(): boolean;
  125797. /**
  125798. * Enable or disable the inter-frames time capture
  125799. */
  125800. set captureInterFrameTime(value: boolean);
  125801. /**
  125802. * Gets the perf counter used for render time capture
  125803. */
  125804. get renderTimeCounter(): PerfCounter;
  125805. /**
  125806. * Gets the render time capture status
  125807. */
  125808. get captureRenderTime(): boolean;
  125809. /**
  125810. * Enable or disable the render time capture
  125811. */
  125812. set captureRenderTime(value: boolean);
  125813. /**
  125814. * Gets the perf counter used for camera render time capture
  125815. */
  125816. get cameraRenderTimeCounter(): PerfCounter;
  125817. /**
  125818. * Gets the camera render time capture status
  125819. */
  125820. get captureCameraRenderTime(): boolean;
  125821. /**
  125822. * Enable or disable the camera render time capture
  125823. */
  125824. set captureCameraRenderTime(value: boolean);
  125825. /**
  125826. * Gets the perf counter used for draw calls
  125827. */
  125828. get drawCallsCounter(): PerfCounter;
  125829. /**
  125830. * Instantiates a new scene instrumentation.
  125831. * This class can be used to get instrumentation data from a Babylon engine
  125832. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125833. * @param scene Defines the scene to instrument
  125834. */
  125835. constructor(
  125836. /**
  125837. * Defines the scene to instrument
  125838. */
  125839. scene: Scene);
  125840. /**
  125841. * Dispose and release associated resources.
  125842. */
  125843. dispose(): void;
  125844. }
  125845. }
  125846. declare module BABYLON {
  125847. /** @hidden */
  125848. export var glowMapGenerationPixelShader: {
  125849. name: string;
  125850. shader: string;
  125851. };
  125852. }
  125853. declare module BABYLON {
  125854. /** @hidden */
  125855. export var glowMapGenerationVertexShader: {
  125856. name: string;
  125857. shader: string;
  125858. };
  125859. }
  125860. declare module BABYLON {
  125861. /**
  125862. * Effect layer options. This helps customizing the behaviour
  125863. * of the effect layer.
  125864. */
  125865. export interface IEffectLayerOptions {
  125866. /**
  125867. * Multiplication factor apply to the canvas size to compute the render target size
  125868. * used to generated the objects (the smaller the faster).
  125869. */
  125870. mainTextureRatio: number;
  125871. /**
  125872. * Enforces a fixed size texture to ensure effect stability across devices.
  125873. */
  125874. mainTextureFixedSize?: number;
  125875. /**
  125876. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125877. */
  125878. alphaBlendingMode: number;
  125879. /**
  125880. * The camera attached to the layer.
  125881. */
  125882. camera: Nullable<Camera>;
  125883. /**
  125884. * The rendering group to draw the layer in.
  125885. */
  125886. renderingGroupId: number;
  125887. }
  125888. /**
  125889. * The effect layer Helps adding post process effect blended with the main pass.
  125890. *
  125891. * This can be for instance use to generate glow or higlight effects on the scene.
  125892. *
  125893. * The effect layer class can not be used directly and is intented to inherited from to be
  125894. * customized per effects.
  125895. */
  125896. export abstract class EffectLayer {
  125897. private _vertexBuffers;
  125898. private _indexBuffer;
  125899. private _cachedDefines;
  125900. private _effectLayerMapGenerationEffect;
  125901. private _effectLayerOptions;
  125902. private _mergeEffect;
  125903. protected _scene: Scene;
  125904. protected _engine: Engine;
  125905. protected _maxSize: number;
  125906. protected _mainTextureDesiredSize: ISize;
  125907. protected _mainTexture: RenderTargetTexture;
  125908. protected _shouldRender: boolean;
  125909. protected _postProcesses: PostProcess[];
  125910. protected _textures: BaseTexture[];
  125911. protected _emissiveTextureAndColor: {
  125912. texture: Nullable<BaseTexture>;
  125913. color: Color4;
  125914. };
  125915. /**
  125916. * The name of the layer
  125917. */
  125918. name: string;
  125919. /**
  125920. * The clear color of the texture used to generate the glow map.
  125921. */
  125922. neutralColor: Color4;
  125923. /**
  125924. * Specifies whether the highlight layer is enabled or not.
  125925. */
  125926. isEnabled: boolean;
  125927. /**
  125928. * Gets the camera attached to the layer.
  125929. */
  125930. get camera(): Nullable<Camera>;
  125931. /**
  125932. * Gets the rendering group id the layer should render in.
  125933. */
  125934. get renderingGroupId(): number;
  125935. set renderingGroupId(renderingGroupId: number);
  125936. /**
  125937. * An event triggered when the effect layer has been disposed.
  125938. */
  125939. onDisposeObservable: Observable<EffectLayer>;
  125940. /**
  125941. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125942. */
  125943. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125944. /**
  125945. * An event triggered when the generated texture is being merged in the scene.
  125946. */
  125947. onBeforeComposeObservable: Observable<EffectLayer>;
  125948. /**
  125949. * An event triggered when the mesh is rendered into the effect render target.
  125950. */
  125951. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125952. /**
  125953. * An event triggered after the mesh has been rendered into the effect render target.
  125954. */
  125955. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125956. /**
  125957. * An event triggered when the generated texture has been merged in the scene.
  125958. */
  125959. onAfterComposeObservable: Observable<EffectLayer>;
  125960. /**
  125961. * An event triggered when the efffect layer changes its size.
  125962. */
  125963. onSizeChangedObservable: Observable<EffectLayer>;
  125964. /** @hidden */
  125965. static _SceneComponentInitialization: (scene: Scene) => void;
  125966. /**
  125967. * Instantiates a new effect Layer and references it in the scene.
  125968. * @param name The name of the layer
  125969. * @param scene The scene to use the layer in
  125970. */
  125971. constructor(
  125972. /** The Friendly of the effect in the scene */
  125973. name: string, scene: Scene);
  125974. /**
  125975. * Get the effect name of the layer.
  125976. * @return The effect name
  125977. */
  125978. abstract getEffectName(): string;
  125979. /**
  125980. * Checks for the readiness of the element composing the layer.
  125981. * @param subMesh the mesh to check for
  125982. * @param useInstances specify whether or not to use instances to render the mesh
  125983. * @return true if ready otherwise, false
  125984. */
  125985. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125986. /**
  125987. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125988. * @returns true if the effect requires stencil during the main canvas render pass.
  125989. */
  125990. abstract needStencil(): boolean;
  125991. /**
  125992. * Create the merge effect. This is the shader use to blit the information back
  125993. * to the main canvas at the end of the scene rendering.
  125994. * @returns The effect containing the shader used to merge the effect on the main canvas
  125995. */
  125996. protected abstract _createMergeEffect(): Effect;
  125997. /**
  125998. * Creates the render target textures and post processes used in the effect layer.
  125999. */
  126000. protected abstract _createTextureAndPostProcesses(): void;
  126001. /**
  126002. * Implementation specific of rendering the generating effect on the main canvas.
  126003. * @param effect The effect used to render through
  126004. */
  126005. protected abstract _internalRender(effect: Effect): void;
  126006. /**
  126007. * Sets the required values for both the emissive texture and and the main color.
  126008. */
  126009. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126010. /**
  126011. * Free any resources and references associated to a mesh.
  126012. * Internal use
  126013. * @param mesh The mesh to free.
  126014. */
  126015. abstract _disposeMesh(mesh: Mesh): void;
  126016. /**
  126017. * Serializes this layer (Glow or Highlight for example)
  126018. * @returns a serialized layer object
  126019. */
  126020. abstract serialize?(): any;
  126021. /**
  126022. * Initializes the effect layer with the required options.
  126023. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126024. */
  126025. protected _init(options: Partial<IEffectLayerOptions>): void;
  126026. /**
  126027. * Generates the index buffer of the full screen quad blending to the main canvas.
  126028. */
  126029. private _generateIndexBuffer;
  126030. /**
  126031. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126032. */
  126033. private _generateVertexBuffer;
  126034. /**
  126035. * Sets the main texture desired size which is the closest power of two
  126036. * of the engine canvas size.
  126037. */
  126038. private _setMainTextureSize;
  126039. /**
  126040. * Creates the main texture for the effect layer.
  126041. */
  126042. protected _createMainTexture(): void;
  126043. /**
  126044. * Adds specific effects defines.
  126045. * @param defines The defines to add specifics to.
  126046. */
  126047. protected _addCustomEffectDefines(defines: string[]): void;
  126048. /**
  126049. * Checks for the readiness of the element composing the layer.
  126050. * @param subMesh the mesh to check for
  126051. * @param useInstances specify whether or not to use instances to render the mesh
  126052. * @param emissiveTexture the associated emissive texture used to generate the glow
  126053. * @return true if ready otherwise, false
  126054. */
  126055. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126056. /**
  126057. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126058. */
  126059. render(): void;
  126060. /**
  126061. * Determine if a given mesh will be used in the current effect.
  126062. * @param mesh mesh to test
  126063. * @returns true if the mesh will be used
  126064. */
  126065. hasMesh(mesh: AbstractMesh): boolean;
  126066. /**
  126067. * Returns true if the layer contains information to display, otherwise false.
  126068. * @returns true if the glow layer should be rendered
  126069. */
  126070. shouldRender(): boolean;
  126071. /**
  126072. * Returns true if the mesh should render, otherwise false.
  126073. * @param mesh The mesh to render
  126074. * @returns true if it should render otherwise false
  126075. */
  126076. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126077. /**
  126078. * Returns true if the mesh can be rendered, otherwise false.
  126079. * @param mesh The mesh to render
  126080. * @param material The material used on the mesh
  126081. * @returns true if it can be rendered otherwise false
  126082. */
  126083. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126084. /**
  126085. * Returns true if the mesh should render, otherwise false.
  126086. * @param mesh The mesh to render
  126087. * @returns true if it should render otherwise false
  126088. */
  126089. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126090. /**
  126091. * Renders the submesh passed in parameter to the generation map.
  126092. */
  126093. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126094. /**
  126095. * Defines whether the current material of the mesh should be use to render the effect.
  126096. * @param mesh defines the current mesh to render
  126097. */
  126098. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126099. /**
  126100. * Rebuild the required buffers.
  126101. * @hidden Internal use only.
  126102. */
  126103. _rebuild(): void;
  126104. /**
  126105. * Dispose only the render target textures and post process.
  126106. */
  126107. private _disposeTextureAndPostProcesses;
  126108. /**
  126109. * Dispose the highlight layer and free resources.
  126110. */
  126111. dispose(): void;
  126112. /**
  126113. * Gets the class name of the effect layer
  126114. * @returns the string with the class name of the effect layer
  126115. */
  126116. getClassName(): string;
  126117. /**
  126118. * Creates an effect layer from parsed effect layer data
  126119. * @param parsedEffectLayer defines effect layer data
  126120. * @param scene defines the current scene
  126121. * @param rootUrl defines the root URL containing the effect layer information
  126122. * @returns a parsed effect Layer
  126123. */
  126124. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126125. }
  126126. }
  126127. declare module BABYLON {
  126128. interface AbstractScene {
  126129. /**
  126130. * The list of effect layers (highlights/glow) added to the scene
  126131. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126132. * @see http://doc.babylonjs.com/how_to/glow_layer
  126133. */
  126134. effectLayers: Array<EffectLayer>;
  126135. /**
  126136. * Removes the given effect layer from this scene.
  126137. * @param toRemove defines the effect layer to remove
  126138. * @returns the index of the removed effect layer
  126139. */
  126140. removeEffectLayer(toRemove: EffectLayer): number;
  126141. /**
  126142. * Adds the given effect layer to this scene
  126143. * @param newEffectLayer defines the effect layer to add
  126144. */
  126145. addEffectLayer(newEffectLayer: EffectLayer): void;
  126146. }
  126147. /**
  126148. * Defines the layer scene component responsible to manage any effect layers
  126149. * in a given scene.
  126150. */
  126151. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126152. /**
  126153. * The component name helpfull to identify the component in the list of scene components.
  126154. */
  126155. readonly name: string;
  126156. /**
  126157. * The scene the component belongs to.
  126158. */
  126159. scene: Scene;
  126160. private _engine;
  126161. private _renderEffects;
  126162. private _needStencil;
  126163. private _previousStencilState;
  126164. /**
  126165. * Creates a new instance of the component for the given scene
  126166. * @param scene Defines the scene to register the component in
  126167. */
  126168. constructor(scene: Scene);
  126169. /**
  126170. * Registers the component in a given scene
  126171. */
  126172. register(): void;
  126173. /**
  126174. * Rebuilds the elements related to this component in case of
  126175. * context lost for instance.
  126176. */
  126177. rebuild(): void;
  126178. /**
  126179. * Serializes the component data to the specified json object
  126180. * @param serializationObject The object to serialize to
  126181. */
  126182. serialize(serializationObject: any): void;
  126183. /**
  126184. * Adds all the elements from the container to the scene
  126185. * @param container the container holding the elements
  126186. */
  126187. addFromContainer(container: AbstractScene): void;
  126188. /**
  126189. * Removes all the elements in the container from the scene
  126190. * @param container contains the elements to remove
  126191. * @param dispose if the removed element should be disposed (default: false)
  126192. */
  126193. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126194. /**
  126195. * Disposes the component and the associated ressources.
  126196. */
  126197. dispose(): void;
  126198. private _isReadyForMesh;
  126199. private _renderMainTexture;
  126200. private _setStencil;
  126201. private _setStencilBack;
  126202. private _draw;
  126203. private _drawCamera;
  126204. private _drawRenderingGroup;
  126205. }
  126206. }
  126207. declare module BABYLON {
  126208. /** @hidden */
  126209. export var glowMapMergePixelShader: {
  126210. name: string;
  126211. shader: string;
  126212. };
  126213. }
  126214. declare module BABYLON {
  126215. /** @hidden */
  126216. export var glowMapMergeVertexShader: {
  126217. name: string;
  126218. shader: string;
  126219. };
  126220. }
  126221. declare module BABYLON {
  126222. interface AbstractScene {
  126223. /**
  126224. * Return a the first highlight layer of the scene with a given name.
  126225. * @param name The name of the highlight layer to look for.
  126226. * @return The highlight layer if found otherwise null.
  126227. */
  126228. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126229. }
  126230. /**
  126231. * Glow layer options. This helps customizing the behaviour
  126232. * of the glow layer.
  126233. */
  126234. export interface IGlowLayerOptions {
  126235. /**
  126236. * Multiplication factor apply to the canvas size to compute the render target size
  126237. * used to generated the glowing objects (the smaller the faster).
  126238. */
  126239. mainTextureRatio: number;
  126240. /**
  126241. * Enforces a fixed size texture to ensure resize independant blur.
  126242. */
  126243. mainTextureFixedSize?: number;
  126244. /**
  126245. * How big is the kernel of the blur texture.
  126246. */
  126247. blurKernelSize: number;
  126248. /**
  126249. * The camera attached to the layer.
  126250. */
  126251. camera: Nullable<Camera>;
  126252. /**
  126253. * Enable MSAA by chosing the number of samples.
  126254. */
  126255. mainTextureSamples?: number;
  126256. /**
  126257. * The rendering group to draw the layer in.
  126258. */
  126259. renderingGroupId: number;
  126260. }
  126261. /**
  126262. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126263. *
  126264. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126265. *
  126266. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126267. */
  126268. export class GlowLayer extends EffectLayer {
  126269. /**
  126270. * Effect Name of the layer.
  126271. */
  126272. static readonly EffectName: string;
  126273. /**
  126274. * The default blur kernel size used for the glow.
  126275. */
  126276. static DefaultBlurKernelSize: number;
  126277. /**
  126278. * The default texture size ratio used for the glow.
  126279. */
  126280. static DefaultTextureRatio: number;
  126281. /**
  126282. * Sets the kernel size of the blur.
  126283. */
  126284. set blurKernelSize(value: number);
  126285. /**
  126286. * Gets the kernel size of the blur.
  126287. */
  126288. get blurKernelSize(): number;
  126289. /**
  126290. * Sets the glow intensity.
  126291. */
  126292. set intensity(value: number);
  126293. /**
  126294. * Gets the glow intensity.
  126295. */
  126296. get intensity(): number;
  126297. private _options;
  126298. private _intensity;
  126299. private _horizontalBlurPostprocess1;
  126300. private _verticalBlurPostprocess1;
  126301. private _horizontalBlurPostprocess2;
  126302. private _verticalBlurPostprocess2;
  126303. private _blurTexture1;
  126304. private _blurTexture2;
  126305. private _postProcesses1;
  126306. private _postProcesses2;
  126307. private _includedOnlyMeshes;
  126308. private _excludedMeshes;
  126309. private _meshesUsingTheirOwnMaterials;
  126310. /**
  126311. * Callback used to let the user override the color selection on a per mesh basis
  126312. */
  126313. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126314. /**
  126315. * Callback used to let the user override the texture selection on a per mesh basis
  126316. */
  126317. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126318. /**
  126319. * Instantiates a new glow Layer and references it to the scene.
  126320. * @param name The name of the layer
  126321. * @param scene The scene to use the layer in
  126322. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126323. */
  126324. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126325. /**
  126326. * Get the effect name of the layer.
  126327. * @return The effect name
  126328. */
  126329. getEffectName(): string;
  126330. /**
  126331. * Create the merge effect. This is the shader use to blit the information back
  126332. * to the main canvas at the end of the scene rendering.
  126333. */
  126334. protected _createMergeEffect(): Effect;
  126335. /**
  126336. * Creates the render target textures and post processes used in the glow layer.
  126337. */
  126338. protected _createTextureAndPostProcesses(): void;
  126339. /**
  126340. * Checks for the readiness of the element composing the layer.
  126341. * @param subMesh the mesh to check for
  126342. * @param useInstances specify wether or not to use instances to render the mesh
  126343. * @param emissiveTexture the associated emissive texture used to generate the glow
  126344. * @return true if ready otherwise, false
  126345. */
  126346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126347. /**
  126348. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126349. */
  126350. needStencil(): boolean;
  126351. /**
  126352. * Returns true if the mesh can be rendered, otherwise false.
  126353. * @param mesh The mesh to render
  126354. * @param material The material used on the mesh
  126355. * @returns true if it can be rendered otherwise false
  126356. */
  126357. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126358. /**
  126359. * Implementation specific of rendering the generating effect on the main canvas.
  126360. * @param effect The effect used to render through
  126361. */
  126362. protected _internalRender(effect: Effect): void;
  126363. /**
  126364. * Sets the required values for both the emissive texture and and the main color.
  126365. */
  126366. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126367. /**
  126368. * Returns true if the mesh should render, otherwise false.
  126369. * @param mesh The mesh to render
  126370. * @returns true if it should render otherwise false
  126371. */
  126372. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126373. /**
  126374. * Adds specific effects defines.
  126375. * @param defines The defines to add specifics to.
  126376. */
  126377. protected _addCustomEffectDefines(defines: string[]): void;
  126378. /**
  126379. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126380. * @param mesh The mesh to exclude from the glow layer
  126381. */
  126382. addExcludedMesh(mesh: Mesh): void;
  126383. /**
  126384. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126385. * @param mesh The mesh to remove
  126386. */
  126387. removeExcludedMesh(mesh: Mesh): void;
  126388. /**
  126389. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126390. * @param mesh The mesh to include in the glow layer
  126391. */
  126392. addIncludedOnlyMesh(mesh: Mesh): void;
  126393. /**
  126394. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126395. * @param mesh The mesh to remove
  126396. */
  126397. removeIncludedOnlyMesh(mesh: Mesh): void;
  126398. /**
  126399. * Determine if a given mesh will be used in the glow layer
  126400. * @param mesh The mesh to test
  126401. * @returns true if the mesh will be highlighted by the current glow layer
  126402. */
  126403. hasMesh(mesh: AbstractMesh): boolean;
  126404. /**
  126405. * Defines whether the current material of the mesh should be use to render the effect.
  126406. * @param mesh defines the current mesh to render
  126407. */
  126408. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126409. /**
  126410. * Add a mesh to be rendered through its own material and not with emissive only.
  126411. * @param mesh The mesh for which we need to use its material
  126412. */
  126413. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126414. /**
  126415. * Remove a mesh from being rendered through its own material and not with emissive only.
  126416. * @param mesh The mesh for which we need to not use its material
  126417. */
  126418. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126419. /**
  126420. * Free any resources and references associated to a mesh.
  126421. * Internal use
  126422. * @param mesh The mesh to free.
  126423. * @hidden
  126424. */
  126425. _disposeMesh(mesh: Mesh): void;
  126426. /**
  126427. * Gets the class name of the effect layer
  126428. * @returns the string with the class name of the effect layer
  126429. */
  126430. getClassName(): string;
  126431. /**
  126432. * Serializes this glow layer
  126433. * @returns a serialized glow layer object
  126434. */
  126435. serialize(): any;
  126436. /**
  126437. * Creates a Glow Layer from parsed glow layer data
  126438. * @param parsedGlowLayer defines glow layer data
  126439. * @param scene defines the current scene
  126440. * @param rootUrl defines the root URL containing the glow layer information
  126441. * @returns a parsed Glow Layer
  126442. */
  126443. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126444. }
  126445. }
  126446. declare module BABYLON {
  126447. /** @hidden */
  126448. export var glowBlurPostProcessPixelShader: {
  126449. name: string;
  126450. shader: string;
  126451. };
  126452. }
  126453. declare module BABYLON {
  126454. interface AbstractScene {
  126455. /**
  126456. * Return a the first highlight layer of the scene with a given name.
  126457. * @param name The name of the highlight layer to look for.
  126458. * @return The highlight layer if found otherwise null.
  126459. */
  126460. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126461. }
  126462. /**
  126463. * Highlight layer options. This helps customizing the behaviour
  126464. * of the highlight layer.
  126465. */
  126466. export interface IHighlightLayerOptions {
  126467. /**
  126468. * Multiplication factor apply to the canvas size to compute the render target size
  126469. * used to generated the glowing objects (the smaller the faster).
  126470. */
  126471. mainTextureRatio: number;
  126472. /**
  126473. * Enforces a fixed size texture to ensure resize independant blur.
  126474. */
  126475. mainTextureFixedSize?: number;
  126476. /**
  126477. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126478. * of the picture to blur (the smaller the faster).
  126479. */
  126480. blurTextureSizeRatio: number;
  126481. /**
  126482. * How big in texel of the blur texture is the vertical blur.
  126483. */
  126484. blurVerticalSize: number;
  126485. /**
  126486. * How big in texel of the blur texture is the horizontal blur.
  126487. */
  126488. blurHorizontalSize: number;
  126489. /**
  126490. * Alpha blending mode used to apply the blur. Default is combine.
  126491. */
  126492. alphaBlendingMode: number;
  126493. /**
  126494. * The camera attached to the layer.
  126495. */
  126496. camera: Nullable<Camera>;
  126497. /**
  126498. * Should we display highlight as a solid stroke?
  126499. */
  126500. isStroke?: boolean;
  126501. /**
  126502. * The rendering group to draw the layer in.
  126503. */
  126504. renderingGroupId: number;
  126505. }
  126506. /**
  126507. * The highlight layer Helps adding a glow effect around a mesh.
  126508. *
  126509. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126510. * glowy meshes to your scene.
  126511. *
  126512. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126513. */
  126514. export class HighlightLayer extends EffectLayer {
  126515. name: string;
  126516. /**
  126517. * Effect Name of the highlight layer.
  126518. */
  126519. static readonly EffectName: string;
  126520. /**
  126521. * The neutral color used during the preparation of the glow effect.
  126522. * This is black by default as the blend operation is a blend operation.
  126523. */
  126524. static NeutralColor: Color4;
  126525. /**
  126526. * Stencil value used for glowing meshes.
  126527. */
  126528. static GlowingMeshStencilReference: number;
  126529. /**
  126530. * Stencil value used for the other meshes in the scene.
  126531. */
  126532. static NormalMeshStencilReference: number;
  126533. /**
  126534. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126535. */
  126536. innerGlow: boolean;
  126537. /**
  126538. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126539. */
  126540. outerGlow: boolean;
  126541. /**
  126542. * Specifies the horizontal size of the blur.
  126543. */
  126544. set blurHorizontalSize(value: number);
  126545. /**
  126546. * Specifies the vertical size of the blur.
  126547. */
  126548. set blurVerticalSize(value: number);
  126549. /**
  126550. * Gets the horizontal size of the blur.
  126551. */
  126552. get blurHorizontalSize(): number;
  126553. /**
  126554. * Gets the vertical size of the blur.
  126555. */
  126556. get blurVerticalSize(): number;
  126557. /**
  126558. * An event triggered when the highlight layer is being blurred.
  126559. */
  126560. onBeforeBlurObservable: Observable<HighlightLayer>;
  126561. /**
  126562. * An event triggered when the highlight layer has been blurred.
  126563. */
  126564. onAfterBlurObservable: Observable<HighlightLayer>;
  126565. private _instanceGlowingMeshStencilReference;
  126566. private _options;
  126567. private _downSamplePostprocess;
  126568. private _horizontalBlurPostprocess;
  126569. private _verticalBlurPostprocess;
  126570. private _blurTexture;
  126571. private _meshes;
  126572. private _excludedMeshes;
  126573. /**
  126574. * Instantiates a new highlight Layer and references it to the scene..
  126575. * @param name The name of the layer
  126576. * @param scene The scene to use the layer in
  126577. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126578. */
  126579. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126580. /**
  126581. * Get the effect name of the layer.
  126582. * @return The effect name
  126583. */
  126584. getEffectName(): string;
  126585. /**
  126586. * Create the merge effect. This is the shader use to blit the information back
  126587. * to the main canvas at the end of the scene rendering.
  126588. */
  126589. protected _createMergeEffect(): Effect;
  126590. /**
  126591. * Creates the render target textures and post processes used in the highlight layer.
  126592. */
  126593. protected _createTextureAndPostProcesses(): void;
  126594. /**
  126595. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126596. */
  126597. needStencil(): boolean;
  126598. /**
  126599. * Checks for the readiness of the element composing the layer.
  126600. * @param subMesh the mesh to check for
  126601. * @param useInstances specify wether or not to use instances to render the mesh
  126602. * @param emissiveTexture the associated emissive texture used to generate the glow
  126603. * @return true if ready otherwise, false
  126604. */
  126605. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126606. /**
  126607. * Implementation specific of rendering the generating effect on the main canvas.
  126608. * @param effect The effect used to render through
  126609. */
  126610. protected _internalRender(effect: Effect): void;
  126611. /**
  126612. * Returns true if the layer contains information to display, otherwise false.
  126613. */
  126614. shouldRender(): boolean;
  126615. /**
  126616. * Returns true if the mesh should render, otherwise false.
  126617. * @param mesh The mesh to render
  126618. * @returns true if it should render otherwise false
  126619. */
  126620. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126621. /**
  126622. * Sets the required values for both the emissive texture and and the main color.
  126623. */
  126624. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126625. /**
  126626. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126627. * @param mesh The mesh to exclude from the highlight layer
  126628. */
  126629. addExcludedMesh(mesh: Mesh): void;
  126630. /**
  126631. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126632. * @param mesh The mesh to highlight
  126633. */
  126634. removeExcludedMesh(mesh: Mesh): void;
  126635. /**
  126636. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126637. * @param mesh mesh to test
  126638. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126639. */
  126640. hasMesh(mesh: AbstractMesh): boolean;
  126641. /**
  126642. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126643. * @param mesh The mesh to highlight
  126644. * @param color The color of the highlight
  126645. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126646. */
  126647. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126648. /**
  126649. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126650. * @param mesh The mesh to highlight
  126651. */
  126652. removeMesh(mesh: Mesh): void;
  126653. /**
  126654. * Force the stencil to the normal expected value for none glowing parts
  126655. */
  126656. private _defaultStencilReference;
  126657. /**
  126658. * Free any resources and references associated to a mesh.
  126659. * Internal use
  126660. * @param mesh The mesh to free.
  126661. * @hidden
  126662. */
  126663. _disposeMesh(mesh: Mesh): void;
  126664. /**
  126665. * Dispose the highlight layer and free resources.
  126666. */
  126667. dispose(): void;
  126668. /**
  126669. * Gets the class name of the effect layer
  126670. * @returns the string with the class name of the effect layer
  126671. */
  126672. getClassName(): string;
  126673. /**
  126674. * Serializes this Highlight layer
  126675. * @returns a serialized Highlight layer object
  126676. */
  126677. serialize(): any;
  126678. /**
  126679. * Creates a Highlight layer from parsed Highlight layer data
  126680. * @param parsedHightlightLayer defines the Highlight layer data
  126681. * @param scene defines the current scene
  126682. * @param rootUrl defines the root URL containing the Highlight layer information
  126683. * @returns a parsed Highlight layer
  126684. */
  126685. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126686. }
  126687. }
  126688. declare module BABYLON {
  126689. interface AbstractScene {
  126690. /**
  126691. * The list of layers (background and foreground) of the scene
  126692. */
  126693. layers: Array<Layer>;
  126694. }
  126695. /**
  126696. * Defines the layer scene component responsible to manage any layers
  126697. * in a given scene.
  126698. */
  126699. export class LayerSceneComponent implements ISceneComponent {
  126700. /**
  126701. * The component name helpfull to identify the component in the list of scene components.
  126702. */
  126703. readonly name: string;
  126704. /**
  126705. * The scene the component belongs to.
  126706. */
  126707. scene: Scene;
  126708. private _engine;
  126709. /**
  126710. * Creates a new instance of the component for the given scene
  126711. * @param scene Defines the scene to register the component in
  126712. */
  126713. constructor(scene: Scene);
  126714. /**
  126715. * Registers the component in a given scene
  126716. */
  126717. register(): void;
  126718. /**
  126719. * Rebuilds the elements related to this component in case of
  126720. * context lost for instance.
  126721. */
  126722. rebuild(): void;
  126723. /**
  126724. * Disposes the component and the associated ressources.
  126725. */
  126726. dispose(): void;
  126727. private _draw;
  126728. private _drawCameraPredicate;
  126729. private _drawCameraBackground;
  126730. private _drawCameraForeground;
  126731. private _drawRenderTargetPredicate;
  126732. private _drawRenderTargetBackground;
  126733. private _drawRenderTargetForeground;
  126734. /**
  126735. * Adds all the elements from the container to the scene
  126736. * @param container the container holding the elements
  126737. */
  126738. addFromContainer(container: AbstractScene): void;
  126739. /**
  126740. * Removes all the elements in the container from the scene
  126741. * @param container contains the elements to remove
  126742. * @param dispose if the removed element should be disposed (default: false)
  126743. */
  126744. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126745. }
  126746. }
  126747. declare module BABYLON {
  126748. /** @hidden */
  126749. export var layerPixelShader: {
  126750. name: string;
  126751. shader: string;
  126752. };
  126753. }
  126754. declare module BABYLON {
  126755. /** @hidden */
  126756. export var layerVertexShader: {
  126757. name: string;
  126758. shader: string;
  126759. };
  126760. }
  126761. declare module BABYLON {
  126762. /**
  126763. * This represents a full screen 2d layer.
  126764. * This can be useful to display a picture in the background of your scene for instance.
  126765. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126766. */
  126767. export class Layer {
  126768. /**
  126769. * Define the name of the layer.
  126770. */
  126771. name: string;
  126772. /**
  126773. * Define the texture the layer should display.
  126774. */
  126775. texture: Nullable<Texture>;
  126776. /**
  126777. * Is the layer in background or foreground.
  126778. */
  126779. isBackground: boolean;
  126780. /**
  126781. * Define the color of the layer (instead of texture).
  126782. */
  126783. color: Color4;
  126784. /**
  126785. * Define the scale of the layer in order to zoom in out of the texture.
  126786. */
  126787. scale: Vector2;
  126788. /**
  126789. * Define an offset for the layer in order to shift the texture.
  126790. */
  126791. offset: Vector2;
  126792. /**
  126793. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126794. */
  126795. alphaBlendingMode: number;
  126796. /**
  126797. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126798. * Alpha test will not mix with the background color in case of transparency.
  126799. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126800. */
  126801. alphaTest: boolean;
  126802. /**
  126803. * Define a mask to restrict the layer to only some of the scene cameras.
  126804. */
  126805. layerMask: number;
  126806. /**
  126807. * Define the list of render target the layer is visible into.
  126808. */
  126809. renderTargetTextures: RenderTargetTexture[];
  126810. /**
  126811. * Define if the layer is only used in renderTarget or if it also
  126812. * renders in the main frame buffer of the canvas.
  126813. */
  126814. renderOnlyInRenderTargetTextures: boolean;
  126815. private _scene;
  126816. private _vertexBuffers;
  126817. private _indexBuffer;
  126818. private _effect;
  126819. private _previousDefines;
  126820. /**
  126821. * An event triggered when the layer is disposed.
  126822. */
  126823. onDisposeObservable: Observable<Layer>;
  126824. private _onDisposeObserver;
  126825. /**
  126826. * Back compatibility with callback before the onDisposeObservable existed.
  126827. * The set callback will be triggered when the layer has been disposed.
  126828. */
  126829. set onDispose(callback: () => void);
  126830. /**
  126831. * An event triggered before rendering the scene
  126832. */
  126833. onBeforeRenderObservable: Observable<Layer>;
  126834. private _onBeforeRenderObserver;
  126835. /**
  126836. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126837. * The set callback will be triggered just before rendering the layer.
  126838. */
  126839. set onBeforeRender(callback: () => void);
  126840. /**
  126841. * An event triggered after rendering the scene
  126842. */
  126843. onAfterRenderObservable: Observable<Layer>;
  126844. private _onAfterRenderObserver;
  126845. /**
  126846. * Back compatibility with callback before the onAfterRenderObservable existed.
  126847. * The set callback will be triggered just after rendering the layer.
  126848. */
  126849. set onAfterRender(callback: () => void);
  126850. /**
  126851. * Instantiates a new layer.
  126852. * This represents a full screen 2d layer.
  126853. * This can be useful to display a picture in the background of your scene for instance.
  126854. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126855. * @param name Define the name of the layer in the scene
  126856. * @param imgUrl Define the url of the texture to display in the layer
  126857. * @param scene Define the scene the layer belongs to
  126858. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126859. * @param color Defines a color for the layer
  126860. */
  126861. constructor(
  126862. /**
  126863. * Define the name of the layer.
  126864. */
  126865. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126866. private _createIndexBuffer;
  126867. /** @hidden */
  126868. _rebuild(): void;
  126869. /**
  126870. * Renders the layer in the scene.
  126871. */
  126872. render(): void;
  126873. /**
  126874. * Disposes and releases the associated ressources.
  126875. */
  126876. dispose(): void;
  126877. }
  126878. }
  126879. declare module BABYLON {
  126880. /** @hidden */
  126881. export var lensFlarePixelShader: {
  126882. name: string;
  126883. shader: string;
  126884. };
  126885. }
  126886. declare module BABYLON {
  126887. /** @hidden */
  126888. export var lensFlareVertexShader: {
  126889. name: string;
  126890. shader: string;
  126891. };
  126892. }
  126893. declare module BABYLON {
  126894. /**
  126895. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126896. * It is usually composed of several `lensFlare`.
  126897. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126898. */
  126899. export class LensFlareSystem {
  126900. /**
  126901. * Define the name of the lens flare system
  126902. */
  126903. name: string;
  126904. /**
  126905. * List of lens flares used in this system.
  126906. */
  126907. lensFlares: LensFlare[];
  126908. /**
  126909. * Define a limit from the border the lens flare can be visible.
  126910. */
  126911. borderLimit: number;
  126912. /**
  126913. * Define a viewport border we do not want to see the lens flare in.
  126914. */
  126915. viewportBorder: number;
  126916. /**
  126917. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126918. */
  126919. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126920. /**
  126921. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126922. */
  126923. layerMask: number;
  126924. /**
  126925. * Define the id of the lens flare system in the scene.
  126926. * (equal to name by default)
  126927. */
  126928. id: string;
  126929. private _scene;
  126930. private _emitter;
  126931. private _vertexBuffers;
  126932. private _indexBuffer;
  126933. private _effect;
  126934. private _positionX;
  126935. private _positionY;
  126936. private _isEnabled;
  126937. /** @hidden */
  126938. static _SceneComponentInitialization: (scene: Scene) => void;
  126939. /**
  126940. * Instantiates a lens flare system.
  126941. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126942. * It is usually composed of several `lensFlare`.
  126943. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126944. * @param name Define the name of the lens flare system in the scene
  126945. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126946. * @param scene Define the scene the lens flare system belongs to
  126947. */
  126948. constructor(
  126949. /**
  126950. * Define the name of the lens flare system
  126951. */
  126952. name: string, emitter: any, scene: Scene);
  126953. /**
  126954. * Define if the lens flare system is enabled.
  126955. */
  126956. get isEnabled(): boolean;
  126957. set isEnabled(value: boolean);
  126958. /**
  126959. * Get the scene the effects belongs to.
  126960. * @returns the scene holding the lens flare system
  126961. */
  126962. getScene(): Scene;
  126963. /**
  126964. * Get the emitter of the lens flare system.
  126965. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126966. * @returns the emitter of the lens flare system
  126967. */
  126968. getEmitter(): any;
  126969. /**
  126970. * Set the emitter of the lens flare system.
  126971. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126972. * @param newEmitter Define the new emitter of the system
  126973. */
  126974. setEmitter(newEmitter: any): void;
  126975. /**
  126976. * Get the lens flare system emitter position.
  126977. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126978. * @returns the position
  126979. */
  126980. getEmitterPosition(): Vector3;
  126981. /**
  126982. * @hidden
  126983. */
  126984. computeEffectivePosition(globalViewport: Viewport): boolean;
  126985. /** @hidden */
  126986. _isVisible(): boolean;
  126987. /**
  126988. * @hidden
  126989. */
  126990. render(): boolean;
  126991. /**
  126992. * Dispose and release the lens flare with its associated resources.
  126993. */
  126994. dispose(): void;
  126995. /**
  126996. * Parse a lens flare system from a JSON repressentation
  126997. * @param parsedLensFlareSystem Define the JSON to parse
  126998. * @param scene Define the scene the parsed system should be instantiated in
  126999. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127000. * @returns the parsed system
  127001. */
  127002. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127003. /**
  127004. * Serialize the current Lens Flare System into a JSON representation.
  127005. * @returns the serialized JSON
  127006. */
  127007. serialize(): any;
  127008. }
  127009. }
  127010. declare module BABYLON {
  127011. /**
  127012. * This represents one of the lens effect in a `lensFlareSystem`.
  127013. * It controls one of the indiviual texture used in the effect.
  127014. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127015. */
  127016. export class LensFlare {
  127017. /**
  127018. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127019. */
  127020. size: number;
  127021. /**
  127022. * 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.
  127023. */
  127024. position: number;
  127025. /**
  127026. * Define the lens color.
  127027. */
  127028. color: Color3;
  127029. /**
  127030. * Define the lens texture.
  127031. */
  127032. texture: Nullable<Texture>;
  127033. /**
  127034. * Define the alpha mode to render this particular lens.
  127035. */
  127036. alphaMode: number;
  127037. private _system;
  127038. /**
  127039. * Creates a new Lens Flare.
  127040. * This represents one of the lens effect in a `lensFlareSystem`.
  127041. * It controls one of the indiviual texture used in the effect.
  127042. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127043. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127044. * @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.
  127045. * @param color Define the lens color
  127046. * @param imgUrl Define the lens texture url
  127047. * @param system Define the `lensFlareSystem` this flare is part of
  127048. * @returns The newly created Lens Flare
  127049. */
  127050. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127051. /**
  127052. * Instantiates a new Lens Flare.
  127053. * This represents one of the lens effect in a `lensFlareSystem`.
  127054. * It controls one of the indiviual texture used in the effect.
  127055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127056. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127057. * @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.
  127058. * @param color Define the lens color
  127059. * @param imgUrl Define the lens texture url
  127060. * @param system Define the `lensFlareSystem` this flare is part of
  127061. */
  127062. constructor(
  127063. /**
  127064. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127065. */
  127066. size: number,
  127067. /**
  127068. * 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.
  127069. */
  127070. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127071. /**
  127072. * Dispose and release the lens flare with its associated resources.
  127073. */
  127074. dispose(): void;
  127075. }
  127076. }
  127077. declare module BABYLON {
  127078. interface AbstractScene {
  127079. /**
  127080. * The list of lens flare system added to the scene
  127081. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127082. */
  127083. lensFlareSystems: Array<LensFlareSystem>;
  127084. /**
  127085. * Removes the given lens flare system from this scene.
  127086. * @param toRemove The lens flare system to remove
  127087. * @returns The index of the removed lens flare system
  127088. */
  127089. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127090. /**
  127091. * Adds the given lens flare system to this scene
  127092. * @param newLensFlareSystem The lens flare system to add
  127093. */
  127094. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127095. /**
  127096. * Gets a lens flare system using its name
  127097. * @param name defines the name to look for
  127098. * @returns the lens flare system or null if not found
  127099. */
  127100. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127101. /**
  127102. * Gets a lens flare system using its id
  127103. * @param id defines the id to look for
  127104. * @returns the lens flare system or null if not found
  127105. */
  127106. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127107. }
  127108. /**
  127109. * Defines the lens flare scene component responsible to manage any lens flares
  127110. * in a given scene.
  127111. */
  127112. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127113. /**
  127114. * The component name helpfull to identify the component in the list of scene components.
  127115. */
  127116. readonly name: string;
  127117. /**
  127118. * The scene the component belongs to.
  127119. */
  127120. scene: Scene;
  127121. /**
  127122. * Creates a new instance of the component for the given scene
  127123. * @param scene Defines the scene to register the component in
  127124. */
  127125. constructor(scene: Scene);
  127126. /**
  127127. * Registers the component in a given scene
  127128. */
  127129. register(): void;
  127130. /**
  127131. * Rebuilds the elements related to this component in case of
  127132. * context lost for instance.
  127133. */
  127134. rebuild(): void;
  127135. /**
  127136. * Adds all the elements from the container to the scene
  127137. * @param container the container holding the elements
  127138. */
  127139. addFromContainer(container: AbstractScene): void;
  127140. /**
  127141. * Removes all the elements in the container from the scene
  127142. * @param container contains the elements to remove
  127143. * @param dispose if the removed element should be disposed (default: false)
  127144. */
  127145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127146. /**
  127147. * Serializes the component data to the specified json object
  127148. * @param serializationObject The object to serialize to
  127149. */
  127150. serialize(serializationObject: any): void;
  127151. /**
  127152. * Disposes the component and the associated ressources.
  127153. */
  127154. dispose(): void;
  127155. private _draw;
  127156. }
  127157. }
  127158. declare module BABYLON {
  127159. /** @hidden */
  127160. export var depthPixelShader: {
  127161. name: string;
  127162. shader: string;
  127163. };
  127164. }
  127165. declare module BABYLON {
  127166. /** @hidden */
  127167. export var depthVertexShader: {
  127168. name: string;
  127169. shader: string;
  127170. };
  127171. }
  127172. declare module BABYLON {
  127173. /**
  127174. * This represents a depth renderer in Babylon.
  127175. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127176. */
  127177. export class DepthRenderer {
  127178. private _scene;
  127179. private _depthMap;
  127180. private _effect;
  127181. private readonly _storeNonLinearDepth;
  127182. private readonly _clearColor;
  127183. /** Get if the depth renderer is using packed depth or not */
  127184. readonly isPacked: boolean;
  127185. private _cachedDefines;
  127186. private _camera;
  127187. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127188. enabled: boolean;
  127189. /**
  127190. * Specifiess that the depth renderer will only be used within
  127191. * the camera it is created for.
  127192. * This can help forcing its rendering during the camera processing.
  127193. */
  127194. useOnlyInActiveCamera: boolean;
  127195. /** @hidden */
  127196. static _SceneComponentInitialization: (scene: Scene) => void;
  127197. /**
  127198. * Instantiates a depth renderer
  127199. * @param scene The scene the renderer belongs to
  127200. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127201. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127202. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127203. */
  127204. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127205. /**
  127206. * Creates the depth rendering effect and checks if the effect is ready.
  127207. * @param subMesh The submesh to be used to render the depth map of
  127208. * @param useInstances If multiple world instances should be used
  127209. * @returns if the depth renderer is ready to render the depth map
  127210. */
  127211. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127212. /**
  127213. * Gets the texture which the depth map will be written to.
  127214. * @returns The depth map texture
  127215. */
  127216. getDepthMap(): RenderTargetTexture;
  127217. /**
  127218. * Disposes of the depth renderer.
  127219. */
  127220. dispose(): void;
  127221. }
  127222. }
  127223. declare module BABYLON {
  127224. /** @hidden */
  127225. export var minmaxReduxPixelShader: {
  127226. name: string;
  127227. shader: string;
  127228. };
  127229. }
  127230. declare module BABYLON {
  127231. /**
  127232. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127233. * and maximum values from all values of the texture.
  127234. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127235. * The source values are read from the red channel of the texture.
  127236. */
  127237. export class MinMaxReducer {
  127238. /**
  127239. * Observable triggered when the computation has been performed
  127240. */
  127241. onAfterReductionPerformed: Observable<{
  127242. min: number;
  127243. max: number;
  127244. }>;
  127245. protected _camera: Camera;
  127246. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127247. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127248. protected _postProcessManager: PostProcessManager;
  127249. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127250. protected _forceFullscreenViewport: boolean;
  127251. /**
  127252. * Creates a min/max reducer
  127253. * @param camera The camera to use for the post processes
  127254. */
  127255. constructor(camera: Camera);
  127256. /**
  127257. * Gets the texture used to read the values from.
  127258. */
  127259. get sourceTexture(): Nullable<RenderTargetTexture>;
  127260. /**
  127261. * Sets the source texture to read the values from.
  127262. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127263. * because in such textures '1' value must not be taken into account to compute the maximum
  127264. * as this value is used to clear the texture.
  127265. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127266. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127267. * @param depthRedux Indicates if the texture is a depth texture or not
  127268. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127269. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127270. */
  127271. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127272. /**
  127273. * Defines the refresh rate of the computation.
  127274. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127275. */
  127276. get refreshRate(): number;
  127277. set refreshRate(value: number);
  127278. protected _activated: boolean;
  127279. /**
  127280. * Gets the activation status of the reducer
  127281. */
  127282. get activated(): boolean;
  127283. /**
  127284. * Activates the reduction computation.
  127285. * When activated, the observers registered in onAfterReductionPerformed are
  127286. * called after the compuation is performed
  127287. */
  127288. activate(): void;
  127289. /**
  127290. * Deactivates the reduction computation.
  127291. */
  127292. deactivate(): void;
  127293. /**
  127294. * Disposes the min/max reducer
  127295. * @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.
  127296. */
  127297. dispose(disposeAll?: boolean): void;
  127298. }
  127299. }
  127300. declare module BABYLON {
  127301. /**
  127302. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127303. */
  127304. export class DepthReducer extends MinMaxReducer {
  127305. private _depthRenderer;
  127306. private _depthRendererId;
  127307. /**
  127308. * Gets the depth renderer used for the computation.
  127309. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127310. */
  127311. get depthRenderer(): Nullable<DepthRenderer>;
  127312. /**
  127313. * Creates a depth reducer
  127314. * @param camera The camera used to render the depth texture
  127315. */
  127316. constructor(camera: Camera);
  127317. /**
  127318. * Sets the depth renderer to use to generate the depth map
  127319. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127320. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127321. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127322. */
  127323. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127324. /** @hidden */
  127325. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127326. /**
  127327. * Activates the reduction computation.
  127328. * When activated, the observers registered in onAfterReductionPerformed are
  127329. * called after the compuation is performed
  127330. */
  127331. activate(): void;
  127332. /**
  127333. * Deactivates the reduction computation.
  127334. */
  127335. deactivate(): void;
  127336. /**
  127337. * Disposes the depth reducer
  127338. * @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.
  127339. */
  127340. dispose(disposeAll?: boolean): void;
  127341. }
  127342. }
  127343. declare module BABYLON {
  127344. /**
  127345. * A CSM implementation allowing casting shadows on large scenes.
  127346. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127347. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127348. */
  127349. export class CascadedShadowGenerator extends ShadowGenerator {
  127350. private static readonly frustumCornersNDCSpace;
  127351. /**
  127352. * Name of the CSM class
  127353. */
  127354. static CLASSNAME: string;
  127355. /**
  127356. * Defines the default number of cascades used by the CSM.
  127357. */
  127358. static readonly DEFAULT_CASCADES_COUNT: number;
  127359. /**
  127360. * Defines the minimum number of cascades used by the CSM.
  127361. */
  127362. static readonly MIN_CASCADES_COUNT: number;
  127363. /**
  127364. * Defines the maximum number of cascades used by the CSM.
  127365. */
  127366. static readonly MAX_CASCADES_COUNT: number;
  127367. protected _validateFilter(filter: number): number;
  127368. /**
  127369. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127370. */
  127371. penumbraDarkness: number;
  127372. private _numCascades;
  127373. /**
  127374. * Gets or set the number of cascades used by the CSM.
  127375. */
  127376. get numCascades(): number;
  127377. set numCascades(value: number);
  127378. /**
  127379. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127380. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127381. */
  127382. stabilizeCascades: boolean;
  127383. private _freezeShadowCastersBoundingInfo;
  127384. private _freezeShadowCastersBoundingInfoObservable;
  127385. /**
  127386. * Enables or disables the shadow casters bounding info computation.
  127387. * If your shadow casters don't move, you can disable this feature.
  127388. * If it is enabled, the bounding box computation is done every frame.
  127389. */
  127390. get freezeShadowCastersBoundingInfo(): boolean;
  127391. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127392. private _scbiMin;
  127393. private _scbiMax;
  127394. protected _computeShadowCastersBoundingInfo(): void;
  127395. protected _shadowCastersBoundingInfo: BoundingInfo;
  127396. /**
  127397. * Gets or sets the shadow casters bounding info.
  127398. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127399. * so that the system won't overwrite the bounds you provide
  127400. */
  127401. get shadowCastersBoundingInfo(): BoundingInfo;
  127402. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127403. protected _breaksAreDirty: boolean;
  127404. protected _minDistance: number;
  127405. protected _maxDistance: number;
  127406. /**
  127407. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127408. *
  127409. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127410. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127411. * @param min minimal distance for the breaks (default to 0.)
  127412. * @param max maximal distance for the breaks (default to 1.)
  127413. */
  127414. setMinMaxDistance(min: number, max: number): void;
  127415. /** Gets the minimal distance used in the cascade break computation */
  127416. get minDistance(): number;
  127417. /** Gets the maximal distance used in the cascade break computation */
  127418. get maxDistance(): number;
  127419. /**
  127420. * Gets the class name of that object
  127421. * @returns "CascadedShadowGenerator"
  127422. */
  127423. getClassName(): string;
  127424. private _cascadeMinExtents;
  127425. private _cascadeMaxExtents;
  127426. /**
  127427. * Gets a cascade minimum extents
  127428. * @param cascadeIndex index of the cascade
  127429. * @returns the minimum cascade extents
  127430. */
  127431. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127432. /**
  127433. * Gets a cascade maximum extents
  127434. * @param cascadeIndex index of the cascade
  127435. * @returns the maximum cascade extents
  127436. */
  127437. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127438. private _cascades;
  127439. private _currentLayer;
  127440. private _viewSpaceFrustumsZ;
  127441. private _viewMatrices;
  127442. private _projectionMatrices;
  127443. private _transformMatrices;
  127444. private _transformMatricesAsArray;
  127445. private _frustumLengths;
  127446. private _lightSizeUVCorrection;
  127447. private _depthCorrection;
  127448. private _frustumCornersWorldSpace;
  127449. private _frustumCenter;
  127450. private _shadowCameraPos;
  127451. private _shadowMaxZ;
  127452. /**
  127453. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127454. * It defaults to camera.maxZ
  127455. */
  127456. get shadowMaxZ(): number;
  127457. /**
  127458. * Sets the shadow max z distance.
  127459. */
  127460. set shadowMaxZ(value: number);
  127461. protected _debug: boolean;
  127462. /**
  127463. * Gets or sets the debug flag.
  127464. * When enabled, the cascades are materialized by different colors on the screen.
  127465. */
  127466. get debug(): boolean;
  127467. set debug(dbg: boolean);
  127468. private _depthClamp;
  127469. /**
  127470. * Gets or sets the depth clamping value.
  127471. *
  127472. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127473. * to account for the shadow casters far away.
  127474. *
  127475. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127476. */
  127477. get depthClamp(): boolean;
  127478. set depthClamp(value: boolean);
  127479. private _cascadeBlendPercentage;
  127480. /**
  127481. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127482. * It defaults to 0.1 (10% blending).
  127483. */
  127484. get cascadeBlendPercentage(): number;
  127485. set cascadeBlendPercentage(value: number);
  127486. private _lambda;
  127487. /**
  127488. * Gets or set the lambda parameter.
  127489. * This parameter is used to split the camera frustum and create the cascades.
  127490. * 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.
  127491. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127492. */
  127493. get lambda(): number;
  127494. set lambda(value: number);
  127495. /**
  127496. * Gets the view matrix corresponding to a given cascade
  127497. * @param cascadeNum cascade to retrieve the view matrix from
  127498. * @returns the cascade view matrix
  127499. */
  127500. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127501. /**
  127502. * Gets the projection matrix corresponding to a given cascade
  127503. * @param cascadeNum cascade to retrieve the projection matrix from
  127504. * @returns the cascade projection matrix
  127505. */
  127506. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127507. /**
  127508. * Gets the transformation matrix corresponding to a given cascade
  127509. * @param cascadeNum cascade to retrieve the transformation matrix from
  127510. * @returns the cascade transformation matrix
  127511. */
  127512. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127513. private _depthRenderer;
  127514. /**
  127515. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127516. *
  127517. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127518. *
  127519. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127520. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127521. * @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
  127522. */
  127523. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127524. private _depthReducer;
  127525. private _autoCalcDepthBounds;
  127526. /**
  127527. * Gets or sets the autoCalcDepthBounds property.
  127528. *
  127529. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127530. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127531. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127532. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127533. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127534. */
  127535. get autoCalcDepthBounds(): boolean;
  127536. set autoCalcDepthBounds(value: boolean);
  127537. /**
  127538. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127539. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127540. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127541. * for setting the refresh rate on the renderer yourself!
  127542. */
  127543. get autoCalcDepthBoundsRefreshRate(): number;
  127544. set autoCalcDepthBoundsRefreshRate(value: number);
  127545. /**
  127546. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127547. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127548. * you change the camera near/far planes!
  127549. */
  127550. splitFrustum(): void;
  127551. private _splitFrustum;
  127552. private _computeMatrices;
  127553. private _computeFrustumInWorldSpace;
  127554. private _computeCascadeFrustum;
  127555. /** @hidden */
  127556. static _SceneComponentInitialization: (scene: Scene) => void;
  127557. /**
  127558. * Creates a Cascaded Shadow Generator object.
  127559. * A ShadowGenerator is the required tool to use the shadows.
  127560. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127561. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127562. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127563. * @param light The directional light object generating the shadows.
  127564. * @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.
  127565. */
  127566. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127567. protected _initializeGenerator(): void;
  127568. protected _createTargetRenderTexture(): void;
  127569. protected _initializeShadowMap(): void;
  127570. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127571. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127572. /**
  127573. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127574. * @param defines Defines of the material we want to update
  127575. * @param lightIndex Index of the light in the enabled light list of the material
  127576. */
  127577. prepareDefines(defines: any, lightIndex: number): void;
  127578. /**
  127579. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127580. * defined in the generator but impacting the effect).
  127581. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127582. * @param effect The effect we are binfing the information for
  127583. */
  127584. bindShadowLight(lightIndex: string, effect: Effect): void;
  127585. /**
  127586. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127587. * (eq to view projection * shadow projection matrices)
  127588. * @returns The transform matrix used to create the shadow map
  127589. */
  127590. getTransformMatrix(): Matrix;
  127591. /**
  127592. * Disposes the ShadowGenerator.
  127593. * Returns nothing.
  127594. */
  127595. dispose(): void;
  127596. /**
  127597. * Serializes the shadow generator setup to a json object.
  127598. * @returns The serialized JSON object
  127599. */
  127600. serialize(): any;
  127601. /**
  127602. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127603. * @param parsedShadowGenerator The JSON object to parse
  127604. * @param scene The scene to create the shadow map for
  127605. * @returns The parsed shadow generator
  127606. */
  127607. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127608. }
  127609. }
  127610. declare module BABYLON {
  127611. /**
  127612. * Defines the shadow generator component responsible to manage any shadow generators
  127613. * in a given scene.
  127614. */
  127615. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127616. /**
  127617. * The component name helpfull to identify the component in the list of scene components.
  127618. */
  127619. readonly name: string;
  127620. /**
  127621. * The scene the component belongs to.
  127622. */
  127623. scene: Scene;
  127624. /**
  127625. * Creates a new instance of the component for the given scene
  127626. * @param scene Defines the scene to register the component in
  127627. */
  127628. constructor(scene: Scene);
  127629. /**
  127630. * Registers the component in a given scene
  127631. */
  127632. register(): void;
  127633. /**
  127634. * Rebuilds the elements related to this component in case of
  127635. * context lost for instance.
  127636. */
  127637. rebuild(): void;
  127638. /**
  127639. * Serializes the component data to the specified json object
  127640. * @param serializationObject The object to serialize to
  127641. */
  127642. serialize(serializationObject: any): void;
  127643. /**
  127644. * Adds all the elements from the container to the scene
  127645. * @param container the container holding the elements
  127646. */
  127647. addFromContainer(container: AbstractScene): void;
  127648. /**
  127649. * Removes all the elements in the container from the scene
  127650. * @param container contains the elements to remove
  127651. * @param dispose if the removed element should be disposed (default: false)
  127652. */
  127653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127654. /**
  127655. * Rebuilds the elements related to this component in case of
  127656. * context lost for instance.
  127657. */
  127658. dispose(): void;
  127659. private _gatherRenderTargets;
  127660. }
  127661. }
  127662. declare module BABYLON {
  127663. /**
  127664. * A point light is a light defined by an unique point in world space.
  127665. * The light is emitted in every direction from this point.
  127666. * A good example of a point light is a standard light bulb.
  127667. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127668. */
  127669. export class PointLight extends ShadowLight {
  127670. private _shadowAngle;
  127671. /**
  127672. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127673. * This specifies what angle the shadow will use to be created.
  127674. *
  127675. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127676. */
  127677. get shadowAngle(): number;
  127678. /**
  127679. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127680. * This specifies what angle the shadow will use to be created.
  127681. *
  127682. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127683. */
  127684. set shadowAngle(value: number);
  127685. /**
  127686. * Gets the direction if it has been set.
  127687. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127688. */
  127689. get direction(): Vector3;
  127690. /**
  127691. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127692. */
  127693. set direction(value: Vector3);
  127694. /**
  127695. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127696. * A PointLight emits the light in every direction.
  127697. * It can cast shadows.
  127698. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127699. * ```javascript
  127700. * var pointLight = new PointLight("pl", camera.position, scene);
  127701. * ```
  127702. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127703. * @param name The light friendly name
  127704. * @param position The position of the point light in the scene
  127705. * @param scene The scene the lights belongs to
  127706. */
  127707. constructor(name: string, position: Vector3, scene: Scene);
  127708. /**
  127709. * Returns the string "PointLight"
  127710. * @returns the class name
  127711. */
  127712. getClassName(): string;
  127713. /**
  127714. * Returns the integer 0.
  127715. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127716. */
  127717. getTypeID(): number;
  127718. /**
  127719. * Specifies wether or not the shadowmap should be a cube texture.
  127720. * @returns true if the shadowmap needs to be a cube texture.
  127721. */
  127722. needCube(): boolean;
  127723. /**
  127724. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127725. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127726. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127727. */
  127728. getShadowDirection(faceIndex?: number): Vector3;
  127729. /**
  127730. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127731. * - fov = PI / 2
  127732. * - aspect ratio : 1.0
  127733. * - z-near and far equal to the active camera minZ and maxZ.
  127734. * Returns the PointLight.
  127735. */
  127736. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127737. protected _buildUniformLayout(): void;
  127738. /**
  127739. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127740. * @param effect The effect to update
  127741. * @param lightIndex The index of the light in the effect to update
  127742. * @returns The point light
  127743. */
  127744. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127745. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127746. /**
  127747. * Prepares the list of defines specific to the light type.
  127748. * @param defines the list of defines
  127749. * @param lightIndex defines the index of the light for the effect
  127750. */
  127751. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127752. }
  127753. }
  127754. declare module BABYLON {
  127755. /**
  127756. * Header information of HDR texture files.
  127757. */
  127758. export interface HDRInfo {
  127759. /**
  127760. * The height of the texture in pixels.
  127761. */
  127762. height: number;
  127763. /**
  127764. * The width of the texture in pixels.
  127765. */
  127766. width: number;
  127767. /**
  127768. * The index of the beginning of the data in the binary file.
  127769. */
  127770. dataPosition: number;
  127771. }
  127772. /**
  127773. * This groups tools to convert HDR texture to native colors array.
  127774. */
  127775. export class HDRTools {
  127776. private static Ldexp;
  127777. private static Rgbe2float;
  127778. private static readStringLine;
  127779. /**
  127780. * Reads header information from an RGBE texture stored in a native array.
  127781. * More information on this format are available here:
  127782. * https://en.wikipedia.org/wiki/RGBE_image_format
  127783. *
  127784. * @param uint8array The binary file stored in native array.
  127785. * @return The header information.
  127786. */
  127787. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127788. /**
  127789. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127790. * This RGBE texture needs to store the information as a panorama.
  127791. *
  127792. * More information on this format are available here:
  127793. * https://en.wikipedia.org/wiki/RGBE_image_format
  127794. *
  127795. * @param buffer The binary file stored in an array buffer.
  127796. * @param size The expected size of the extracted cubemap.
  127797. * @return The Cube Map information.
  127798. */
  127799. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127800. /**
  127801. * Returns the pixels data extracted from an RGBE texture.
  127802. * This pixels will be stored left to right up to down in the R G B order in one array.
  127803. *
  127804. * More information on this format are available here:
  127805. * https://en.wikipedia.org/wiki/RGBE_image_format
  127806. *
  127807. * @param uint8array The binary file stored in an array buffer.
  127808. * @param hdrInfo The header information of the file.
  127809. * @return The pixels data in RGB right to left up to down order.
  127810. */
  127811. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127812. private static RGBE_ReadPixels_RLE;
  127813. }
  127814. }
  127815. declare module BABYLON {
  127816. /**
  127817. * This represents a texture coming from an HDR input.
  127818. *
  127819. * The only supported format is currently panorama picture stored in RGBE format.
  127820. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127821. */
  127822. export class HDRCubeTexture extends BaseTexture {
  127823. private static _facesMapping;
  127824. private _generateHarmonics;
  127825. private _noMipmap;
  127826. private _textureMatrix;
  127827. private _size;
  127828. private _onLoad;
  127829. private _onError;
  127830. /**
  127831. * The texture URL.
  127832. */
  127833. url: string;
  127834. /**
  127835. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127836. */
  127837. coordinatesMode: number;
  127838. protected _isBlocking: boolean;
  127839. /**
  127840. * Sets wether or not the texture is blocking during loading.
  127841. */
  127842. set isBlocking(value: boolean);
  127843. /**
  127844. * Gets wether or not the texture is blocking during loading.
  127845. */
  127846. get isBlocking(): boolean;
  127847. protected _rotationY: number;
  127848. /**
  127849. * Sets texture matrix rotation angle around Y axis in radians.
  127850. */
  127851. set rotationY(value: number);
  127852. /**
  127853. * Gets texture matrix rotation angle around Y axis radians.
  127854. */
  127855. get rotationY(): number;
  127856. /**
  127857. * Gets or sets the center of the bounding box associated with the cube texture
  127858. * It must define where the camera used to render the texture was set
  127859. */
  127860. boundingBoxPosition: Vector3;
  127861. private _boundingBoxSize;
  127862. /**
  127863. * Gets or sets the size of the bounding box associated with the cube texture
  127864. * When defined, the cubemap will switch to local mode
  127865. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127866. * @example https://www.babylonjs-playground.com/#RNASML
  127867. */
  127868. set boundingBoxSize(value: Vector3);
  127869. get boundingBoxSize(): Vector3;
  127870. /**
  127871. * Instantiates an HDRTexture from the following parameters.
  127872. *
  127873. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127874. * @param scene The scene the texture will be used in
  127875. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127876. * @param noMipmap Forces to not generate the mipmap if true
  127877. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127878. * @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)
  127879. * @param reserved Reserved flag for internal use.
  127880. */
  127881. 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>);
  127882. /**
  127883. * Get the current class name of the texture useful for serialization or dynamic coding.
  127884. * @returns "HDRCubeTexture"
  127885. */
  127886. getClassName(): string;
  127887. /**
  127888. * Occurs when the file is raw .hdr file.
  127889. */
  127890. private loadTexture;
  127891. clone(): HDRCubeTexture;
  127892. delayLoad(): void;
  127893. /**
  127894. * Get the texture reflection matrix used to rotate/transform the reflection.
  127895. * @returns the reflection matrix
  127896. */
  127897. getReflectionTextureMatrix(): Matrix;
  127898. /**
  127899. * Set the texture reflection matrix used to rotate/transform the reflection.
  127900. * @param value Define the reflection matrix to set
  127901. */
  127902. setReflectionTextureMatrix(value: Matrix): void;
  127903. /**
  127904. * Parses a JSON representation of an HDR Texture in order to create the texture
  127905. * @param parsedTexture Define the JSON representation
  127906. * @param scene Define the scene the texture should be created in
  127907. * @param rootUrl Define the root url in case we need to load relative dependencies
  127908. * @returns the newly created texture after parsing
  127909. */
  127910. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127911. serialize(): any;
  127912. }
  127913. }
  127914. declare module BABYLON {
  127915. /**
  127916. * Class used to control physics engine
  127917. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127918. */
  127919. export class PhysicsEngine implements IPhysicsEngine {
  127920. private _physicsPlugin;
  127921. /**
  127922. * Global value used to control the smallest number supported by the simulation
  127923. */
  127924. static Epsilon: number;
  127925. private _impostors;
  127926. private _joints;
  127927. private _subTimeStep;
  127928. /**
  127929. * Gets the gravity vector used by the simulation
  127930. */
  127931. gravity: Vector3;
  127932. /**
  127933. * Factory used to create the default physics plugin.
  127934. * @returns The default physics plugin
  127935. */
  127936. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127937. /**
  127938. * Creates a new Physics Engine
  127939. * @param gravity defines the gravity vector used by the simulation
  127940. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127941. */
  127942. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127943. /**
  127944. * Sets the gravity vector used by the simulation
  127945. * @param gravity defines the gravity vector to use
  127946. */
  127947. setGravity(gravity: Vector3): void;
  127948. /**
  127949. * Set the time step of the physics engine.
  127950. * Default is 1/60.
  127951. * To slow it down, enter 1/600 for example.
  127952. * To speed it up, 1/30
  127953. * @param newTimeStep defines the new timestep to apply to this world.
  127954. */
  127955. setTimeStep(newTimeStep?: number): void;
  127956. /**
  127957. * Get the time step of the physics engine.
  127958. * @returns the current time step
  127959. */
  127960. getTimeStep(): number;
  127961. /**
  127962. * Set the sub time step of the physics engine.
  127963. * Default is 0 meaning there is no sub steps
  127964. * To increase physics resolution precision, set a small value (like 1 ms)
  127965. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127966. */
  127967. setSubTimeStep(subTimeStep?: number): void;
  127968. /**
  127969. * Get the sub time step of the physics engine.
  127970. * @returns the current sub time step
  127971. */
  127972. getSubTimeStep(): number;
  127973. /**
  127974. * Release all resources
  127975. */
  127976. dispose(): void;
  127977. /**
  127978. * Gets the name of the current physics plugin
  127979. * @returns the name of the plugin
  127980. */
  127981. getPhysicsPluginName(): string;
  127982. /**
  127983. * Adding a new impostor for the impostor tracking.
  127984. * This will be done by the impostor itself.
  127985. * @param impostor the impostor to add
  127986. */
  127987. addImpostor(impostor: PhysicsImpostor): void;
  127988. /**
  127989. * Remove an impostor from the engine.
  127990. * This impostor and its mesh will not longer be updated by the physics engine.
  127991. * @param impostor the impostor to remove
  127992. */
  127993. removeImpostor(impostor: PhysicsImpostor): void;
  127994. /**
  127995. * Add a joint to the physics engine
  127996. * @param mainImpostor defines the main impostor to which the joint is added.
  127997. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127998. * @param joint defines the joint that will connect both impostors.
  127999. */
  128000. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128001. /**
  128002. * Removes a joint from the simulation
  128003. * @param mainImpostor defines the impostor used with the joint
  128004. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128005. * @param joint defines the joint to remove
  128006. */
  128007. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128008. /**
  128009. * Called by the scene. No need to call it.
  128010. * @param delta defines the timespam between frames
  128011. */
  128012. _step(delta: number): void;
  128013. /**
  128014. * Gets the current plugin used to run the simulation
  128015. * @returns current plugin
  128016. */
  128017. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128018. /**
  128019. * Gets the list of physic impostors
  128020. * @returns an array of PhysicsImpostor
  128021. */
  128022. getImpostors(): Array<PhysicsImpostor>;
  128023. /**
  128024. * Gets the impostor for a physics enabled object
  128025. * @param object defines the object impersonated by the impostor
  128026. * @returns the PhysicsImpostor or null if not found
  128027. */
  128028. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128029. /**
  128030. * Gets the impostor for a physics body object
  128031. * @param body defines physics body used by the impostor
  128032. * @returns the PhysicsImpostor or null if not found
  128033. */
  128034. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128035. /**
  128036. * Does a raycast in the physics world
  128037. * @param from when should the ray start?
  128038. * @param to when should the ray end?
  128039. * @returns PhysicsRaycastResult
  128040. */
  128041. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128042. }
  128043. }
  128044. declare module BABYLON {
  128045. /** @hidden */
  128046. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128047. private _useDeltaForWorldStep;
  128048. world: any;
  128049. name: string;
  128050. private _physicsMaterials;
  128051. private _fixedTimeStep;
  128052. private _cannonRaycastResult;
  128053. private _raycastResult;
  128054. private _physicsBodysToRemoveAfterStep;
  128055. BJSCANNON: any;
  128056. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128057. setGravity(gravity: Vector3): void;
  128058. setTimeStep(timeStep: number): void;
  128059. getTimeStep(): number;
  128060. executeStep(delta: number): void;
  128061. private _removeMarkedPhysicsBodiesFromWorld;
  128062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128063. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128064. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128065. private _processChildMeshes;
  128066. removePhysicsBody(impostor: PhysicsImpostor): void;
  128067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128069. private _addMaterial;
  128070. private _checkWithEpsilon;
  128071. private _createShape;
  128072. private _createHeightmap;
  128073. private _minus90X;
  128074. private _plus90X;
  128075. private _tmpPosition;
  128076. private _tmpDeltaPosition;
  128077. private _tmpUnityRotation;
  128078. private _updatePhysicsBodyTransformation;
  128079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128081. isSupported(): boolean;
  128082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128084. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128087. getBodyMass(impostor: PhysicsImpostor): number;
  128088. getBodyFriction(impostor: PhysicsImpostor): number;
  128089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128090. getBodyRestitution(impostor: PhysicsImpostor): number;
  128091. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128092. sleepBody(impostor: PhysicsImpostor): void;
  128093. wakeUpBody(impostor: PhysicsImpostor): void;
  128094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128095. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128098. getRadius(impostor: PhysicsImpostor): number;
  128099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128100. dispose(): void;
  128101. private _extendNamespace;
  128102. /**
  128103. * Does a raycast in the physics world
  128104. * @param from when should the ray start?
  128105. * @param to when should the ray end?
  128106. * @returns PhysicsRaycastResult
  128107. */
  128108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128109. }
  128110. }
  128111. declare module BABYLON {
  128112. /** @hidden */
  128113. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128114. world: any;
  128115. name: string;
  128116. BJSOIMO: any;
  128117. private _raycastResult;
  128118. constructor(iterations?: number, oimoInjection?: any);
  128119. setGravity(gravity: Vector3): void;
  128120. setTimeStep(timeStep: number): void;
  128121. getTimeStep(): number;
  128122. private _tmpImpostorsArray;
  128123. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128127. private _tmpPositionVector;
  128128. removePhysicsBody(impostor: PhysicsImpostor): void;
  128129. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128130. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128131. isSupported(): boolean;
  128132. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128133. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128134. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128135. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128136. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128137. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128138. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128139. getBodyMass(impostor: PhysicsImpostor): number;
  128140. getBodyFriction(impostor: PhysicsImpostor): number;
  128141. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128142. getBodyRestitution(impostor: PhysicsImpostor): number;
  128143. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128144. sleepBody(impostor: PhysicsImpostor): void;
  128145. wakeUpBody(impostor: PhysicsImpostor): void;
  128146. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128147. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128148. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128149. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128150. getRadius(impostor: PhysicsImpostor): number;
  128151. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128152. dispose(): void;
  128153. /**
  128154. * Does a raycast in the physics world
  128155. * @param from when should the ray start?
  128156. * @param to when should the ray end?
  128157. * @returns PhysicsRaycastResult
  128158. */
  128159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128160. }
  128161. }
  128162. declare module BABYLON {
  128163. /**
  128164. * Class containing static functions to help procedurally build meshes
  128165. */
  128166. export class RibbonBuilder {
  128167. /**
  128168. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128169. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128170. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128171. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128172. * * 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
  128173. * * 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
  128174. * * 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
  128175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128177. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128178. * * 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
  128179. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128180. * * 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
  128181. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128183. * @param name defines the name of the mesh
  128184. * @param options defines the options used to create the mesh
  128185. * @param scene defines the hosting scene
  128186. * @returns the ribbon mesh
  128187. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128188. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128189. */
  128190. static CreateRibbon(name: string, options: {
  128191. pathArray: Vector3[][];
  128192. closeArray?: boolean;
  128193. closePath?: boolean;
  128194. offset?: number;
  128195. updatable?: boolean;
  128196. sideOrientation?: number;
  128197. frontUVs?: Vector4;
  128198. backUVs?: Vector4;
  128199. instance?: Mesh;
  128200. invertUV?: boolean;
  128201. uvs?: Vector2[];
  128202. colors?: Color4[];
  128203. }, scene?: Nullable<Scene>): Mesh;
  128204. }
  128205. }
  128206. declare module BABYLON {
  128207. /**
  128208. * Class containing static functions to help procedurally build meshes
  128209. */
  128210. export class ShapeBuilder {
  128211. /**
  128212. * 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.
  128213. * * 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.
  128214. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128215. * * 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.
  128216. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128217. * * 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
  128218. * * 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
  128219. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128224. * @param name defines the name of the mesh
  128225. * @param options defines the options used to create the mesh
  128226. * @param scene defines the hosting scene
  128227. * @returns the extruded shape mesh
  128228. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128230. */
  128231. static ExtrudeShape(name: string, options: {
  128232. shape: Vector3[];
  128233. path: Vector3[];
  128234. scale?: number;
  128235. rotation?: number;
  128236. cap?: number;
  128237. updatable?: boolean;
  128238. sideOrientation?: number;
  128239. frontUVs?: Vector4;
  128240. backUVs?: Vector4;
  128241. instance?: Mesh;
  128242. invertUV?: boolean;
  128243. }, scene?: Nullable<Scene>): Mesh;
  128244. /**
  128245. * Creates an custom extruded shape mesh.
  128246. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128247. * * 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.
  128248. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128249. * * 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
  128250. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128251. * * 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
  128252. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128253. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128254. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128255. * * 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
  128256. * * 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
  128257. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128260. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128262. * @param name defines the name of the mesh
  128263. * @param options defines the options used to create the mesh
  128264. * @param scene defines the hosting scene
  128265. * @returns the custom extruded shape mesh
  128266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128269. */
  128270. static ExtrudeShapeCustom(name: string, options: {
  128271. shape: Vector3[];
  128272. path: Vector3[];
  128273. scaleFunction?: any;
  128274. rotationFunction?: any;
  128275. ribbonCloseArray?: boolean;
  128276. ribbonClosePath?: boolean;
  128277. cap?: number;
  128278. updatable?: boolean;
  128279. sideOrientation?: number;
  128280. frontUVs?: Vector4;
  128281. backUVs?: Vector4;
  128282. instance?: Mesh;
  128283. invertUV?: boolean;
  128284. }, scene?: Nullable<Scene>): Mesh;
  128285. private static _ExtrudeShapeGeneric;
  128286. }
  128287. }
  128288. declare module BABYLON {
  128289. /**
  128290. * AmmoJS Physics plugin
  128291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128292. * @see https://github.com/kripken/ammo.js/
  128293. */
  128294. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128295. private _useDeltaForWorldStep;
  128296. /**
  128297. * Reference to the Ammo library
  128298. */
  128299. bjsAMMO: any;
  128300. /**
  128301. * Created ammoJS world which physics bodies are added to
  128302. */
  128303. world: any;
  128304. /**
  128305. * Name of the plugin
  128306. */
  128307. name: string;
  128308. private _timeStep;
  128309. private _fixedTimeStep;
  128310. private _maxSteps;
  128311. private _tmpQuaternion;
  128312. private _tmpAmmoTransform;
  128313. private _tmpAmmoQuaternion;
  128314. private _tmpAmmoConcreteContactResultCallback;
  128315. private _collisionConfiguration;
  128316. private _dispatcher;
  128317. private _overlappingPairCache;
  128318. private _solver;
  128319. private _softBodySolver;
  128320. private _tmpAmmoVectorA;
  128321. private _tmpAmmoVectorB;
  128322. private _tmpAmmoVectorC;
  128323. private _tmpAmmoVectorD;
  128324. private _tmpContactCallbackResult;
  128325. private _tmpAmmoVectorRCA;
  128326. private _tmpAmmoVectorRCB;
  128327. private _raycastResult;
  128328. private static readonly DISABLE_COLLISION_FLAG;
  128329. private static readonly KINEMATIC_FLAG;
  128330. private static readonly DISABLE_DEACTIVATION_FLAG;
  128331. /**
  128332. * Initializes the ammoJS plugin
  128333. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128334. * @param ammoInjection can be used to inject your own ammo reference
  128335. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128336. */
  128337. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128338. /**
  128339. * Sets the gravity of the physics world (m/(s^2))
  128340. * @param gravity Gravity to set
  128341. */
  128342. setGravity(gravity: Vector3): void;
  128343. /**
  128344. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128345. * @param timeStep timestep to use in seconds
  128346. */
  128347. setTimeStep(timeStep: number): void;
  128348. /**
  128349. * 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)
  128350. * @param fixedTimeStep fixedTimeStep to use in seconds
  128351. */
  128352. setFixedTimeStep(fixedTimeStep: number): void;
  128353. /**
  128354. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128355. * @param maxSteps the maximum number of steps by the physics engine per frame
  128356. */
  128357. setMaxSteps(maxSteps: number): void;
  128358. /**
  128359. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128360. * @returns the current timestep in seconds
  128361. */
  128362. getTimeStep(): number;
  128363. /**
  128364. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128365. */
  128366. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128367. private _isImpostorInContact;
  128368. private _isImpostorPairInContact;
  128369. private _stepSimulation;
  128370. /**
  128371. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128372. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128373. * After the step the babylon meshes are set to the position of the physics imposters
  128374. * @param delta amount of time to step forward
  128375. * @param impostors array of imposters to update before/after the step
  128376. */
  128377. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128378. /**
  128379. * Update babylon mesh to match physics world object
  128380. * @param impostor imposter to match
  128381. */
  128382. private _afterSoftStep;
  128383. /**
  128384. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128385. * @param impostor imposter to match
  128386. */
  128387. private _ropeStep;
  128388. /**
  128389. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128390. * @param impostor imposter to match
  128391. */
  128392. private _softbodyOrClothStep;
  128393. private _tmpVector;
  128394. private _tmpMatrix;
  128395. /**
  128396. * Applies an impulse on the imposter
  128397. * @param impostor imposter to apply impulse to
  128398. * @param force amount of force to be applied to the imposter
  128399. * @param contactPoint the location to apply the impulse on the imposter
  128400. */
  128401. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128402. /**
  128403. * Applies a force on the imposter
  128404. * @param impostor imposter to apply force
  128405. * @param force amount of force to be applied to the imposter
  128406. * @param contactPoint the location to apply the force on the imposter
  128407. */
  128408. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128409. /**
  128410. * Creates a physics body using the plugin
  128411. * @param impostor the imposter to create the physics body on
  128412. */
  128413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128414. /**
  128415. * Removes the physics body from the imposter and disposes of the body's memory
  128416. * @param impostor imposter to remove the physics body from
  128417. */
  128418. removePhysicsBody(impostor: PhysicsImpostor): void;
  128419. /**
  128420. * Generates a joint
  128421. * @param impostorJoint the imposter joint to create the joint with
  128422. */
  128423. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128424. /**
  128425. * Removes a joint
  128426. * @param impostorJoint the imposter joint to remove the joint from
  128427. */
  128428. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128429. private _addMeshVerts;
  128430. /**
  128431. * Initialise the soft body vertices to match its object's (mesh) vertices
  128432. * Softbody vertices (nodes) are in world space and to match this
  128433. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128434. * @param impostor to create the softbody for
  128435. */
  128436. private _softVertexData;
  128437. /**
  128438. * Create an impostor's soft body
  128439. * @param impostor to create the softbody for
  128440. */
  128441. private _createSoftbody;
  128442. /**
  128443. * Create cloth for an impostor
  128444. * @param impostor to create the softbody for
  128445. */
  128446. private _createCloth;
  128447. /**
  128448. * Create rope for an impostor
  128449. * @param impostor to create the softbody for
  128450. */
  128451. private _createRope;
  128452. /**
  128453. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128454. * @param impostor to create the custom physics shape for
  128455. */
  128456. private _createCustom;
  128457. private _addHullVerts;
  128458. private _createShape;
  128459. /**
  128460. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128461. * @param impostor imposter containing the physics body and babylon object
  128462. */
  128463. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128464. /**
  128465. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128466. * @param impostor imposter containing the physics body and babylon object
  128467. * @param newPosition new position
  128468. * @param newRotation new rotation
  128469. */
  128470. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128471. /**
  128472. * If this plugin is supported
  128473. * @returns true if its supported
  128474. */
  128475. isSupported(): boolean;
  128476. /**
  128477. * Sets the linear velocity of the physics body
  128478. * @param impostor imposter to set the velocity on
  128479. * @param velocity velocity to set
  128480. */
  128481. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128482. /**
  128483. * Sets the angular velocity of the physics body
  128484. * @param impostor imposter to set the velocity on
  128485. * @param velocity velocity to set
  128486. */
  128487. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128488. /**
  128489. * gets the linear velocity
  128490. * @param impostor imposter to get linear velocity from
  128491. * @returns linear velocity
  128492. */
  128493. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128494. /**
  128495. * gets the angular velocity
  128496. * @param impostor imposter to get angular velocity from
  128497. * @returns angular velocity
  128498. */
  128499. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128500. /**
  128501. * Sets the mass of physics body
  128502. * @param impostor imposter to set the mass on
  128503. * @param mass mass to set
  128504. */
  128505. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128506. /**
  128507. * Gets the mass of the physics body
  128508. * @param impostor imposter to get the mass from
  128509. * @returns mass
  128510. */
  128511. getBodyMass(impostor: PhysicsImpostor): number;
  128512. /**
  128513. * Gets friction of the impostor
  128514. * @param impostor impostor to get friction from
  128515. * @returns friction value
  128516. */
  128517. getBodyFriction(impostor: PhysicsImpostor): number;
  128518. /**
  128519. * Sets friction of the impostor
  128520. * @param impostor impostor to set friction on
  128521. * @param friction friction value
  128522. */
  128523. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128524. /**
  128525. * Gets restitution of the impostor
  128526. * @param impostor impostor to get restitution from
  128527. * @returns restitution value
  128528. */
  128529. getBodyRestitution(impostor: PhysicsImpostor): number;
  128530. /**
  128531. * Sets resitution of the impostor
  128532. * @param impostor impostor to set resitution on
  128533. * @param restitution resitution value
  128534. */
  128535. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128536. /**
  128537. * Gets pressure inside the impostor
  128538. * @param impostor impostor to get pressure from
  128539. * @returns pressure value
  128540. */
  128541. getBodyPressure(impostor: PhysicsImpostor): number;
  128542. /**
  128543. * Sets pressure inside a soft body impostor
  128544. * Cloth and rope must remain 0 pressure
  128545. * @param impostor impostor to set pressure on
  128546. * @param pressure pressure value
  128547. */
  128548. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128549. /**
  128550. * Gets stiffness of the impostor
  128551. * @param impostor impostor to get stiffness from
  128552. * @returns pressure value
  128553. */
  128554. getBodyStiffness(impostor: PhysicsImpostor): number;
  128555. /**
  128556. * Sets stiffness of the impostor
  128557. * @param impostor impostor to set stiffness on
  128558. * @param stiffness stiffness value from 0 to 1
  128559. */
  128560. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128561. /**
  128562. * Gets velocityIterations of the impostor
  128563. * @param impostor impostor to get velocity iterations from
  128564. * @returns velocityIterations value
  128565. */
  128566. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128567. /**
  128568. * Sets velocityIterations of the impostor
  128569. * @param impostor impostor to set velocity iterations on
  128570. * @param velocityIterations velocityIterations value
  128571. */
  128572. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128573. /**
  128574. * Gets positionIterations of the impostor
  128575. * @param impostor impostor to get position iterations from
  128576. * @returns positionIterations value
  128577. */
  128578. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128579. /**
  128580. * Sets positionIterations of the impostor
  128581. * @param impostor impostor to set position on
  128582. * @param positionIterations positionIterations value
  128583. */
  128584. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128585. /**
  128586. * Append an anchor to a cloth object
  128587. * @param impostor is the cloth impostor to add anchor to
  128588. * @param otherImpostor is the rigid impostor to anchor to
  128589. * @param width ratio across width from 0 to 1
  128590. * @param height ratio up height from 0 to 1
  128591. * @param influence the elasticity between cloth 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. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128595. /**
  128596. * Append an hook to a rope object
  128597. * @param impostor is the rope impostor to add hook to
  128598. * @param otherImpostor is the rigid impostor to hook to
  128599. * @param length ratio along the rope from 0 to 1
  128600. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128601. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128602. */
  128603. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128604. /**
  128605. * Sleeps the physics body and stops it from being active
  128606. * @param impostor impostor to sleep
  128607. */
  128608. sleepBody(impostor: PhysicsImpostor): void;
  128609. /**
  128610. * Activates the physics body
  128611. * @param impostor impostor to activate
  128612. */
  128613. wakeUpBody(impostor: PhysicsImpostor): void;
  128614. /**
  128615. * Updates the distance parameters of the joint
  128616. * @param joint joint to update
  128617. * @param maxDistance maximum distance of the joint
  128618. * @param minDistance minimum distance of the joint
  128619. */
  128620. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128621. /**
  128622. * Sets a motor on the joint
  128623. * @param joint joint to set motor on
  128624. * @param speed speed of the motor
  128625. * @param maxForce maximum force of the motor
  128626. * @param motorIndex index of the motor
  128627. */
  128628. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128629. /**
  128630. * Sets the motors limit
  128631. * @param joint joint to set limit on
  128632. * @param upperLimit upper limit
  128633. * @param lowerLimit lower limit
  128634. */
  128635. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128636. /**
  128637. * Syncs the position and rotation of a mesh with the impostor
  128638. * @param mesh mesh to sync
  128639. * @param impostor impostor to update the mesh with
  128640. */
  128641. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128642. /**
  128643. * Gets the radius of the impostor
  128644. * @param impostor impostor to get radius from
  128645. * @returns the radius
  128646. */
  128647. getRadius(impostor: PhysicsImpostor): number;
  128648. /**
  128649. * Gets the box size of the impostor
  128650. * @param impostor impostor to get box size from
  128651. * @param result the resulting box size
  128652. */
  128653. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128654. /**
  128655. * Disposes of the impostor
  128656. */
  128657. dispose(): void;
  128658. /**
  128659. * Does a raycast in the physics world
  128660. * @param from when should the ray start?
  128661. * @param to when should the ray end?
  128662. * @returns PhysicsRaycastResult
  128663. */
  128664. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128665. }
  128666. }
  128667. declare module BABYLON {
  128668. interface AbstractScene {
  128669. /**
  128670. * The list of reflection probes added to the scene
  128671. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128672. */
  128673. reflectionProbes: Array<ReflectionProbe>;
  128674. /**
  128675. * Removes the given reflection probe from this scene.
  128676. * @param toRemove The reflection probe to remove
  128677. * @returns The index of the removed reflection probe
  128678. */
  128679. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128680. /**
  128681. * Adds the given reflection probe to this scene.
  128682. * @param newReflectionProbe The reflection probe to add
  128683. */
  128684. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128685. }
  128686. /**
  128687. * Class used to generate realtime reflection / refraction cube textures
  128688. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128689. */
  128690. export class ReflectionProbe {
  128691. /** defines the name of the probe */
  128692. name: string;
  128693. private _scene;
  128694. private _renderTargetTexture;
  128695. private _projectionMatrix;
  128696. private _viewMatrix;
  128697. private _target;
  128698. private _add;
  128699. private _attachedMesh;
  128700. private _invertYAxis;
  128701. /** Gets or sets probe position (center of the cube map) */
  128702. position: Vector3;
  128703. /**
  128704. * Creates a new reflection probe
  128705. * @param name defines the name of the probe
  128706. * @param size defines the texture resolution (for each face)
  128707. * @param scene defines the hosting scene
  128708. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128709. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128710. */
  128711. constructor(
  128712. /** defines the name of the probe */
  128713. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128714. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128715. get samples(): number;
  128716. set samples(value: number);
  128717. /** Gets or sets the refresh rate to use (on every frame by default) */
  128718. get refreshRate(): number;
  128719. set refreshRate(value: number);
  128720. /**
  128721. * Gets the hosting scene
  128722. * @returns a Scene
  128723. */
  128724. getScene(): Scene;
  128725. /** Gets the internal CubeTexture used to render to */
  128726. get cubeTexture(): RenderTargetTexture;
  128727. /** Gets the list of meshes to render */
  128728. get renderList(): Nullable<AbstractMesh[]>;
  128729. /**
  128730. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128731. * @param mesh defines the mesh to attach to
  128732. */
  128733. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128734. /**
  128735. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128736. * @param renderingGroupId The rendering group id corresponding to its index
  128737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128738. */
  128739. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128740. /**
  128741. * Clean all associated resources
  128742. */
  128743. dispose(): void;
  128744. /**
  128745. * Converts the reflection probe information to a readable string for debug purpose.
  128746. * @param fullDetails Supports for multiple levels of logging within scene loading
  128747. * @returns the human readable reflection probe info
  128748. */
  128749. toString(fullDetails?: boolean): string;
  128750. /**
  128751. * Get the class name of the relfection probe.
  128752. * @returns "ReflectionProbe"
  128753. */
  128754. getClassName(): string;
  128755. /**
  128756. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128757. * @returns The JSON representation of the texture
  128758. */
  128759. serialize(): any;
  128760. /**
  128761. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128762. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128763. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128764. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128765. * @returns The parsed reflection probe if successful
  128766. */
  128767. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128768. }
  128769. }
  128770. declare module BABYLON {
  128771. /** @hidden */
  128772. export var _BabylonLoaderRegistered: boolean;
  128773. /**
  128774. * Helps setting up some configuration for the babylon file loader.
  128775. */
  128776. export class BabylonFileLoaderConfiguration {
  128777. /**
  128778. * The loader does not allow injecting custom physix engine into the plugins.
  128779. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128780. * So you could set this variable to your engine import to make it work.
  128781. */
  128782. static LoaderInjectedPhysicsEngine: any;
  128783. }
  128784. }
  128785. declare module BABYLON {
  128786. /**
  128787. * The Physically based simple base material of BJS.
  128788. *
  128789. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128790. * It is used as the base class for both the specGloss and metalRough conventions.
  128791. */
  128792. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128793. /**
  128794. * Number of Simultaneous lights allowed on the material.
  128795. */
  128796. maxSimultaneousLights: number;
  128797. /**
  128798. * If sets to true, disables all the lights affecting the material.
  128799. */
  128800. disableLighting: boolean;
  128801. /**
  128802. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128803. */
  128804. environmentTexture: BaseTexture;
  128805. /**
  128806. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128807. */
  128808. invertNormalMapX: boolean;
  128809. /**
  128810. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128811. */
  128812. invertNormalMapY: boolean;
  128813. /**
  128814. * Normal map used in the model.
  128815. */
  128816. normalTexture: BaseTexture;
  128817. /**
  128818. * Emissivie color used to self-illuminate the model.
  128819. */
  128820. emissiveColor: Color3;
  128821. /**
  128822. * Emissivie texture used to self-illuminate the model.
  128823. */
  128824. emissiveTexture: BaseTexture;
  128825. /**
  128826. * Occlusion Channel Strenght.
  128827. */
  128828. occlusionStrength: number;
  128829. /**
  128830. * Occlusion Texture of the material (adding extra occlusion effects).
  128831. */
  128832. occlusionTexture: BaseTexture;
  128833. /**
  128834. * Defines the alpha limits in alpha test mode.
  128835. */
  128836. alphaCutOff: number;
  128837. /**
  128838. * Gets the current double sided mode.
  128839. */
  128840. get doubleSided(): boolean;
  128841. /**
  128842. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128843. */
  128844. set doubleSided(value: boolean);
  128845. /**
  128846. * Stores the pre-calculated light information of a mesh in a texture.
  128847. */
  128848. lightmapTexture: BaseTexture;
  128849. /**
  128850. * If true, the light map contains occlusion information instead of lighting info.
  128851. */
  128852. useLightmapAsShadowmap: boolean;
  128853. /**
  128854. * Instantiates a new PBRMaterial instance.
  128855. *
  128856. * @param name The material name
  128857. * @param scene The scene the material will be use in.
  128858. */
  128859. constructor(name: string, scene: Scene);
  128860. getClassName(): string;
  128861. }
  128862. }
  128863. declare module BABYLON {
  128864. /**
  128865. * The PBR material of BJS following the metal roughness convention.
  128866. *
  128867. * This fits to the PBR convention in the GLTF definition:
  128868. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128869. */
  128870. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128871. /**
  128872. * The base color has two different interpretations depending on the value of metalness.
  128873. * When the material is a metal, the base color is the specific measured reflectance value
  128874. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128875. * of the material.
  128876. */
  128877. baseColor: Color3;
  128878. /**
  128879. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128880. * well as opacity information in the alpha channel.
  128881. */
  128882. baseTexture: BaseTexture;
  128883. /**
  128884. * Specifies the metallic scalar value of the material.
  128885. * Can also be used to scale the metalness values of the metallic texture.
  128886. */
  128887. metallic: number;
  128888. /**
  128889. * Specifies the roughness scalar value of the material.
  128890. * Can also be used to scale the roughness values of the metallic texture.
  128891. */
  128892. roughness: number;
  128893. /**
  128894. * Texture containing both the metallic value in the B channel and the
  128895. * roughness value in the G channel to keep better precision.
  128896. */
  128897. metallicRoughnessTexture: BaseTexture;
  128898. /**
  128899. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128900. *
  128901. * @param name The material name
  128902. * @param scene The scene the material will be use in.
  128903. */
  128904. constructor(name: string, scene: Scene);
  128905. /**
  128906. * Return the currrent class name of the material.
  128907. */
  128908. getClassName(): string;
  128909. /**
  128910. * Makes a duplicate of the current material.
  128911. * @param name - name to use for the new material.
  128912. */
  128913. clone(name: string): PBRMetallicRoughnessMaterial;
  128914. /**
  128915. * Serialize the material to a parsable JSON object.
  128916. */
  128917. serialize(): any;
  128918. /**
  128919. * Parses a JSON object correponding to the serialize function.
  128920. */
  128921. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128922. }
  128923. }
  128924. declare module BABYLON {
  128925. /**
  128926. * The PBR material of BJS following the specular glossiness convention.
  128927. *
  128928. * This fits to the PBR convention in the GLTF definition:
  128929. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128930. */
  128931. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128932. /**
  128933. * Specifies the diffuse color of the material.
  128934. */
  128935. diffuseColor: Color3;
  128936. /**
  128937. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128938. * channel.
  128939. */
  128940. diffuseTexture: BaseTexture;
  128941. /**
  128942. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128943. */
  128944. specularColor: Color3;
  128945. /**
  128946. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128947. */
  128948. glossiness: number;
  128949. /**
  128950. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128951. */
  128952. specularGlossinessTexture: BaseTexture;
  128953. /**
  128954. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128955. *
  128956. * @param name The material name
  128957. * @param scene The scene the material will be use in.
  128958. */
  128959. constructor(name: string, scene: Scene);
  128960. /**
  128961. * Return the currrent class name of the material.
  128962. */
  128963. getClassName(): string;
  128964. /**
  128965. * Makes a duplicate of the current material.
  128966. * @param name - name to use for the new material.
  128967. */
  128968. clone(name: string): PBRSpecularGlossinessMaterial;
  128969. /**
  128970. * Serialize the material to a parsable JSON object.
  128971. */
  128972. serialize(): any;
  128973. /**
  128974. * Parses a JSON object correponding to the serialize function.
  128975. */
  128976. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128977. }
  128978. }
  128979. declare module BABYLON {
  128980. /**
  128981. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128982. * It can help converting any input color in a desired output one. This can then be used to create effects
  128983. * from sepia, black and white to sixties or futuristic rendering...
  128984. *
  128985. * The only supported format is currently 3dl.
  128986. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128987. */
  128988. export class ColorGradingTexture extends BaseTexture {
  128989. /**
  128990. * The current texture matrix. (will always be identity in color grading texture)
  128991. */
  128992. private _textureMatrix;
  128993. /**
  128994. * The texture URL.
  128995. */
  128996. url: string;
  128997. /**
  128998. * Empty line regex stored for GC.
  128999. */
  129000. private static _noneEmptyLineRegex;
  129001. private _engine;
  129002. /**
  129003. * Instantiates a ColorGradingTexture from the following parameters.
  129004. *
  129005. * @param url The location of the color gradind data (currently only supporting 3dl)
  129006. * @param scene The scene the texture will be used in
  129007. */
  129008. constructor(url: string, scene: Scene);
  129009. /**
  129010. * Returns the texture matrix used in most of the material.
  129011. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129012. */
  129013. getTextureMatrix(): Matrix;
  129014. /**
  129015. * Occurs when the file being loaded is a .3dl LUT file.
  129016. */
  129017. private load3dlTexture;
  129018. /**
  129019. * Starts the loading process of the texture.
  129020. */
  129021. private loadTexture;
  129022. /**
  129023. * Clones the color gradind texture.
  129024. */
  129025. clone(): ColorGradingTexture;
  129026. /**
  129027. * Called during delayed load for textures.
  129028. */
  129029. delayLoad(): void;
  129030. /**
  129031. * Parses a color grading texture serialized by Babylon.
  129032. * @param parsedTexture The texture information being parsedTexture
  129033. * @param scene The scene to load the texture in
  129034. * @param rootUrl The root url of the data assets to load
  129035. * @return A color gradind texture
  129036. */
  129037. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129038. /**
  129039. * Serializes the LUT texture to json format.
  129040. */
  129041. serialize(): any;
  129042. }
  129043. }
  129044. declare module BABYLON {
  129045. /**
  129046. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129047. */
  129048. export class EquiRectangularCubeTexture extends BaseTexture {
  129049. /** The six faces of the cube. */
  129050. private static _FacesMapping;
  129051. private _noMipmap;
  129052. private _onLoad;
  129053. private _onError;
  129054. /** The size of the cubemap. */
  129055. private _size;
  129056. /** The buffer of the image. */
  129057. private _buffer;
  129058. /** The width of the input image. */
  129059. private _width;
  129060. /** The height of the input image. */
  129061. private _height;
  129062. /** The URL to the image. */
  129063. url: string;
  129064. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129065. coordinatesMode: number;
  129066. /**
  129067. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129068. * @param url The location of the image
  129069. * @param scene The scene the texture will be used in
  129070. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129071. * @param noMipmap Forces to not generate the mipmap if true
  129072. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129073. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129074. * @param onLoad — defines a callback called when texture is loaded
  129075. * @param onError — defines a callback called if there is an error
  129076. */
  129077. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129078. /**
  129079. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129080. */
  129081. private loadImage;
  129082. /**
  129083. * Convert the image buffer into a cubemap and create a CubeTexture.
  129084. */
  129085. private loadTexture;
  129086. /**
  129087. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129088. * @param buffer The ArrayBuffer that should be converted.
  129089. * @returns The buffer as Float32Array.
  129090. */
  129091. private getFloat32ArrayFromArrayBuffer;
  129092. /**
  129093. * Get the current class name of the texture useful for serialization or dynamic coding.
  129094. * @returns "EquiRectangularCubeTexture"
  129095. */
  129096. getClassName(): string;
  129097. /**
  129098. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129099. * @returns A clone of the current EquiRectangularCubeTexture.
  129100. */
  129101. clone(): EquiRectangularCubeTexture;
  129102. }
  129103. }
  129104. declare module BABYLON {
  129105. /**
  129106. * Based on jsTGALoader - Javascript loader for TGA file
  129107. * By Vincent Thibault
  129108. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129109. */
  129110. export class TGATools {
  129111. private static _TYPE_INDEXED;
  129112. private static _TYPE_RGB;
  129113. private static _TYPE_GREY;
  129114. private static _TYPE_RLE_INDEXED;
  129115. private static _TYPE_RLE_RGB;
  129116. private static _TYPE_RLE_GREY;
  129117. private static _ORIGIN_MASK;
  129118. private static _ORIGIN_SHIFT;
  129119. private static _ORIGIN_BL;
  129120. private static _ORIGIN_BR;
  129121. private static _ORIGIN_UL;
  129122. private static _ORIGIN_UR;
  129123. /**
  129124. * Gets the header of a TGA file
  129125. * @param data defines the TGA data
  129126. * @returns the header
  129127. */
  129128. static GetTGAHeader(data: Uint8Array): any;
  129129. /**
  129130. * Uploads TGA content to a Babylon Texture
  129131. * @hidden
  129132. */
  129133. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129134. /** @hidden */
  129135. 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;
  129136. /** @hidden */
  129137. 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;
  129138. /** @hidden */
  129139. 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;
  129140. /** @hidden */
  129141. 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;
  129142. /** @hidden */
  129143. 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;
  129144. /** @hidden */
  129145. 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;
  129146. }
  129147. }
  129148. declare module BABYLON {
  129149. /**
  129150. * Implementation of the TGA Texture Loader.
  129151. * @hidden
  129152. */
  129153. export class _TGATextureLoader implements IInternalTextureLoader {
  129154. /**
  129155. * Defines wether the loader supports cascade loading the different faces.
  129156. */
  129157. readonly supportCascades: boolean;
  129158. /**
  129159. * This returns if the loader support the current file information.
  129160. * @param extension defines the file extension of the file being loaded
  129161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129162. * @param fallback defines the fallback internal texture if any
  129163. * @param isBase64 defines whether the texture is encoded as a base64
  129164. * @param isBuffer defines whether the texture data are stored as a buffer
  129165. * @returns true if the loader can load the specified file
  129166. */
  129167. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129168. /**
  129169. * Transform the url before loading if required.
  129170. * @param rootUrl the url of the texture
  129171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129172. * @returns the transformed texture
  129173. */
  129174. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129175. /**
  129176. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129177. * @param rootUrl the url of the texture
  129178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129179. * @returns the fallback texture
  129180. */
  129181. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129182. /**
  129183. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129184. * @param data contains the texture data
  129185. * @param texture defines the BabylonJS internal texture
  129186. * @param createPolynomials will be true if polynomials have been requested
  129187. * @param onLoad defines the callback to trigger once the texture is ready
  129188. * @param onError defines the callback to trigger in case of error
  129189. */
  129190. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129191. /**
  129192. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129193. * @param data contains the texture data
  129194. * @param texture defines the BabylonJS internal texture
  129195. * @param callback defines the method to call once ready to upload
  129196. */
  129197. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129198. }
  129199. }
  129200. declare module BABYLON {
  129201. /**
  129202. * Info about the .basis files
  129203. */
  129204. class BasisFileInfo {
  129205. /**
  129206. * If the file has alpha
  129207. */
  129208. hasAlpha: boolean;
  129209. /**
  129210. * Info about each image of the basis file
  129211. */
  129212. images: Array<{
  129213. levels: Array<{
  129214. width: number;
  129215. height: number;
  129216. transcodedPixels: ArrayBufferView;
  129217. }>;
  129218. }>;
  129219. }
  129220. /**
  129221. * Result of transcoding a basis file
  129222. */
  129223. class TranscodeResult {
  129224. /**
  129225. * Info about the .basis file
  129226. */
  129227. fileInfo: BasisFileInfo;
  129228. /**
  129229. * Format to use when loading the file
  129230. */
  129231. format: number;
  129232. }
  129233. /**
  129234. * Configuration options for the Basis transcoder
  129235. */
  129236. export class BasisTranscodeConfiguration {
  129237. /**
  129238. * Supported compression formats used to determine the supported output format of the transcoder
  129239. */
  129240. supportedCompressionFormats?: {
  129241. /**
  129242. * etc1 compression format
  129243. */
  129244. etc1?: boolean;
  129245. /**
  129246. * s3tc compression format
  129247. */
  129248. s3tc?: boolean;
  129249. /**
  129250. * pvrtc compression format
  129251. */
  129252. pvrtc?: boolean;
  129253. /**
  129254. * etc2 compression format
  129255. */
  129256. etc2?: boolean;
  129257. };
  129258. /**
  129259. * If mipmap levels should be loaded for transcoded images (Default: true)
  129260. */
  129261. loadMipmapLevels?: boolean;
  129262. /**
  129263. * Index of a single image to load (Default: all images)
  129264. */
  129265. loadSingleImage?: number;
  129266. }
  129267. /**
  129268. * Used to load .Basis files
  129269. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129270. */
  129271. export class BasisTools {
  129272. private static _IgnoreSupportedFormats;
  129273. /**
  129274. * URL to use when loading the basis transcoder
  129275. */
  129276. static JSModuleURL: string;
  129277. /**
  129278. * URL to use when loading the wasm module for the transcoder
  129279. */
  129280. static WasmModuleURL: string;
  129281. /**
  129282. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129283. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129284. * @returns internal format corresponding to the Basis format
  129285. */
  129286. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129287. private static _WorkerPromise;
  129288. private static _Worker;
  129289. private static _actionId;
  129290. private static _CreateWorkerAsync;
  129291. /**
  129292. * Transcodes a loaded image file to compressed pixel data
  129293. * @param data image data to transcode
  129294. * @param config configuration options for the transcoding
  129295. * @returns a promise resulting in the transcoded image
  129296. */
  129297. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129298. /**
  129299. * Loads a texture from the transcode result
  129300. * @param texture texture load to
  129301. * @param transcodeResult the result of transcoding the basis file to load from
  129302. */
  129303. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129304. }
  129305. }
  129306. declare module BABYLON {
  129307. /**
  129308. * Loader for .basis file format
  129309. */
  129310. export class _BasisTextureLoader implements IInternalTextureLoader {
  129311. /**
  129312. * Defines whether the loader supports cascade loading the different faces.
  129313. */
  129314. readonly supportCascades: boolean;
  129315. /**
  129316. * This returns if the loader support the current file information.
  129317. * @param extension defines the file extension of the file being loaded
  129318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129319. * @param fallback defines the fallback internal texture if any
  129320. * @param isBase64 defines whether the texture is encoded as a base64
  129321. * @param isBuffer defines whether the texture data are stored as a buffer
  129322. * @returns true if the loader can load the specified file
  129323. */
  129324. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129325. /**
  129326. * Transform the url before loading if required.
  129327. * @param rootUrl the url of the texture
  129328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129329. * @returns the transformed texture
  129330. */
  129331. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129332. /**
  129333. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129334. * @param rootUrl the url of the texture
  129335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129336. * @returns the fallback texture
  129337. */
  129338. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129339. /**
  129340. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129341. * @param data contains the texture data
  129342. * @param texture defines the BabylonJS internal texture
  129343. * @param createPolynomials will be true if polynomials have been requested
  129344. * @param onLoad defines the callback to trigger once the texture is ready
  129345. * @param onError defines the callback to trigger in case of error
  129346. */
  129347. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129348. /**
  129349. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129350. * @param data contains the texture data
  129351. * @param texture defines the BabylonJS internal texture
  129352. * @param callback defines the method to call once ready to upload
  129353. */
  129354. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129355. }
  129356. }
  129357. declare module BABYLON {
  129358. /**
  129359. * 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.
  129360. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129361. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129362. */
  129363. export class CustomProceduralTexture extends ProceduralTexture {
  129364. private _animate;
  129365. private _time;
  129366. private _config;
  129367. private _texturePath;
  129368. /**
  129369. * Instantiates a new Custom Procedural Texture.
  129370. * 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.
  129371. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129372. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129373. * @param name Define the name of the texture
  129374. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129375. * @param size Define the size of the texture to create
  129376. * @param scene Define the scene the texture belongs to
  129377. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129378. * @param generateMipMaps Define if the texture should creates mip maps or not
  129379. */
  129380. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129381. private _loadJson;
  129382. /**
  129383. * Is the texture ready to be used ? (rendered at least once)
  129384. * @returns true if ready, otherwise, false.
  129385. */
  129386. isReady(): boolean;
  129387. /**
  129388. * Render the texture to its associated render target.
  129389. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129390. */
  129391. render(useCameraPostProcess?: boolean): void;
  129392. /**
  129393. * Update the list of dependant textures samplers in the shader.
  129394. */
  129395. updateTextures(): void;
  129396. /**
  129397. * Update the uniform values of the procedural texture in the shader.
  129398. */
  129399. updateShaderUniforms(): void;
  129400. /**
  129401. * Define if the texture animates or not.
  129402. */
  129403. get animate(): boolean;
  129404. set animate(value: boolean);
  129405. }
  129406. }
  129407. declare module BABYLON {
  129408. /** @hidden */
  129409. export var noisePixelShader: {
  129410. name: string;
  129411. shader: string;
  129412. };
  129413. }
  129414. declare module BABYLON {
  129415. /**
  129416. * Class used to generate noise procedural textures
  129417. */
  129418. export class NoiseProceduralTexture extends ProceduralTexture {
  129419. private _time;
  129420. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129421. brightness: number;
  129422. /** Defines the number of octaves to process */
  129423. octaves: number;
  129424. /** Defines the level of persistence (0.8 by default) */
  129425. persistence: number;
  129426. /** Gets or sets animation speed factor (default is 1) */
  129427. animationSpeedFactor: number;
  129428. /**
  129429. * Creates a new NoiseProceduralTexture
  129430. * @param name defines the name fo the texture
  129431. * @param size defines the size of the texture (default is 256)
  129432. * @param scene defines the hosting scene
  129433. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129434. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129435. */
  129436. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129437. private _updateShaderUniforms;
  129438. protected _getDefines(): string;
  129439. /** Generate the current state of the procedural texture */
  129440. render(useCameraPostProcess?: boolean): void;
  129441. /**
  129442. * Serializes this noise procedural texture
  129443. * @returns a serialized noise procedural texture object
  129444. */
  129445. serialize(): any;
  129446. /**
  129447. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129448. * @param parsedTexture defines parsed texture data
  129449. * @param scene defines the current scene
  129450. * @param rootUrl defines the root URL containing noise procedural texture information
  129451. * @returns a parsed NoiseProceduralTexture
  129452. */
  129453. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129454. }
  129455. }
  129456. declare module BABYLON {
  129457. /**
  129458. * Raw cube texture where the raw buffers are passed in
  129459. */
  129460. export class RawCubeTexture extends CubeTexture {
  129461. /**
  129462. * Creates a cube texture where the raw buffers are passed in.
  129463. * @param scene defines the scene the texture is attached to
  129464. * @param data defines the array of data to use to create each face
  129465. * @param size defines the size of the textures
  129466. * @param format defines the format of the data
  129467. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129468. * @param generateMipMaps defines if the engine should generate the mip levels
  129469. * @param invertY defines if data must be stored with Y axis inverted
  129470. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129471. * @param compression defines the compression used (null by default)
  129472. */
  129473. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129474. /**
  129475. * Updates the raw cube texture.
  129476. * @param data defines the data to store
  129477. * @param format defines the data format
  129478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129479. * @param invertY defines if data must be stored with Y axis inverted
  129480. * @param compression defines the compression used (null by default)
  129481. * @param level defines which level of the texture to update
  129482. */
  129483. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129484. /**
  129485. * Updates a raw cube texture with RGBD encoded data.
  129486. * @param data defines the array of data [mipmap][face] to use to create each face
  129487. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129488. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129489. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129490. * @returns a promsie that resolves when the operation is complete
  129491. */
  129492. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129493. /**
  129494. * Clones the raw cube texture.
  129495. * @return a new cube texture
  129496. */
  129497. clone(): CubeTexture;
  129498. /** @hidden */
  129499. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129500. }
  129501. }
  129502. declare module BABYLON {
  129503. /**
  129504. * Class used to store 3D textures containing user data
  129505. */
  129506. export class RawTexture3D extends Texture {
  129507. /** Gets or sets the texture format to use */
  129508. format: number;
  129509. private _engine;
  129510. /**
  129511. * Create a new RawTexture3D
  129512. * @param data defines the data of the texture
  129513. * @param width defines the width of the texture
  129514. * @param height defines the height of the texture
  129515. * @param depth defines the depth of the texture
  129516. * @param format defines the texture format to use
  129517. * @param scene defines the hosting scene
  129518. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129519. * @param invertY defines if texture must be stored with Y axis inverted
  129520. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129521. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129522. */
  129523. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129524. /** Gets or sets the texture format to use */
  129525. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129526. /**
  129527. * Update the texture with new data
  129528. * @param data defines the data to store in the texture
  129529. */
  129530. update(data: ArrayBufferView): void;
  129531. }
  129532. }
  129533. declare module BABYLON {
  129534. /**
  129535. * Class used to store 2D array textures containing user data
  129536. */
  129537. export class RawTexture2DArray extends Texture {
  129538. /** Gets or sets the texture format to use */
  129539. format: number;
  129540. private _engine;
  129541. /**
  129542. * Create a new RawTexture2DArray
  129543. * @param data defines the data of the texture
  129544. * @param width defines the width of the texture
  129545. * @param height defines the height of the texture
  129546. * @param depth defines the number of layers of the texture
  129547. * @param format defines the texture format to use
  129548. * @param scene defines the hosting scene
  129549. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129550. * @param invertY defines if texture must be stored with Y axis inverted
  129551. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129553. */
  129554. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129555. /** Gets or sets the texture format to use */
  129556. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129557. /**
  129558. * Update the texture with new data
  129559. * @param data defines the data to store in the texture
  129560. */
  129561. update(data: ArrayBufferView): void;
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * Creates a refraction texture used by refraction channel of the standard material.
  129567. * It is like a mirror but to see through a material.
  129568. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129569. */
  129570. export class RefractionTexture extends RenderTargetTexture {
  129571. /**
  129572. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129573. * 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.
  129574. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129575. */
  129576. refractionPlane: Plane;
  129577. /**
  129578. * Define how deep under the surface we should see.
  129579. */
  129580. depth: number;
  129581. /**
  129582. * Creates a refraction texture used by refraction channel of the standard material.
  129583. * It is like a mirror but to see through a material.
  129584. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129585. * @param name Define the texture name
  129586. * @param size Define the size of the underlying texture
  129587. * @param scene Define the scene the refraction belongs to
  129588. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129589. */
  129590. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129591. /**
  129592. * Clone the refraction texture.
  129593. * @returns the cloned texture
  129594. */
  129595. clone(): RefractionTexture;
  129596. /**
  129597. * Serialize the texture to a JSON representation you could use in Parse later on
  129598. * @returns the serialized JSON representation
  129599. */
  129600. serialize(): any;
  129601. }
  129602. }
  129603. declare module BABYLON {
  129604. /**
  129605. * Defines the options related to the creation of an HtmlElementTexture
  129606. */
  129607. export interface IHtmlElementTextureOptions {
  129608. /**
  129609. * Defines wether mip maps should be created or not.
  129610. */
  129611. generateMipMaps?: boolean;
  129612. /**
  129613. * Defines the sampling mode of the texture.
  129614. */
  129615. samplingMode?: number;
  129616. /**
  129617. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129618. */
  129619. engine: Nullable<ThinEngine>;
  129620. /**
  129621. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129622. */
  129623. scene: Nullable<Scene>;
  129624. }
  129625. /**
  129626. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129627. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129628. * is automatically managed.
  129629. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129630. * in your application.
  129631. *
  129632. * As the update is not automatic, you need to call them manually.
  129633. */
  129634. export class HtmlElementTexture extends BaseTexture {
  129635. /**
  129636. * The texture URL.
  129637. */
  129638. element: HTMLVideoElement | HTMLCanvasElement;
  129639. private static readonly DefaultOptions;
  129640. private _textureMatrix;
  129641. private _engine;
  129642. private _isVideo;
  129643. private _generateMipMaps;
  129644. private _samplingMode;
  129645. /**
  129646. * Instantiates a HtmlElementTexture from the following parameters.
  129647. *
  129648. * @param name Defines the name of the texture
  129649. * @param element Defines the video or canvas the texture is filled with
  129650. * @param options Defines the other none mandatory texture creation options
  129651. */
  129652. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129653. private _createInternalTexture;
  129654. /**
  129655. * Returns the texture matrix used in most of the material.
  129656. */
  129657. getTextureMatrix(): Matrix;
  129658. /**
  129659. * Updates the content of the texture.
  129660. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129661. */
  129662. update(invertY?: Nullable<boolean>): void;
  129663. }
  129664. }
  129665. declare module BABYLON {
  129666. /**
  129667. * Defines the basic options interface of a TexturePacker Frame
  129668. */
  129669. export interface ITexturePackerFrame {
  129670. /**
  129671. * The frame ID
  129672. */
  129673. id: number;
  129674. /**
  129675. * The frames Scale
  129676. */
  129677. scale: Vector2;
  129678. /**
  129679. * The Frames offset
  129680. */
  129681. offset: Vector2;
  129682. }
  129683. /**
  129684. * This is a support class for frame Data on texture packer sets.
  129685. */
  129686. export class TexturePackerFrame implements ITexturePackerFrame {
  129687. /**
  129688. * The frame ID
  129689. */
  129690. id: number;
  129691. /**
  129692. * The frames Scale
  129693. */
  129694. scale: Vector2;
  129695. /**
  129696. * The Frames offset
  129697. */
  129698. offset: Vector2;
  129699. /**
  129700. * Initializes a texture package frame.
  129701. * @param id The numerical frame identifier
  129702. * @param scale Scalar Vector2 for UV frame
  129703. * @param offset Vector2 for the frame position in UV units.
  129704. * @returns TexturePackerFrame
  129705. */
  129706. constructor(id: number, scale: Vector2, offset: Vector2);
  129707. }
  129708. }
  129709. declare module BABYLON {
  129710. /**
  129711. * Defines the basic options interface of a TexturePacker
  129712. */
  129713. export interface ITexturePackerOptions {
  129714. /**
  129715. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129716. */
  129717. map?: string[];
  129718. /**
  129719. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129720. */
  129721. uvsIn?: string;
  129722. /**
  129723. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129724. */
  129725. uvsOut?: string;
  129726. /**
  129727. * number representing the layout style. Defaults to LAYOUT_STRIP
  129728. */
  129729. layout?: number;
  129730. /**
  129731. * number of columns if using custom column count layout(2). This defaults to 4.
  129732. */
  129733. colnum?: number;
  129734. /**
  129735. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129736. */
  129737. updateInputMeshes?: boolean;
  129738. /**
  129739. * boolean flag to dispose all the source textures. Defaults to true.
  129740. */
  129741. disposeSources?: boolean;
  129742. /**
  129743. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129744. */
  129745. fillBlanks?: boolean;
  129746. /**
  129747. * string value representing the context fill style color. Defaults to 'black'.
  129748. */
  129749. customFillColor?: string;
  129750. /**
  129751. * Width and Height Value of each Frame in the TexturePacker Sets
  129752. */
  129753. frameSize?: number;
  129754. /**
  129755. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129756. */
  129757. paddingRatio?: number;
  129758. /**
  129759. * Number that declares the fill method for the padding gutter.
  129760. */
  129761. paddingMode?: number;
  129762. /**
  129763. * If in SUBUV_COLOR padding mode what color to use.
  129764. */
  129765. paddingColor?: Color3 | Color4;
  129766. }
  129767. /**
  129768. * Defines the basic interface of a TexturePacker JSON File
  129769. */
  129770. export interface ITexturePackerJSON {
  129771. /**
  129772. * The frame ID
  129773. */
  129774. name: string;
  129775. /**
  129776. * The base64 channel data
  129777. */
  129778. sets: any;
  129779. /**
  129780. * The options of the Packer
  129781. */
  129782. options: ITexturePackerOptions;
  129783. /**
  129784. * The frame data of the Packer
  129785. */
  129786. frames: Array<number>;
  129787. }
  129788. /**
  129789. * This is a support class that generates a series of packed texture sets.
  129790. * @see https://doc.babylonjs.com/babylon101/materials
  129791. */
  129792. export class TexturePacker {
  129793. /** Packer Layout Constant 0 */
  129794. static readonly LAYOUT_STRIP: number;
  129795. /** Packer Layout Constant 1 */
  129796. static readonly LAYOUT_POWER2: number;
  129797. /** Packer Layout Constant 2 */
  129798. static readonly LAYOUT_COLNUM: number;
  129799. /** Packer Layout Constant 0 */
  129800. static readonly SUBUV_WRAP: number;
  129801. /** Packer Layout Constant 1 */
  129802. static readonly SUBUV_EXTEND: number;
  129803. /** Packer Layout Constant 2 */
  129804. static readonly SUBUV_COLOR: number;
  129805. /** The Name of the Texture Package */
  129806. name: string;
  129807. /** The scene scope of the TexturePacker */
  129808. scene: Scene;
  129809. /** The Meshes to target */
  129810. meshes: AbstractMesh[];
  129811. /** Arguments passed with the Constructor */
  129812. options: ITexturePackerOptions;
  129813. /** The promise that is started upon initialization */
  129814. promise: Nullable<Promise<TexturePacker | string>>;
  129815. /** The Container object for the channel sets that are generated */
  129816. sets: object;
  129817. /** The Container array for the frames that are generated */
  129818. frames: TexturePackerFrame[];
  129819. /** The expected number of textures the system is parsing. */
  129820. private _expecting;
  129821. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129822. private _paddingValue;
  129823. /**
  129824. * Initializes a texture package series from an array of meshes or a single mesh.
  129825. * @param name The name of the package
  129826. * @param meshes The target meshes to compose the package from
  129827. * @param options The arguments that texture packer should follow while building.
  129828. * @param scene The scene which the textures are scoped to.
  129829. * @returns TexturePacker
  129830. */
  129831. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129832. /**
  129833. * Starts the package process
  129834. * @param resolve The promises resolution function
  129835. * @returns TexturePacker
  129836. */
  129837. private _createFrames;
  129838. /**
  129839. * Calculates the Size of the Channel Sets
  129840. * @returns Vector2
  129841. */
  129842. private _calculateSize;
  129843. /**
  129844. * Calculates the UV data for the frames.
  129845. * @param baseSize the base frameSize
  129846. * @param padding the base frame padding
  129847. * @param dtSize size of the Dynamic Texture for that channel
  129848. * @param dtUnits is 1/dtSize
  129849. * @param update flag to update the input meshes
  129850. */
  129851. private _calculateMeshUVFrames;
  129852. /**
  129853. * Calculates the frames Offset.
  129854. * @param index of the frame
  129855. * @returns Vector2
  129856. */
  129857. private _getFrameOffset;
  129858. /**
  129859. * Updates a Mesh to the frame data
  129860. * @param mesh that is the target
  129861. * @param frameID or the frame index
  129862. */
  129863. private _updateMeshUV;
  129864. /**
  129865. * Updates a Meshes materials to use the texture packer channels
  129866. * @param m is the mesh to target
  129867. * @param force all channels on the packer to be set.
  129868. */
  129869. private _updateTextureReferences;
  129870. /**
  129871. * Public method to set a Mesh to a frame
  129872. * @param m that is the target
  129873. * @param frameID or the frame index
  129874. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129875. */
  129876. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129877. /**
  129878. * Starts the async promise to compile the texture packer.
  129879. * @returns Promise<void>
  129880. */
  129881. processAsync(): Promise<void>;
  129882. /**
  129883. * Disposes all textures associated with this packer
  129884. */
  129885. dispose(): void;
  129886. /**
  129887. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129888. * @param imageType is the image type to use.
  129889. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129890. */
  129891. download(imageType?: string, quality?: number): void;
  129892. /**
  129893. * Public method to load a texturePacker JSON file.
  129894. * @param data of the JSON file in string format.
  129895. */
  129896. updateFromJSON(data: string): void;
  129897. }
  129898. }
  129899. declare module BABYLON {
  129900. /**
  129901. * Enum used to define the target of a block
  129902. */
  129903. export enum NodeMaterialBlockTargets {
  129904. /** Vertex shader */
  129905. Vertex = 1,
  129906. /** Fragment shader */
  129907. Fragment = 2,
  129908. /** Neutral */
  129909. Neutral = 4,
  129910. /** Vertex and Fragment */
  129911. VertexAndFragment = 3
  129912. }
  129913. }
  129914. declare module BABYLON {
  129915. /**
  129916. * Defines the kind of connection point for node based material
  129917. */
  129918. export enum NodeMaterialBlockConnectionPointTypes {
  129919. /** Float */
  129920. Float = 1,
  129921. /** Int */
  129922. Int = 2,
  129923. /** Vector2 */
  129924. Vector2 = 4,
  129925. /** Vector3 */
  129926. Vector3 = 8,
  129927. /** Vector4 */
  129928. Vector4 = 16,
  129929. /** Color3 */
  129930. Color3 = 32,
  129931. /** Color4 */
  129932. Color4 = 64,
  129933. /** Matrix */
  129934. Matrix = 128,
  129935. /** Detect type based on connection */
  129936. AutoDetect = 1024,
  129937. /** Output type that will be defined by input type */
  129938. BasedOnInput = 2048
  129939. }
  129940. }
  129941. declare module BABYLON {
  129942. /**
  129943. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129944. */
  129945. export enum NodeMaterialBlockConnectionPointMode {
  129946. /** Value is an uniform */
  129947. Uniform = 0,
  129948. /** Value is a mesh attribute */
  129949. Attribute = 1,
  129950. /** Value is a varying between vertex and fragment shaders */
  129951. Varying = 2,
  129952. /** Mode is undefined */
  129953. Undefined = 3
  129954. }
  129955. }
  129956. declare module BABYLON {
  129957. /**
  129958. * Enum used to define system values e.g. values automatically provided by the system
  129959. */
  129960. export enum NodeMaterialSystemValues {
  129961. /** World */
  129962. World = 1,
  129963. /** View */
  129964. View = 2,
  129965. /** Projection */
  129966. Projection = 3,
  129967. /** ViewProjection */
  129968. ViewProjection = 4,
  129969. /** WorldView */
  129970. WorldView = 5,
  129971. /** WorldViewProjection */
  129972. WorldViewProjection = 6,
  129973. /** CameraPosition */
  129974. CameraPosition = 7,
  129975. /** Fog Color */
  129976. FogColor = 8,
  129977. /** Delta time */
  129978. DeltaTime = 9
  129979. }
  129980. }
  129981. declare module BABYLON {
  129982. /**
  129983. * Root class for all node material optimizers
  129984. */
  129985. export class NodeMaterialOptimizer {
  129986. /**
  129987. * Function used to optimize a NodeMaterial graph
  129988. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129989. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129990. */
  129991. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129992. }
  129993. }
  129994. declare module BABYLON {
  129995. /**
  129996. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129997. */
  129998. export class TransformBlock extends NodeMaterialBlock {
  129999. /**
  130000. * Defines the value to use to complement W value to transform it to a Vector4
  130001. */
  130002. complementW: number;
  130003. /**
  130004. * Defines the value to use to complement z value to transform it to a Vector4
  130005. */
  130006. complementZ: number;
  130007. /**
  130008. * Creates a new TransformBlock
  130009. * @param name defines the block name
  130010. */
  130011. constructor(name: string);
  130012. /**
  130013. * Gets the current class name
  130014. * @returns the class name
  130015. */
  130016. getClassName(): string;
  130017. /**
  130018. * Gets the vector input
  130019. */
  130020. get vector(): NodeMaterialConnectionPoint;
  130021. /**
  130022. * Gets the output component
  130023. */
  130024. get output(): NodeMaterialConnectionPoint;
  130025. /**
  130026. * Gets the matrix transform input
  130027. */
  130028. get transform(): NodeMaterialConnectionPoint;
  130029. protected _buildBlock(state: NodeMaterialBuildState): this;
  130030. serialize(): any;
  130031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130032. protected _dumpPropertiesCode(): string;
  130033. }
  130034. }
  130035. declare module BABYLON {
  130036. /**
  130037. * Block used to output the vertex position
  130038. */
  130039. export class VertexOutputBlock extends NodeMaterialBlock {
  130040. /**
  130041. * Creates a new VertexOutputBlock
  130042. * @param name defines the block name
  130043. */
  130044. constructor(name: string);
  130045. /**
  130046. * Gets the current class name
  130047. * @returns the class name
  130048. */
  130049. getClassName(): string;
  130050. /**
  130051. * Gets the vector input component
  130052. */
  130053. get vector(): NodeMaterialConnectionPoint;
  130054. protected _buildBlock(state: NodeMaterialBuildState): this;
  130055. }
  130056. }
  130057. declare module BABYLON {
  130058. /**
  130059. * Block used to output the final color
  130060. */
  130061. export class FragmentOutputBlock extends NodeMaterialBlock {
  130062. /**
  130063. * Create a new FragmentOutputBlock
  130064. * @param name defines the block name
  130065. */
  130066. constructor(name: string);
  130067. /**
  130068. * Gets the current class name
  130069. * @returns the class name
  130070. */
  130071. getClassName(): string;
  130072. /**
  130073. * Gets the rgba input component
  130074. */
  130075. get rgba(): NodeMaterialConnectionPoint;
  130076. /**
  130077. * Gets the rgb input component
  130078. */
  130079. get rgb(): NodeMaterialConnectionPoint;
  130080. /**
  130081. * Gets the a input component
  130082. */
  130083. get a(): NodeMaterialConnectionPoint;
  130084. protected _buildBlock(state: NodeMaterialBuildState): this;
  130085. }
  130086. }
  130087. declare module BABYLON {
  130088. /**
  130089. * Block used to read a reflection texture from a sampler
  130090. */
  130091. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130092. private _define3DName;
  130093. private _defineCubicName;
  130094. private _defineExplicitName;
  130095. private _defineProjectionName;
  130096. private _defineLocalCubicName;
  130097. private _defineSphericalName;
  130098. private _definePlanarName;
  130099. private _defineEquirectangularName;
  130100. private _defineMirroredEquirectangularFixedName;
  130101. private _defineEquirectangularFixedName;
  130102. private _defineSkyboxName;
  130103. private _cubeSamplerName;
  130104. private _2DSamplerName;
  130105. private _positionUVWName;
  130106. private _directionWName;
  130107. private _reflectionCoordsName;
  130108. private _reflection2DCoordsName;
  130109. private _reflectionColorName;
  130110. private _reflectionMatrixName;
  130111. /**
  130112. * Gets or sets the texture associated with the node
  130113. */
  130114. texture: Nullable<BaseTexture>;
  130115. /**
  130116. * Create a new TextureBlock
  130117. * @param name defines the block name
  130118. */
  130119. constructor(name: string);
  130120. /**
  130121. * Gets the current class name
  130122. * @returns the class name
  130123. */
  130124. getClassName(): string;
  130125. /**
  130126. * Gets the world position input component
  130127. */
  130128. get position(): NodeMaterialConnectionPoint;
  130129. /**
  130130. * Gets the world position input component
  130131. */
  130132. get worldPosition(): NodeMaterialConnectionPoint;
  130133. /**
  130134. * Gets the world normal input component
  130135. */
  130136. get worldNormal(): NodeMaterialConnectionPoint;
  130137. /**
  130138. * Gets the world input component
  130139. */
  130140. get world(): NodeMaterialConnectionPoint;
  130141. /**
  130142. * Gets the camera (or eye) position component
  130143. */
  130144. get cameraPosition(): NodeMaterialConnectionPoint;
  130145. /**
  130146. * Gets the view input component
  130147. */
  130148. get view(): NodeMaterialConnectionPoint;
  130149. /**
  130150. * Gets the rgb output component
  130151. */
  130152. get rgb(): NodeMaterialConnectionPoint;
  130153. /**
  130154. * Gets the r output component
  130155. */
  130156. get r(): NodeMaterialConnectionPoint;
  130157. /**
  130158. * Gets the g output component
  130159. */
  130160. get g(): NodeMaterialConnectionPoint;
  130161. /**
  130162. * Gets the b output component
  130163. */
  130164. get b(): NodeMaterialConnectionPoint;
  130165. autoConfigure(material: NodeMaterial): void;
  130166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130167. isReady(): boolean;
  130168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130169. private _injectVertexCode;
  130170. private _writeOutput;
  130171. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130172. protected _dumpPropertiesCode(): string;
  130173. serialize(): any;
  130174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130175. }
  130176. }
  130177. declare module BABYLON {
  130178. /**
  130179. * Interface used to configure the node material editor
  130180. */
  130181. export interface INodeMaterialEditorOptions {
  130182. /** Define the URl to load node editor script */
  130183. editorURL?: string;
  130184. }
  130185. /** @hidden */
  130186. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130187. NORMAL: boolean;
  130188. TANGENT: boolean;
  130189. UV1: boolean;
  130190. /** BONES */
  130191. NUM_BONE_INFLUENCERS: number;
  130192. BonesPerMesh: number;
  130193. BONETEXTURE: boolean;
  130194. /** MORPH TARGETS */
  130195. MORPHTARGETS: boolean;
  130196. MORPHTARGETS_NORMAL: boolean;
  130197. MORPHTARGETS_TANGENT: boolean;
  130198. MORPHTARGETS_UV: boolean;
  130199. NUM_MORPH_INFLUENCERS: number;
  130200. /** IMAGE PROCESSING */
  130201. IMAGEPROCESSING: boolean;
  130202. VIGNETTE: boolean;
  130203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130204. VIGNETTEBLENDMODEOPAQUE: boolean;
  130205. TONEMAPPING: boolean;
  130206. TONEMAPPING_ACES: boolean;
  130207. CONTRAST: boolean;
  130208. EXPOSURE: boolean;
  130209. COLORCURVES: boolean;
  130210. COLORGRADING: boolean;
  130211. COLORGRADING3D: boolean;
  130212. SAMPLER3DGREENDEPTH: boolean;
  130213. SAMPLER3DBGRMAP: boolean;
  130214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130215. /** MISC. */
  130216. BUMPDIRECTUV: number;
  130217. constructor();
  130218. setValue(name: string, value: boolean): void;
  130219. }
  130220. /**
  130221. * Class used to configure NodeMaterial
  130222. */
  130223. export interface INodeMaterialOptions {
  130224. /**
  130225. * Defines if blocks should emit comments
  130226. */
  130227. emitComments: boolean;
  130228. }
  130229. /**
  130230. * Class used to create a node based material built by assembling shader blocks
  130231. */
  130232. export class NodeMaterial extends PushMaterial {
  130233. private static _BuildIdGenerator;
  130234. private _options;
  130235. private _vertexCompilationState;
  130236. private _fragmentCompilationState;
  130237. private _sharedData;
  130238. private _buildId;
  130239. private _buildWasSuccessful;
  130240. private _cachedWorldViewMatrix;
  130241. private _cachedWorldViewProjectionMatrix;
  130242. private _optimizers;
  130243. private _animationFrame;
  130244. /** Define the Url to load node editor script */
  130245. static EditorURL: string;
  130246. /** Define the Url to load snippets */
  130247. static SnippetUrl: string;
  130248. private BJSNODEMATERIALEDITOR;
  130249. /** Get the inspector from bundle or global */
  130250. private _getGlobalNodeMaterialEditor;
  130251. /**
  130252. * Gets or sets data used by visual editor
  130253. * @see https://nme.babylonjs.com
  130254. */
  130255. editorData: any;
  130256. /**
  130257. * 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)
  130258. */
  130259. ignoreAlpha: boolean;
  130260. /**
  130261. * Defines the maximum number of lights that can be used in the material
  130262. */
  130263. maxSimultaneousLights: number;
  130264. /**
  130265. * Observable raised when the material is built
  130266. */
  130267. onBuildObservable: Observable<NodeMaterial>;
  130268. /**
  130269. * Gets or sets the root nodes of the material vertex shader
  130270. */
  130271. _vertexOutputNodes: NodeMaterialBlock[];
  130272. /**
  130273. * Gets or sets the root nodes of the material fragment (pixel) shader
  130274. */
  130275. _fragmentOutputNodes: NodeMaterialBlock[];
  130276. /** Gets or sets options to control the node material overall behavior */
  130277. get options(): INodeMaterialOptions;
  130278. set options(options: INodeMaterialOptions);
  130279. /**
  130280. * Default configuration related to image processing available in the standard Material.
  130281. */
  130282. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130283. /**
  130284. * Gets the image processing configuration used either in this material.
  130285. */
  130286. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130287. /**
  130288. * Sets the Default image processing configuration used either in the this material.
  130289. *
  130290. * If sets to null, the scene one is in use.
  130291. */
  130292. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130293. /**
  130294. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130295. */
  130296. attachedBlocks: NodeMaterialBlock[];
  130297. /**
  130298. * Create a new node based material
  130299. * @param name defines the material name
  130300. * @param scene defines the hosting scene
  130301. * @param options defines creation option
  130302. */
  130303. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130304. /**
  130305. * Gets the current class name of the material e.g. "NodeMaterial"
  130306. * @returns the class name
  130307. */
  130308. getClassName(): string;
  130309. /**
  130310. * Keep track of the image processing observer to allow dispose and replace.
  130311. */
  130312. private _imageProcessingObserver;
  130313. /**
  130314. * Attaches a new image processing configuration to the Standard Material.
  130315. * @param configuration
  130316. */
  130317. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130318. /**
  130319. * Get a block by its name
  130320. * @param name defines the name of the block to retrieve
  130321. * @returns the required block or null if not found
  130322. */
  130323. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130324. /**
  130325. * Get a block by its name
  130326. * @param predicate defines the predicate used to find the good candidate
  130327. * @returns the required block or null if not found
  130328. */
  130329. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130330. /**
  130331. * Get an input block by its name
  130332. * @param predicate defines the predicate used to find the good candidate
  130333. * @returns the required input block or null if not found
  130334. */
  130335. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130336. /**
  130337. * Gets the list of input blocks attached to this material
  130338. * @returns an array of InputBlocks
  130339. */
  130340. getInputBlocks(): InputBlock[];
  130341. /**
  130342. * Adds a new optimizer to the list of optimizers
  130343. * @param optimizer defines the optimizers to add
  130344. * @returns the current material
  130345. */
  130346. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130347. /**
  130348. * Remove an optimizer from the list of optimizers
  130349. * @param optimizer defines the optimizers to remove
  130350. * @returns the current material
  130351. */
  130352. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130353. /**
  130354. * Add a new block to the list of output nodes
  130355. * @param node defines the node to add
  130356. * @returns the current material
  130357. */
  130358. addOutputNode(node: NodeMaterialBlock): this;
  130359. /**
  130360. * Remove a block from the list of root nodes
  130361. * @param node defines the node to remove
  130362. * @returns the current material
  130363. */
  130364. removeOutputNode(node: NodeMaterialBlock): this;
  130365. private _addVertexOutputNode;
  130366. private _removeVertexOutputNode;
  130367. private _addFragmentOutputNode;
  130368. private _removeFragmentOutputNode;
  130369. /**
  130370. * Specifies if the material will require alpha blending
  130371. * @returns a boolean specifying if alpha blending is needed
  130372. */
  130373. needAlphaBlending(): boolean;
  130374. /**
  130375. * Specifies if this material should be rendered in alpha test mode
  130376. * @returns a boolean specifying if an alpha test is needed.
  130377. */
  130378. needAlphaTesting(): boolean;
  130379. private _initializeBlock;
  130380. private _resetDualBlocks;
  130381. /**
  130382. * Remove a block from the current node material
  130383. * @param block defines the block to remove
  130384. */
  130385. removeBlock(block: NodeMaterialBlock): void;
  130386. /**
  130387. * Build the material and generates the inner effect
  130388. * @param verbose defines if the build should log activity
  130389. */
  130390. build(verbose?: boolean): void;
  130391. /**
  130392. * Runs an otpimization phase to try to improve the shader code
  130393. */
  130394. optimize(): void;
  130395. private _prepareDefinesForAttributes;
  130396. /**
  130397. * Get if the submesh is ready to be used and all its information available.
  130398. * Child classes can use it to update shaders
  130399. * @param mesh defines the mesh to check
  130400. * @param subMesh defines which submesh to check
  130401. * @param useInstances specifies that instances should be used
  130402. * @returns a boolean indicating that the submesh is ready or not
  130403. */
  130404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130405. /**
  130406. * Get a string representing the shaders built by the current node graph
  130407. */
  130408. get compiledShaders(): string;
  130409. /**
  130410. * Binds the world matrix to the material
  130411. * @param world defines the world transformation matrix
  130412. */
  130413. bindOnlyWorldMatrix(world: Matrix): void;
  130414. /**
  130415. * Binds the submesh to this material by preparing the effect and shader to draw
  130416. * @param world defines the world transformation matrix
  130417. * @param mesh defines the mesh containing the submesh
  130418. * @param subMesh defines the submesh to bind the material to
  130419. */
  130420. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130421. /**
  130422. * Gets the active textures from the material
  130423. * @returns an array of textures
  130424. */
  130425. getActiveTextures(): BaseTexture[];
  130426. /**
  130427. * Gets the list of texture blocks
  130428. * @returns an array of texture blocks
  130429. */
  130430. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130431. /**
  130432. * Specifies if the material uses a texture
  130433. * @param texture defines the texture to check against the material
  130434. * @returns a boolean specifying if the material uses the texture
  130435. */
  130436. hasTexture(texture: BaseTexture): boolean;
  130437. /**
  130438. * Disposes the material
  130439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130442. */
  130443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130444. /** Creates the node editor window. */
  130445. private _createNodeEditor;
  130446. /**
  130447. * Launch the node material editor
  130448. * @param config Define the configuration of the editor
  130449. * @return a promise fulfilled when the node editor is visible
  130450. */
  130451. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130452. /**
  130453. * Clear the current material
  130454. */
  130455. clear(): void;
  130456. /**
  130457. * Clear the current material and set it to a default state
  130458. */
  130459. setToDefault(): void;
  130460. /**
  130461. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130462. * @param url defines the url to load from
  130463. * @returns a promise that will fullfil when the material is fully loaded
  130464. */
  130465. loadAsync(url: string): Promise<void>;
  130466. private _gatherBlocks;
  130467. /**
  130468. * Generate a string containing the code declaration required to create an equivalent of this material
  130469. * @returns a string
  130470. */
  130471. generateCode(): string;
  130472. /**
  130473. * Serializes this material in a JSON representation
  130474. * @returns the serialized material object
  130475. */
  130476. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130477. private _restoreConnections;
  130478. /**
  130479. * Clear the current graph and load a new one from a serialization object
  130480. * @param source defines the JSON representation of the material
  130481. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130482. */
  130483. loadFromSerialization(source: any, rootUrl?: string): void;
  130484. /**
  130485. * Creates a node material from parsed material data
  130486. * @param source defines the JSON representation of the material
  130487. * @param scene defines the hosting scene
  130488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130489. * @returns a new node material
  130490. */
  130491. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130492. /**
  130493. * Creates a node material from a snippet saved in a remote file
  130494. * @param name defines the name of the material to create
  130495. * @param url defines the url to load from
  130496. * @param scene defines the hosting scene
  130497. * @returns a promise that will resolve to the new node material
  130498. */
  130499. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130500. /**
  130501. * Creates a node material from a snippet saved by the node material editor
  130502. * @param snippetId defines the snippet to load
  130503. * @param scene defines the hosting scene
  130504. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130505. * @returns a promise that will resolve to the new node material
  130506. */
  130507. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130508. /**
  130509. * Creates a new node material set to default basic configuration
  130510. * @param name defines the name of the material
  130511. * @param scene defines the hosting scene
  130512. * @returns a new NodeMaterial
  130513. */
  130514. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130515. }
  130516. }
  130517. declare module BABYLON {
  130518. /**
  130519. * Block used to read a texture from a sampler
  130520. */
  130521. export class TextureBlock extends NodeMaterialBlock {
  130522. private _defineName;
  130523. private _linearDefineName;
  130524. private _tempTextureRead;
  130525. private _samplerName;
  130526. private _transformedUVName;
  130527. private _textureTransformName;
  130528. private _textureInfoName;
  130529. private _mainUVName;
  130530. private _mainUVDefineName;
  130531. /**
  130532. * Gets or sets the texture associated with the node
  130533. */
  130534. texture: Nullable<Texture>;
  130535. /**
  130536. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130537. */
  130538. convertToGammaSpace: boolean;
  130539. /**
  130540. * Create a new TextureBlock
  130541. * @param name defines the block name
  130542. */
  130543. constructor(name: string);
  130544. /**
  130545. * Gets the current class name
  130546. * @returns the class name
  130547. */
  130548. getClassName(): string;
  130549. /**
  130550. * Gets the uv input component
  130551. */
  130552. get uv(): NodeMaterialConnectionPoint;
  130553. /**
  130554. * Gets the rgba output component
  130555. */
  130556. get rgba(): NodeMaterialConnectionPoint;
  130557. /**
  130558. * Gets the rgb output component
  130559. */
  130560. get rgb(): NodeMaterialConnectionPoint;
  130561. /**
  130562. * Gets the r output component
  130563. */
  130564. get r(): NodeMaterialConnectionPoint;
  130565. /**
  130566. * Gets the g output component
  130567. */
  130568. get g(): NodeMaterialConnectionPoint;
  130569. /**
  130570. * Gets the b output component
  130571. */
  130572. get b(): NodeMaterialConnectionPoint;
  130573. /**
  130574. * Gets the a output component
  130575. */
  130576. get a(): NodeMaterialConnectionPoint;
  130577. get target(): NodeMaterialBlockTargets;
  130578. autoConfigure(material: NodeMaterial): void;
  130579. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130581. isReady(): boolean;
  130582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130583. private get _isMixed();
  130584. private _injectVertexCode;
  130585. private _writeTextureRead;
  130586. private _writeOutput;
  130587. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130588. protected _dumpPropertiesCode(): string;
  130589. serialize(): any;
  130590. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130591. }
  130592. }
  130593. declare module BABYLON {
  130594. /**
  130595. * Class used to store shared data between 2 NodeMaterialBuildState
  130596. */
  130597. export class NodeMaterialBuildStateSharedData {
  130598. /**
  130599. * Gets the list of emitted varyings
  130600. */
  130601. temps: string[];
  130602. /**
  130603. * Gets the list of emitted varyings
  130604. */
  130605. varyings: string[];
  130606. /**
  130607. * Gets the varying declaration string
  130608. */
  130609. varyingDeclaration: string;
  130610. /**
  130611. * Input blocks
  130612. */
  130613. inputBlocks: InputBlock[];
  130614. /**
  130615. * Input blocks
  130616. */
  130617. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130618. /**
  130619. * Bindable blocks (Blocks that need to set data to the effect)
  130620. */
  130621. bindableBlocks: NodeMaterialBlock[];
  130622. /**
  130623. * List of blocks that can provide a compilation fallback
  130624. */
  130625. blocksWithFallbacks: NodeMaterialBlock[];
  130626. /**
  130627. * List of blocks that can provide a define update
  130628. */
  130629. blocksWithDefines: NodeMaterialBlock[];
  130630. /**
  130631. * List of blocks that can provide a repeatable content
  130632. */
  130633. repeatableContentBlocks: NodeMaterialBlock[];
  130634. /**
  130635. * List of blocks that can provide a dynamic list of uniforms
  130636. */
  130637. dynamicUniformBlocks: NodeMaterialBlock[];
  130638. /**
  130639. * List of blocks that can block the isReady function for the material
  130640. */
  130641. blockingBlocks: NodeMaterialBlock[];
  130642. /**
  130643. * Gets the list of animated inputs
  130644. */
  130645. animatedInputs: InputBlock[];
  130646. /**
  130647. * Build Id used to avoid multiple recompilations
  130648. */
  130649. buildId: number;
  130650. /** List of emitted variables */
  130651. variableNames: {
  130652. [key: string]: number;
  130653. };
  130654. /** List of emitted defines */
  130655. defineNames: {
  130656. [key: string]: number;
  130657. };
  130658. /** Should emit comments? */
  130659. emitComments: boolean;
  130660. /** Emit build activity */
  130661. verbose: boolean;
  130662. /** Gets or sets the hosting scene */
  130663. scene: Scene;
  130664. /**
  130665. * Gets the compilation hints emitted at compilation time
  130666. */
  130667. hints: {
  130668. needWorldViewMatrix: boolean;
  130669. needWorldViewProjectionMatrix: boolean;
  130670. needAlphaBlending: boolean;
  130671. needAlphaTesting: boolean;
  130672. };
  130673. /**
  130674. * List of compilation checks
  130675. */
  130676. checks: {
  130677. emitVertex: boolean;
  130678. emitFragment: boolean;
  130679. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130680. };
  130681. /** Creates a new shared data */
  130682. constructor();
  130683. /**
  130684. * Emits console errors and exceptions if there is a failing check
  130685. */
  130686. emitErrors(): void;
  130687. }
  130688. }
  130689. declare module BABYLON {
  130690. /**
  130691. * Class used to store node based material build state
  130692. */
  130693. export class NodeMaterialBuildState {
  130694. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130695. supportUniformBuffers: boolean;
  130696. /**
  130697. * Gets the list of emitted attributes
  130698. */
  130699. attributes: string[];
  130700. /**
  130701. * Gets the list of emitted uniforms
  130702. */
  130703. uniforms: string[];
  130704. /**
  130705. * Gets the list of emitted constants
  130706. */
  130707. constants: string[];
  130708. /**
  130709. * Gets the list of emitted samplers
  130710. */
  130711. samplers: string[];
  130712. /**
  130713. * Gets the list of emitted functions
  130714. */
  130715. functions: {
  130716. [key: string]: string;
  130717. };
  130718. /**
  130719. * Gets the list of emitted extensions
  130720. */
  130721. extensions: {
  130722. [key: string]: string;
  130723. };
  130724. /**
  130725. * Gets the target of the compilation state
  130726. */
  130727. target: NodeMaterialBlockTargets;
  130728. /**
  130729. * Gets the list of emitted counters
  130730. */
  130731. counters: {
  130732. [key: string]: number;
  130733. };
  130734. /**
  130735. * Shared data between multiple NodeMaterialBuildState instances
  130736. */
  130737. sharedData: NodeMaterialBuildStateSharedData;
  130738. /** @hidden */
  130739. _vertexState: NodeMaterialBuildState;
  130740. /** @hidden */
  130741. _attributeDeclaration: string;
  130742. /** @hidden */
  130743. _uniformDeclaration: string;
  130744. /** @hidden */
  130745. _constantDeclaration: string;
  130746. /** @hidden */
  130747. _samplerDeclaration: string;
  130748. /** @hidden */
  130749. _varyingTransfer: string;
  130750. private _repeatableContentAnchorIndex;
  130751. /** @hidden */
  130752. _builtCompilationString: string;
  130753. /**
  130754. * Gets the emitted compilation strings
  130755. */
  130756. compilationString: string;
  130757. /**
  130758. * Finalize the compilation strings
  130759. * @param state defines the current compilation state
  130760. */
  130761. finalize(state: NodeMaterialBuildState): void;
  130762. /** @hidden */
  130763. get _repeatableContentAnchor(): string;
  130764. /** @hidden */
  130765. _getFreeVariableName(prefix: string): string;
  130766. /** @hidden */
  130767. _getFreeDefineName(prefix: string): string;
  130768. /** @hidden */
  130769. _excludeVariableName(name: string): void;
  130770. /** @hidden */
  130771. _emit2DSampler(name: string): void;
  130772. /** @hidden */
  130773. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130774. /** @hidden */
  130775. _emitExtension(name: string, extension: string): void;
  130776. /** @hidden */
  130777. _emitFunction(name: string, code: string, comments: string): void;
  130778. /** @hidden */
  130779. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130780. replaceStrings?: {
  130781. search: RegExp;
  130782. replace: string;
  130783. }[];
  130784. repeatKey?: string;
  130785. }): string;
  130786. /** @hidden */
  130787. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130788. repeatKey?: string;
  130789. removeAttributes?: boolean;
  130790. removeUniforms?: boolean;
  130791. removeVaryings?: boolean;
  130792. removeIfDef?: boolean;
  130793. replaceStrings?: {
  130794. search: RegExp;
  130795. replace: string;
  130796. }[];
  130797. }, storeKey?: string): void;
  130798. /** @hidden */
  130799. _registerTempVariable(name: string): boolean;
  130800. /** @hidden */
  130801. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130802. /** @hidden */
  130803. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130804. /** @hidden */
  130805. _emitFloat(value: number): string;
  130806. }
  130807. }
  130808. declare module BABYLON {
  130809. /**
  130810. * Defines a block that can be used inside a node based material
  130811. */
  130812. export class NodeMaterialBlock {
  130813. private _buildId;
  130814. private _buildTarget;
  130815. private _target;
  130816. private _isFinalMerger;
  130817. private _isInput;
  130818. protected _isUnique: boolean;
  130819. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130820. inputsAreExclusive: boolean;
  130821. /** @hidden */
  130822. _codeVariableName: string;
  130823. /** @hidden */
  130824. _inputs: NodeMaterialConnectionPoint[];
  130825. /** @hidden */
  130826. _outputs: NodeMaterialConnectionPoint[];
  130827. /** @hidden */
  130828. _preparationId: number;
  130829. /**
  130830. * Gets or sets the name of the block
  130831. */
  130832. name: string;
  130833. /**
  130834. * Gets or sets the unique id of the node
  130835. */
  130836. uniqueId: number;
  130837. /**
  130838. * Gets or sets the comments associated with this block
  130839. */
  130840. comments: string;
  130841. /**
  130842. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130843. */
  130844. get isUnique(): boolean;
  130845. /**
  130846. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130847. */
  130848. get isFinalMerger(): boolean;
  130849. /**
  130850. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130851. */
  130852. get isInput(): boolean;
  130853. /**
  130854. * Gets or sets the build Id
  130855. */
  130856. get buildId(): number;
  130857. set buildId(value: number);
  130858. /**
  130859. * Gets or sets the target of the block
  130860. */
  130861. get target(): NodeMaterialBlockTargets;
  130862. set target(value: NodeMaterialBlockTargets);
  130863. /**
  130864. * Gets the list of input points
  130865. */
  130866. get inputs(): NodeMaterialConnectionPoint[];
  130867. /** Gets the list of output points */
  130868. get outputs(): NodeMaterialConnectionPoint[];
  130869. /**
  130870. * Find an input by its name
  130871. * @param name defines the name of the input to look for
  130872. * @returns the input or null if not found
  130873. */
  130874. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130875. /**
  130876. * Find an output by its name
  130877. * @param name defines the name of the outputto look for
  130878. * @returns the output or null if not found
  130879. */
  130880. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130881. /**
  130882. * Creates a new NodeMaterialBlock
  130883. * @param name defines the block name
  130884. * @param target defines the target of that block (Vertex by default)
  130885. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130886. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130887. */
  130888. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130889. /**
  130890. * Initialize the block and prepare the context for build
  130891. * @param state defines the state that will be used for the build
  130892. */
  130893. initialize(state: NodeMaterialBuildState): void;
  130894. /**
  130895. * Bind data to effect. Will only be called for blocks with isBindable === true
  130896. * @param effect defines the effect to bind data to
  130897. * @param nodeMaterial defines the hosting NodeMaterial
  130898. * @param mesh defines the mesh that will be rendered
  130899. */
  130900. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130901. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130902. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130903. protected _writeFloat(value: number): string;
  130904. /**
  130905. * Gets the current class name e.g. "NodeMaterialBlock"
  130906. * @returns the class name
  130907. */
  130908. getClassName(): string;
  130909. /**
  130910. * Register a new input. 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 isOptional defines a boolean indicating that this input can be omitted
  130914. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130915. * @returns the current block
  130916. */
  130917. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130918. /**
  130919. * Register a new output. Must be called inside a block constructor
  130920. * @param name defines the connection point name
  130921. * @param type defines the connection point type
  130922. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130923. * @returns the current block
  130924. */
  130925. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130926. /**
  130927. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130928. * @param forOutput defines an optional connection point to check compatibility with
  130929. * @returns the first available input or null
  130930. */
  130931. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130932. /**
  130933. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130934. * @param forBlock defines an optional block to check compatibility with
  130935. * @returns the first available input or null
  130936. */
  130937. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130938. /**
  130939. * Gets the sibling of the given output
  130940. * @param current defines the current output
  130941. * @returns the next output in the list or null
  130942. */
  130943. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130944. /**
  130945. * Connect current block with another block
  130946. * @param other defines the block to connect with
  130947. * @param options define the various options to help pick the right connections
  130948. * @returns the current block
  130949. */
  130950. connectTo(other: NodeMaterialBlock, options?: {
  130951. input?: string;
  130952. output?: string;
  130953. outputSwizzle?: string;
  130954. }): this | undefined;
  130955. protected _buildBlock(state: NodeMaterialBuildState): void;
  130956. /**
  130957. * Add uniforms, samplers and uniform buffers at compilation time
  130958. * @param state defines the state to update
  130959. * @param nodeMaterial defines the node material requesting the update
  130960. * @param defines defines the material defines to update
  130961. * @param uniformBuffers defines the list of uniform buffer names
  130962. */
  130963. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130964. /**
  130965. * Add potential fallbacks if shader compilation fails
  130966. * @param mesh defines the mesh to be rendered
  130967. * @param fallbacks defines the current prioritized list of fallbacks
  130968. */
  130969. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130970. /**
  130971. * Initialize defines for shader compilation
  130972. * @param mesh defines the mesh to be rendered
  130973. * @param nodeMaterial defines the node material requesting the update
  130974. * @param defines defines the material defines to update
  130975. * @param useInstances specifies that instances should be used
  130976. */
  130977. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130978. /**
  130979. * Update defines for shader compilation
  130980. * @param mesh defines the mesh to be rendered
  130981. * @param nodeMaterial defines the node material requesting the update
  130982. * @param defines defines the material defines to update
  130983. * @param useInstances specifies that instances should be used
  130984. */
  130985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130986. /**
  130987. * Lets the block try to connect some inputs automatically
  130988. * @param material defines the hosting NodeMaterial
  130989. */
  130990. autoConfigure(material: NodeMaterial): void;
  130991. /**
  130992. * Function called when a block is declared as repeatable content generator
  130993. * @param vertexShaderState defines the current compilation state for the vertex shader
  130994. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130995. * @param mesh defines the mesh to be rendered
  130996. * @param defines defines the material defines to update
  130997. */
  130998. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130999. /**
  131000. * Checks if the block is ready
  131001. * @param mesh defines the mesh to be rendered
  131002. * @param nodeMaterial defines the node material requesting the update
  131003. * @param defines defines the material defines to update
  131004. * @param useInstances specifies that instances should be used
  131005. * @returns true if the block is ready
  131006. */
  131007. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131008. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131009. private _processBuild;
  131010. /**
  131011. * Compile the current node and generate the shader code
  131012. * @param state defines the current compilation state (uniforms, samplers, current string)
  131013. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131014. * @returns true if already built
  131015. */
  131016. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131017. protected _inputRename(name: string): string;
  131018. protected _outputRename(name: string): string;
  131019. protected _dumpPropertiesCode(): string;
  131020. /** @hidden */
  131021. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131022. /** @hidden */
  131023. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131024. /**
  131025. * Clone the current block to a new identical block
  131026. * @param scene defines the hosting scene
  131027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131028. * @returns a copy of the current block
  131029. */
  131030. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131031. /**
  131032. * Serializes this block in a JSON representation
  131033. * @returns the serialized block object
  131034. */
  131035. serialize(): any;
  131036. /** @hidden */
  131037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131038. /**
  131039. * Release resources
  131040. */
  131041. dispose(): void;
  131042. }
  131043. }
  131044. declare module BABYLON {
  131045. /**
  131046. * Enum defining the type of animations supported by InputBlock
  131047. */
  131048. export enum AnimatedInputBlockTypes {
  131049. /** No animation */
  131050. None = 0,
  131051. /** Time based animation. Will only work for floats */
  131052. Time = 1
  131053. }
  131054. }
  131055. declare module BABYLON {
  131056. /**
  131057. * Block used to expose an input value
  131058. */
  131059. export class InputBlock extends NodeMaterialBlock {
  131060. private _mode;
  131061. private _associatedVariableName;
  131062. private _storedValue;
  131063. private _valueCallback;
  131064. private _type;
  131065. private _animationType;
  131066. /** Gets or set a value used to limit the range of float values */
  131067. min: number;
  131068. /** Gets or set a value used to limit the range of float values */
  131069. max: number;
  131070. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131071. isBoolean: boolean;
  131072. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131073. matrixMode: number;
  131074. /** @hidden */
  131075. _systemValue: Nullable<NodeMaterialSystemValues>;
  131076. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131077. visibleInInspector: boolean;
  131078. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131079. isConstant: boolean;
  131080. /** Gets or sets the group to use to display this block in the Inspector */
  131081. groupInInspector: string;
  131082. /**
  131083. * Gets or sets the connection point type (default is float)
  131084. */
  131085. get type(): NodeMaterialBlockConnectionPointTypes;
  131086. /**
  131087. * Creates a new InputBlock
  131088. * @param name defines the block name
  131089. * @param target defines the target of that block (Vertex by default)
  131090. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131091. */
  131092. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131093. /**
  131094. * Gets the output component
  131095. */
  131096. get output(): NodeMaterialConnectionPoint;
  131097. /**
  131098. * Set the source of this connection point to a vertex attribute
  131099. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131100. * @returns the current connection point
  131101. */
  131102. setAsAttribute(attributeName?: string): InputBlock;
  131103. /**
  131104. * Set the source of this connection point to a system value
  131105. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131106. * @returns the current connection point
  131107. */
  131108. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131109. /**
  131110. * Gets or sets the value of that point.
  131111. * Please note that this value will be ignored if valueCallback is defined
  131112. */
  131113. get value(): any;
  131114. set value(value: any);
  131115. /**
  131116. * Gets or sets a callback used to get the value of that point.
  131117. * Please note that setting this value will force the connection point to ignore the value property
  131118. */
  131119. get valueCallback(): () => any;
  131120. set valueCallback(value: () => any);
  131121. /**
  131122. * Gets or sets the associated variable name in the shader
  131123. */
  131124. get associatedVariableName(): string;
  131125. set associatedVariableName(value: string);
  131126. /** Gets or sets the type of animation applied to the input */
  131127. get animationType(): AnimatedInputBlockTypes;
  131128. set animationType(value: AnimatedInputBlockTypes);
  131129. /**
  131130. * Gets a boolean indicating that this connection point not defined yet
  131131. */
  131132. get isUndefined(): boolean;
  131133. /**
  131134. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131135. * In this case the connection point name must be the name of the uniform to use.
  131136. * Can only be set on inputs
  131137. */
  131138. get isUniform(): boolean;
  131139. set isUniform(value: boolean);
  131140. /**
  131141. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131142. * In this case the connection point name must be the name of the attribute to use
  131143. * Can only be set on inputs
  131144. */
  131145. get isAttribute(): boolean;
  131146. set isAttribute(value: boolean);
  131147. /**
  131148. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131149. * Can only be set on exit points
  131150. */
  131151. get isVarying(): boolean;
  131152. set isVarying(value: boolean);
  131153. /**
  131154. * Gets a boolean indicating that the current connection point is a system value
  131155. */
  131156. get isSystemValue(): boolean;
  131157. /**
  131158. * Gets or sets the current well known value or null if not defined as a system value
  131159. */
  131160. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131161. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131162. /**
  131163. * Gets the current class name
  131164. * @returns the class name
  131165. */
  131166. getClassName(): string;
  131167. /**
  131168. * Animate the input if animationType !== None
  131169. * @param scene defines the rendering scene
  131170. */
  131171. animate(scene: Scene): void;
  131172. private _emitDefine;
  131173. initialize(state: NodeMaterialBuildState): void;
  131174. /**
  131175. * Set the input block to its default value (based on its type)
  131176. */
  131177. setDefaultValue(): void;
  131178. private _emitConstant;
  131179. private _emit;
  131180. /** @hidden */
  131181. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131182. /** @hidden */
  131183. _transmit(effect: Effect, scene: Scene): void;
  131184. protected _buildBlock(state: NodeMaterialBuildState): void;
  131185. protected _dumpPropertiesCode(): string;
  131186. serialize(): any;
  131187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131188. }
  131189. }
  131190. declare module BABYLON {
  131191. /**
  131192. * Enum used to define the compatibility state between two connection points
  131193. */
  131194. export enum NodeMaterialConnectionPointCompatibilityStates {
  131195. /** Points are compatibles */
  131196. Compatible = 0,
  131197. /** Points are incompatible because of their types */
  131198. TypeIncompatible = 1,
  131199. /** Points are incompatible because of their targets (vertex vs fragment) */
  131200. TargetIncompatible = 2
  131201. }
  131202. /**
  131203. * Defines the direction of a connection point
  131204. */
  131205. export enum NodeMaterialConnectionPointDirection {
  131206. /** Input */
  131207. Input = 0,
  131208. /** Output */
  131209. Output = 1
  131210. }
  131211. /**
  131212. * Defines a connection point for a block
  131213. */
  131214. export class NodeMaterialConnectionPoint {
  131215. /** @hidden */
  131216. _ownerBlock: NodeMaterialBlock;
  131217. /** @hidden */
  131218. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131219. private _endpoints;
  131220. private _associatedVariableName;
  131221. private _direction;
  131222. /** @hidden */
  131223. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131224. /** @hidden */
  131225. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131226. private _type;
  131227. /** @hidden */
  131228. _enforceAssociatedVariableName: boolean;
  131229. /** Gets the direction of the point */
  131230. get direction(): NodeMaterialConnectionPointDirection;
  131231. /**
  131232. * Gets or sets the additional types supported by this connection point
  131233. */
  131234. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131235. /**
  131236. * Gets or sets the additional types excluded by this connection point
  131237. */
  131238. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131239. /**
  131240. * Observable triggered when this point is connected
  131241. */
  131242. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131243. /**
  131244. * Gets or sets the associated variable name in the shader
  131245. */
  131246. get associatedVariableName(): string;
  131247. set associatedVariableName(value: string);
  131248. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131249. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131250. /**
  131251. * Gets or sets the connection point type (default is float)
  131252. */
  131253. get type(): NodeMaterialBlockConnectionPointTypes;
  131254. set type(value: NodeMaterialBlockConnectionPointTypes);
  131255. /**
  131256. * Gets or sets the connection point name
  131257. */
  131258. name: string;
  131259. /**
  131260. * Gets or sets a boolean indicating that this connection point can be omitted
  131261. */
  131262. isOptional: boolean;
  131263. /**
  131264. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131265. */
  131266. define: string;
  131267. /** @hidden */
  131268. _prioritizeVertex: boolean;
  131269. private _target;
  131270. /** Gets or sets the target of that connection point */
  131271. get target(): NodeMaterialBlockTargets;
  131272. set target(value: NodeMaterialBlockTargets);
  131273. /**
  131274. * Gets a boolean indicating that the current point is connected
  131275. */
  131276. get isConnected(): boolean;
  131277. /**
  131278. * Gets a boolean indicating that the current point is connected to an input block
  131279. */
  131280. get isConnectedToInputBlock(): boolean;
  131281. /**
  131282. * Gets a the connected input block (if any)
  131283. */
  131284. get connectInputBlock(): Nullable<InputBlock>;
  131285. /** Get the other side of the connection (if any) */
  131286. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131287. /** Get the block that owns this connection point */
  131288. get ownerBlock(): NodeMaterialBlock;
  131289. /** Get the block connected on the other side of this connection (if any) */
  131290. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131291. /** Get the block connected on the endpoints of this connection (if any) */
  131292. get connectedBlocks(): Array<NodeMaterialBlock>;
  131293. /** Gets the list of connected endpoints */
  131294. get endpoints(): NodeMaterialConnectionPoint[];
  131295. /** Gets a boolean indicating if that output point is connected to at least one input */
  131296. get hasEndpoints(): boolean;
  131297. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131298. get isConnectedInVertexShader(): boolean;
  131299. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131300. get isConnectedInFragmentShader(): boolean;
  131301. /**
  131302. * Creates a new connection point
  131303. * @param name defines the connection point name
  131304. * @param ownerBlock defines the block hosting this connection point
  131305. * @param direction defines the direction of the connection point
  131306. */
  131307. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131308. /**
  131309. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131310. * @returns the class name
  131311. */
  131312. getClassName(): string;
  131313. /**
  131314. * Gets a boolean indicating if the current point can be connected to another point
  131315. * @param connectionPoint defines the other connection point
  131316. * @returns a boolean
  131317. */
  131318. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131319. /**
  131320. * Gets a number indicating if the current point can be connected to another point
  131321. * @param connectionPoint defines the other connection point
  131322. * @returns a number defining the compatibility state
  131323. */
  131324. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131325. /**
  131326. * Connect this point to another connection point
  131327. * @param connectionPoint defines the other connection point
  131328. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131329. * @returns the current connection point
  131330. */
  131331. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131332. /**
  131333. * Disconnect this point from one of his endpoint
  131334. * @param endpoint defines the other connection point
  131335. * @returns the current connection point
  131336. */
  131337. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131338. /**
  131339. * Serializes this point in a JSON representation
  131340. * @returns the serialized point object
  131341. */
  131342. serialize(): any;
  131343. /**
  131344. * Release resources
  131345. */
  131346. dispose(): void;
  131347. }
  131348. }
  131349. declare module BABYLON {
  131350. /**
  131351. * Block used to add support for vertex skinning (bones)
  131352. */
  131353. export class BonesBlock extends NodeMaterialBlock {
  131354. /**
  131355. * Creates a new BonesBlock
  131356. * @param name defines the block name
  131357. */
  131358. constructor(name: string);
  131359. /**
  131360. * Initialize the block and prepare the context for build
  131361. * @param state defines the state that will be used for the build
  131362. */
  131363. initialize(state: NodeMaterialBuildState): void;
  131364. /**
  131365. * Gets the current class name
  131366. * @returns the class name
  131367. */
  131368. getClassName(): string;
  131369. /**
  131370. * Gets the matrix indices input component
  131371. */
  131372. get matricesIndices(): NodeMaterialConnectionPoint;
  131373. /**
  131374. * Gets the matrix weights input component
  131375. */
  131376. get matricesWeights(): NodeMaterialConnectionPoint;
  131377. /**
  131378. * Gets the extra matrix indices input component
  131379. */
  131380. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131381. /**
  131382. * Gets the extra matrix weights input component
  131383. */
  131384. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131385. /**
  131386. * Gets the world input component
  131387. */
  131388. get world(): NodeMaterialConnectionPoint;
  131389. /**
  131390. * Gets the output component
  131391. */
  131392. get output(): NodeMaterialConnectionPoint;
  131393. autoConfigure(material: NodeMaterial): void;
  131394. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131397. protected _buildBlock(state: NodeMaterialBuildState): this;
  131398. }
  131399. }
  131400. declare module BABYLON {
  131401. /**
  131402. * Block used to add support for instances
  131403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131404. */
  131405. export class InstancesBlock extends NodeMaterialBlock {
  131406. /**
  131407. * Creates a new InstancesBlock
  131408. * @param name defines the block name
  131409. */
  131410. constructor(name: string);
  131411. /**
  131412. * Gets the current class name
  131413. * @returns the class name
  131414. */
  131415. getClassName(): string;
  131416. /**
  131417. * Gets the first world row input component
  131418. */
  131419. get world0(): NodeMaterialConnectionPoint;
  131420. /**
  131421. * Gets the second world row input component
  131422. */
  131423. get world1(): NodeMaterialConnectionPoint;
  131424. /**
  131425. * Gets the third world row input component
  131426. */
  131427. get world2(): NodeMaterialConnectionPoint;
  131428. /**
  131429. * Gets the forth world row input component
  131430. */
  131431. get world3(): NodeMaterialConnectionPoint;
  131432. /**
  131433. * Gets the world input component
  131434. */
  131435. get world(): NodeMaterialConnectionPoint;
  131436. /**
  131437. * Gets the output component
  131438. */
  131439. get output(): NodeMaterialConnectionPoint;
  131440. /**
  131441. * Gets the isntanceID component
  131442. */
  131443. get instanceID(): NodeMaterialConnectionPoint;
  131444. autoConfigure(material: NodeMaterial): void;
  131445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131446. protected _buildBlock(state: NodeMaterialBuildState): this;
  131447. }
  131448. }
  131449. declare module BABYLON {
  131450. /**
  131451. * Block used to add morph targets support to vertex shader
  131452. */
  131453. export class MorphTargetsBlock extends NodeMaterialBlock {
  131454. private _repeatableContentAnchor;
  131455. /**
  131456. * Create a new MorphTargetsBlock
  131457. * @param name defines the block name
  131458. */
  131459. constructor(name: string);
  131460. /**
  131461. * Gets the current class name
  131462. * @returns the class name
  131463. */
  131464. getClassName(): string;
  131465. /**
  131466. * Gets the position input component
  131467. */
  131468. get position(): NodeMaterialConnectionPoint;
  131469. /**
  131470. * Gets the normal input component
  131471. */
  131472. get normal(): NodeMaterialConnectionPoint;
  131473. /**
  131474. * Gets the tangent input component
  131475. */
  131476. get tangent(): NodeMaterialConnectionPoint;
  131477. /**
  131478. * Gets the tangent input component
  131479. */
  131480. get uv(): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Gets the position output component
  131483. */
  131484. get positionOutput(): NodeMaterialConnectionPoint;
  131485. /**
  131486. * Gets the normal output component
  131487. */
  131488. get normalOutput(): NodeMaterialConnectionPoint;
  131489. /**
  131490. * Gets the tangent output component
  131491. */
  131492. get tangentOutput(): NodeMaterialConnectionPoint;
  131493. /**
  131494. * Gets the tangent output component
  131495. */
  131496. get uvOutput(): NodeMaterialConnectionPoint;
  131497. initialize(state: NodeMaterialBuildState): void;
  131498. autoConfigure(material: NodeMaterial): void;
  131499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131501. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131502. protected _buildBlock(state: NodeMaterialBuildState): this;
  131503. }
  131504. }
  131505. declare module BABYLON {
  131506. /**
  131507. * Block used to get data information from a light
  131508. */
  131509. export class LightInformationBlock extends NodeMaterialBlock {
  131510. private _lightDataUniformName;
  131511. private _lightColorUniformName;
  131512. private _lightTypeDefineName;
  131513. /**
  131514. * Gets or sets the light associated with this block
  131515. */
  131516. light: Nullable<Light>;
  131517. /**
  131518. * Creates a new LightInformationBlock
  131519. * @param name defines the block name
  131520. */
  131521. constructor(name: string);
  131522. /**
  131523. * Gets the current class name
  131524. * @returns the class name
  131525. */
  131526. getClassName(): string;
  131527. /**
  131528. * Gets the world position input component
  131529. */
  131530. get worldPosition(): NodeMaterialConnectionPoint;
  131531. /**
  131532. * Gets the direction output component
  131533. */
  131534. get direction(): NodeMaterialConnectionPoint;
  131535. /**
  131536. * Gets the direction output component
  131537. */
  131538. get color(): NodeMaterialConnectionPoint;
  131539. /**
  131540. * Gets the direction output component
  131541. */
  131542. get intensity(): NodeMaterialConnectionPoint;
  131543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131544. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131545. protected _buildBlock(state: NodeMaterialBuildState): this;
  131546. serialize(): any;
  131547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131548. }
  131549. }
  131550. declare module BABYLON {
  131551. /**
  131552. * Block used to add image processing support to fragment shader
  131553. */
  131554. export class ImageProcessingBlock extends NodeMaterialBlock {
  131555. /**
  131556. * Create a new ImageProcessingBlock
  131557. * @param name defines the block name
  131558. */
  131559. constructor(name: string);
  131560. /**
  131561. * Gets the current class name
  131562. * @returns the class name
  131563. */
  131564. getClassName(): string;
  131565. /**
  131566. * Gets the color input component
  131567. */
  131568. get color(): NodeMaterialConnectionPoint;
  131569. /**
  131570. * Gets the output component
  131571. */
  131572. get output(): NodeMaterialConnectionPoint;
  131573. /**
  131574. * Initialize the block and prepare the context for build
  131575. * @param state defines the state that will be used for the build
  131576. */
  131577. initialize(state: NodeMaterialBuildState): void;
  131578. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131581. protected _buildBlock(state: NodeMaterialBuildState): this;
  131582. }
  131583. }
  131584. declare module BABYLON {
  131585. /**
  131586. * Block used to pertub normals based on a normal map
  131587. */
  131588. export class PerturbNormalBlock extends NodeMaterialBlock {
  131589. private _tangentSpaceParameterName;
  131590. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131591. invertX: boolean;
  131592. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131593. invertY: boolean;
  131594. /**
  131595. * Create a new PerturbNormalBlock
  131596. * @param name defines the block name
  131597. */
  131598. constructor(name: string);
  131599. /**
  131600. * Gets the current class name
  131601. * @returns the class name
  131602. */
  131603. getClassName(): string;
  131604. /**
  131605. * Gets the world position input component
  131606. */
  131607. get worldPosition(): NodeMaterialConnectionPoint;
  131608. /**
  131609. * Gets the world normal input component
  131610. */
  131611. get worldNormal(): NodeMaterialConnectionPoint;
  131612. /**
  131613. * Gets the world tangent input component
  131614. */
  131615. get worldTangent(): NodeMaterialConnectionPoint;
  131616. /**
  131617. * Gets the uv input component
  131618. */
  131619. get uv(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Gets the normal map color input component
  131622. */
  131623. get normalMapColor(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the strength input component
  131626. */
  131627. get strength(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the output component
  131630. */
  131631. get output(): NodeMaterialConnectionPoint;
  131632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131634. autoConfigure(material: NodeMaterial): void;
  131635. protected _buildBlock(state: NodeMaterialBuildState): this;
  131636. protected _dumpPropertiesCode(): string;
  131637. serialize(): any;
  131638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131639. }
  131640. }
  131641. declare module BABYLON {
  131642. /**
  131643. * Block used to discard a pixel if a value is smaller than a cutoff
  131644. */
  131645. export class DiscardBlock extends NodeMaterialBlock {
  131646. /**
  131647. * Create a new DiscardBlock
  131648. * @param name defines the block name
  131649. */
  131650. constructor(name: string);
  131651. /**
  131652. * Gets the current class name
  131653. * @returns the class name
  131654. */
  131655. getClassName(): string;
  131656. /**
  131657. * Gets the color input component
  131658. */
  131659. get value(): NodeMaterialConnectionPoint;
  131660. /**
  131661. * Gets the cutoff input component
  131662. */
  131663. get cutoff(): NodeMaterialConnectionPoint;
  131664. protected _buildBlock(state: NodeMaterialBuildState): this;
  131665. }
  131666. }
  131667. declare module BABYLON {
  131668. /**
  131669. * Block used to test if the fragment shader is front facing
  131670. */
  131671. export class FrontFacingBlock extends NodeMaterialBlock {
  131672. /**
  131673. * Creates a new FrontFacingBlock
  131674. * @param name defines the block name
  131675. */
  131676. constructor(name: string);
  131677. /**
  131678. * Gets the current class name
  131679. * @returns the class name
  131680. */
  131681. getClassName(): string;
  131682. /**
  131683. * Gets the output component
  131684. */
  131685. get output(): NodeMaterialConnectionPoint;
  131686. protected _buildBlock(state: NodeMaterialBuildState): this;
  131687. }
  131688. }
  131689. declare module BABYLON {
  131690. /**
  131691. * Block used to get the derivative value on x and y of a given input
  131692. */
  131693. export class DerivativeBlock extends NodeMaterialBlock {
  131694. /**
  131695. * Create a new DerivativeBlock
  131696. * @param name defines the block name
  131697. */
  131698. constructor(name: string);
  131699. /**
  131700. * Gets the current class name
  131701. * @returns the class name
  131702. */
  131703. getClassName(): string;
  131704. /**
  131705. * Gets the input component
  131706. */
  131707. get input(): NodeMaterialConnectionPoint;
  131708. /**
  131709. * Gets the derivative output on x
  131710. */
  131711. get dx(): NodeMaterialConnectionPoint;
  131712. /**
  131713. * Gets the derivative output on y
  131714. */
  131715. get dy(): NodeMaterialConnectionPoint;
  131716. protected _buildBlock(state: NodeMaterialBuildState): this;
  131717. }
  131718. }
  131719. declare module BABYLON {
  131720. /**
  131721. * Block used to add support for scene fog
  131722. */
  131723. export class FogBlock extends NodeMaterialBlock {
  131724. private _fogDistanceName;
  131725. private _fogParameters;
  131726. /**
  131727. * Create a new FogBlock
  131728. * @param name defines the block name
  131729. */
  131730. constructor(name: string);
  131731. /**
  131732. * Gets the current class name
  131733. * @returns the class name
  131734. */
  131735. getClassName(): string;
  131736. /**
  131737. * Gets the world position input component
  131738. */
  131739. get worldPosition(): NodeMaterialConnectionPoint;
  131740. /**
  131741. * Gets the view input component
  131742. */
  131743. get view(): NodeMaterialConnectionPoint;
  131744. /**
  131745. * Gets the color input component
  131746. */
  131747. get input(): NodeMaterialConnectionPoint;
  131748. /**
  131749. * Gets the fog color input component
  131750. */
  131751. get fogColor(): NodeMaterialConnectionPoint;
  131752. /**
  131753. * Gets the output component
  131754. */
  131755. get output(): NodeMaterialConnectionPoint;
  131756. autoConfigure(material: NodeMaterial): void;
  131757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131759. protected _buildBlock(state: NodeMaterialBuildState): this;
  131760. }
  131761. }
  131762. declare module BABYLON {
  131763. /**
  131764. * Block used to add light in the fragment shader
  131765. */
  131766. export class LightBlock extends NodeMaterialBlock {
  131767. private _lightId;
  131768. /**
  131769. * Gets or sets the light associated with this block
  131770. */
  131771. light: Nullable<Light>;
  131772. /**
  131773. * Create a new LightBlock
  131774. * @param name defines the block name
  131775. */
  131776. constructor(name: string);
  131777. /**
  131778. * Gets the current class name
  131779. * @returns the class name
  131780. */
  131781. getClassName(): string;
  131782. /**
  131783. * Gets the world position input component
  131784. */
  131785. get worldPosition(): NodeMaterialConnectionPoint;
  131786. /**
  131787. * Gets the world normal input component
  131788. */
  131789. get worldNormal(): NodeMaterialConnectionPoint;
  131790. /**
  131791. * Gets the camera (or eye) position component
  131792. */
  131793. get cameraPosition(): NodeMaterialConnectionPoint;
  131794. /**
  131795. * Gets the glossiness component
  131796. */
  131797. get glossiness(): NodeMaterialConnectionPoint;
  131798. /**
  131799. * Gets the glossinness power component
  131800. */
  131801. get glossPower(): NodeMaterialConnectionPoint;
  131802. /**
  131803. * Gets the diffuse color component
  131804. */
  131805. get diffuseColor(): NodeMaterialConnectionPoint;
  131806. /**
  131807. * Gets the specular color component
  131808. */
  131809. get specularColor(): NodeMaterialConnectionPoint;
  131810. /**
  131811. * Gets the diffuse output component
  131812. */
  131813. get diffuseOutput(): NodeMaterialConnectionPoint;
  131814. /**
  131815. * Gets the specular output component
  131816. */
  131817. get specularOutput(): NodeMaterialConnectionPoint;
  131818. /**
  131819. * Gets the shadow output component
  131820. */
  131821. get shadow(): NodeMaterialConnectionPoint;
  131822. autoConfigure(material: NodeMaterial): void;
  131823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131824. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131826. private _injectVertexCode;
  131827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131828. serialize(): any;
  131829. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Block used to multiply 2 values
  131835. */
  131836. export class MultiplyBlock extends NodeMaterialBlock {
  131837. /**
  131838. * Creates a new MultiplyBlock
  131839. * @param name defines the block name
  131840. */
  131841. constructor(name: string);
  131842. /**
  131843. * Gets the current class name
  131844. * @returns the class name
  131845. */
  131846. getClassName(): string;
  131847. /**
  131848. * Gets the left operand input component
  131849. */
  131850. get left(): NodeMaterialConnectionPoint;
  131851. /**
  131852. * Gets the right operand input component
  131853. */
  131854. get right(): NodeMaterialConnectionPoint;
  131855. /**
  131856. * Gets the output component
  131857. */
  131858. get output(): NodeMaterialConnectionPoint;
  131859. protected _buildBlock(state: NodeMaterialBuildState): this;
  131860. }
  131861. }
  131862. declare module BABYLON {
  131863. /**
  131864. * Block used to add 2 vectors
  131865. */
  131866. export class AddBlock extends NodeMaterialBlock {
  131867. /**
  131868. * Creates a new AddBlock
  131869. * @param name defines the block name
  131870. */
  131871. constructor(name: string);
  131872. /**
  131873. * Gets the current class name
  131874. * @returns the class name
  131875. */
  131876. getClassName(): string;
  131877. /**
  131878. * Gets the left operand input component
  131879. */
  131880. get left(): NodeMaterialConnectionPoint;
  131881. /**
  131882. * Gets the right operand input component
  131883. */
  131884. get right(): NodeMaterialConnectionPoint;
  131885. /**
  131886. * Gets the output component
  131887. */
  131888. get output(): NodeMaterialConnectionPoint;
  131889. protected _buildBlock(state: NodeMaterialBuildState): this;
  131890. }
  131891. }
  131892. declare module BABYLON {
  131893. /**
  131894. * Block used to scale a vector by a float
  131895. */
  131896. export class ScaleBlock extends NodeMaterialBlock {
  131897. /**
  131898. * Creates a new ScaleBlock
  131899. * @param name defines the block name
  131900. */
  131901. constructor(name: string);
  131902. /**
  131903. * Gets the current class name
  131904. * @returns the class name
  131905. */
  131906. getClassName(): string;
  131907. /**
  131908. * Gets the input component
  131909. */
  131910. get input(): NodeMaterialConnectionPoint;
  131911. /**
  131912. * Gets the factor input component
  131913. */
  131914. get factor(): NodeMaterialConnectionPoint;
  131915. /**
  131916. * Gets the output component
  131917. */
  131918. get output(): NodeMaterialConnectionPoint;
  131919. protected _buildBlock(state: NodeMaterialBuildState): this;
  131920. }
  131921. }
  131922. declare module BABYLON {
  131923. /**
  131924. * Block used to clamp a float
  131925. */
  131926. export class ClampBlock extends NodeMaterialBlock {
  131927. /** Gets or sets the minimum range */
  131928. minimum: number;
  131929. /** Gets or sets the maximum range */
  131930. maximum: number;
  131931. /**
  131932. * Creates a new ClampBlock
  131933. * @param name defines the block name
  131934. */
  131935. constructor(name: string);
  131936. /**
  131937. * Gets the current class name
  131938. * @returns the class name
  131939. */
  131940. getClassName(): string;
  131941. /**
  131942. * Gets the value input component
  131943. */
  131944. get value(): NodeMaterialConnectionPoint;
  131945. /**
  131946. * Gets the output component
  131947. */
  131948. get output(): NodeMaterialConnectionPoint;
  131949. protected _buildBlock(state: NodeMaterialBuildState): this;
  131950. protected _dumpPropertiesCode(): string;
  131951. serialize(): any;
  131952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131953. }
  131954. }
  131955. declare module BABYLON {
  131956. /**
  131957. * Block used to apply a cross product between 2 vectors
  131958. */
  131959. export class CrossBlock extends NodeMaterialBlock {
  131960. /**
  131961. * Creates a new CrossBlock
  131962. * @param name defines the block name
  131963. */
  131964. constructor(name: string);
  131965. /**
  131966. * Gets the current class name
  131967. * @returns the class name
  131968. */
  131969. getClassName(): string;
  131970. /**
  131971. * Gets the left operand input component
  131972. */
  131973. get left(): NodeMaterialConnectionPoint;
  131974. /**
  131975. * Gets the right operand input component
  131976. */
  131977. get right(): NodeMaterialConnectionPoint;
  131978. /**
  131979. * Gets the output component
  131980. */
  131981. get output(): NodeMaterialConnectionPoint;
  131982. protected _buildBlock(state: NodeMaterialBuildState): this;
  131983. }
  131984. }
  131985. declare module BABYLON {
  131986. /**
  131987. * Block used to apply a dot product between 2 vectors
  131988. */
  131989. export class DotBlock extends NodeMaterialBlock {
  131990. /**
  131991. * Creates a new DotBlock
  131992. * @param name defines the block name
  131993. */
  131994. constructor(name: string);
  131995. /**
  131996. * Gets the current class name
  131997. * @returns the class name
  131998. */
  131999. getClassName(): string;
  132000. /**
  132001. * Gets the left operand input component
  132002. */
  132003. get left(): NodeMaterialConnectionPoint;
  132004. /**
  132005. * Gets the right operand input component
  132006. */
  132007. get right(): NodeMaterialConnectionPoint;
  132008. /**
  132009. * Gets the output component
  132010. */
  132011. get output(): NodeMaterialConnectionPoint;
  132012. protected _buildBlock(state: NodeMaterialBuildState): this;
  132013. }
  132014. }
  132015. declare module BABYLON {
  132016. /**
  132017. * Block used to remap a float from a range to a new one
  132018. */
  132019. export class RemapBlock extends NodeMaterialBlock {
  132020. /**
  132021. * Gets or sets the source range
  132022. */
  132023. sourceRange: Vector2;
  132024. /**
  132025. * Gets or sets the target range
  132026. */
  132027. targetRange: Vector2;
  132028. /**
  132029. * Creates a new RemapBlock
  132030. * @param name defines the block name
  132031. */
  132032. constructor(name: string);
  132033. /**
  132034. * Gets the current class name
  132035. * @returns the class name
  132036. */
  132037. getClassName(): string;
  132038. /**
  132039. * Gets the input component
  132040. */
  132041. get input(): NodeMaterialConnectionPoint;
  132042. /**
  132043. * Gets the source min input component
  132044. */
  132045. get sourceMin(): NodeMaterialConnectionPoint;
  132046. /**
  132047. * Gets the source max input component
  132048. */
  132049. get sourceMax(): NodeMaterialConnectionPoint;
  132050. /**
  132051. * Gets the target min input component
  132052. */
  132053. get targetMin(): NodeMaterialConnectionPoint;
  132054. /**
  132055. * Gets the target max input component
  132056. */
  132057. get targetMax(): NodeMaterialConnectionPoint;
  132058. /**
  132059. * Gets the output component
  132060. */
  132061. get output(): NodeMaterialConnectionPoint;
  132062. protected _buildBlock(state: NodeMaterialBuildState): this;
  132063. protected _dumpPropertiesCode(): string;
  132064. serialize(): any;
  132065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132066. }
  132067. }
  132068. declare module BABYLON {
  132069. /**
  132070. * Block used to normalize a vector
  132071. */
  132072. export class NormalizeBlock extends NodeMaterialBlock {
  132073. /**
  132074. * Creates a new NormalizeBlock
  132075. * @param name defines the block name
  132076. */
  132077. constructor(name: string);
  132078. /**
  132079. * Gets the current class name
  132080. * @returns the class name
  132081. */
  132082. getClassName(): string;
  132083. /**
  132084. * Gets the input component
  132085. */
  132086. get input(): NodeMaterialConnectionPoint;
  132087. /**
  132088. * Gets the output component
  132089. */
  132090. get output(): NodeMaterialConnectionPoint;
  132091. protected _buildBlock(state: NodeMaterialBuildState): this;
  132092. }
  132093. }
  132094. declare module BABYLON {
  132095. /**
  132096. * Operations supported by the Trigonometry block
  132097. */
  132098. export enum TrigonometryBlockOperations {
  132099. /** Cos */
  132100. Cos = 0,
  132101. /** Sin */
  132102. Sin = 1,
  132103. /** Abs */
  132104. Abs = 2,
  132105. /** Exp */
  132106. Exp = 3,
  132107. /** Exp2 */
  132108. Exp2 = 4,
  132109. /** Round */
  132110. Round = 5,
  132111. /** Floor */
  132112. Floor = 6,
  132113. /** Ceiling */
  132114. Ceiling = 7,
  132115. /** Square root */
  132116. Sqrt = 8,
  132117. /** Log */
  132118. Log = 9,
  132119. /** Tangent */
  132120. Tan = 10,
  132121. /** Arc tangent */
  132122. ArcTan = 11,
  132123. /** Arc cosinus */
  132124. ArcCos = 12,
  132125. /** Arc sinus */
  132126. ArcSin = 13,
  132127. /** Fraction */
  132128. Fract = 14,
  132129. /** Sign */
  132130. Sign = 15,
  132131. /** To radians (from degrees) */
  132132. Radians = 16,
  132133. /** To degrees (from radians) */
  132134. Degrees = 17
  132135. }
  132136. /**
  132137. * Block used to apply trigonometry operation to floats
  132138. */
  132139. export class TrigonometryBlock extends NodeMaterialBlock {
  132140. /**
  132141. * Gets or sets the operation applied by the block
  132142. */
  132143. operation: TrigonometryBlockOperations;
  132144. /**
  132145. * Creates a new TrigonometryBlock
  132146. * @param name defines the block name
  132147. */
  132148. constructor(name: string);
  132149. /**
  132150. * Gets the current class name
  132151. * @returns the class name
  132152. */
  132153. getClassName(): string;
  132154. /**
  132155. * Gets the input component
  132156. */
  132157. get input(): NodeMaterialConnectionPoint;
  132158. /**
  132159. * Gets the output component
  132160. */
  132161. get output(): NodeMaterialConnectionPoint;
  132162. protected _buildBlock(state: NodeMaterialBuildState): this;
  132163. serialize(): any;
  132164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132165. protected _dumpPropertiesCode(): string;
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. /**
  132170. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132171. */
  132172. export class ColorMergerBlock extends NodeMaterialBlock {
  132173. /**
  132174. * Create a new ColorMergerBlock
  132175. * @param name defines the block name
  132176. */
  132177. constructor(name: string);
  132178. /**
  132179. * Gets the current class name
  132180. * @returns the class name
  132181. */
  132182. getClassName(): string;
  132183. /**
  132184. * Gets the rgb component (input)
  132185. */
  132186. get rgbIn(): NodeMaterialConnectionPoint;
  132187. /**
  132188. * Gets the r component (input)
  132189. */
  132190. get r(): NodeMaterialConnectionPoint;
  132191. /**
  132192. * Gets the g component (input)
  132193. */
  132194. get g(): NodeMaterialConnectionPoint;
  132195. /**
  132196. * Gets the b component (input)
  132197. */
  132198. get b(): NodeMaterialConnectionPoint;
  132199. /**
  132200. * Gets the a component (input)
  132201. */
  132202. get a(): NodeMaterialConnectionPoint;
  132203. /**
  132204. * Gets the rgba component (output)
  132205. */
  132206. get rgba(): NodeMaterialConnectionPoint;
  132207. /**
  132208. * Gets the rgb component (output)
  132209. */
  132210. get rgbOut(): NodeMaterialConnectionPoint;
  132211. /**
  132212. * Gets the rgb component (output)
  132213. * @deprecated Please use rgbOut instead.
  132214. */
  132215. get rgb(): NodeMaterialConnectionPoint;
  132216. protected _buildBlock(state: NodeMaterialBuildState): this;
  132217. }
  132218. }
  132219. declare module BABYLON {
  132220. /**
  132221. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132222. */
  132223. export class VectorMergerBlock extends NodeMaterialBlock {
  132224. /**
  132225. * Create a new VectorMergerBlock
  132226. * @param name defines the block name
  132227. */
  132228. constructor(name: string);
  132229. /**
  132230. * Gets the current class name
  132231. * @returns the class name
  132232. */
  132233. getClassName(): string;
  132234. /**
  132235. * Gets the xyz component (input)
  132236. */
  132237. get xyzIn(): NodeMaterialConnectionPoint;
  132238. /**
  132239. * Gets the xy component (input)
  132240. */
  132241. get xyIn(): NodeMaterialConnectionPoint;
  132242. /**
  132243. * Gets the x component (input)
  132244. */
  132245. get x(): NodeMaterialConnectionPoint;
  132246. /**
  132247. * Gets the y component (input)
  132248. */
  132249. get y(): NodeMaterialConnectionPoint;
  132250. /**
  132251. * Gets the z component (input)
  132252. */
  132253. get z(): NodeMaterialConnectionPoint;
  132254. /**
  132255. * Gets the w component (input)
  132256. */
  132257. get w(): NodeMaterialConnectionPoint;
  132258. /**
  132259. * Gets the xyzw component (output)
  132260. */
  132261. get xyzw(): NodeMaterialConnectionPoint;
  132262. /**
  132263. * Gets the xyz component (output)
  132264. */
  132265. get xyzOut(): NodeMaterialConnectionPoint;
  132266. /**
  132267. * Gets the xy component (output)
  132268. */
  132269. get xyOut(): NodeMaterialConnectionPoint;
  132270. /**
  132271. * Gets the xy component (output)
  132272. * @deprecated Please use xyOut instead.
  132273. */
  132274. get xy(): NodeMaterialConnectionPoint;
  132275. /**
  132276. * Gets the xyz component (output)
  132277. * @deprecated Please use xyzOut instead.
  132278. */
  132279. get xyz(): NodeMaterialConnectionPoint;
  132280. protected _buildBlock(state: NodeMaterialBuildState): this;
  132281. }
  132282. }
  132283. declare module BABYLON {
  132284. /**
  132285. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132286. */
  132287. export class ColorSplitterBlock extends NodeMaterialBlock {
  132288. /**
  132289. * Create a new ColorSplitterBlock
  132290. * @param name defines the block name
  132291. */
  132292. constructor(name: string);
  132293. /**
  132294. * Gets the current class name
  132295. * @returns the class name
  132296. */
  132297. getClassName(): string;
  132298. /**
  132299. * Gets the rgba component (input)
  132300. */
  132301. get rgba(): NodeMaterialConnectionPoint;
  132302. /**
  132303. * Gets the rgb component (input)
  132304. */
  132305. get rgbIn(): NodeMaterialConnectionPoint;
  132306. /**
  132307. * Gets the rgb component (output)
  132308. */
  132309. get rgbOut(): NodeMaterialConnectionPoint;
  132310. /**
  132311. * Gets the r component (output)
  132312. */
  132313. get r(): NodeMaterialConnectionPoint;
  132314. /**
  132315. * Gets the g component (output)
  132316. */
  132317. get g(): NodeMaterialConnectionPoint;
  132318. /**
  132319. * Gets the b component (output)
  132320. */
  132321. get b(): NodeMaterialConnectionPoint;
  132322. /**
  132323. * Gets the a component (output)
  132324. */
  132325. get a(): NodeMaterialConnectionPoint;
  132326. protected _inputRename(name: string): string;
  132327. protected _outputRename(name: string): string;
  132328. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132329. }
  132330. }
  132331. declare module BABYLON {
  132332. /**
  132333. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132334. */
  132335. export class VectorSplitterBlock extends NodeMaterialBlock {
  132336. /**
  132337. * Create a new VectorSplitterBlock
  132338. * @param name defines the block name
  132339. */
  132340. constructor(name: string);
  132341. /**
  132342. * Gets the current class name
  132343. * @returns the class name
  132344. */
  132345. getClassName(): string;
  132346. /**
  132347. * Gets the xyzw component (input)
  132348. */
  132349. get xyzw(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the xyz component (input)
  132352. */
  132353. get xyzIn(): NodeMaterialConnectionPoint;
  132354. /**
  132355. * Gets the xy component (input)
  132356. */
  132357. get xyIn(): NodeMaterialConnectionPoint;
  132358. /**
  132359. * Gets the xyz component (output)
  132360. */
  132361. get xyzOut(): NodeMaterialConnectionPoint;
  132362. /**
  132363. * Gets the xy component (output)
  132364. */
  132365. get xyOut(): NodeMaterialConnectionPoint;
  132366. /**
  132367. * Gets the x component (output)
  132368. */
  132369. get x(): NodeMaterialConnectionPoint;
  132370. /**
  132371. * Gets the y component (output)
  132372. */
  132373. get y(): NodeMaterialConnectionPoint;
  132374. /**
  132375. * Gets the z component (output)
  132376. */
  132377. get z(): NodeMaterialConnectionPoint;
  132378. /**
  132379. * Gets the w component (output)
  132380. */
  132381. get w(): NodeMaterialConnectionPoint;
  132382. protected _inputRename(name: string): string;
  132383. protected _outputRename(name: string): string;
  132384. protected _buildBlock(state: NodeMaterialBuildState): this;
  132385. }
  132386. }
  132387. declare module BABYLON {
  132388. /**
  132389. * Block used to lerp between 2 values
  132390. */
  132391. export class LerpBlock extends NodeMaterialBlock {
  132392. /**
  132393. * Creates a new LerpBlock
  132394. * @param name defines the block name
  132395. */
  132396. constructor(name: string);
  132397. /**
  132398. * Gets the current class name
  132399. * @returns the class name
  132400. */
  132401. getClassName(): string;
  132402. /**
  132403. * Gets the left operand input component
  132404. */
  132405. get left(): NodeMaterialConnectionPoint;
  132406. /**
  132407. * Gets the right operand input component
  132408. */
  132409. get right(): NodeMaterialConnectionPoint;
  132410. /**
  132411. * Gets the gradient operand input component
  132412. */
  132413. get gradient(): NodeMaterialConnectionPoint;
  132414. /**
  132415. * Gets the output component
  132416. */
  132417. get output(): NodeMaterialConnectionPoint;
  132418. protected _buildBlock(state: NodeMaterialBuildState): this;
  132419. }
  132420. }
  132421. declare module BABYLON {
  132422. /**
  132423. * Block used to divide 2 vectors
  132424. */
  132425. export class DivideBlock extends NodeMaterialBlock {
  132426. /**
  132427. * Creates a new DivideBlock
  132428. * @param name defines the block name
  132429. */
  132430. constructor(name: string);
  132431. /**
  132432. * Gets the current class name
  132433. * @returns the class name
  132434. */
  132435. getClassName(): string;
  132436. /**
  132437. * Gets the left operand input component
  132438. */
  132439. get left(): NodeMaterialConnectionPoint;
  132440. /**
  132441. * Gets the right operand input component
  132442. */
  132443. get right(): NodeMaterialConnectionPoint;
  132444. /**
  132445. * Gets the output component
  132446. */
  132447. get output(): NodeMaterialConnectionPoint;
  132448. protected _buildBlock(state: NodeMaterialBuildState): this;
  132449. }
  132450. }
  132451. declare module BABYLON {
  132452. /**
  132453. * Block used to subtract 2 vectors
  132454. */
  132455. export class SubtractBlock extends NodeMaterialBlock {
  132456. /**
  132457. * Creates a new SubtractBlock
  132458. * @param name defines the block name
  132459. */
  132460. constructor(name: string);
  132461. /**
  132462. * Gets the current class name
  132463. * @returns the class name
  132464. */
  132465. getClassName(): string;
  132466. /**
  132467. * Gets the left operand input component
  132468. */
  132469. get left(): NodeMaterialConnectionPoint;
  132470. /**
  132471. * Gets the right operand input component
  132472. */
  132473. get right(): NodeMaterialConnectionPoint;
  132474. /**
  132475. * Gets the output component
  132476. */
  132477. get output(): NodeMaterialConnectionPoint;
  132478. protected _buildBlock(state: NodeMaterialBuildState): this;
  132479. }
  132480. }
  132481. declare module BABYLON {
  132482. /**
  132483. * Block used to step a value
  132484. */
  132485. export class StepBlock extends NodeMaterialBlock {
  132486. /**
  132487. * Creates a new StepBlock
  132488. * @param name defines the block name
  132489. */
  132490. constructor(name: string);
  132491. /**
  132492. * Gets the current class name
  132493. * @returns the class name
  132494. */
  132495. getClassName(): string;
  132496. /**
  132497. * Gets the value operand input component
  132498. */
  132499. get value(): NodeMaterialConnectionPoint;
  132500. /**
  132501. * Gets the edge operand input component
  132502. */
  132503. get edge(): NodeMaterialConnectionPoint;
  132504. /**
  132505. * Gets the output component
  132506. */
  132507. get output(): NodeMaterialConnectionPoint;
  132508. protected _buildBlock(state: NodeMaterialBuildState): this;
  132509. }
  132510. }
  132511. declare module BABYLON {
  132512. /**
  132513. * Block used to get the opposite (1 - x) of a value
  132514. */
  132515. export class OneMinusBlock extends NodeMaterialBlock {
  132516. /**
  132517. * Creates a new OneMinusBlock
  132518. * @param name defines the block name
  132519. */
  132520. constructor(name: string);
  132521. /**
  132522. * Gets the current class name
  132523. * @returns the class name
  132524. */
  132525. getClassName(): string;
  132526. /**
  132527. * Gets the input component
  132528. */
  132529. get input(): NodeMaterialConnectionPoint;
  132530. /**
  132531. * Gets the output component
  132532. */
  132533. get output(): NodeMaterialConnectionPoint;
  132534. protected _buildBlock(state: NodeMaterialBuildState): this;
  132535. }
  132536. }
  132537. declare module BABYLON {
  132538. /**
  132539. * Block used to get the view direction
  132540. */
  132541. export class ViewDirectionBlock extends NodeMaterialBlock {
  132542. /**
  132543. * Creates a new ViewDirectionBlock
  132544. * @param name defines the block name
  132545. */
  132546. constructor(name: string);
  132547. /**
  132548. * Gets the current class name
  132549. * @returns the class name
  132550. */
  132551. getClassName(): string;
  132552. /**
  132553. * Gets the world position component
  132554. */
  132555. get worldPosition(): NodeMaterialConnectionPoint;
  132556. /**
  132557. * Gets the camera position component
  132558. */
  132559. get cameraPosition(): NodeMaterialConnectionPoint;
  132560. /**
  132561. * Gets the output component
  132562. */
  132563. get output(): NodeMaterialConnectionPoint;
  132564. autoConfigure(material: NodeMaterial): void;
  132565. protected _buildBlock(state: NodeMaterialBuildState): this;
  132566. }
  132567. }
  132568. declare module BABYLON {
  132569. /**
  132570. * Block used to compute fresnel value
  132571. */
  132572. export class FresnelBlock extends NodeMaterialBlock {
  132573. /**
  132574. * Create a new FresnelBlock
  132575. * @param name defines the block name
  132576. */
  132577. constructor(name: string);
  132578. /**
  132579. * Gets the current class name
  132580. * @returns the class name
  132581. */
  132582. getClassName(): string;
  132583. /**
  132584. * Gets the world normal input component
  132585. */
  132586. get worldNormal(): NodeMaterialConnectionPoint;
  132587. /**
  132588. * Gets the view direction input component
  132589. */
  132590. get viewDirection(): NodeMaterialConnectionPoint;
  132591. /**
  132592. * Gets the bias input component
  132593. */
  132594. get bias(): NodeMaterialConnectionPoint;
  132595. /**
  132596. * Gets the camera (or eye) position component
  132597. */
  132598. get power(): NodeMaterialConnectionPoint;
  132599. /**
  132600. * Gets the fresnel output component
  132601. */
  132602. get fresnel(): NodeMaterialConnectionPoint;
  132603. autoConfigure(material: NodeMaterial): void;
  132604. protected _buildBlock(state: NodeMaterialBuildState): this;
  132605. }
  132606. }
  132607. declare module BABYLON {
  132608. /**
  132609. * Block used to get the max of 2 values
  132610. */
  132611. export class MaxBlock extends NodeMaterialBlock {
  132612. /**
  132613. * Creates a new MaxBlock
  132614. * @param name defines the block name
  132615. */
  132616. constructor(name: string);
  132617. /**
  132618. * Gets the current class name
  132619. * @returns the class name
  132620. */
  132621. getClassName(): string;
  132622. /**
  132623. * Gets the left operand input component
  132624. */
  132625. get left(): NodeMaterialConnectionPoint;
  132626. /**
  132627. * Gets the right operand input component
  132628. */
  132629. get right(): NodeMaterialConnectionPoint;
  132630. /**
  132631. * Gets the output component
  132632. */
  132633. get output(): NodeMaterialConnectionPoint;
  132634. protected _buildBlock(state: NodeMaterialBuildState): this;
  132635. }
  132636. }
  132637. declare module BABYLON {
  132638. /**
  132639. * Block used to get the min of 2 values
  132640. */
  132641. export class MinBlock extends NodeMaterialBlock {
  132642. /**
  132643. * Creates a new MinBlock
  132644. * @param name defines the block name
  132645. */
  132646. constructor(name: string);
  132647. /**
  132648. * Gets the current class name
  132649. * @returns the class name
  132650. */
  132651. getClassName(): string;
  132652. /**
  132653. * Gets the left operand input component
  132654. */
  132655. get left(): NodeMaterialConnectionPoint;
  132656. /**
  132657. * Gets the right operand input component
  132658. */
  132659. get right(): NodeMaterialConnectionPoint;
  132660. /**
  132661. * Gets the output component
  132662. */
  132663. get output(): NodeMaterialConnectionPoint;
  132664. protected _buildBlock(state: NodeMaterialBuildState): this;
  132665. }
  132666. }
  132667. declare module BABYLON {
  132668. /**
  132669. * Block used to get the distance between 2 values
  132670. */
  132671. export class DistanceBlock extends NodeMaterialBlock {
  132672. /**
  132673. * Creates a new DistanceBlock
  132674. * @param name defines the block name
  132675. */
  132676. constructor(name: string);
  132677. /**
  132678. * Gets the current class name
  132679. * @returns the class name
  132680. */
  132681. getClassName(): string;
  132682. /**
  132683. * Gets the left operand input component
  132684. */
  132685. get left(): NodeMaterialConnectionPoint;
  132686. /**
  132687. * Gets the right operand input component
  132688. */
  132689. get right(): NodeMaterialConnectionPoint;
  132690. /**
  132691. * Gets the output component
  132692. */
  132693. get output(): NodeMaterialConnectionPoint;
  132694. protected _buildBlock(state: NodeMaterialBuildState): this;
  132695. }
  132696. }
  132697. declare module BABYLON {
  132698. /**
  132699. * Block used to get the length of a vector
  132700. */
  132701. export class LengthBlock extends NodeMaterialBlock {
  132702. /**
  132703. * Creates a new LengthBlock
  132704. * @param name defines the block name
  132705. */
  132706. constructor(name: string);
  132707. /**
  132708. * Gets the current class name
  132709. * @returns the class name
  132710. */
  132711. getClassName(): string;
  132712. /**
  132713. * Gets the value input component
  132714. */
  132715. get value(): NodeMaterialConnectionPoint;
  132716. /**
  132717. * Gets the output component
  132718. */
  132719. get output(): NodeMaterialConnectionPoint;
  132720. protected _buildBlock(state: NodeMaterialBuildState): this;
  132721. }
  132722. }
  132723. declare module BABYLON {
  132724. /**
  132725. * Block used to get negative version of a value (i.e. x * -1)
  132726. */
  132727. export class NegateBlock extends NodeMaterialBlock {
  132728. /**
  132729. * Creates a new NegateBlock
  132730. * @param name defines the block name
  132731. */
  132732. constructor(name: string);
  132733. /**
  132734. * Gets the current class name
  132735. * @returns the class name
  132736. */
  132737. getClassName(): string;
  132738. /**
  132739. * Gets the value input component
  132740. */
  132741. get value(): NodeMaterialConnectionPoint;
  132742. /**
  132743. * Gets the output component
  132744. */
  132745. get output(): NodeMaterialConnectionPoint;
  132746. protected _buildBlock(state: NodeMaterialBuildState): this;
  132747. }
  132748. }
  132749. declare module BABYLON {
  132750. /**
  132751. * Block used to get the value of the first parameter raised to the power of the second
  132752. */
  132753. export class PowBlock extends NodeMaterialBlock {
  132754. /**
  132755. * Creates a new PowBlock
  132756. * @param name defines the block name
  132757. */
  132758. constructor(name: string);
  132759. /**
  132760. * Gets the current class name
  132761. * @returns the class name
  132762. */
  132763. getClassName(): string;
  132764. /**
  132765. * Gets the value operand input component
  132766. */
  132767. get value(): NodeMaterialConnectionPoint;
  132768. /**
  132769. * Gets the power operand input component
  132770. */
  132771. get power(): NodeMaterialConnectionPoint;
  132772. /**
  132773. * Gets the output component
  132774. */
  132775. get output(): NodeMaterialConnectionPoint;
  132776. protected _buildBlock(state: NodeMaterialBuildState): this;
  132777. }
  132778. }
  132779. declare module BABYLON {
  132780. /**
  132781. * Block used to get a random number
  132782. */
  132783. export class RandomNumberBlock extends NodeMaterialBlock {
  132784. /**
  132785. * Creates a new RandomNumberBlock
  132786. * @param name defines the block name
  132787. */
  132788. constructor(name: string);
  132789. /**
  132790. * Gets the current class name
  132791. * @returns the class name
  132792. */
  132793. getClassName(): string;
  132794. /**
  132795. * Gets the seed input component
  132796. */
  132797. get seed(): NodeMaterialConnectionPoint;
  132798. /**
  132799. * Gets the output component
  132800. */
  132801. get output(): NodeMaterialConnectionPoint;
  132802. protected _buildBlock(state: NodeMaterialBuildState): this;
  132803. }
  132804. }
  132805. declare module BABYLON {
  132806. /**
  132807. * Block used to compute arc tangent of 2 values
  132808. */
  132809. export class ArcTan2Block extends NodeMaterialBlock {
  132810. /**
  132811. * Creates a new ArcTan2Block
  132812. * @param name defines the block name
  132813. */
  132814. constructor(name: string);
  132815. /**
  132816. * Gets the current class name
  132817. * @returns the class name
  132818. */
  132819. getClassName(): string;
  132820. /**
  132821. * Gets the x operand input component
  132822. */
  132823. get x(): NodeMaterialConnectionPoint;
  132824. /**
  132825. * Gets the y operand input component
  132826. */
  132827. get y(): NodeMaterialConnectionPoint;
  132828. /**
  132829. * Gets the output component
  132830. */
  132831. get output(): NodeMaterialConnectionPoint;
  132832. protected _buildBlock(state: NodeMaterialBuildState): this;
  132833. }
  132834. }
  132835. declare module BABYLON {
  132836. /**
  132837. * Block used to smooth step a value
  132838. */
  132839. export class SmoothStepBlock extends NodeMaterialBlock {
  132840. /**
  132841. * Creates a new SmoothStepBlock
  132842. * @param name defines the block name
  132843. */
  132844. constructor(name: string);
  132845. /**
  132846. * Gets the current class name
  132847. * @returns the class name
  132848. */
  132849. getClassName(): string;
  132850. /**
  132851. * Gets the value operand input component
  132852. */
  132853. get value(): NodeMaterialConnectionPoint;
  132854. /**
  132855. * Gets the first edge operand input component
  132856. */
  132857. get edge0(): NodeMaterialConnectionPoint;
  132858. /**
  132859. * Gets the second edge operand input component
  132860. */
  132861. get edge1(): NodeMaterialConnectionPoint;
  132862. /**
  132863. * Gets the output component
  132864. */
  132865. get output(): NodeMaterialConnectionPoint;
  132866. protected _buildBlock(state: NodeMaterialBuildState): this;
  132867. }
  132868. }
  132869. declare module BABYLON {
  132870. /**
  132871. * Block used to get the reciprocal (1 / x) of a value
  132872. */
  132873. export class ReciprocalBlock extends NodeMaterialBlock {
  132874. /**
  132875. * Creates a new ReciprocalBlock
  132876. * @param name defines the block name
  132877. */
  132878. constructor(name: string);
  132879. /**
  132880. * Gets the current class name
  132881. * @returns the class name
  132882. */
  132883. getClassName(): string;
  132884. /**
  132885. * Gets the input component
  132886. */
  132887. get input(): NodeMaterialConnectionPoint;
  132888. /**
  132889. * Gets the output component
  132890. */
  132891. get output(): NodeMaterialConnectionPoint;
  132892. protected _buildBlock(state: NodeMaterialBuildState): this;
  132893. }
  132894. }
  132895. declare module BABYLON {
  132896. /**
  132897. * Block used to replace a color by another one
  132898. */
  132899. export class ReplaceColorBlock extends NodeMaterialBlock {
  132900. /**
  132901. * Creates a new ReplaceColorBlock
  132902. * @param name defines the block name
  132903. */
  132904. constructor(name: string);
  132905. /**
  132906. * Gets the current class name
  132907. * @returns the class name
  132908. */
  132909. getClassName(): string;
  132910. /**
  132911. * Gets the value input component
  132912. */
  132913. get value(): NodeMaterialConnectionPoint;
  132914. /**
  132915. * Gets the reference input component
  132916. */
  132917. get reference(): NodeMaterialConnectionPoint;
  132918. /**
  132919. * Gets the distance input component
  132920. */
  132921. get distance(): NodeMaterialConnectionPoint;
  132922. /**
  132923. * Gets the replacement input component
  132924. */
  132925. get replacement(): NodeMaterialConnectionPoint;
  132926. /**
  132927. * Gets the output component
  132928. */
  132929. get output(): NodeMaterialConnectionPoint;
  132930. protected _buildBlock(state: NodeMaterialBuildState): this;
  132931. }
  132932. }
  132933. declare module BABYLON {
  132934. /**
  132935. * Block used to posterize a value
  132936. * @see https://en.wikipedia.org/wiki/Posterization
  132937. */
  132938. export class PosterizeBlock extends NodeMaterialBlock {
  132939. /**
  132940. * Creates a new PosterizeBlock
  132941. * @param name defines the block name
  132942. */
  132943. constructor(name: string);
  132944. /**
  132945. * Gets the current class name
  132946. * @returns the class name
  132947. */
  132948. getClassName(): string;
  132949. /**
  132950. * Gets the value input component
  132951. */
  132952. get value(): NodeMaterialConnectionPoint;
  132953. /**
  132954. * Gets the steps input component
  132955. */
  132956. get steps(): NodeMaterialConnectionPoint;
  132957. /**
  132958. * Gets the output component
  132959. */
  132960. get output(): NodeMaterialConnectionPoint;
  132961. protected _buildBlock(state: NodeMaterialBuildState): this;
  132962. }
  132963. }
  132964. declare module BABYLON {
  132965. /**
  132966. * Operations supported by the Wave block
  132967. */
  132968. export enum WaveBlockKind {
  132969. /** SawTooth */
  132970. SawTooth = 0,
  132971. /** Square */
  132972. Square = 1,
  132973. /** Triangle */
  132974. Triangle = 2
  132975. }
  132976. /**
  132977. * Block used to apply wave operation to floats
  132978. */
  132979. export class WaveBlock extends NodeMaterialBlock {
  132980. /**
  132981. * Gets or sets the kibnd of wave to be applied by the block
  132982. */
  132983. kind: WaveBlockKind;
  132984. /**
  132985. * Creates a new WaveBlock
  132986. * @param name defines the block name
  132987. */
  132988. constructor(name: string);
  132989. /**
  132990. * Gets the current class name
  132991. * @returns the class name
  132992. */
  132993. getClassName(): string;
  132994. /**
  132995. * Gets the input component
  132996. */
  132997. get input(): NodeMaterialConnectionPoint;
  132998. /**
  132999. * Gets the output component
  133000. */
  133001. get output(): NodeMaterialConnectionPoint;
  133002. protected _buildBlock(state: NodeMaterialBuildState): this;
  133003. serialize(): any;
  133004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133005. }
  133006. }
  133007. declare module BABYLON {
  133008. /**
  133009. * Class used to store a color step for the GradientBlock
  133010. */
  133011. export class GradientBlockColorStep {
  133012. /**
  133013. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133014. */
  133015. step: number;
  133016. /**
  133017. * Gets or sets the color associated with this step
  133018. */
  133019. color: Color3;
  133020. /**
  133021. * Creates a new GradientBlockColorStep
  133022. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133023. * @param color defines the color associated with this step
  133024. */
  133025. constructor(
  133026. /**
  133027. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133028. */
  133029. step: number,
  133030. /**
  133031. * Gets or sets the color associated with this step
  133032. */
  133033. color: Color3);
  133034. }
  133035. /**
  133036. * Block used to return a color from a gradient based on an input value between 0 and 1
  133037. */
  133038. export class GradientBlock extends NodeMaterialBlock {
  133039. /**
  133040. * Gets or sets the list of color steps
  133041. */
  133042. colorSteps: GradientBlockColorStep[];
  133043. /**
  133044. * Creates a new GradientBlock
  133045. * @param name defines the block name
  133046. */
  133047. constructor(name: string);
  133048. /**
  133049. * Gets the current class name
  133050. * @returns the class name
  133051. */
  133052. getClassName(): string;
  133053. /**
  133054. * Gets the gradient input component
  133055. */
  133056. get gradient(): NodeMaterialConnectionPoint;
  133057. /**
  133058. * Gets the output component
  133059. */
  133060. get output(): NodeMaterialConnectionPoint;
  133061. private _writeColorConstant;
  133062. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133063. serialize(): any;
  133064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133065. protected _dumpPropertiesCode(): string;
  133066. }
  133067. }
  133068. declare module BABYLON {
  133069. /**
  133070. * Block used to normalize lerp between 2 values
  133071. */
  133072. export class NLerpBlock extends NodeMaterialBlock {
  133073. /**
  133074. * Creates a new NLerpBlock
  133075. * @param name defines the block name
  133076. */
  133077. constructor(name: string);
  133078. /**
  133079. * Gets the current class name
  133080. * @returns the class name
  133081. */
  133082. getClassName(): string;
  133083. /**
  133084. * Gets the left operand input component
  133085. */
  133086. get left(): NodeMaterialConnectionPoint;
  133087. /**
  133088. * Gets the right operand input component
  133089. */
  133090. get right(): NodeMaterialConnectionPoint;
  133091. /**
  133092. * Gets the gradient operand input component
  133093. */
  133094. get gradient(): NodeMaterialConnectionPoint;
  133095. /**
  133096. * Gets the output component
  133097. */
  133098. get output(): NodeMaterialConnectionPoint;
  133099. protected _buildBlock(state: NodeMaterialBuildState): this;
  133100. }
  133101. }
  133102. declare module BABYLON {
  133103. /**
  133104. * block used to Generate a Worley Noise 3D Noise Pattern
  133105. */
  133106. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133107. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133108. manhattanDistance: boolean;
  133109. /**
  133110. * Creates a new WorleyNoise3DBlock
  133111. * @param name defines the block name
  133112. */
  133113. constructor(name: string);
  133114. /**
  133115. * Gets the current class name
  133116. * @returns the class name
  133117. */
  133118. getClassName(): string;
  133119. /**
  133120. * Gets the seed input component
  133121. */
  133122. get seed(): NodeMaterialConnectionPoint;
  133123. /**
  133124. * Gets the jitter input component
  133125. */
  133126. get jitter(): NodeMaterialConnectionPoint;
  133127. /**
  133128. * Gets the output component
  133129. */
  133130. get output(): NodeMaterialConnectionPoint;
  133131. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133132. /**
  133133. * Exposes the properties to the UI?
  133134. */
  133135. protected _dumpPropertiesCode(): string;
  133136. /**
  133137. * Exposes the properties to the Seralize?
  133138. */
  133139. serialize(): any;
  133140. /**
  133141. * Exposes the properties to the deseralize?
  133142. */
  133143. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133144. }
  133145. }
  133146. declare module BABYLON {
  133147. /**
  133148. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133149. */
  133150. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133151. /**
  133152. * Creates a new SimplexPerlin3DBlock
  133153. * @param name defines the block name
  133154. */
  133155. constructor(name: string);
  133156. /**
  133157. * Gets the current class name
  133158. * @returns the class name
  133159. */
  133160. getClassName(): string;
  133161. /**
  133162. * Gets the seed operand input component
  133163. */
  133164. get seed(): NodeMaterialConnectionPoint;
  133165. /**
  133166. * Gets the output component
  133167. */
  133168. get output(): NodeMaterialConnectionPoint;
  133169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133170. }
  133171. }
  133172. declare module BABYLON {
  133173. /**
  133174. * Block used to blend normals
  133175. */
  133176. export class NormalBlendBlock extends NodeMaterialBlock {
  133177. /**
  133178. * Creates a new NormalBlendBlock
  133179. * @param name defines the block name
  133180. */
  133181. constructor(name: string);
  133182. /**
  133183. * Gets the current class name
  133184. * @returns the class name
  133185. */
  133186. getClassName(): string;
  133187. /**
  133188. * Gets the first input component
  133189. */
  133190. get normalMap0(): NodeMaterialConnectionPoint;
  133191. /**
  133192. * Gets the second input component
  133193. */
  133194. get normalMap1(): NodeMaterialConnectionPoint;
  133195. /**
  133196. * Gets the output component
  133197. */
  133198. get output(): NodeMaterialConnectionPoint;
  133199. protected _buildBlock(state: NodeMaterialBuildState): this;
  133200. }
  133201. }
  133202. declare module BABYLON {
  133203. /**
  133204. * Block used to rotate a 2d vector by a given angle
  133205. */
  133206. export class Rotate2dBlock extends NodeMaterialBlock {
  133207. /**
  133208. * Creates a new Rotate2dBlock
  133209. * @param name defines the block name
  133210. */
  133211. constructor(name: string);
  133212. /**
  133213. * Gets the current class name
  133214. * @returns the class name
  133215. */
  133216. getClassName(): string;
  133217. /**
  133218. * Gets the input vector
  133219. */
  133220. get input(): NodeMaterialConnectionPoint;
  133221. /**
  133222. * Gets the input angle
  133223. */
  133224. get angle(): NodeMaterialConnectionPoint;
  133225. /**
  133226. * Gets the output component
  133227. */
  133228. get output(): NodeMaterialConnectionPoint;
  133229. autoConfigure(material: NodeMaterial): void;
  133230. protected _buildBlock(state: NodeMaterialBuildState): this;
  133231. }
  133232. }
  133233. declare module BABYLON {
  133234. /**
  133235. * Block used to get the reflected vector from a direction and a normal
  133236. */
  133237. export class ReflectBlock extends NodeMaterialBlock {
  133238. /**
  133239. * Creates a new ReflectBlock
  133240. * @param name defines the block name
  133241. */
  133242. constructor(name: string);
  133243. /**
  133244. * Gets the current class name
  133245. * @returns the class name
  133246. */
  133247. getClassName(): string;
  133248. /**
  133249. * Gets the incident component
  133250. */
  133251. get incident(): NodeMaterialConnectionPoint;
  133252. /**
  133253. * Gets the normal component
  133254. */
  133255. get normal(): NodeMaterialConnectionPoint;
  133256. /**
  133257. * Gets the output component
  133258. */
  133259. get output(): NodeMaterialConnectionPoint;
  133260. protected _buildBlock(state: NodeMaterialBuildState): this;
  133261. }
  133262. }
  133263. declare module BABYLON {
  133264. /**
  133265. * Block used to get the refracted vector from a direction and a normal
  133266. */
  133267. export class RefractBlock extends NodeMaterialBlock {
  133268. /**
  133269. * Creates a new RefractBlock
  133270. * @param name defines the block name
  133271. */
  133272. constructor(name: string);
  133273. /**
  133274. * Gets the current class name
  133275. * @returns the class name
  133276. */
  133277. getClassName(): string;
  133278. /**
  133279. * Gets the incident component
  133280. */
  133281. get incident(): NodeMaterialConnectionPoint;
  133282. /**
  133283. * Gets the normal component
  133284. */
  133285. get normal(): NodeMaterialConnectionPoint;
  133286. /**
  133287. * Gets the index of refraction component
  133288. */
  133289. get ior(): NodeMaterialConnectionPoint;
  133290. /**
  133291. * Gets the output component
  133292. */
  133293. get output(): NodeMaterialConnectionPoint;
  133294. protected _buildBlock(state: NodeMaterialBuildState): this;
  133295. }
  133296. }
  133297. declare module BABYLON {
  133298. /**
  133299. * Block used to desaturate a color
  133300. */
  133301. export class DesaturateBlock extends NodeMaterialBlock {
  133302. /**
  133303. * Creates a new DesaturateBlock
  133304. * @param name defines the block name
  133305. */
  133306. constructor(name: string);
  133307. /**
  133308. * Gets the current class name
  133309. * @returns the class name
  133310. */
  133311. getClassName(): string;
  133312. /**
  133313. * Gets the color operand input component
  133314. */
  133315. get color(): NodeMaterialConnectionPoint;
  133316. /**
  133317. * Gets the level operand input component
  133318. */
  133319. get level(): NodeMaterialConnectionPoint;
  133320. /**
  133321. * Gets the output component
  133322. */
  133323. get output(): NodeMaterialConnectionPoint;
  133324. protected _buildBlock(state: NodeMaterialBuildState): this;
  133325. }
  133326. }
  133327. declare module BABYLON {
  133328. /**
  133329. * Effect Render Options
  133330. */
  133331. export interface IEffectRendererOptions {
  133332. /**
  133333. * Defines the vertices positions.
  133334. */
  133335. positions?: number[];
  133336. /**
  133337. * Defines the indices.
  133338. */
  133339. indices?: number[];
  133340. }
  133341. /**
  133342. * Helper class to render one or more effects
  133343. */
  133344. export class EffectRenderer {
  133345. private engine;
  133346. private static _DefaultOptions;
  133347. private _vertexBuffers;
  133348. private _indexBuffer;
  133349. private _ringBufferIndex;
  133350. private _ringScreenBuffer;
  133351. private _fullscreenViewport;
  133352. private _getNextFrameBuffer;
  133353. /**
  133354. * Creates an effect renderer
  133355. * @param engine the engine to use for rendering
  133356. * @param options defines the options of the effect renderer
  133357. */
  133358. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133359. /**
  133360. * Sets the current viewport in normalized coordinates 0-1
  133361. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133362. */
  133363. setViewport(viewport?: Viewport): void;
  133364. /**
  133365. * Binds the embedded attributes buffer to the effect.
  133366. * @param effect Defines the effect to bind the attributes for
  133367. */
  133368. bindBuffers(effect: Effect): void;
  133369. /**
  133370. * Sets the current effect wrapper to use during draw.
  133371. * The effect needs to be ready before calling this api.
  133372. * This also sets the default full screen position attribute.
  133373. * @param effectWrapper Defines the effect to draw with
  133374. */
  133375. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133376. /**
  133377. * Draws a full screen quad.
  133378. */
  133379. draw(): void;
  133380. /**
  133381. * renders one or more effects to a specified texture
  133382. * @param effectWrappers list of effects to renderer
  133383. * @param outputTexture texture to draw to, if null it will render to the screen
  133384. */
  133385. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133386. /**
  133387. * Disposes of the effect renderer
  133388. */
  133389. dispose(): void;
  133390. }
  133391. /**
  133392. * Options to create an EffectWrapper
  133393. */
  133394. interface EffectWrapperCreationOptions {
  133395. /**
  133396. * Engine to use to create the effect
  133397. */
  133398. engine: ThinEngine;
  133399. /**
  133400. * Fragment shader for the effect
  133401. */
  133402. fragmentShader: string;
  133403. /**
  133404. * Vertex shader for the effect
  133405. */
  133406. vertexShader?: string;
  133407. /**
  133408. * Attributes to use in the shader
  133409. */
  133410. attributeNames?: Array<string>;
  133411. /**
  133412. * Uniforms to use in the shader
  133413. */
  133414. uniformNames?: Array<string>;
  133415. /**
  133416. * Texture sampler names to use in the shader
  133417. */
  133418. samplerNames?: Array<string>;
  133419. /**
  133420. * The friendly name of the effect displayed in Spector.
  133421. */
  133422. name?: string;
  133423. }
  133424. /**
  133425. * Wraps an effect to be used for rendering
  133426. */
  133427. export class EffectWrapper {
  133428. /**
  133429. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133430. */
  133431. onApplyObservable: Observable<{}>;
  133432. /**
  133433. * The underlying effect
  133434. */
  133435. effect: Effect;
  133436. /**
  133437. * Creates an effect to be renderer
  133438. * @param creationOptions options to create the effect
  133439. */
  133440. constructor(creationOptions: EffectWrapperCreationOptions);
  133441. /**
  133442. * Disposes of the effect wrapper
  133443. */
  133444. dispose(): void;
  133445. }
  133446. }
  133447. declare module BABYLON {
  133448. /**
  133449. * Helper class to push actions to a pool of workers.
  133450. */
  133451. export class WorkerPool implements IDisposable {
  133452. private _workerInfos;
  133453. private _pendingActions;
  133454. /**
  133455. * Constructor
  133456. * @param workers Array of workers to use for actions
  133457. */
  133458. constructor(workers: Array<Worker>);
  133459. /**
  133460. * Terminates all workers and clears any pending actions.
  133461. */
  133462. dispose(): void;
  133463. /**
  133464. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133465. * pended until a worker has completed its action.
  133466. * @param action The action to perform. Call onComplete when the action is complete.
  133467. */
  133468. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133469. private _execute;
  133470. }
  133471. }
  133472. declare module BABYLON {
  133473. /**
  133474. * Configuration for Draco compression
  133475. */
  133476. export interface IDracoCompressionConfiguration {
  133477. /**
  133478. * Configuration for the decoder.
  133479. */
  133480. decoder: {
  133481. /**
  133482. * The url to the WebAssembly module.
  133483. */
  133484. wasmUrl?: string;
  133485. /**
  133486. * The url to the WebAssembly binary.
  133487. */
  133488. wasmBinaryUrl?: string;
  133489. /**
  133490. * The url to the fallback JavaScript module.
  133491. */
  133492. fallbackUrl?: string;
  133493. };
  133494. }
  133495. /**
  133496. * Draco compression (https://google.github.io/draco/)
  133497. *
  133498. * This class wraps the Draco module.
  133499. *
  133500. * **Encoder**
  133501. *
  133502. * The encoder is not currently implemented.
  133503. *
  133504. * **Decoder**
  133505. *
  133506. * 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.
  133507. *
  133508. * To update the configuration, use the following code:
  133509. * ```javascript
  133510. * DracoCompression.Configuration = {
  133511. * decoder: {
  133512. * wasmUrl: "<url to the WebAssembly library>",
  133513. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133514. * fallbackUrl: "<url to the fallback JavaScript library>",
  133515. * }
  133516. * };
  133517. * ```
  133518. *
  133519. * 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.
  133520. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133521. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133522. *
  133523. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133524. * ```javascript
  133525. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133526. * ```
  133527. *
  133528. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133529. */
  133530. export class DracoCompression implements IDisposable {
  133531. private _workerPoolPromise?;
  133532. private _decoderModulePromise?;
  133533. /**
  133534. * The configuration. Defaults to the following urls:
  133535. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133536. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133537. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133538. */
  133539. static Configuration: IDracoCompressionConfiguration;
  133540. /**
  133541. * Returns true if the decoder configuration is available.
  133542. */
  133543. static get DecoderAvailable(): boolean;
  133544. /**
  133545. * Default number of workers to create when creating the draco compression object.
  133546. */
  133547. static DefaultNumWorkers: number;
  133548. private static GetDefaultNumWorkers;
  133549. private static _Default;
  133550. /**
  133551. * Default instance for the draco compression object.
  133552. */
  133553. static get Default(): DracoCompression;
  133554. /**
  133555. * Constructor
  133556. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133557. */
  133558. constructor(numWorkers?: number);
  133559. /**
  133560. * Stop all async operations and release resources.
  133561. */
  133562. dispose(): void;
  133563. /**
  133564. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133565. * @returns a promise that resolves when ready
  133566. */
  133567. whenReadyAsync(): Promise<void>;
  133568. /**
  133569. * Decode Draco compressed mesh data to vertex data.
  133570. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133571. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133572. * @returns A promise that resolves with the decoded vertex data
  133573. */
  133574. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133575. [kind: string]: number;
  133576. }): Promise<VertexData>;
  133577. }
  133578. }
  133579. declare module BABYLON {
  133580. /**
  133581. * Class for building Constructive Solid Geometry
  133582. */
  133583. export class CSG {
  133584. private polygons;
  133585. /**
  133586. * The world matrix
  133587. */
  133588. matrix: Matrix;
  133589. /**
  133590. * Stores the position
  133591. */
  133592. position: Vector3;
  133593. /**
  133594. * Stores the rotation
  133595. */
  133596. rotation: Vector3;
  133597. /**
  133598. * Stores the rotation quaternion
  133599. */
  133600. rotationQuaternion: Nullable<Quaternion>;
  133601. /**
  133602. * Stores the scaling vector
  133603. */
  133604. scaling: Vector3;
  133605. /**
  133606. * Convert the Mesh to CSG
  133607. * @param mesh The Mesh to convert to CSG
  133608. * @returns A new CSG from the Mesh
  133609. */
  133610. static FromMesh(mesh: Mesh): CSG;
  133611. /**
  133612. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133613. * @param polygons Polygons used to construct a CSG solid
  133614. */
  133615. private static FromPolygons;
  133616. /**
  133617. * Clones, or makes a deep copy, of the CSG
  133618. * @returns A new CSG
  133619. */
  133620. clone(): CSG;
  133621. /**
  133622. * Unions this CSG with another CSG
  133623. * @param csg The CSG to union against this CSG
  133624. * @returns The unioned CSG
  133625. */
  133626. union(csg: CSG): CSG;
  133627. /**
  133628. * Unions this CSG with another CSG in place
  133629. * @param csg The CSG to union against this CSG
  133630. */
  133631. unionInPlace(csg: CSG): void;
  133632. /**
  133633. * Subtracts this CSG with another CSG
  133634. * @param csg The CSG to subtract against this CSG
  133635. * @returns A new CSG
  133636. */
  133637. subtract(csg: CSG): CSG;
  133638. /**
  133639. * Subtracts this CSG with another CSG in place
  133640. * @param csg The CSG to subtact against this CSG
  133641. */
  133642. subtractInPlace(csg: CSG): void;
  133643. /**
  133644. * Intersect this CSG with another CSG
  133645. * @param csg The CSG to intersect against this CSG
  133646. * @returns A new CSG
  133647. */
  133648. intersect(csg: CSG): CSG;
  133649. /**
  133650. * Intersects this CSG with another CSG in place
  133651. * @param csg The CSG to intersect against this CSG
  133652. */
  133653. intersectInPlace(csg: CSG): void;
  133654. /**
  133655. * Return a new CSG solid with solid and empty space switched. This solid is
  133656. * not modified.
  133657. * @returns A new CSG solid with solid and empty space switched
  133658. */
  133659. inverse(): CSG;
  133660. /**
  133661. * Inverses the CSG in place
  133662. */
  133663. inverseInPlace(): void;
  133664. /**
  133665. * This is used to keep meshes transformations so they can be restored
  133666. * when we build back a Babylon Mesh
  133667. * NB : All CSG operations are performed in world coordinates
  133668. * @param csg The CSG to copy the transform attributes from
  133669. * @returns This CSG
  133670. */
  133671. copyTransformAttributes(csg: CSG): CSG;
  133672. /**
  133673. * Build Raw mesh from CSG
  133674. * Coordinates here are in world space
  133675. * @param name The name of the mesh geometry
  133676. * @param scene The Scene
  133677. * @param keepSubMeshes Specifies if the submeshes should be kept
  133678. * @returns A new Mesh
  133679. */
  133680. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133681. /**
  133682. * Build Mesh from CSG taking material and transforms into account
  133683. * @param name The name of the Mesh
  133684. * @param material The material of the Mesh
  133685. * @param scene The Scene
  133686. * @param keepSubMeshes Specifies if submeshes should be kept
  133687. * @returns The new Mesh
  133688. */
  133689. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133690. }
  133691. }
  133692. declare module BABYLON {
  133693. /**
  133694. * Class used to create a trail following a mesh
  133695. */
  133696. export class TrailMesh extends Mesh {
  133697. private _generator;
  133698. private _autoStart;
  133699. private _running;
  133700. private _diameter;
  133701. private _length;
  133702. private _sectionPolygonPointsCount;
  133703. private _sectionVectors;
  133704. private _sectionNormalVectors;
  133705. private _beforeRenderObserver;
  133706. /**
  133707. * @constructor
  133708. * @param name The value used by scene.getMeshByName() to do a lookup.
  133709. * @param generator The mesh or transform node to generate a trail.
  133710. * @param scene The scene to add this mesh to.
  133711. * @param diameter Diameter of trailing mesh. Default is 1.
  133712. * @param length Length of trailing mesh. Default is 60.
  133713. * @param autoStart Automatically start trailing mesh. Default true.
  133714. */
  133715. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133716. /**
  133717. * "TrailMesh"
  133718. * @returns "TrailMesh"
  133719. */
  133720. getClassName(): string;
  133721. private _createMesh;
  133722. /**
  133723. * Start trailing mesh.
  133724. */
  133725. start(): void;
  133726. /**
  133727. * Stop trailing mesh.
  133728. */
  133729. stop(): void;
  133730. /**
  133731. * Update trailing mesh geometry.
  133732. */
  133733. update(): void;
  133734. /**
  133735. * Returns a new TrailMesh object.
  133736. * @param name is a string, the name given to the new mesh
  133737. * @param newGenerator use new generator object for cloned trail mesh
  133738. * @returns a new mesh
  133739. */
  133740. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133741. /**
  133742. * Serializes this trail mesh
  133743. * @param serializationObject object to write serialization to
  133744. */
  133745. serialize(serializationObject: any): void;
  133746. /**
  133747. * Parses a serialized trail mesh
  133748. * @param parsedMesh the serialized mesh
  133749. * @param scene the scene to create the trail mesh in
  133750. * @returns the created trail mesh
  133751. */
  133752. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133753. }
  133754. }
  133755. declare module BABYLON {
  133756. /**
  133757. * Class containing static functions to help procedurally build meshes
  133758. */
  133759. export class TiledBoxBuilder {
  133760. /**
  133761. * Creates a box mesh
  133762. * 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)
  133763. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133767. * @param name defines the name of the mesh
  133768. * @param options defines the options used to create the mesh
  133769. * @param scene defines the hosting scene
  133770. * @returns the box mesh
  133771. */
  133772. static CreateTiledBox(name: string, options: {
  133773. pattern?: number;
  133774. width?: number;
  133775. height?: number;
  133776. depth?: number;
  133777. tileSize?: number;
  133778. tileWidth?: number;
  133779. tileHeight?: number;
  133780. alignHorizontal?: number;
  133781. alignVertical?: number;
  133782. faceUV?: Vector4[];
  133783. faceColors?: Color4[];
  133784. sideOrientation?: number;
  133785. updatable?: boolean;
  133786. }, scene?: Nullable<Scene>): Mesh;
  133787. }
  133788. }
  133789. declare module BABYLON {
  133790. /**
  133791. * Class containing static functions to help procedurally build meshes
  133792. */
  133793. export class TorusKnotBuilder {
  133794. /**
  133795. * Creates a torus knot mesh
  133796. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133797. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133798. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133799. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133800. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133801. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133803. * @param name defines the name of the mesh
  133804. * @param options defines the options used to create the mesh
  133805. * @param scene defines the hosting scene
  133806. * @returns the torus knot mesh
  133807. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133808. */
  133809. static CreateTorusKnot(name: string, options: {
  133810. radius?: number;
  133811. tube?: number;
  133812. radialSegments?: number;
  133813. tubularSegments?: number;
  133814. p?: number;
  133815. q?: number;
  133816. updatable?: boolean;
  133817. sideOrientation?: number;
  133818. frontUVs?: Vector4;
  133819. backUVs?: Vector4;
  133820. }, scene: any): Mesh;
  133821. }
  133822. }
  133823. declare module BABYLON {
  133824. /**
  133825. * Polygon
  133826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133827. */
  133828. export class Polygon {
  133829. /**
  133830. * Creates a rectangle
  133831. * @param xmin bottom X coord
  133832. * @param ymin bottom Y coord
  133833. * @param xmax top X coord
  133834. * @param ymax top Y coord
  133835. * @returns points that make the resulting rectation
  133836. */
  133837. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133838. /**
  133839. * Creates a circle
  133840. * @param radius radius of circle
  133841. * @param cx scale in x
  133842. * @param cy scale in y
  133843. * @param numberOfSides number of sides that make up the circle
  133844. * @returns points that make the resulting circle
  133845. */
  133846. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133847. /**
  133848. * Creates a polygon from input string
  133849. * @param input Input polygon data
  133850. * @returns the parsed points
  133851. */
  133852. static Parse(input: string): Vector2[];
  133853. /**
  133854. * Starts building a polygon from x and y coordinates
  133855. * @param x x coordinate
  133856. * @param y y coordinate
  133857. * @returns the started path2
  133858. */
  133859. static StartingAt(x: number, y: number): Path2;
  133860. }
  133861. /**
  133862. * Builds a polygon
  133863. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133864. */
  133865. export class PolygonMeshBuilder {
  133866. private _points;
  133867. private _outlinepoints;
  133868. private _holes;
  133869. private _name;
  133870. private _scene;
  133871. private _epoints;
  133872. private _eholes;
  133873. private _addToepoint;
  133874. /**
  133875. * Babylon reference to the earcut plugin.
  133876. */
  133877. bjsEarcut: any;
  133878. /**
  133879. * Creates a PolygonMeshBuilder
  133880. * @param name name of the builder
  133881. * @param contours Path of the polygon
  133882. * @param scene scene to add to when creating the mesh
  133883. * @param earcutInjection can be used to inject your own earcut reference
  133884. */
  133885. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133886. /**
  133887. * Adds a whole within the polygon
  133888. * @param hole Array of points defining the hole
  133889. * @returns this
  133890. */
  133891. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133892. /**
  133893. * Creates the polygon
  133894. * @param updatable If the mesh should be updatable
  133895. * @param depth The depth of the mesh created
  133896. * @returns the created mesh
  133897. */
  133898. build(updatable?: boolean, depth?: number): Mesh;
  133899. /**
  133900. * Creates the polygon
  133901. * @param depth The depth of the mesh created
  133902. * @returns the created VertexData
  133903. */
  133904. buildVertexData(depth?: number): VertexData;
  133905. /**
  133906. * Adds a side to the polygon
  133907. * @param positions points that make the polygon
  133908. * @param normals normals of the polygon
  133909. * @param uvs uvs of the polygon
  133910. * @param indices indices of the polygon
  133911. * @param bounds bounds of the polygon
  133912. * @param points points of the polygon
  133913. * @param depth depth of the polygon
  133914. * @param flip flip of the polygon
  133915. */
  133916. private addSide;
  133917. }
  133918. }
  133919. declare module BABYLON {
  133920. /**
  133921. * Class containing static functions to help procedurally build meshes
  133922. */
  133923. export class PolygonBuilder {
  133924. /**
  133925. * Creates a polygon mesh
  133926. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133927. * * 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
  133928. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133931. * * Remember you can only change the shape positions, not their number when updating a polygon
  133932. * @param name defines the name of the mesh
  133933. * @param options defines the options used to create the mesh
  133934. * @param scene defines the hosting scene
  133935. * @param earcutInjection can be used to inject your own earcut reference
  133936. * @returns the polygon mesh
  133937. */
  133938. static CreatePolygon(name: string, options: {
  133939. shape: Vector3[];
  133940. holes?: Vector3[][];
  133941. depth?: number;
  133942. faceUV?: Vector4[];
  133943. faceColors?: Color4[];
  133944. updatable?: boolean;
  133945. sideOrientation?: number;
  133946. frontUVs?: Vector4;
  133947. backUVs?: Vector4;
  133948. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133949. /**
  133950. * Creates an extruded polygon mesh, with depth in the Y direction.
  133951. * * 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)
  133952. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133953. * @param name defines the name of the mesh
  133954. * @param options defines the options used to create the mesh
  133955. * @param scene defines the hosting scene
  133956. * @param earcutInjection can be used to inject your own earcut reference
  133957. * @returns the polygon mesh
  133958. */
  133959. static ExtrudePolygon(name: string, options: {
  133960. shape: Vector3[];
  133961. holes?: Vector3[][];
  133962. depth?: number;
  133963. faceUV?: Vector4[];
  133964. faceColors?: Color4[];
  133965. updatable?: boolean;
  133966. sideOrientation?: number;
  133967. frontUVs?: Vector4;
  133968. backUVs?: Vector4;
  133969. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133970. }
  133971. }
  133972. declare module BABYLON {
  133973. /**
  133974. * Class containing static functions to help procedurally build meshes
  133975. */
  133976. export class LatheBuilder {
  133977. /**
  133978. * Creates lathe mesh.
  133979. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133980. * * 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
  133981. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133982. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133983. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133984. * * 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
  133985. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133986. * * 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
  133987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133991. * @param name defines the name of the mesh
  133992. * @param options defines the options used to create the mesh
  133993. * @param scene defines the hosting scene
  133994. * @returns the lathe mesh
  133995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133996. */
  133997. static CreateLathe(name: string, options: {
  133998. shape: Vector3[];
  133999. radius?: number;
  134000. tessellation?: number;
  134001. clip?: number;
  134002. arc?: number;
  134003. closed?: boolean;
  134004. updatable?: boolean;
  134005. sideOrientation?: number;
  134006. frontUVs?: Vector4;
  134007. backUVs?: Vector4;
  134008. cap?: number;
  134009. invertUV?: boolean;
  134010. }, scene?: Nullable<Scene>): Mesh;
  134011. }
  134012. }
  134013. declare module BABYLON {
  134014. /**
  134015. * Class containing static functions to help procedurally build meshes
  134016. */
  134017. export class TiledPlaneBuilder {
  134018. /**
  134019. * Creates a tiled plane mesh
  134020. * * The parameter `pattern` will, depending on value, do nothing or
  134021. * * * flip (reflect about central vertical) alternate tiles across and up
  134022. * * * flip every tile on alternate rows
  134023. * * * rotate (180 degs) alternate tiles across and up
  134024. * * * rotate every tile on alternate rows
  134025. * * * flip and rotate alternate tiles across and up
  134026. * * * flip and rotate every tile on alternate rows
  134027. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134028. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134030. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134031. * * 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)
  134032. * * 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)
  134033. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134034. * @param name defines the name of the mesh
  134035. * @param options defines the options used to create the mesh
  134036. * @param scene defines the hosting scene
  134037. * @returns the box mesh
  134038. */
  134039. static CreateTiledPlane(name: string, options: {
  134040. pattern?: number;
  134041. tileSize?: number;
  134042. tileWidth?: number;
  134043. tileHeight?: number;
  134044. size?: number;
  134045. width?: number;
  134046. height?: number;
  134047. alignHorizontal?: number;
  134048. alignVertical?: number;
  134049. sideOrientation?: number;
  134050. frontUVs?: Vector4;
  134051. backUVs?: Vector4;
  134052. updatable?: boolean;
  134053. }, scene?: Nullable<Scene>): Mesh;
  134054. }
  134055. }
  134056. declare module BABYLON {
  134057. /**
  134058. * Class containing static functions to help procedurally build meshes
  134059. */
  134060. export class TubeBuilder {
  134061. /**
  134062. * Creates a tube mesh.
  134063. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134064. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134065. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134066. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134067. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134068. * * 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)
  134069. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134070. * * 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
  134071. * * 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
  134072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134076. * @param name defines the name of the mesh
  134077. * @param options defines the options used to create the mesh
  134078. * @param scene defines the hosting scene
  134079. * @returns the tube mesh
  134080. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134081. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134082. */
  134083. static CreateTube(name: string, options: {
  134084. path: Vector3[];
  134085. radius?: number;
  134086. tessellation?: number;
  134087. radiusFunction?: {
  134088. (i: number, distance: number): number;
  134089. };
  134090. cap?: number;
  134091. arc?: number;
  134092. updatable?: boolean;
  134093. sideOrientation?: number;
  134094. frontUVs?: Vector4;
  134095. backUVs?: Vector4;
  134096. instance?: Mesh;
  134097. invertUV?: boolean;
  134098. }, scene?: Nullable<Scene>): Mesh;
  134099. }
  134100. }
  134101. declare module BABYLON {
  134102. /**
  134103. * Class containing static functions to help procedurally build meshes
  134104. */
  134105. export class IcoSphereBuilder {
  134106. /**
  134107. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134108. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134109. * * 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`)
  134110. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134111. * * 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
  134112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134115. * @param name defines the name of the mesh
  134116. * @param options defines the options used to create the mesh
  134117. * @param scene defines the hosting scene
  134118. * @returns the icosahedron mesh
  134119. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134120. */
  134121. static CreateIcoSphere(name: string, options: {
  134122. radius?: number;
  134123. radiusX?: number;
  134124. radiusY?: number;
  134125. radiusZ?: number;
  134126. flat?: boolean;
  134127. subdivisions?: number;
  134128. sideOrientation?: number;
  134129. frontUVs?: Vector4;
  134130. backUVs?: Vector4;
  134131. updatable?: boolean;
  134132. }, scene?: Nullable<Scene>): Mesh;
  134133. }
  134134. }
  134135. declare module BABYLON {
  134136. /**
  134137. * Class containing static functions to help procedurally build meshes
  134138. */
  134139. export class DecalBuilder {
  134140. /**
  134141. * Creates a decal mesh.
  134142. * 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
  134143. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134144. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134145. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134146. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134147. * @param name defines the name of the mesh
  134148. * @param sourceMesh defines the mesh where the decal must be applied
  134149. * @param options defines the options used to create the mesh
  134150. * @param scene defines the hosting scene
  134151. * @returns the decal mesh
  134152. * @see https://doc.babylonjs.com/how_to/decals
  134153. */
  134154. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134155. position?: Vector3;
  134156. normal?: Vector3;
  134157. size?: Vector3;
  134158. angle?: number;
  134159. }): Mesh;
  134160. }
  134161. }
  134162. declare module BABYLON {
  134163. /**
  134164. * Class containing static functions to help procedurally build meshes
  134165. */
  134166. export class MeshBuilder {
  134167. /**
  134168. * Creates a box mesh
  134169. * * The parameter `size` sets the size (float) of each box side (default 1)
  134170. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134171. * * 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)
  134172. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134176. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134177. * @param name defines the name of the mesh
  134178. * @param options defines the options used to create the mesh
  134179. * @param scene defines the hosting scene
  134180. * @returns the box mesh
  134181. */
  134182. static CreateBox(name: string, options: {
  134183. size?: number;
  134184. width?: number;
  134185. height?: number;
  134186. depth?: number;
  134187. faceUV?: Vector4[];
  134188. faceColors?: Color4[];
  134189. sideOrientation?: number;
  134190. frontUVs?: Vector4;
  134191. backUVs?: Vector4;
  134192. updatable?: boolean;
  134193. }, scene?: Nullable<Scene>): Mesh;
  134194. /**
  134195. * Creates a tiled box mesh
  134196. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134198. * @param name defines the name of the mesh
  134199. * @param options defines the options used to create the mesh
  134200. * @param scene defines the hosting scene
  134201. * @returns the tiled box mesh
  134202. */
  134203. static CreateTiledBox(name: string, options: {
  134204. pattern?: number;
  134205. size?: number;
  134206. width?: number;
  134207. height?: number;
  134208. depth: number;
  134209. tileSize?: number;
  134210. tileWidth?: number;
  134211. tileHeight?: number;
  134212. faceUV?: Vector4[];
  134213. faceColors?: Color4[];
  134214. alignHorizontal?: number;
  134215. alignVertical?: number;
  134216. sideOrientation?: number;
  134217. updatable?: boolean;
  134218. }, scene?: Nullable<Scene>): Mesh;
  134219. /**
  134220. * Creates a sphere mesh
  134221. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134222. * * 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`)
  134223. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134224. * * 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
  134225. * * 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)
  134226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134229. * @param name defines the name of the mesh
  134230. * @param options defines the options used to create the mesh
  134231. * @param scene defines the hosting scene
  134232. * @returns the sphere mesh
  134233. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134234. */
  134235. static CreateSphere(name: string, options: {
  134236. segments?: number;
  134237. diameter?: number;
  134238. diameterX?: number;
  134239. diameterY?: number;
  134240. diameterZ?: number;
  134241. arc?: number;
  134242. slice?: number;
  134243. sideOrientation?: number;
  134244. frontUVs?: Vector4;
  134245. backUVs?: Vector4;
  134246. updatable?: boolean;
  134247. }, scene?: Nullable<Scene>): Mesh;
  134248. /**
  134249. * Creates a plane polygonal mesh. By default, this is a disc
  134250. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134251. * * 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
  134252. * * 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
  134253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134256. * @param name defines the name of the mesh
  134257. * @param options defines the options used to create the mesh
  134258. * @param scene defines the hosting scene
  134259. * @returns the plane polygonal mesh
  134260. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134261. */
  134262. static CreateDisc(name: string, options: {
  134263. radius?: number;
  134264. tessellation?: number;
  134265. arc?: number;
  134266. updatable?: boolean;
  134267. sideOrientation?: number;
  134268. frontUVs?: Vector4;
  134269. backUVs?: Vector4;
  134270. }, scene?: Nullable<Scene>): Mesh;
  134271. /**
  134272. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134273. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134274. * * 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`)
  134275. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134276. * * 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
  134277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134280. * @param name defines the name of the mesh
  134281. * @param options defines the options used to create the mesh
  134282. * @param scene defines the hosting scene
  134283. * @returns the icosahedron mesh
  134284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134285. */
  134286. static CreateIcoSphere(name: string, options: {
  134287. radius?: number;
  134288. radiusX?: number;
  134289. radiusY?: number;
  134290. radiusZ?: number;
  134291. flat?: boolean;
  134292. subdivisions?: number;
  134293. sideOrientation?: number;
  134294. frontUVs?: Vector4;
  134295. backUVs?: Vector4;
  134296. updatable?: boolean;
  134297. }, scene?: Nullable<Scene>): Mesh;
  134298. /**
  134299. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134300. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134301. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134302. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134303. * * 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
  134304. * * 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
  134305. * * 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
  134306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134309. * * 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
  134310. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134311. * * 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
  134312. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134314. * @param name defines the name of the mesh
  134315. * @param options defines the options used to create the mesh
  134316. * @param scene defines the hosting scene
  134317. * @returns the ribbon mesh
  134318. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134319. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134320. */
  134321. static CreateRibbon(name: string, options: {
  134322. pathArray: Vector3[][];
  134323. closeArray?: boolean;
  134324. closePath?: boolean;
  134325. offset?: number;
  134326. updatable?: boolean;
  134327. sideOrientation?: number;
  134328. frontUVs?: Vector4;
  134329. backUVs?: Vector4;
  134330. instance?: Mesh;
  134331. invertUV?: boolean;
  134332. uvs?: Vector2[];
  134333. colors?: Color4[];
  134334. }, scene?: Nullable<Scene>): Mesh;
  134335. /**
  134336. * Creates a cylinder or a cone mesh
  134337. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134338. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134339. * * 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.
  134340. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134341. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134342. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134343. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134344. * * 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).
  134345. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134346. * * 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).
  134347. * * 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
  134348. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134349. * * 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
  134350. * * 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.
  134351. * * If `enclose` is false, a ring surface is one element.
  134352. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134353. * * 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
  134354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134357. * @param name defines the name of the mesh
  134358. * @param options defines the options used to create the mesh
  134359. * @param scene defines the hosting scene
  134360. * @returns the cylinder mesh
  134361. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134362. */
  134363. static CreateCylinder(name: string, options: {
  134364. height?: number;
  134365. diameterTop?: number;
  134366. diameterBottom?: number;
  134367. diameter?: number;
  134368. tessellation?: number;
  134369. subdivisions?: number;
  134370. arc?: number;
  134371. faceColors?: Color4[];
  134372. faceUV?: Vector4[];
  134373. updatable?: boolean;
  134374. hasRings?: boolean;
  134375. enclose?: boolean;
  134376. cap?: number;
  134377. sideOrientation?: number;
  134378. frontUVs?: Vector4;
  134379. backUVs?: Vector4;
  134380. }, scene?: Nullable<Scene>): Mesh;
  134381. /**
  134382. * Creates a torus mesh
  134383. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134384. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134385. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134389. * @param name defines the name of the mesh
  134390. * @param options defines the options used to create the mesh
  134391. * @param scene defines the hosting scene
  134392. * @returns the torus mesh
  134393. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134394. */
  134395. static CreateTorus(name: string, options: {
  134396. diameter?: number;
  134397. thickness?: number;
  134398. tessellation?: number;
  134399. updatable?: boolean;
  134400. sideOrientation?: number;
  134401. frontUVs?: Vector4;
  134402. backUVs?: Vector4;
  134403. }, scene?: Nullable<Scene>): Mesh;
  134404. /**
  134405. * Creates a torus knot mesh
  134406. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134407. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134408. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134409. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134413. * @param name defines the name of the mesh
  134414. * @param options defines the options used to create the mesh
  134415. * @param scene defines the hosting scene
  134416. * @returns the torus knot mesh
  134417. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134418. */
  134419. static CreateTorusKnot(name: string, options: {
  134420. radius?: number;
  134421. tube?: number;
  134422. radialSegments?: number;
  134423. tubularSegments?: number;
  134424. p?: number;
  134425. q?: number;
  134426. updatable?: boolean;
  134427. sideOrientation?: number;
  134428. frontUVs?: Vector4;
  134429. backUVs?: Vector4;
  134430. }, scene?: Nullable<Scene>): Mesh;
  134431. /**
  134432. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134433. * * 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
  134434. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134435. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134436. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134437. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134438. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134439. * * 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
  134440. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134442. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134443. * @param name defines the name of the new line system
  134444. * @param options defines the options used to create the line system
  134445. * @param scene defines the hosting scene
  134446. * @returns a new line system mesh
  134447. */
  134448. static CreateLineSystem(name: string, options: {
  134449. lines: Vector3[][];
  134450. updatable?: boolean;
  134451. instance?: Nullable<LinesMesh>;
  134452. colors?: Nullable<Color4[][]>;
  134453. useVertexAlpha?: boolean;
  134454. }, scene: Nullable<Scene>): LinesMesh;
  134455. /**
  134456. * Creates a line mesh
  134457. * 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
  134458. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134459. * * The parameter `points` is an array successive Vector3
  134460. * * 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
  134461. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134462. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134463. * * When updating an instance, remember that only point positions can change, not the number of points
  134464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134466. * @param name defines the name of the new line system
  134467. * @param options defines the options used to create the line system
  134468. * @param scene defines the hosting scene
  134469. * @returns a new line mesh
  134470. */
  134471. static CreateLines(name: string, options: {
  134472. points: Vector3[];
  134473. updatable?: boolean;
  134474. instance?: Nullable<LinesMesh>;
  134475. colors?: Color4[];
  134476. useVertexAlpha?: boolean;
  134477. }, scene?: Nullable<Scene>): LinesMesh;
  134478. /**
  134479. * Creates a dashed line mesh
  134480. * * 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
  134481. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134482. * * The parameter `points` is an array successive Vector3
  134483. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134484. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134485. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134486. * * 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
  134487. * * When updating an instance, remember that only point positions can change, not the number of points
  134488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134489. * @param name defines the name of the mesh
  134490. * @param options defines the options used to create the mesh
  134491. * @param scene defines the hosting scene
  134492. * @returns the dashed line mesh
  134493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134494. */
  134495. static CreateDashedLines(name: string, options: {
  134496. points: Vector3[];
  134497. dashSize?: number;
  134498. gapSize?: number;
  134499. dashNb?: number;
  134500. updatable?: boolean;
  134501. instance?: LinesMesh;
  134502. }, scene?: Nullable<Scene>): LinesMesh;
  134503. /**
  134504. * 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.
  134505. * * 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.
  134506. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134507. * * 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.
  134508. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134509. * * 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
  134510. * * 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
  134511. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134516. * @param name defines the name of the mesh
  134517. * @param options defines the options used to create the mesh
  134518. * @param scene defines the hosting scene
  134519. * @returns the extruded shape mesh
  134520. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134522. */
  134523. static ExtrudeShape(name: string, options: {
  134524. shape: Vector3[];
  134525. path: Vector3[];
  134526. scale?: number;
  134527. rotation?: number;
  134528. cap?: number;
  134529. updatable?: boolean;
  134530. sideOrientation?: number;
  134531. frontUVs?: Vector4;
  134532. backUVs?: Vector4;
  134533. instance?: Mesh;
  134534. invertUV?: boolean;
  134535. }, scene?: Nullable<Scene>): Mesh;
  134536. /**
  134537. * Creates an custom extruded shape mesh.
  134538. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134539. * * 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.
  134540. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134541. * * 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
  134542. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134543. * * 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
  134544. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134545. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134546. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134547. * * 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
  134548. * * 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
  134549. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134554. * @param name defines the name of the mesh
  134555. * @param options defines the options used to create the mesh
  134556. * @param scene defines the hosting scene
  134557. * @returns the custom extruded shape mesh
  134558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134561. */
  134562. static ExtrudeShapeCustom(name: string, options: {
  134563. shape: Vector3[];
  134564. path: Vector3[];
  134565. scaleFunction?: any;
  134566. rotationFunction?: any;
  134567. ribbonCloseArray?: boolean;
  134568. ribbonClosePath?: boolean;
  134569. cap?: number;
  134570. updatable?: boolean;
  134571. sideOrientation?: number;
  134572. frontUVs?: Vector4;
  134573. backUVs?: Vector4;
  134574. instance?: Mesh;
  134575. invertUV?: boolean;
  134576. }, scene?: Nullable<Scene>): Mesh;
  134577. /**
  134578. * Creates lathe mesh.
  134579. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134580. * * 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
  134581. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134582. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134583. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134584. * * 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
  134585. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134586. * * 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
  134587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134589. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134591. * @param name defines the name of the mesh
  134592. * @param options defines the options used to create the mesh
  134593. * @param scene defines the hosting scene
  134594. * @returns the lathe mesh
  134595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134596. */
  134597. static CreateLathe(name: string, options: {
  134598. shape: Vector3[];
  134599. radius?: number;
  134600. tessellation?: number;
  134601. clip?: number;
  134602. arc?: number;
  134603. closed?: boolean;
  134604. updatable?: boolean;
  134605. sideOrientation?: number;
  134606. frontUVs?: Vector4;
  134607. backUVs?: Vector4;
  134608. cap?: number;
  134609. invertUV?: boolean;
  134610. }, scene?: Nullable<Scene>): Mesh;
  134611. /**
  134612. * Creates a tiled plane mesh
  134613. * * You can set a limited pattern arrangement with the tiles
  134614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134617. * @param name defines the name of the mesh
  134618. * @param options defines the options used to create the mesh
  134619. * @param scene defines the hosting scene
  134620. * @returns the plane mesh
  134621. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134622. */
  134623. static CreateTiledPlane(name: string, options: {
  134624. pattern?: number;
  134625. tileSize?: number;
  134626. tileWidth?: number;
  134627. tileHeight?: number;
  134628. size?: number;
  134629. width?: number;
  134630. height?: number;
  134631. alignHorizontal?: number;
  134632. alignVertical?: number;
  134633. sideOrientation?: number;
  134634. frontUVs?: Vector4;
  134635. backUVs?: Vector4;
  134636. updatable?: boolean;
  134637. }, scene?: Nullable<Scene>): Mesh;
  134638. /**
  134639. * Creates a plane mesh
  134640. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134641. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134642. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134646. * @param name defines the name of the mesh
  134647. * @param options defines the options used to create the mesh
  134648. * @param scene defines the hosting scene
  134649. * @returns the plane mesh
  134650. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134651. */
  134652. static CreatePlane(name: string, options: {
  134653. size?: number;
  134654. width?: number;
  134655. height?: number;
  134656. sideOrientation?: number;
  134657. frontUVs?: Vector4;
  134658. backUVs?: Vector4;
  134659. updatable?: boolean;
  134660. sourcePlane?: Plane;
  134661. }, scene?: Nullable<Scene>): Mesh;
  134662. /**
  134663. * Creates a ground mesh
  134664. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134665. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134667. * @param name defines the name of the mesh
  134668. * @param options defines the options used to create the mesh
  134669. * @param scene defines the hosting scene
  134670. * @returns the ground mesh
  134671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134672. */
  134673. static CreateGround(name: string, options: {
  134674. width?: number;
  134675. height?: number;
  134676. subdivisions?: number;
  134677. subdivisionsX?: number;
  134678. subdivisionsY?: number;
  134679. updatable?: boolean;
  134680. }, scene?: Nullable<Scene>): Mesh;
  134681. /**
  134682. * Creates a tiled ground mesh
  134683. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134684. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134685. * * 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
  134686. * * 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
  134687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134688. * @param name defines the name of the mesh
  134689. * @param options defines the options used to create the mesh
  134690. * @param scene defines the hosting scene
  134691. * @returns the tiled ground mesh
  134692. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134693. */
  134694. static CreateTiledGround(name: string, options: {
  134695. xmin: number;
  134696. zmin: number;
  134697. xmax: number;
  134698. zmax: number;
  134699. subdivisions?: {
  134700. w: number;
  134701. h: number;
  134702. };
  134703. precision?: {
  134704. w: number;
  134705. h: number;
  134706. };
  134707. updatable?: boolean;
  134708. }, scene?: Nullable<Scene>): Mesh;
  134709. /**
  134710. * Creates a ground mesh from a height map
  134711. * * The parameter `url` sets the URL of the height map image resource.
  134712. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134713. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134714. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134715. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134716. * * 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.
  134717. * * 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).
  134718. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134720. * @param name defines the name of the mesh
  134721. * @param url defines the url to the height map
  134722. * @param options defines the options used to create the mesh
  134723. * @param scene defines the hosting scene
  134724. * @returns the ground mesh
  134725. * @see https://doc.babylonjs.com/babylon101/height_map
  134726. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134727. */
  134728. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134729. width?: number;
  134730. height?: number;
  134731. subdivisions?: number;
  134732. minHeight?: number;
  134733. maxHeight?: number;
  134734. colorFilter?: Color3;
  134735. alphaFilter?: number;
  134736. updatable?: boolean;
  134737. onReady?: (mesh: GroundMesh) => void;
  134738. }, scene?: Nullable<Scene>): GroundMesh;
  134739. /**
  134740. * Creates a polygon mesh
  134741. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134742. * * 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
  134743. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134746. * * Remember you can only change the shape positions, not their number when updating a polygon
  134747. * @param name defines the name of the mesh
  134748. * @param options defines the options used to create the mesh
  134749. * @param scene defines the hosting scene
  134750. * @param earcutInjection can be used to inject your own earcut reference
  134751. * @returns the polygon mesh
  134752. */
  134753. static CreatePolygon(name: string, options: {
  134754. shape: Vector3[];
  134755. holes?: Vector3[][];
  134756. depth?: number;
  134757. faceUV?: Vector4[];
  134758. faceColors?: Color4[];
  134759. updatable?: boolean;
  134760. sideOrientation?: number;
  134761. frontUVs?: Vector4;
  134762. backUVs?: Vector4;
  134763. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134764. /**
  134765. * Creates an extruded polygon mesh, with depth in the Y direction.
  134766. * * 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)
  134767. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134768. * @param name defines the name of the mesh
  134769. * @param options defines the options used to create the mesh
  134770. * @param scene defines the hosting scene
  134771. * @param earcutInjection can be used to inject your own earcut reference
  134772. * @returns the polygon mesh
  134773. */
  134774. static ExtrudePolygon(name: string, options: {
  134775. shape: Vector3[];
  134776. holes?: Vector3[][];
  134777. depth?: number;
  134778. faceUV?: Vector4[];
  134779. faceColors?: Color4[];
  134780. updatable?: boolean;
  134781. sideOrientation?: number;
  134782. frontUVs?: Vector4;
  134783. backUVs?: Vector4;
  134784. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134785. /**
  134786. * Creates a tube mesh.
  134787. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134788. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134789. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134790. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134791. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134792. * * 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)
  134793. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134794. * * 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
  134795. * * 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
  134796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134800. * @param name defines the name of the mesh
  134801. * @param options defines the options used to create the mesh
  134802. * @param scene defines the hosting scene
  134803. * @returns the tube mesh
  134804. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134805. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134806. */
  134807. static CreateTube(name: string, options: {
  134808. path: Vector3[];
  134809. radius?: number;
  134810. tessellation?: number;
  134811. radiusFunction?: {
  134812. (i: number, distance: number): number;
  134813. };
  134814. cap?: number;
  134815. arc?: number;
  134816. updatable?: boolean;
  134817. sideOrientation?: number;
  134818. frontUVs?: Vector4;
  134819. backUVs?: Vector4;
  134820. instance?: Mesh;
  134821. invertUV?: boolean;
  134822. }, scene?: Nullable<Scene>): Mesh;
  134823. /**
  134824. * Creates a polyhedron mesh
  134825. * * 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
  134826. * * The parameter `size` (positive float, default 1) sets the polygon size
  134827. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134828. * * 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`
  134829. * * 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
  134830. * * 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)`)
  134831. * * 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
  134832. * * 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
  134833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134836. * @param name defines the name of the mesh
  134837. * @param options defines the options used to create the mesh
  134838. * @param scene defines the hosting scene
  134839. * @returns the polyhedron mesh
  134840. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134841. */
  134842. static CreatePolyhedron(name: string, options: {
  134843. type?: number;
  134844. size?: number;
  134845. sizeX?: number;
  134846. sizeY?: number;
  134847. sizeZ?: number;
  134848. custom?: any;
  134849. faceUV?: Vector4[];
  134850. faceColors?: Color4[];
  134851. flat?: boolean;
  134852. updatable?: boolean;
  134853. sideOrientation?: number;
  134854. frontUVs?: Vector4;
  134855. backUVs?: Vector4;
  134856. }, scene?: Nullable<Scene>): Mesh;
  134857. /**
  134858. * Creates a decal mesh.
  134859. * 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
  134860. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134861. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134862. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134863. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134864. * @param name defines the name of the mesh
  134865. * @param sourceMesh defines the mesh where the decal must be applied
  134866. * @param options defines the options used to create the mesh
  134867. * @param scene defines the hosting scene
  134868. * @returns the decal mesh
  134869. * @see https://doc.babylonjs.com/how_to/decals
  134870. */
  134871. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134872. position?: Vector3;
  134873. normal?: Vector3;
  134874. size?: Vector3;
  134875. angle?: number;
  134876. }): Mesh;
  134877. }
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * A simplifier interface for future simplification implementations
  134882. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134883. */
  134884. export interface ISimplifier {
  134885. /**
  134886. * Simplification of a given mesh according to the given settings.
  134887. * Since this requires computation, it is assumed that the function runs async.
  134888. * @param settings The settings of the simplification, including quality and distance
  134889. * @param successCallback A callback that will be called after the mesh was simplified.
  134890. * @param errorCallback in case of an error, this callback will be called. optional.
  134891. */
  134892. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134893. }
  134894. /**
  134895. * Expected simplification settings.
  134896. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134898. */
  134899. export interface ISimplificationSettings {
  134900. /**
  134901. * Gets or sets the expected quality
  134902. */
  134903. quality: number;
  134904. /**
  134905. * Gets or sets the distance when this optimized version should be used
  134906. */
  134907. distance: number;
  134908. /**
  134909. * Gets an already optimized mesh
  134910. */
  134911. optimizeMesh?: boolean;
  134912. }
  134913. /**
  134914. * Class used to specify simplification options
  134915. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134916. */
  134917. export class SimplificationSettings implements ISimplificationSettings {
  134918. /** expected quality */
  134919. quality: number;
  134920. /** distance when this optimized version should be used */
  134921. distance: number;
  134922. /** already optimized mesh */
  134923. optimizeMesh?: boolean | undefined;
  134924. /**
  134925. * Creates a SimplificationSettings
  134926. * @param quality expected quality
  134927. * @param distance distance when this optimized version should be used
  134928. * @param optimizeMesh already optimized mesh
  134929. */
  134930. constructor(
  134931. /** expected quality */
  134932. quality: number,
  134933. /** distance when this optimized version should be used */
  134934. distance: number,
  134935. /** already optimized mesh */
  134936. optimizeMesh?: boolean | undefined);
  134937. }
  134938. /**
  134939. * Interface used to define a simplification task
  134940. */
  134941. export interface ISimplificationTask {
  134942. /**
  134943. * Array of settings
  134944. */
  134945. settings: Array<ISimplificationSettings>;
  134946. /**
  134947. * Simplification type
  134948. */
  134949. simplificationType: SimplificationType;
  134950. /**
  134951. * Mesh to simplify
  134952. */
  134953. mesh: Mesh;
  134954. /**
  134955. * Callback called on success
  134956. */
  134957. successCallback?: () => void;
  134958. /**
  134959. * Defines if parallel processing can be used
  134960. */
  134961. parallelProcessing: boolean;
  134962. }
  134963. /**
  134964. * Queue used to order the simplification tasks
  134965. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134966. */
  134967. export class SimplificationQueue {
  134968. private _simplificationArray;
  134969. /**
  134970. * Gets a boolean indicating that the process is still running
  134971. */
  134972. running: boolean;
  134973. /**
  134974. * Creates a new queue
  134975. */
  134976. constructor();
  134977. /**
  134978. * Adds a new simplification task
  134979. * @param task defines a task to add
  134980. */
  134981. addTask(task: ISimplificationTask): void;
  134982. /**
  134983. * Execute next task
  134984. */
  134985. executeNext(): void;
  134986. /**
  134987. * Execute a simplification task
  134988. * @param task defines the task to run
  134989. */
  134990. runSimplification(task: ISimplificationTask): void;
  134991. private getSimplifier;
  134992. }
  134993. /**
  134994. * The implemented types of simplification
  134995. * At the moment only Quadratic Error Decimation is implemented
  134996. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134997. */
  134998. export enum SimplificationType {
  134999. /** Quadratic error decimation */
  135000. QUADRATIC = 0
  135001. }
  135002. }
  135003. declare module BABYLON {
  135004. interface Scene {
  135005. /** @hidden (Backing field) */
  135006. _simplificationQueue: SimplificationQueue;
  135007. /**
  135008. * Gets or sets the simplification queue attached to the scene
  135009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135010. */
  135011. simplificationQueue: SimplificationQueue;
  135012. }
  135013. interface Mesh {
  135014. /**
  135015. * Simplify the mesh according to the given array of settings.
  135016. * Function will return immediately and will simplify async
  135017. * @param settings a collection of simplification settings
  135018. * @param parallelProcessing should all levels calculate parallel or one after the other
  135019. * @param simplificationType the type of simplification to run
  135020. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135021. * @returns the current mesh
  135022. */
  135023. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135024. }
  135025. /**
  135026. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135027. * created in a scene
  135028. */
  135029. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135030. /**
  135031. * The component name helpfull to identify the component in the list of scene components.
  135032. */
  135033. readonly name: string;
  135034. /**
  135035. * The scene the component belongs to.
  135036. */
  135037. scene: Scene;
  135038. /**
  135039. * Creates a new instance of the component for the given scene
  135040. * @param scene Defines the scene to register the component in
  135041. */
  135042. constructor(scene: Scene);
  135043. /**
  135044. * Registers the component in a given scene
  135045. */
  135046. register(): void;
  135047. /**
  135048. * Rebuilds the elements related to this component in case of
  135049. * context lost for instance.
  135050. */
  135051. rebuild(): void;
  135052. /**
  135053. * Disposes the component and the associated ressources
  135054. */
  135055. dispose(): void;
  135056. private _beforeCameraUpdate;
  135057. }
  135058. }
  135059. declare module BABYLON {
  135060. /**
  135061. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135062. */
  135063. export interface INavigationEnginePlugin {
  135064. /**
  135065. * plugin name
  135066. */
  135067. name: string;
  135068. /**
  135069. * Creates a navigation mesh
  135070. * @param meshes array of all the geometry used to compute the navigatio mesh
  135071. * @param parameters bunch of parameters used to filter geometry
  135072. */
  135073. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135074. /**
  135075. * Create a navigation mesh debug mesh
  135076. * @param scene is where the mesh will be added
  135077. * @returns debug display mesh
  135078. */
  135079. createDebugNavMesh(scene: Scene): Mesh;
  135080. /**
  135081. * Get a navigation mesh constrained position, closest to the parameter position
  135082. * @param position world position
  135083. * @returns the closest point to position constrained by the navigation mesh
  135084. */
  135085. getClosestPoint(position: Vector3): Vector3;
  135086. /**
  135087. * Get a navigation mesh constrained position, within a particular radius
  135088. * @param position world position
  135089. * @param maxRadius the maximum distance to the constrained world position
  135090. * @returns the closest point to position constrained by the navigation mesh
  135091. */
  135092. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135093. /**
  135094. * Compute the final position from a segment made of destination-position
  135095. * @param position world position
  135096. * @param destination world position
  135097. * @returns the resulting point along the navmesh
  135098. */
  135099. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135100. /**
  135101. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135102. * @param start world position
  135103. * @param end world position
  135104. * @returns array containing world position composing the path
  135105. */
  135106. computePath(start: Vector3, end: Vector3): Vector3[];
  135107. /**
  135108. * If this plugin is supported
  135109. * @returns true if plugin is supported
  135110. */
  135111. isSupported(): boolean;
  135112. /**
  135113. * Create a new Crowd so you can add agents
  135114. * @param maxAgents the maximum agent count in the crowd
  135115. * @param maxAgentRadius the maximum radius an agent can have
  135116. * @param scene to attach the crowd to
  135117. * @returns the crowd you can add agents to
  135118. */
  135119. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135120. /**
  135121. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135122. * The queries will try to find a solution within those bounds
  135123. * default is (1,1,1)
  135124. * @param extent x,y,z value that define the extent around the queries point of reference
  135125. */
  135126. setDefaultQueryExtent(extent: Vector3): void;
  135127. /**
  135128. * Get the Bounding box extent specified by setDefaultQueryExtent
  135129. * @returns the box extent values
  135130. */
  135131. getDefaultQueryExtent(): Vector3;
  135132. /**
  135133. * Release all resources
  135134. */
  135135. dispose(): void;
  135136. }
  135137. /**
  135138. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135139. */
  135140. export interface ICrowd {
  135141. /**
  135142. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135143. * You can attach anything to that node. The node position is updated in the scene update tick.
  135144. * @param pos world position that will be constrained by the navigation mesh
  135145. * @param parameters agent parameters
  135146. * @param transform hooked to the agent that will be update by the scene
  135147. * @returns agent index
  135148. */
  135149. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135150. /**
  135151. * Returns the agent position in world space
  135152. * @param index agent index returned by addAgent
  135153. * @returns world space position
  135154. */
  135155. getAgentPosition(index: number): Vector3;
  135156. /**
  135157. * Gets the agent velocity in world space
  135158. * @param index agent index returned by addAgent
  135159. * @returns world space velocity
  135160. */
  135161. getAgentVelocity(index: number): Vector3;
  135162. /**
  135163. * remove a particular agent previously created
  135164. * @param index agent index returned by addAgent
  135165. */
  135166. removeAgent(index: number): void;
  135167. /**
  135168. * get the list of all agents attached to this crowd
  135169. * @returns list of agent indices
  135170. */
  135171. getAgents(): number[];
  135172. /**
  135173. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135174. * @param deltaTime in seconds
  135175. */
  135176. update(deltaTime: number): void;
  135177. /**
  135178. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135179. * @param index agent index returned by addAgent
  135180. * @param destination targeted world position
  135181. */
  135182. agentGoto(index: number, destination: Vector3): void;
  135183. /**
  135184. * Teleport the agent to a new position
  135185. * @param index agent index returned by addAgent
  135186. * @param destination targeted world position
  135187. */
  135188. agentTeleport(index: number, destination: Vector3): void;
  135189. /**
  135190. * Update agent parameters
  135191. * @param index agent index returned by addAgent
  135192. * @param parameters agent parameters
  135193. */
  135194. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135195. /**
  135196. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135197. * The queries will try to find a solution within those bounds
  135198. * default is (1,1,1)
  135199. * @param extent x,y,z value that define the extent around the queries point of reference
  135200. */
  135201. setDefaultQueryExtent(extent: Vector3): void;
  135202. /**
  135203. * Get the Bounding box extent specified by setDefaultQueryExtent
  135204. * @returns the box extent values
  135205. */
  135206. getDefaultQueryExtent(): Vector3;
  135207. /**
  135208. * Release all resources
  135209. */
  135210. dispose(): void;
  135211. }
  135212. /**
  135213. * Configures an agent
  135214. */
  135215. export interface IAgentParameters {
  135216. /**
  135217. * Agent radius. [Limit: >= 0]
  135218. */
  135219. radius: number;
  135220. /**
  135221. * Agent height. [Limit: > 0]
  135222. */
  135223. height: number;
  135224. /**
  135225. * Maximum allowed acceleration. [Limit: >= 0]
  135226. */
  135227. maxAcceleration: number;
  135228. /**
  135229. * Maximum allowed speed. [Limit: >= 0]
  135230. */
  135231. maxSpeed: number;
  135232. /**
  135233. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135234. */
  135235. collisionQueryRange: number;
  135236. /**
  135237. * The path visibility optimization range. [Limit: > 0]
  135238. */
  135239. pathOptimizationRange: number;
  135240. /**
  135241. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135242. */
  135243. separationWeight: number;
  135244. }
  135245. /**
  135246. * Configures the navigation mesh creation
  135247. */
  135248. export interface INavMeshParameters {
  135249. /**
  135250. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135251. */
  135252. cs: number;
  135253. /**
  135254. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135255. */
  135256. ch: number;
  135257. /**
  135258. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135259. */
  135260. walkableSlopeAngle: number;
  135261. /**
  135262. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135263. * be considered walkable. [Limit: >= 3] [Units: vx]
  135264. */
  135265. walkableHeight: number;
  135266. /**
  135267. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135268. */
  135269. walkableClimb: number;
  135270. /**
  135271. * The distance to erode/shrink the walkable area of the heightfield away from
  135272. * obstructions. [Limit: >=0] [Units: vx]
  135273. */
  135274. walkableRadius: number;
  135275. /**
  135276. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135277. */
  135278. maxEdgeLen: number;
  135279. /**
  135280. * The maximum distance a simplfied contour's border edges should deviate
  135281. * the original raw contour. [Limit: >=0] [Units: vx]
  135282. */
  135283. maxSimplificationError: number;
  135284. /**
  135285. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135286. */
  135287. minRegionArea: number;
  135288. /**
  135289. * Any regions with a span count smaller than this value will, if possible,
  135290. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135291. */
  135292. mergeRegionArea: number;
  135293. /**
  135294. * The maximum number of vertices allowed for polygons generated during the
  135295. * contour to polygon conversion process. [Limit: >= 3]
  135296. */
  135297. maxVertsPerPoly: number;
  135298. /**
  135299. * Sets the sampling distance to use when generating the detail mesh.
  135300. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135301. */
  135302. detailSampleDist: number;
  135303. /**
  135304. * The maximum distance the detail mesh surface should deviate from heightfield
  135305. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135306. */
  135307. detailSampleMaxError: number;
  135308. }
  135309. }
  135310. declare module BABYLON {
  135311. /**
  135312. * RecastJS navigation plugin
  135313. */
  135314. export class RecastJSPlugin implements INavigationEnginePlugin {
  135315. /**
  135316. * Reference to the Recast library
  135317. */
  135318. bjsRECAST: any;
  135319. /**
  135320. * plugin name
  135321. */
  135322. name: string;
  135323. /**
  135324. * the first navmesh created. We might extend this to support multiple navmeshes
  135325. */
  135326. navMesh: any;
  135327. /**
  135328. * Initializes the recastJS plugin
  135329. * @param recastInjection can be used to inject your own recast reference
  135330. */
  135331. constructor(recastInjection?: any);
  135332. /**
  135333. * Creates a navigation mesh
  135334. * @param meshes array of all the geometry used to compute the navigatio mesh
  135335. * @param parameters bunch of parameters used to filter geometry
  135336. */
  135337. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135338. /**
  135339. * Create a navigation mesh debug mesh
  135340. * @param scene is where the mesh will be added
  135341. * @returns debug display mesh
  135342. */
  135343. createDebugNavMesh(scene: Scene): Mesh;
  135344. /**
  135345. * Get a navigation mesh constrained position, closest to the parameter position
  135346. * @param position world position
  135347. * @returns the closest point to position constrained by the navigation mesh
  135348. */
  135349. getClosestPoint(position: Vector3): Vector3;
  135350. /**
  135351. * Get a navigation mesh constrained position, within a particular radius
  135352. * @param position world position
  135353. * @param maxRadius the maximum distance to the constrained world position
  135354. * @returns the closest point to position constrained by the navigation mesh
  135355. */
  135356. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135357. /**
  135358. * Compute the final position from a segment made of destination-position
  135359. * @param position world position
  135360. * @param destination world position
  135361. * @returns the resulting point along the navmesh
  135362. */
  135363. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135364. /**
  135365. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135366. * @param start world position
  135367. * @param end world position
  135368. * @returns array containing world position composing the path
  135369. */
  135370. computePath(start: Vector3, end: Vector3): Vector3[];
  135371. /**
  135372. * Create a new Crowd so you can add agents
  135373. * @param maxAgents the maximum agent count in the crowd
  135374. * @param maxAgentRadius the maximum radius an agent can have
  135375. * @param scene to attach the crowd to
  135376. * @returns the crowd you can add agents to
  135377. */
  135378. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135379. /**
  135380. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135381. * The queries will try to find a solution within those bounds
  135382. * default is (1,1,1)
  135383. * @param extent x,y,z value that define the extent around the queries point of reference
  135384. */
  135385. setDefaultQueryExtent(extent: Vector3): void;
  135386. /**
  135387. * Get the Bounding box extent specified by setDefaultQueryExtent
  135388. * @returns the box extent values
  135389. */
  135390. getDefaultQueryExtent(): Vector3;
  135391. /**
  135392. * Disposes
  135393. */
  135394. dispose(): void;
  135395. /**
  135396. * If this plugin is supported
  135397. * @returns true if plugin is supported
  135398. */
  135399. isSupported(): boolean;
  135400. }
  135401. /**
  135402. * Recast detour crowd implementation
  135403. */
  135404. export class RecastJSCrowd implements ICrowd {
  135405. /**
  135406. * Recast/detour plugin
  135407. */
  135408. bjsRECASTPlugin: RecastJSPlugin;
  135409. /**
  135410. * Link to the detour crowd
  135411. */
  135412. recastCrowd: any;
  135413. /**
  135414. * One transform per agent
  135415. */
  135416. transforms: TransformNode[];
  135417. /**
  135418. * All agents created
  135419. */
  135420. agents: number[];
  135421. /**
  135422. * Link to the scene is kept to unregister the crowd from the scene
  135423. */
  135424. private _scene;
  135425. /**
  135426. * Observer for crowd updates
  135427. */
  135428. private _onBeforeAnimationsObserver;
  135429. /**
  135430. * Constructor
  135431. * @param plugin recastJS plugin
  135432. * @param maxAgents the maximum agent count in the crowd
  135433. * @param maxAgentRadius the maximum radius an agent can have
  135434. * @param scene to attach the crowd to
  135435. * @returns the crowd you can add agents to
  135436. */
  135437. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135438. /**
  135439. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135440. * You can attach anything to that node. The node position is updated in the scene update tick.
  135441. * @param pos world position that will be constrained by the navigation mesh
  135442. * @param parameters agent parameters
  135443. * @param transform hooked to the agent that will be update by the scene
  135444. * @returns agent index
  135445. */
  135446. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135447. /**
  135448. * Returns the agent position in world space
  135449. * @param index agent index returned by addAgent
  135450. * @returns world space position
  135451. */
  135452. getAgentPosition(index: number): Vector3;
  135453. /**
  135454. * Returns the agent velocity in world space
  135455. * @param index agent index returned by addAgent
  135456. * @returns world space velocity
  135457. */
  135458. getAgentVelocity(index: number): Vector3;
  135459. /**
  135460. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135461. * @param index agent index returned by addAgent
  135462. * @param destination targeted world position
  135463. */
  135464. agentGoto(index: number, destination: Vector3): void;
  135465. /**
  135466. * Teleport the agent to a new position
  135467. * @param index agent index returned by addAgent
  135468. * @param destination targeted world position
  135469. */
  135470. agentTeleport(index: number, destination: Vector3): void;
  135471. /**
  135472. * Update agent parameters
  135473. * @param index agent index returned by addAgent
  135474. * @param parameters agent parameters
  135475. */
  135476. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135477. /**
  135478. * remove a particular agent previously created
  135479. * @param index agent index returned by addAgent
  135480. */
  135481. removeAgent(index: number): void;
  135482. /**
  135483. * get the list of all agents attached to this crowd
  135484. * @returns list of agent indices
  135485. */
  135486. getAgents(): number[];
  135487. /**
  135488. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135489. * @param deltaTime in seconds
  135490. */
  135491. update(deltaTime: number): void;
  135492. /**
  135493. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135494. * The queries will try to find a solution within those bounds
  135495. * default is (1,1,1)
  135496. * @param extent x,y,z value that define the extent around the queries point of reference
  135497. */
  135498. setDefaultQueryExtent(extent: Vector3): void;
  135499. /**
  135500. * Get the Bounding box extent specified by setDefaultQueryExtent
  135501. * @returns the box extent values
  135502. */
  135503. getDefaultQueryExtent(): Vector3;
  135504. /**
  135505. * Release all resources
  135506. */
  135507. dispose(): void;
  135508. }
  135509. }
  135510. declare module BABYLON {
  135511. /**
  135512. * Class used to enable access to IndexedDB
  135513. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135514. */
  135515. export class Database implements IOfflineProvider {
  135516. private _callbackManifestChecked;
  135517. private _currentSceneUrl;
  135518. private _db;
  135519. private _enableSceneOffline;
  135520. private _enableTexturesOffline;
  135521. private _manifestVersionFound;
  135522. private _mustUpdateRessources;
  135523. private _hasReachedQuota;
  135524. private _isSupported;
  135525. private _idbFactory;
  135526. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135527. private static IsUASupportingBlobStorage;
  135528. /**
  135529. * Gets a boolean indicating if Database storate is enabled (off by default)
  135530. */
  135531. static IDBStorageEnabled: boolean;
  135532. /**
  135533. * Gets a boolean indicating if scene must be saved in the database
  135534. */
  135535. get enableSceneOffline(): boolean;
  135536. /**
  135537. * Gets a boolean indicating if textures must be saved in the database
  135538. */
  135539. get enableTexturesOffline(): boolean;
  135540. /**
  135541. * Creates a new Database
  135542. * @param urlToScene defines the url to load the scene
  135543. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135544. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135545. */
  135546. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135547. private static _ParseURL;
  135548. private static _ReturnFullUrlLocation;
  135549. private _checkManifestFile;
  135550. /**
  135551. * Open the database and make it available
  135552. * @param successCallback defines the callback to call on success
  135553. * @param errorCallback defines the callback to call on error
  135554. */
  135555. open(successCallback: () => void, errorCallback: () => void): void;
  135556. /**
  135557. * Loads an image from the database
  135558. * @param url defines the url to load from
  135559. * @param image defines the target DOM image
  135560. */
  135561. loadImage(url: string, image: HTMLImageElement): void;
  135562. private _loadImageFromDBAsync;
  135563. private _saveImageIntoDBAsync;
  135564. private _checkVersionFromDB;
  135565. private _loadVersionFromDBAsync;
  135566. private _saveVersionIntoDBAsync;
  135567. /**
  135568. * Loads a file from database
  135569. * @param url defines the URL to load from
  135570. * @param sceneLoaded defines a callback to call on success
  135571. * @param progressCallBack defines a callback to call when progress changed
  135572. * @param errorCallback defines a callback to call on error
  135573. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135574. */
  135575. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135576. private _loadFileAsync;
  135577. private _saveFileAsync;
  135578. /**
  135579. * Validates if xhr data is correct
  135580. * @param xhr defines the request to validate
  135581. * @param dataType defines the expected data type
  135582. * @returns true if data is correct
  135583. */
  135584. private static _ValidateXHRData;
  135585. }
  135586. }
  135587. declare module BABYLON {
  135588. /** @hidden */
  135589. export var gpuUpdateParticlesPixelShader: {
  135590. name: string;
  135591. shader: string;
  135592. };
  135593. }
  135594. declare module BABYLON {
  135595. /** @hidden */
  135596. export var gpuUpdateParticlesVertexShader: {
  135597. name: string;
  135598. shader: string;
  135599. };
  135600. }
  135601. declare module BABYLON {
  135602. /** @hidden */
  135603. export var clipPlaneFragmentDeclaration2: {
  135604. name: string;
  135605. shader: string;
  135606. };
  135607. }
  135608. declare module BABYLON {
  135609. /** @hidden */
  135610. export var gpuRenderParticlesPixelShader: {
  135611. name: string;
  135612. shader: string;
  135613. };
  135614. }
  135615. declare module BABYLON {
  135616. /** @hidden */
  135617. export var clipPlaneVertexDeclaration2: {
  135618. name: string;
  135619. shader: string;
  135620. };
  135621. }
  135622. declare module BABYLON {
  135623. /** @hidden */
  135624. export var gpuRenderParticlesVertexShader: {
  135625. name: string;
  135626. shader: string;
  135627. };
  135628. }
  135629. declare module BABYLON {
  135630. /**
  135631. * This represents a GPU particle system in Babylon
  135632. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135633. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135634. */
  135635. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135636. /**
  135637. * The layer mask we are rendering the particles through.
  135638. */
  135639. layerMask: number;
  135640. private _capacity;
  135641. private _activeCount;
  135642. private _currentActiveCount;
  135643. private _accumulatedCount;
  135644. private _renderEffect;
  135645. private _updateEffect;
  135646. private _buffer0;
  135647. private _buffer1;
  135648. private _spriteBuffer;
  135649. private _updateVAO;
  135650. private _renderVAO;
  135651. private _targetIndex;
  135652. private _sourceBuffer;
  135653. private _targetBuffer;
  135654. private _engine;
  135655. private _currentRenderId;
  135656. private _started;
  135657. private _stopped;
  135658. private _timeDelta;
  135659. private _randomTexture;
  135660. private _randomTexture2;
  135661. private _attributesStrideSize;
  135662. private _updateEffectOptions;
  135663. private _randomTextureSize;
  135664. private _actualFrame;
  135665. private readonly _rawTextureWidth;
  135666. /**
  135667. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135668. */
  135669. static get IsSupported(): boolean;
  135670. /**
  135671. * An event triggered when the system is disposed.
  135672. */
  135673. onDisposeObservable: Observable<GPUParticleSystem>;
  135674. /**
  135675. * Gets the maximum number of particles active at the same time.
  135676. * @returns The max number of active particles.
  135677. */
  135678. getCapacity(): number;
  135679. /**
  135680. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135681. * to override the particles.
  135682. */
  135683. forceDepthWrite: boolean;
  135684. /**
  135685. * Gets or set the number of active particles
  135686. */
  135687. get activeParticleCount(): number;
  135688. set activeParticleCount(value: number);
  135689. private _preWarmDone;
  135690. /**
  135691. * Is this system ready to be used/rendered
  135692. * @return true if the system is ready
  135693. */
  135694. isReady(): boolean;
  135695. /**
  135696. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135697. * @returns True if it has been started, otherwise false.
  135698. */
  135699. isStarted(): boolean;
  135700. /**
  135701. * Starts the particle system and begins to emit
  135702. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135703. */
  135704. start(delay?: number): void;
  135705. /**
  135706. * Stops the particle system.
  135707. */
  135708. stop(): void;
  135709. /**
  135710. * Remove all active particles
  135711. */
  135712. reset(): void;
  135713. /**
  135714. * Returns the string "GPUParticleSystem"
  135715. * @returns a string containing the class name
  135716. */
  135717. getClassName(): string;
  135718. private _colorGradientsTexture;
  135719. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135720. /**
  135721. * Adds a new color gradient
  135722. * @param gradient defines the gradient to use (between 0 and 1)
  135723. * @param color1 defines the color to affect to the specified gradient
  135724. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135725. * @returns the current particle system
  135726. */
  135727. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135728. /**
  135729. * Remove a specific color gradient
  135730. * @param gradient defines the gradient to remove
  135731. * @returns the current particle system
  135732. */
  135733. removeColorGradient(gradient: number): GPUParticleSystem;
  135734. private _angularSpeedGradientsTexture;
  135735. private _sizeGradientsTexture;
  135736. private _velocityGradientsTexture;
  135737. private _limitVelocityGradientsTexture;
  135738. private _dragGradientsTexture;
  135739. private _addFactorGradient;
  135740. /**
  135741. * Adds a new size gradient
  135742. * @param gradient defines the gradient to use (between 0 and 1)
  135743. * @param factor defines the size factor to affect to the specified gradient
  135744. * @returns the current particle system
  135745. */
  135746. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135747. /**
  135748. * Remove a specific size gradient
  135749. * @param gradient defines the gradient to remove
  135750. * @returns the current particle system
  135751. */
  135752. removeSizeGradient(gradient: number): GPUParticleSystem;
  135753. /**
  135754. * Adds a new angular speed gradient
  135755. * @param gradient defines the gradient to use (between 0 and 1)
  135756. * @param factor defines the angular speed to affect to the specified gradient
  135757. * @returns the current particle system
  135758. */
  135759. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135760. /**
  135761. * Remove a specific angular speed gradient
  135762. * @param gradient defines the gradient to remove
  135763. * @returns the current particle system
  135764. */
  135765. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135766. /**
  135767. * Adds a new velocity gradient
  135768. * @param gradient defines the gradient to use (between 0 and 1)
  135769. * @param factor defines the velocity to affect to the specified gradient
  135770. * @returns the current particle system
  135771. */
  135772. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135773. /**
  135774. * Remove a specific velocity gradient
  135775. * @param gradient defines the gradient to remove
  135776. * @returns the current particle system
  135777. */
  135778. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135779. /**
  135780. * Adds a new limit velocity gradient
  135781. * @param gradient defines the gradient to use (between 0 and 1)
  135782. * @param factor defines the limit velocity value to affect to the specified gradient
  135783. * @returns the current particle system
  135784. */
  135785. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135786. /**
  135787. * Remove a specific limit velocity gradient
  135788. * @param gradient defines the gradient to remove
  135789. * @returns the current particle system
  135790. */
  135791. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135792. /**
  135793. * Adds a new drag gradient
  135794. * @param gradient defines the gradient to use (between 0 and 1)
  135795. * @param factor defines the drag value to affect to the specified gradient
  135796. * @returns the current particle system
  135797. */
  135798. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135799. /**
  135800. * Remove a specific drag gradient
  135801. * @param gradient defines the gradient to remove
  135802. * @returns the current particle system
  135803. */
  135804. removeDragGradient(gradient: number): GPUParticleSystem;
  135805. /**
  135806. * Not supported by GPUParticleSystem
  135807. * @param gradient defines the gradient to use (between 0 and 1)
  135808. * @param factor defines the emit rate value to affect to the specified gradient
  135809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135810. * @returns the current particle system
  135811. */
  135812. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135813. /**
  135814. * Not supported by GPUParticleSystem
  135815. * @param gradient defines the gradient to remove
  135816. * @returns the current particle system
  135817. */
  135818. removeEmitRateGradient(gradient: number): IParticleSystem;
  135819. /**
  135820. * Not supported by GPUParticleSystem
  135821. * @param gradient defines the gradient to use (between 0 and 1)
  135822. * @param factor defines the start size value to affect to the specified gradient
  135823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135824. * @returns the current particle system
  135825. */
  135826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135827. /**
  135828. * Not supported by GPUParticleSystem
  135829. * @param gradient defines the gradient to remove
  135830. * @returns the current particle system
  135831. */
  135832. removeStartSizeGradient(gradient: number): IParticleSystem;
  135833. /**
  135834. * Not supported by GPUParticleSystem
  135835. * @param gradient defines the gradient to use (between 0 and 1)
  135836. * @param min defines the color remap minimal range
  135837. * @param max defines the color remap maximal range
  135838. * @returns the current particle system
  135839. */
  135840. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135841. /**
  135842. * Not supported by GPUParticleSystem
  135843. * @param gradient defines the gradient to remove
  135844. * @returns the current particle system
  135845. */
  135846. removeColorRemapGradient(): IParticleSystem;
  135847. /**
  135848. * Not supported by GPUParticleSystem
  135849. * @param gradient defines the gradient to use (between 0 and 1)
  135850. * @param min defines the alpha remap minimal range
  135851. * @param max defines the alpha remap maximal range
  135852. * @returns the current particle system
  135853. */
  135854. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135855. /**
  135856. * Not supported by GPUParticleSystem
  135857. * @param gradient defines the gradient to remove
  135858. * @returns the current particle system
  135859. */
  135860. removeAlphaRemapGradient(): IParticleSystem;
  135861. /**
  135862. * Not supported by GPUParticleSystem
  135863. * @param gradient defines the gradient to use (between 0 and 1)
  135864. * @param color defines the color to affect to the specified gradient
  135865. * @returns the current particle system
  135866. */
  135867. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135868. /**
  135869. * Not supported by GPUParticleSystem
  135870. * @param gradient defines the gradient to remove
  135871. * @returns the current particle system
  135872. */
  135873. removeRampGradient(): IParticleSystem;
  135874. /**
  135875. * Not supported by GPUParticleSystem
  135876. * @returns the list of ramp gradients
  135877. */
  135878. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135879. /**
  135880. * Not supported by GPUParticleSystem
  135881. * Gets or sets a boolean indicating that ramp gradients must be used
  135882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135883. */
  135884. get useRampGradients(): boolean;
  135885. set useRampGradients(value: boolean);
  135886. /**
  135887. * Not supported by GPUParticleSystem
  135888. * @param gradient defines the gradient to use (between 0 and 1)
  135889. * @param factor defines the life time factor to affect to the specified gradient
  135890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135891. * @returns the current particle system
  135892. */
  135893. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135894. /**
  135895. * Not supported by GPUParticleSystem
  135896. * @param gradient defines the gradient to remove
  135897. * @returns the current particle system
  135898. */
  135899. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135900. /**
  135901. * Instantiates a GPU particle system.
  135902. * 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.
  135903. * @param name The name of the particle system
  135904. * @param options The options used to create the system
  135905. * @param scene The scene the particle system belongs to
  135906. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135907. */
  135908. constructor(name: string, options: Partial<{
  135909. capacity: number;
  135910. randomTextureSize: number;
  135911. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135912. protected _reset(): void;
  135913. private _createUpdateVAO;
  135914. private _createRenderVAO;
  135915. private _initialize;
  135916. /** @hidden */
  135917. _recreateUpdateEffect(): void;
  135918. /** @hidden */
  135919. _recreateRenderEffect(): void;
  135920. /**
  135921. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135922. * @param preWarm defines if we are in the pre-warmimg phase
  135923. */
  135924. animate(preWarm?: boolean): void;
  135925. private _createFactorGradientTexture;
  135926. private _createSizeGradientTexture;
  135927. private _createAngularSpeedGradientTexture;
  135928. private _createVelocityGradientTexture;
  135929. private _createLimitVelocityGradientTexture;
  135930. private _createDragGradientTexture;
  135931. private _createColorGradientTexture;
  135932. /**
  135933. * Renders the particle system in its current state
  135934. * @param preWarm defines if the system should only update the particles but not render them
  135935. * @returns the current number of particles
  135936. */
  135937. render(preWarm?: boolean): number;
  135938. /**
  135939. * Rebuilds the particle system
  135940. */
  135941. rebuild(): void;
  135942. private _releaseBuffers;
  135943. private _releaseVAOs;
  135944. /**
  135945. * Disposes the particle system and free the associated resources
  135946. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135947. */
  135948. dispose(disposeTexture?: boolean): void;
  135949. /**
  135950. * Clones the particle system.
  135951. * @param name The name of the cloned object
  135952. * @param newEmitter The new emitter to use
  135953. * @returns the cloned particle system
  135954. */
  135955. clone(name: string, newEmitter: any): GPUParticleSystem;
  135956. /**
  135957. * Serializes the particle system to a JSON object.
  135958. * @returns the JSON object
  135959. */
  135960. serialize(): any;
  135961. /**
  135962. * Parses a JSON object to create a GPU particle system.
  135963. * @param parsedParticleSystem The JSON object to parse
  135964. * @param scene The scene to create the particle system in
  135965. * @param rootUrl The root url to use to load external dependencies like texture
  135966. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135967. * @returns the parsed GPU particle system
  135968. */
  135969. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135970. }
  135971. }
  135972. declare module BABYLON {
  135973. /**
  135974. * Represents a set of particle systems working together to create a specific effect
  135975. */
  135976. export class ParticleSystemSet implements IDisposable {
  135977. /**
  135978. * Gets or sets base Assets URL
  135979. */
  135980. static BaseAssetsUrl: string;
  135981. private _emitterCreationOptions;
  135982. private _emitterNode;
  135983. /**
  135984. * Gets the particle system list
  135985. */
  135986. systems: IParticleSystem[];
  135987. /**
  135988. * Gets the emitter node used with this set
  135989. */
  135990. get emitterNode(): Nullable<TransformNode>;
  135991. /**
  135992. * Creates a new emitter mesh as a sphere
  135993. * @param options defines the options used to create the sphere
  135994. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135995. * @param scene defines the hosting scene
  135996. */
  135997. setEmitterAsSphere(options: {
  135998. diameter: number;
  135999. segments: number;
  136000. color: Color3;
  136001. }, renderingGroupId: number, scene: Scene): void;
  136002. /**
  136003. * Starts all particle systems of the set
  136004. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136005. */
  136006. start(emitter?: AbstractMesh): void;
  136007. /**
  136008. * Release all associated resources
  136009. */
  136010. dispose(): void;
  136011. /**
  136012. * Serialize the set into a JSON compatible object
  136013. * @returns a JSON compatible representation of the set
  136014. */
  136015. serialize(): any;
  136016. /**
  136017. * Parse a new ParticleSystemSet from a serialized source
  136018. * @param data defines a JSON compatible representation of the set
  136019. * @param scene defines the hosting scene
  136020. * @param gpu defines if we want GPU particles or CPU particles
  136021. * @returns a new ParticleSystemSet
  136022. */
  136023. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136024. }
  136025. }
  136026. declare module BABYLON {
  136027. /**
  136028. * This class is made for on one-liner static method to help creating particle system set.
  136029. */
  136030. export class ParticleHelper {
  136031. /**
  136032. * Gets or sets base Assets URL
  136033. */
  136034. static BaseAssetsUrl: string;
  136035. /**
  136036. * Create a default particle system that you can tweak
  136037. * @param emitter defines the emitter to use
  136038. * @param capacity defines the system capacity (default is 500 particles)
  136039. * @param scene defines the hosting scene
  136040. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136041. * @returns the new Particle system
  136042. */
  136043. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136044. /**
  136045. * This is the main static method (one-liner) of this helper to create different particle systems
  136046. * @param type This string represents the type to the particle system to create
  136047. * @param scene The scene where the particle system should live
  136048. * @param gpu If the system will use gpu
  136049. * @returns the ParticleSystemSet created
  136050. */
  136051. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136052. /**
  136053. * Static function used to export a particle system to a ParticleSystemSet variable.
  136054. * Please note that the emitter shape is not exported
  136055. * @param systems defines the particle systems to export
  136056. * @returns the created particle system set
  136057. */
  136058. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136059. }
  136060. }
  136061. declare module BABYLON {
  136062. interface Engine {
  136063. /**
  136064. * Create an effect to use with particle systems.
  136065. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136066. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136067. * @param uniformsNames defines a list of attribute names
  136068. * @param samplers defines an array of string used to represent textures
  136069. * @param defines defines the string containing the defines to use to compile the shaders
  136070. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136071. * @param onCompiled defines a function to call when the effect creation is successful
  136072. * @param onError defines a function to call when the effect creation has failed
  136073. * @returns the new Effect
  136074. */
  136075. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136076. }
  136077. interface Mesh {
  136078. /**
  136079. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136080. * @returns an array of IParticleSystem
  136081. */
  136082. getEmittedParticleSystems(): IParticleSystem[];
  136083. /**
  136084. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136085. * @returns an array of IParticleSystem
  136086. */
  136087. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136088. }
  136089. /**
  136090. * @hidden
  136091. */
  136092. export var _IDoNeedToBeInTheBuild: number;
  136093. }
  136094. declare module BABYLON {
  136095. /** Defines the 4 color options */
  136096. export enum PointColor {
  136097. /** color value */
  136098. Color = 2,
  136099. /** uv value */
  136100. UV = 1,
  136101. /** random value */
  136102. Random = 0,
  136103. /** stated value */
  136104. Stated = 3
  136105. }
  136106. /**
  136107. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136108. * 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.
  136109. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136110. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136111. *
  136112. * Full documentation here : TO BE ENTERED
  136113. */
  136114. export class PointsCloudSystem implements IDisposable {
  136115. /**
  136116. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136117. * Example : var p = SPS.particles[i];
  136118. */
  136119. particles: CloudPoint[];
  136120. /**
  136121. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136122. */
  136123. nbParticles: number;
  136124. /**
  136125. * This a counter for your own usage. It's not set by any SPS functions.
  136126. */
  136127. counter: number;
  136128. /**
  136129. * The PCS name. This name is also given to the underlying mesh.
  136130. */
  136131. name: string;
  136132. /**
  136133. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136134. */
  136135. mesh: Mesh;
  136136. /**
  136137. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136138. * Please read :
  136139. */
  136140. vars: any;
  136141. /**
  136142. * @hidden
  136143. */
  136144. _size: number;
  136145. private _scene;
  136146. private _promises;
  136147. private _positions;
  136148. private _indices;
  136149. private _normals;
  136150. private _colors;
  136151. private _uvs;
  136152. private _indices32;
  136153. private _positions32;
  136154. private _colors32;
  136155. private _uvs32;
  136156. private _updatable;
  136157. private _isVisibilityBoxLocked;
  136158. private _alwaysVisible;
  136159. private _groups;
  136160. private _groupCounter;
  136161. private _computeParticleColor;
  136162. private _computeParticleTexture;
  136163. private _computeParticleRotation;
  136164. private _computeBoundingBox;
  136165. private _isReady;
  136166. /**
  136167. * Creates a PCS (Points Cloud System) object
  136168. * @param name (String) is the PCS name, this will be the underlying mesh name
  136169. * @param pointSize (number) is the size for each point
  136170. * @param scene (Scene) is the scene in which the PCS is added
  136171. * @param options defines the options of the PCS e.g.
  136172. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136173. */
  136174. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136175. updatable?: boolean;
  136176. });
  136177. /**
  136178. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136179. * If no points were added to the PCS, the returned mesh is just a single point.
  136180. * @returns a promise for the created mesh
  136181. */
  136182. buildMeshAsync(): Promise<Mesh>;
  136183. /**
  136184. * @hidden
  136185. */
  136186. private _buildMesh;
  136187. private _addParticle;
  136188. private _randomUnitVector;
  136189. private _getColorIndicesForCoord;
  136190. private _setPointsColorOrUV;
  136191. private _colorFromTexture;
  136192. private _calculateDensity;
  136193. /**
  136194. * Adds points to the PCS in random positions within a unit sphere
  136195. * @param nb (positive integer) the number of particles to be created from this model
  136196. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136197. * @returns the number of groups in the system
  136198. */
  136199. addPoints(nb: number, pointFunction?: any): number;
  136200. /**
  136201. * Adds points to the PCS from the surface of the model shape
  136202. * @param mesh is any Mesh object that will be used as a surface model for the points
  136203. * @param nb (positive integer) the number of particles to be created from this model
  136204. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136205. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136206. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136207. * @returns the number of groups in the system
  136208. */
  136209. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136210. /**
  136211. * Adds points to the PCS inside the model shape
  136212. * @param mesh is any Mesh object that will be used as a surface model for the points
  136213. * @param nb (positive integer) the number of particles to be created from this model
  136214. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136215. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136216. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136217. * @returns the number of groups in the system
  136218. */
  136219. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136220. /**
  136221. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136222. * This method calls `updateParticle()` for each particle of the SPS.
  136223. * For an animated SPS, it is usually called within the render loop.
  136224. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136225. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136226. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136227. * @returns the PCS.
  136228. */
  136229. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136230. /**
  136231. * Disposes the PCS.
  136232. */
  136233. dispose(): void;
  136234. /**
  136235. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136236. * doc :
  136237. * @returns the PCS.
  136238. */
  136239. refreshVisibleSize(): PointsCloudSystem;
  136240. /**
  136241. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136242. * @param size the size (float) of the visibility box
  136243. * note : this doesn't lock the PCS mesh bounding box.
  136244. * doc :
  136245. */
  136246. setVisibilityBox(size: number): void;
  136247. /**
  136248. * Gets whether the PCS is always visible or not
  136249. * doc :
  136250. */
  136251. get isAlwaysVisible(): boolean;
  136252. /**
  136253. * Sets the PCS as always visible or not
  136254. * doc :
  136255. */
  136256. set isAlwaysVisible(val: boolean);
  136257. /**
  136258. * Tells to `setParticles()` to compute the particle rotations or not
  136259. * Default value : false. The PCS is faster when it's set to false
  136260. * Note : particle rotations are only applied to parent particles
  136261. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136262. */
  136263. set computeParticleRotation(val: boolean);
  136264. /**
  136265. * Tells to `setParticles()` to compute the particle colors or not.
  136266. * Default value : true. The PCS is faster when it's set to false.
  136267. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136268. */
  136269. set computeParticleColor(val: boolean);
  136270. set computeParticleTexture(val: boolean);
  136271. /**
  136272. * Gets if `setParticles()` computes the particle colors or not.
  136273. * Default value : false. The PCS is faster when it's set to false.
  136274. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136275. */
  136276. get computeParticleColor(): boolean;
  136277. /**
  136278. * Gets if `setParticles()` computes the particle textures or not.
  136279. * Default value : false. The PCS is faster when it's set to false.
  136280. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136281. */
  136282. get computeParticleTexture(): boolean;
  136283. /**
  136284. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136285. */
  136286. set computeBoundingBox(val: boolean);
  136287. /**
  136288. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136289. */
  136290. get computeBoundingBox(): boolean;
  136291. /**
  136292. * This function does nothing. It may be overwritten to set all the particle first values.
  136293. * The PCS doesn't call this function, you may have to call it by your own.
  136294. * doc :
  136295. */
  136296. initParticles(): void;
  136297. /**
  136298. * This function does nothing. It may be overwritten to recycle a particle
  136299. * The PCS doesn't call this function, you can to call it
  136300. * doc :
  136301. * @param particle The particle to recycle
  136302. * @returns the recycled particle
  136303. */
  136304. recycleParticle(particle: CloudPoint): CloudPoint;
  136305. /**
  136306. * Updates a particle : this function should be overwritten by the user.
  136307. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136308. * doc :
  136309. * @example : just set a particle position or velocity and recycle conditions
  136310. * @param particle The particle to update
  136311. * @returns the updated particle
  136312. */
  136313. updateParticle(particle: CloudPoint): CloudPoint;
  136314. /**
  136315. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136322. /**
  136323. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136324. * This will be passed three parameters.
  136325. * This does nothing and may be overwritten by the user.
  136326. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136327. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136328. * @param update the boolean update value actually passed to setParticles()
  136329. */
  136330. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136331. }
  136332. }
  136333. declare module BABYLON {
  136334. /**
  136335. * Represents one particle of a points cloud system.
  136336. */
  136337. export class CloudPoint {
  136338. /**
  136339. * particle global index
  136340. */
  136341. idx: number;
  136342. /**
  136343. * The color of the particle
  136344. */
  136345. color: Nullable<Color4>;
  136346. /**
  136347. * The world space position of the particle.
  136348. */
  136349. position: Vector3;
  136350. /**
  136351. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136352. */
  136353. rotation: Vector3;
  136354. /**
  136355. * The world space rotation quaternion of the particle.
  136356. */
  136357. rotationQuaternion: Nullable<Quaternion>;
  136358. /**
  136359. * The uv of the particle.
  136360. */
  136361. uv: Nullable<Vector2>;
  136362. /**
  136363. * The current speed of the particle.
  136364. */
  136365. velocity: Vector3;
  136366. /**
  136367. * The pivot point in the particle local space.
  136368. */
  136369. pivot: Vector3;
  136370. /**
  136371. * Must the particle be translated from its pivot point in its local space ?
  136372. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136373. * Default : false
  136374. */
  136375. translateFromPivot: boolean;
  136376. /**
  136377. * Index of this particle in the global "positions" array (Internal use)
  136378. * @hidden
  136379. */
  136380. _pos: number;
  136381. /**
  136382. * @hidden Index of this particle in the global "indices" array (Internal use)
  136383. */
  136384. _ind: number;
  136385. /**
  136386. * Group this particle belongs to
  136387. */
  136388. _group: PointsGroup;
  136389. /**
  136390. * Group id of this particle
  136391. */
  136392. groupId: number;
  136393. /**
  136394. * Index of the particle in its group id (Internal use)
  136395. */
  136396. idxInGroup: number;
  136397. /**
  136398. * @hidden Particle BoundingInfo object (Internal use)
  136399. */
  136400. _boundingInfo: BoundingInfo;
  136401. /**
  136402. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136403. */
  136404. _pcs: PointsCloudSystem;
  136405. /**
  136406. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136407. */
  136408. _stillInvisible: boolean;
  136409. /**
  136410. * @hidden Last computed particle rotation matrix
  136411. */
  136412. _rotationMatrix: number[];
  136413. /**
  136414. * Parent particle Id, if any.
  136415. * Default null.
  136416. */
  136417. parentId: Nullable<number>;
  136418. /**
  136419. * @hidden Internal global position in the PCS.
  136420. */
  136421. _globalPosition: Vector3;
  136422. /**
  136423. * Creates a Point Cloud object.
  136424. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136425. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136426. * @param group (PointsGroup) is the group the particle belongs to
  136427. * @param groupId (integer) is the group identifier in the PCS.
  136428. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136429. * @param pcs defines the PCS it is associated to
  136430. */
  136431. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136432. /**
  136433. * get point size
  136434. */
  136435. get size(): Vector3;
  136436. /**
  136437. * Set point size
  136438. */
  136439. set size(scale: Vector3);
  136440. /**
  136441. * Legacy support, changed quaternion to rotationQuaternion
  136442. */
  136443. get quaternion(): Nullable<Quaternion>;
  136444. /**
  136445. * Legacy support, changed quaternion to rotationQuaternion
  136446. */
  136447. set quaternion(q: Nullable<Quaternion>);
  136448. /**
  136449. * Returns a boolean. True if the particle intersects a mesh, else false
  136450. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136451. * @param target is the object (point or mesh) what the intersection is computed against
  136452. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136453. * @returns true if it intersects
  136454. */
  136455. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136456. /**
  136457. * get the rotation matrix of the particle
  136458. * @hidden
  136459. */
  136460. getRotationMatrix(m: Matrix): void;
  136461. }
  136462. /**
  136463. * Represents a group of points in a points cloud system
  136464. * * PCS internal tool, don't use it manually.
  136465. */
  136466. export class PointsGroup {
  136467. /**
  136468. * The group id
  136469. * @hidden
  136470. */
  136471. groupID: number;
  136472. /**
  136473. * image data for group (internal use)
  136474. * @hidden
  136475. */
  136476. _groupImageData: Nullable<ArrayBufferView>;
  136477. /**
  136478. * Image Width (internal use)
  136479. * @hidden
  136480. */
  136481. _groupImgWidth: number;
  136482. /**
  136483. * Image Height (internal use)
  136484. * @hidden
  136485. */
  136486. _groupImgHeight: number;
  136487. /**
  136488. * Custom position function (internal use)
  136489. * @hidden
  136490. */
  136491. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136492. /**
  136493. * density per facet for surface points
  136494. * @hidden
  136495. */
  136496. _groupDensity: number[];
  136497. /**
  136498. * Only when points are colored by texture carries pointer to texture list array
  136499. * @hidden
  136500. */
  136501. _textureNb: number;
  136502. /**
  136503. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136504. * PCS internal tool, don't use it manually.
  136505. * @hidden
  136506. */
  136507. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136508. }
  136509. }
  136510. declare module BABYLON {
  136511. interface Scene {
  136512. /** @hidden (Backing field) */
  136513. _physicsEngine: Nullable<IPhysicsEngine>;
  136514. /** @hidden */
  136515. _physicsTimeAccumulator: number;
  136516. /**
  136517. * Gets the current physics engine
  136518. * @returns a IPhysicsEngine or null if none attached
  136519. */
  136520. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136521. /**
  136522. * Enables physics to the current scene
  136523. * @param gravity defines the scene's gravity for the physics engine
  136524. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136525. * @return a boolean indicating if the physics engine was initialized
  136526. */
  136527. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136528. /**
  136529. * Disables and disposes the physics engine associated with the scene
  136530. */
  136531. disablePhysicsEngine(): void;
  136532. /**
  136533. * Gets a boolean indicating if there is an active physics engine
  136534. * @returns a boolean indicating if there is an active physics engine
  136535. */
  136536. isPhysicsEnabled(): boolean;
  136537. /**
  136538. * Deletes a physics compound impostor
  136539. * @param compound defines the compound to delete
  136540. */
  136541. deleteCompoundImpostor(compound: any): void;
  136542. /**
  136543. * An event triggered when physic simulation is about to be run
  136544. */
  136545. onBeforePhysicsObservable: Observable<Scene>;
  136546. /**
  136547. * An event triggered when physic simulation has been done
  136548. */
  136549. onAfterPhysicsObservable: Observable<Scene>;
  136550. }
  136551. interface AbstractMesh {
  136552. /** @hidden */
  136553. _physicsImpostor: Nullable<PhysicsImpostor>;
  136554. /**
  136555. * Gets or sets impostor used for physic simulation
  136556. * @see http://doc.babylonjs.com/features/physics_engine
  136557. */
  136558. physicsImpostor: Nullable<PhysicsImpostor>;
  136559. /**
  136560. * Gets the current physics impostor
  136561. * @see http://doc.babylonjs.com/features/physics_engine
  136562. * @returns a physics impostor or null
  136563. */
  136564. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136565. /** Apply a physic impulse to the mesh
  136566. * @param force defines the force to apply
  136567. * @param contactPoint defines where to apply the force
  136568. * @returns the current mesh
  136569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136570. */
  136571. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136572. /**
  136573. * Creates a physic joint between two meshes
  136574. * @param otherMesh defines the other mesh to use
  136575. * @param pivot1 defines the pivot to use on this mesh
  136576. * @param pivot2 defines the pivot to use on the other mesh
  136577. * @param options defines additional options (can be plugin dependent)
  136578. * @returns the current mesh
  136579. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136580. */
  136581. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136582. /** @hidden */
  136583. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136584. }
  136585. /**
  136586. * Defines the physics engine scene component responsible to manage a physics engine
  136587. */
  136588. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136589. /**
  136590. * The component name helpful to identify the component in the list of scene components.
  136591. */
  136592. readonly name: string;
  136593. /**
  136594. * The scene the component belongs to.
  136595. */
  136596. scene: Scene;
  136597. /**
  136598. * Creates a new instance of the component for the given scene
  136599. * @param scene Defines the scene to register the component in
  136600. */
  136601. constructor(scene: Scene);
  136602. /**
  136603. * Registers the component in a given scene
  136604. */
  136605. register(): void;
  136606. /**
  136607. * Rebuilds the elements related to this component in case of
  136608. * context lost for instance.
  136609. */
  136610. rebuild(): void;
  136611. /**
  136612. * Disposes the component and the associated ressources
  136613. */
  136614. dispose(): void;
  136615. }
  136616. }
  136617. declare module BABYLON {
  136618. /**
  136619. * A helper for physics simulations
  136620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136621. */
  136622. export class PhysicsHelper {
  136623. private _scene;
  136624. private _physicsEngine;
  136625. /**
  136626. * Initializes the Physics helper
  136627. * @param scene Babylon.js scene
  136628. */
  136629. constructor(scene: Scene);
  136630. /**
  136631. * Applies a radial explosion impulse
  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. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136639. /**
  136640. * Applies a radial explosion force
  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 radial explosion event, or null
  136646. */
  136647. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136648. /**
  136649. * Creates a gravitational field
  136650. * @param origin the origin of the explosion
  136651. * @param radiusOrEventOptions the radius or the options of radial explosion
  136652. * @param strength the explosion strength
  136653. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136654. * @returns A physics gravitational field event, or null
  136655. */
  136656. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136657. /**
  136658. * Creates a physics updraft event
  136659. * @param origin the origin of the updraft
  136660. * @param radiusOrEventOptions the radius or the options of the updraft
  136661. * @param strength the strength of the updraft
  136662. * @param height the height of the updraft
  136663. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136664. * @returns A physics updraft event, or null
  136665. */
  136666. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136667. /**
  136668. * Creates a physics vortex event
  136669. * @param origin the of the vortex
  136670. * @param radiusOrEventOptions the radius or the options of the vortex
  136671. * @param strength the strength of the vortex
  136672. * @param height the height of the vortex
  136673. * @returns a Physics vortex event, or null
  136674. * A physics vortex event or null
  136675. */
  136676. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136677. }
  136678. /**
  136679. * Represents a physics radial explosion event
  136680. */
  136681. class PhysicsRadialExplosionEvent {
  136682. private _scene;
  136683. private _options;
  136684. private _sphere;
  136685. private _dataFetched;
  136686. /**
  136687. * Initializes a radial explosioin event
  136688. * @param _scene BabylonJS scene
  136689. * @param _options The options for the vortex event
  136690. */
  136691. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136692. /**
  136693. * Returns the data related to the radial explosion event (sphere).
  136694. * @returns The radial explosion event data
  136695. */
  136696. getData(): PhysicsRadialExplosionEventData;
  136697. /**
  136698. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136699. * @param impostor A physics imposter
  136700. * @param origin the origin of the explosion
  136701. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136702. */
  136703. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136704. /**
  136705. * Triggers affecterd impostors callbacks
  136706. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136707. */
  136708. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136709. /**
  136710. * Disposes the sphere.
  136711. * @param force Specifies if the sphere should be disposed by force
  136712. */
  136713. dispose(force?: boolean): void;
  136714. /*** Helpers ***/
  136715. private _prepareSphere;
  136716. private _intersectsWithSphere;
  136717. }
  136718. /**
  136719. * Represents a gravitational field event
  136720. */
  136721. class PhysicsGravitationalFieldEvent {
  136722. private _physicsHelper;
  136723. private _scene;
  136724. private _origin;
  136725. private _options;
  136726. private _tickCallback;
  136727. private _sphere;
  136728. private _dataFetched;
  136729. /**
  136730. * Initializes the physics gravitational field event
  136731. * @param _physicsHelper A physics helper
  136732. * @param _scene BabylonJS scene
  136733. * @param _origin The origin position of the gravitational field event
  136734. * @param _options The options for the vortex event
  136735. */
  136736. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136737. /**
  136738. * Returns the data related to the gravitational field event (sphere).
  136739. * @returns A gravitational field event
  136740. */
  136741. getData(): PhysicsGravitationalFieldEventData;
  136742. /**
  136743. * Enables the gravitational field.
  136744. */
  136745. enable(): void;
  136746. /**
  136747. * Disables the gravitational field.
  136748. */
  136749. disable(): void;
  136750. /**
  136751. * Disposes the sphere.
  136752. * @param force The force to dispose from the gravitational field event
  136753. */
  136754. dispose(force?: boolean): void;
  136755. private _tick;
  136756. }
  136757. /**
  136758. * Represents a physics updraft event
  136759. */
  136760. class PhysicsUpdraftEvent {
  136761. private _scene;
  136762. private _origin;
  136763. private _options;
  136764. private _physicsEngine;
  136765. private _originTop;
  136766. private _originDirection;
  136767. private _tickCallback;
  136768. private _cylinder;
  136769. private _cylinderPosition;
  136770. private _dataFetched;
  136771. /**
  136772. * Initializes the physics updraft event
  136773. * @param _scene BabylonJS scene
  136774. * @param _origin The origin position of the updraft
  136775. * @param _options The options for the updraft event
  136776. */
  136777. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136778. /**
  136779. * Returns the data related to the updraft event (cylinder).
  136780. * @returns A physics updraft event
  136781. */
  136782. getData(): PhysicsUpdraftEventData;
  136783. /**
  136784. * Enables the updraft.
  136785. */
  136786. enable(): void;
  136787. /**
  136788. * Disables the updraft.
  136789. */
  136790. disable(): void;
  136791. /**
  136792. * Disposes the cylinder.
  136793. * @param force Specifies if the updraft should be disposed by force
  136794. */
  136795. dispose(force?: boolean): void;
  136796. private getImpostorHitData;
  136797. private _tick;
  136798. /*** Helpers ***/
  136799. private _prepareCylinder;
  136800. private _intersectsWithCylinder;
  136801. }
  136802. /**
  136803. * Represents a physics vortex event
  136804. */
  136805. class PhysicsVortexEvent {
  136806. private _scene;
  136807. private _origin;
  136808. private _options;
  136809. private _physicsEngine;
  136810. private _originTop;
  136811. private _tickCallback;
  136812. private _cylinder;
  136813. private _cylinderPosition;
  136814. private _dataFetched;
  136815. /**
  136816. * Initializes the physics vortex event
  136817. * @param _scene The BabylonJS scene
  136818. * @param _origin The origin position of the vortex
  136819. * @param _options The options for the vortex event
  136820. */
  136821. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136822. /**
  136823. * Returns the data related to the vortex event (cylinder).
  136824. * @returns The physics vortex event data
  136825. */
  136826. getData(): PhysicsVortexEventData;
  136827. /**
  136828. * Enables the vortex.
  136829. */
  136830. enable(): void;
  136831. /**
  136832. * Disables the cortex.
  136833. */
  136834. disable(): void;
  136835. /**
  136836. * Disposes the sphere.
  136837. * @param force
  136838. */
  136839. dispose(force?: boolean): void;
  136840. private getImpostorHitData;
  136841. private _tick;
  136842. /*** Helpers ***/
  136843. private _prepareCylinder;
  136844. private _intersectsWithCylinder;
  136845. }
  136846. /**
  136847. * Options fot the radial explosion event
  136848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136849. */
  136850. export class PhysicsRadialExplosionEventOptions {
  136851. /**
  136852. * The radius of the sphere for the radial explosion.
  136853. */
  136854. radius: number;
  136855. /**
  136856. * The strenth of the explosion.
  136857. */
  136858. strength: number;
  136859. /**
  136860. * The strenght of the force in correspondence to the distance of the affected object
  136861. */
  136862. falloff: PhysicsRadialImpulseFalloff;
  136863. /**
  136864. * Sphere options for the radial explosion.
  136865. */
  136866. sphere: {
  136867. segments: number;
  136868. diameter: number;
  136869. };
  136870. /**
  136871. * Sphere options for the radial explosion.
  136872. */
  136873. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136874. }
  136875. /**
  136876. * Options fot the updraft event
  136877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136878. */
  136879. export class PhysicsUpdraftEventOptions {
  136880. /**
  136881. * The radius of the cylinder for the vortex
  136882. */
  136883. radius: number;
  136884. /**
  136885. * The strenth of the updraft.
  136886. */
  136887. strength: number;
  136888. /**
  136889. * The height of the cylinder for the updraft.
  136890. */
  136891. height: number;
  136892. /**
  136893. * The mode for the the updraft.
  136894. */
  136895. updraftMode: PhysicsUpdraftMode;
  136896. }
  136897. /**
  136898. * Options fot the vortex event
  136899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136900. */
  136901. export class PhysicsVortexEventOptions {
  136902. /**
  136903. * The radius of the cylinder for the vortex
  136904. */
  136905. radius: number;
  136906. /**
  136907. * The strenth of the vortex.
  136908. */
  136909. strength: number;
  136910. /**
  136911. * The height of the cylinder for the vortex.
  136912. */
  136913. height: number;
  136914. /**
  136915. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136916. */
  136917. centripetalForceThreshold: number;
  136918. /**
  136919. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136920. */
  136921. centripetalForceMultiplier: number;
  136922. /**
  136923. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136924. */
  136925. centrifugalForceMultiplier: number;
  136926. /**
  136927. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136928. */
  136929. updraftForceMultiplier: number;
  136930. }
  136931. /**
  136932. * The strenght of the force in correspondence to the distance of the affected object
  136933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136934. */
  136935. export enum PhysicsRadialImpulseFalloff {
  136936. /** Defines that impulse is constant in strength across it's whole radius */
  136937. Constant = 0,
  136938. /** Defines that impulse gets weaker if it's further from the origin */
  136939. Linear = 1
  136940. }
  136941. /**
  136942. * The strength of the force in correspondence to the distance of the affected object
  136943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136944. */
  136945. export enum PhysicsUpdraftMode {
  136946. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136947. Center = 0,
  136948. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136949. Perpendicular = 1
  136950. }
  136951. /**
  136952. * Interface for a physics hit data
  136953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136954. */
  136955. export interface PhysicsHitData {
  136956. /**
  136957. * The force applied at the contact point
  136958. */
  136959. force: Vector3;
  136960. /**
  136961. * The contact point
  136962. */
  136963. contactPoint: Vector3;
  136964. /**
  136965. * The distance from the origin to the contact point
  136966. */
  136967. distanceFromOrigin: number;
  136968. }
  136969. /**
  136970. * Interface for radial explosion event data
  136971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136972. */
  136973. export interface PhysicsRadialExplosionEventData {
  136974. /**
  136975. * A sphere used for the radial explosion event
  136976. */
  136977. sphere: Mesh;
  136978. }
  136979. /**
  136980. * Interface for gravitational field event data
  136981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136982. */
  136983. export interface PhysicsGravitationalFieldEventData {
  136984. /**
  136985. * A sphere mesh used for the gravitational field event
  136986. */
  136987. sphere: Mesh;
  136988. }
  136989. /**
  136990. * Interface for updraft event data
  136991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136992. */
  136993. export interface PhysicsUpdraftEventData {
  136994. /**
  136995. * A cylinder used for the updraft event
  136996. */
  136997. cylinder: Mesh;
  136998. }
  136999. /**
  137000. * Interface for vortex event data
  137001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137002. */
  137003. export interface PhysicsVortexEventData {
  137004. /**
  137005. * A cylinder used for the vortex event
  137006. */
  137007. cylinder: Mesh;
  137008. }
  137009. /**
  137010. * Interface for an affected physics impostor
  137011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137012. */
  137013. export interface PhysicsAffectedImpostorWithData {
  137014. /**
  137015. * The impostor affected by the effect
  137016. */
  137017. impostor: PhysicsImpostor;
  137018. /**
  137019. * The data about the hit/horce from the explosion
  137020. */
  137021. hitData: PhysicsHitData;
  137022. }
  137023. }
  137024. declare module BABYLON {
  137025. /** @hidden */
  137026. export var blackAndWhitePixelShader: {
  137027. name: string;
  137028. shader: string;
  137029. };
  137030. }
  137031. declare module BABYLON {
  137032. /**
  137033. * Post process used to render in black and white
  137034. */
  137035. export class BlackAndWhitePostProcess extends PostProcess {
  137036. /**
  137037. * Linear about to convert he result to black and white (default: 1)
  137038. */
  137039. degree: number;
  137040. /**
  137041. * Creates a black and white post process
  137042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137043. * @param name The name of the effect.
  137044. * @param options The required width/height ratio to downsize to before computing the render pass.
  137045. * @param camera The camera to apply the render pass to.
  137046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137047. * @param engine The engine which the post process will be applied. (default: current engine)
  137048. * @param reusable If the post process can be reused on the same frame. (default: false)
  137049. */
  137050. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137051. }
  137052. }
  137053. declare module BABYLON {
  137054. /**
  137055. * This represents a set of one or more post processes in Babylon.
  137056. * A post process can be used to apply a shader to a texture after it is rendered.
  137057. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137058. */
  137059. export class PostProcessRenderEffect {
  137060. private _postProcesses;
  137061. private _getPostProcesses;
  137062. private _singleInstance;
  137063. private _cameras;
  137064. private _indicesForCamera;
  137065. /**
  137066. * Name of the effect
  137067. * @hidden
  137068. */
  137069. _name: string;
  137070. /**
  137071. * Instantiates a post process render effect.
  137072. * A post process can be used to apply a shader to a texture after it is rendered.
  137073. * @param engine The engine the effect is tied to
  137074. * @param name The name of the effect
  137075. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137076. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137077. */
  137078. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137079. /**
  137080. * Checks if all the post processes in the effect are supported.
  137081. */
  137082. get isSupported(): boolean;
  137083. /**
  137084. * Updates the current state of the effect
  137085. * @hidden
  137086. */
  137087. _update(): void;
  137088. /**
  137089. * Attaches the effect on cameras
  137090. * @param cameras The camera to attach to.
  137091. * @hidden
  137092. */
  137093. _attachCameras(cameras: Camera): void;
  137094. /**
  137095. * Attaches the effect on cameras
  137096. * @param cameras The camera to attach to.
  137097. * @hidden
  137098. */
  137099. _attachCameras(cameras: Camera[]): void;
  137100. /**
  137101. * Detaches the effect on cameras
  137102. * @param cameras The camera to detatch from.
  137103. * @hidden
  137104. */
  137105. _detachCameras(cameras: Camera): void;
  137106. /**
  137107. * Detatches the effect on cameras
  137108. * @param cameras The camera to detatch from.
  137109. * @hidden
  137110. */
  137111. _detachCameras(cameras: Camera[]): void;
  137112. /**
  137113. * Enables the effect on given cameras
  137114. * @param cameras The camera to enable.
  137115. * @hidden
  137116. */
  137117. _enable(cameras: Camera): void;
  137118. /**
  137119. * Enables the effect on given cameras
  137120. * @param cameras The camera to enable.
  137121. * @hidden
  137122. */
  137123. _enable(cameras: Nullable<Camera[]>): void;
  137124. /**
  137125. * Disables the effect on the given cameras
  137126. * @param cameras The camera to disable.
  137127. * @hidden
  137128. */
  137129. _disable(cameras: Camera): void;
  137130. /**
  137131. * Disables the effect on the given cameras
  137132. * @param cameras The camera to disable.
  137133. * @hidden
  137134. */
  137135. _disable(cameras: Nullable<Camera[]>): void;
  137136. /**
  137137. * Gets a list of the post processes contained in the effect.
  137138. * @param camera The camera to get the post processes on.
  137139. * @returns The list of the post processes in the effect.
  137140. */
  137141. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137142. }
  137143. }
  137144. declare module BABYLON {
  137145. /** @hidden */
  137146. export var extractHighlightsPixelShader: {
  137147. name: string;
  137148. shader: string;
  137149. };
  137150. }
  137151. declare module BABYLON {
  137152. /**
  137153. * 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.
  137154. */
  137155. export class ExtractHighlightsPostProcess extends PostProcess {
  137156. /**
  137157. * The luminance threshold, pixels below this value will be set to black.
  137158. */
  137159. threshold: number;
  137160. /** @hidden */
  137161. _exposure: number;
  137162. /**
  137163. * Post process which has the input texture to be used when performing highlight extraction
  137164. * @hidden
  137165. */
  137166. _inputPostProcess: Nullable<PostProcess>;
  137167. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137168. }
  137169. }
  137170. declare module BABYLON {
  137171. /** @hidden */
  137172. export var bloomMergePixelShader: {
  137173. name: string;
  137174. shader: string;
  137175. };
  137176. }
  137177. declare module BABYLON {
  137178. /**
  137179. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137180. */
  137181. export class BloomMergePostProcess extends PostProcess {
  137182. /** Weight of the bloom to be added to the original input. */
  137183. weight: number;
  137184. /**
  137185. * Creates a new instance of @see BloomMergePostProcess
  137186. * @param name The name of the effect.
  137187. * @param originalFromInput Post process which's input will be used for the merge.
  137188. * @param blurred Blurred highlights post process which's output will be used.
  137189. * @param weight Weight of the bloom to be added to the original input.
  137190. * @param options The required width/height ratio to downsize to before computing the render pass.
  137191. * @param camera The camera to apply the render pass to.
  137192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137193. * @param engine The engine which the post process will be applied. (default: current engine)
  137194. * @param reusable If the post process can be reused on the same frame. (default: false)
  137195. * @param textureType Type of textures used when performing the post process. (default: 0)
  137196. * @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)
  137197. */
  137198. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137199. /** Weight of the bloom to be added to the original input. */
  137200. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137201. }
  137202. }
  137203. declare module BABYLON {
  137204. /**
  137205. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137206. */
  137207. export class BloomEffect extends PostProcessRenderEffect {
  137208. private bloomScale;
  137209. /**
  137210. * @hidden Internal
  137211. */
  137212. _effects: Array<PostProcess>;
  137213. /**
  137214. * @hidden Internal
  137215. */
  137216. _downscale: ExtractHighlightsPostProcess;
  137217. private _blurX;
  137218. private _blurY;
  137219. private _merge;
  137220. /**
  137221. * The luminance threshold to find bright areas of the image to bloom.
  137222. */
  137223. get threshold(): number;
  137224. set threshold(value: number);
  137225. /**
  137226. * The strength of the bloom.
  137227. */
  137228. get weight(): number;
  137229. set weight(value: number);
  137230. /**
  137231. * Specifies the size of the bloom blur kernel, relative to the final output size
  137232. */
  137233. get kernel(): number;
  137234. set kernel(value: number);
  137235. /**
  137236. * Creates a new instance of @see BloomEffect
  137237. * @param scene The scene the effect belongs to.
  137238. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137239. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137240. * @param bloomWeight The the strength of bloom.
  137241. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137242. * @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)
  137243. */
  137244. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137245. /**
  137246. * Disposes each of the internal effects for a given camera.
  137247. * @param camera The camera to dispose the effect on.
  137248. */
  137249. disposeEffects(camera: Camera): void;
  137250. /**
  137251. * @hidden Internal
  137252. */
  137253. _updateEffects(): void;
  137254. /**
  137255. * Internal
  137256. * @returns if all the contained post processes are ready.
  137257. * @hidden
  137258. */
  137259. _isReady(): boolean;
  137260. }
  137261. }
  137262. declare module BABYLON {
  137263. /** @hidden */
  137264. export var chromaticAberrationPixelShader: {
  137265. name: string;
  137266. shader: string;
  137267. };
  137268. }
  137269. declare module BABYLON {
  137270. /**
  137271. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137272. */
  137273. export class ChromaticAberrationPostProcess extends PostProcess {
  137274. /**
  137275. * The amount of seperation of rgb channels (default: 30)
  137276. */
  137277. aberrationAmount: number;
  137278. /**
  137279. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137280. */
  137281. radialIntensity: number;
  137282. /**
  137283. * 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))
  137284. */
  137285. direction: Vector2;
  137286. /**
  137287. * 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))
  137288. */
  137289. centerPosition: Vector2;
  137290. /**
  137291. * Creates a new instance ChromaticAberrationPostProcess
  137292. * @param name The name of the effect.
  137293. * @param screenWidth The width of the screen to apply the effect on.
  137294. * @param screenHeight The height of the screen to apply the effect on.
  137295. * @param options The required width/height ratio to downsize to before computing the render pass.
  137296. * @param camera The camera to apply the render pass to.
  137297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137298. * @param engine The engine which the post process will be applied. (default: current engine)
  137299. * @param reusable If the post process can be reused on the same frame. (default: false)
  137300. * @param textureType Type of textures used when performing the post process. (default: 0)
  137301. * @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)
  137302. */
  137303. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137304. }
  137305. }
  137306. declare module BABYLON {
  137307. /** @hidden */
  137308. export var circleOfConfusionPixelShader: {
  137309. name: string;
  137310. shader: string;
  137311. };
  137312. }
  137313. declare module BABYLON {
  137314. /**
  137315. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137316. */
  137317. export class CircleOfConfusionPostProcess extends PostProcess {
  137318. /**
  137319. * 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.
  137320. */
  137321. lensSize: number;
  137322. /**
  137323. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137324. */
  137325. fStop: number;
  137326. /**
  137327. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137328. */
  137329. focusDistance: number;
  137330. /**
  137331. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137332. */
  137333. focalLength: number;
  137334. private _depthTexture;
  137335. /**
  137336. * Creates a new instance CircleOfConfusionPostProcess
  137337. * @param name The name of the effect.
  137338. * @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.
  137339. * @param options The required width/height ratio to downsize to before computing the render pass.
  137340. * @param camera The camera to apply the render pass to.
  137341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137342. * @param engine The engine which the post process will be applied. (default: current engine)
  137343. * @param reusable If the post process can be reused on the same frame. (default: false)
  137344. * @param textureType Type of textures used when performing the post process. (default: 0)
  137345. * @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)
  137346. */
  137347. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137348. /**
  137349. * 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.
  137350. */
  137351. set depthTexture(value: RenderTargetTexture);
  137352. }
  137353. }
  137354. declare module BABYLON {
  137355. /** @hidden */
  137356. export var colorCorrectionPixelShader: {
  137357. name: string;
  137358. shader: string;
  137359. };
  137360. }
  137361. declare module BABYLON {
  137362. /**
  137363. *
  137364. * This post-process allows the modification of rendered colors by using
  137365. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137366. *
  137367. * The object needs to be provided an url to a texture containing the color
  137368. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137369. * Use an image editing software to tweak the LUT to match your needs.
  137370. *
  137371. * For an example of a color LUT, see here:
  137372. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137373. * For explanations on color grading, see here:
  137374. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137375. *
  137376. */
  137377. export class ColorCorrectionPostProcess extends PostProcess {
  137378. private _colorTableTexture;
  137379. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137380. }
  137381. }
  137382. declare module BABYLON {
  137383. /** @hidden */
  137384. export var convolutionPixelShader: {
  137385. name: string;
  137386. shader: string;
  137387. };
  137388. }
  137389. declare module BABYLON {
  137390. /**
  137391. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137392. * input texture to perform effects such as edge detection or sharpening
  137393. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137394. */
  137395. export class ConvolutionPostProcess extends PostProcess {
  137396. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137397. kernel: number[];
  137398. /**
  137399. * Creates a new instance ConvolutionPostProcess
  137400. * @param name The name of the effect.
  137401. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137402. * @param options The required width/height ratio to downsize to before computing the render pass.
  137403. * @param camera The camera to apply the render pass to.
  137404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137405. * @param engine The engine which the post process will be applied. (default: current engine)
  137406. * @param reusable If the post process can be reused on the same frame. (default: false)
  137407. * @param textureType Type of textures used when performing the post process. (default: 0)
  137408. */
  137409. constructor(name: string,
  137410. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137411. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137412. /**
  137413. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137414. */
  137415. static EdgeDetect0Kernel: number[];
  137416. /**
  137417. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137418. */
  137419. static EdgeDetect1Kernel: number[];
  137420. /**
  137421. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137422. */
  137423. static EdgeDetect2Kernel: number[];
  137424. /**
  137425. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137426. */
  137427. static SharpenKernel: number[];
  137428. /**
  137429. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137430. */
  137431. static EmbossKernel: number[];
  137432. /**
  137433. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137434. */
  137435. static GaussianKernel: number[];
  137436. }
  137437. }
  137438. declare module BABYLON {
  137439. /**
  137440. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137441. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137442. * based on samples that have a large difference in distance than the center pixel.
  137443. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137444. */
  137445. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137446. direction: Vector2;
  137447. /**
  137448. * Creates a new instance CircleOfConfusionPostProcess
  137449. * @param name The name of the effect.
  137450. * @param scene The scene the effect belongs to.
  137451. * @param direction The direction the blur should be applied.
  137452. * @param kernel The size of the kernel used to blur.
  137453. * @param options The required width/height ratio to downsize to before computing the render pass.
  137454. * @param camera The camera to apply the render pass to.
  137455. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137456. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137458. * @param engine The engine which the post process will be applied. (default: current engine)
  137459. * @param reusable If the post process can be reused on the same frame. (default: false)
  137460. * @param textureType Type of textures used when performing the post process. (default: 0)
  137461. * @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)
  137462. */
  137463. 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);
  137464. }
  137465. }
  137466. declare module BABYLON {
  137467. /** @hidden */
  137468. export var depthOfFieldMergePixelShader: {
  137469. name: string;
  137470. shader: string;
  137471. };
  137472. }
  137473. declare module BABYLON {
  137474. /**
  137475. * Options to be set when merging outputs from the default pipeline.
  137476. */
  137477. export class DepthOfFieldMergePostProcessOptions {
  137478. /**
  137479. * The original image to merge on top of
  137480. */
  137481. originalFromInput: PostProcess;
  137482. /**
  137483. * Parameters to perform the merge of the depth of field effect
  137484. */
  137485. depthOfField?: {
  137486. circleOfConfusion: PostProcess;
  137487. blurSteps: Array<PostProcess>;
  137488. };
  137489. /**
  137490. * Parameters to perform the merge of bloom effect
  137491. */
  137492. bloom?: {
  137493. blurred: PostProcess;
  137494. weight: number;
  137495. };
  137496. }
  137497. /**
  137498. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137499. */
  137500. export class DepthOfFieldMergePostProcess extends PostProcess {
  137501. private blurSteps;
  137502. /**
  137503. * Creates a new instance of DepthOfFieldMergePostProcess
  137504. * @param name The name of the effect.
  137505. * @param originalFromInput Post process which's input will be used for the merge.
  137506. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137507. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137508. * @param options The required width/height ratio to downsize to before computing the render pass.
  137509. * @param camera The camera to apply the render pass to.
  137510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137511. * @param engine The engine which the post process will be applied. (default: current engine)
  137512. * @param reusable If the post process can be reused on the same frame. (default: false)
  137513. * @param textureType Type of textures used when performing the post process. (default: 0)
  137514. * @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)
  137515. */
  137516. 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);
  137517. /**
  137518. * Updates the effect with the current post process compile time values and recompiles the shader.
  137519. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137520. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137521. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137522. * @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
  137523. * @param onCompiled Called when the shader has been compiled.
  137524. * @param onError Called if there is an error when compiling a shader.
  137525. */
  137526. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137527. }
  137528. }
  137529. declare module BABYLON {
  137530. /**
  137531. * Specifies the level of max blur that should be applied when using the depth of field effect
  137532. */
  137533. export enum DepthOfFieldEffectBlurLevel {
  137534. /**
  137535. * Subtle blur
  137536. */
  137537. Low = 0,
  137538. /**
  137539. * Medium blur
  137540. */
  137541. Medium = 1,
  137542. /**
  137543. * Large blur
  137544. */
  137545. High = 2
  137546. }
  137547. /**
  137548. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137549. */
  137550. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137551. private _circleOfConfusion;
  137552. /**
  137553. * @hidden Internal, blurs from high to low
  137554. */
  137555. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137556. private _depthOfFieldBlurY;
  137557. private _dofMerge;
  137558. /**
  137559. * @hidden Internal post processes in depth of field effect
  137560. */
  137561. _effects: Array<PostProcess>;
  137562. /**
  137563. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137564. */
  137565. set focalLength(value: number);
  137566. get focalLength(): number;
  137567. /**
  137568. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137569. */
  137570. set fStop(value: number);
  137571. get fStop(): number;
  137572. /**
  137573. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137574. */
  137575. set focusDistance(value: number);
  137576. get focusDistance(): number;
  137577. /**
  137578. * 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.
  137579. */
  137580. set lensSize(value: number);
  137581. get lensSize(): number;
  137582. /**
  137583. * Creates a new instance DepthOfFieldEffect
  137584. * @param scene The scene the effect belongs to.
  137585. * @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.
  137586. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137587. * @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)
  137588. */
  137589. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137590. /**
  137591. * Get the current class name of the current effet
  137592. * @returns "DepthOfFieldEffect"
  137593. */
  137594. getClassName(): string;
  137595. /**
  137596. * 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.
  137597. */
  137598. set depthTexture(value: RenderTargetTexture);
  137599. /**
  137600. * Disposes each of the internal effects for a given camera.
  137601. * @param camera The camera to dispose the effect on.
  137602. */
  137603. disposeEffects(camera: Camera): void;
  137604. /**
  137605. * @hidden Internal
  137606. */
  137607. _updateEffects(): void;
  137608. /**
  137609. * Internal
  137610. * @returns if all the contained post processes are ready.
  137611. * @hidden
  137612. */
  137613. _isReady(): boolean;
  137614. }
  137615. }
  137616. declare module BABYLON {
  137617. /** @hidden */
  137618. export var displayPassPixelShader: {
  137619. name: string;
  137620. shader: string;
  137621. };
  137622. }
  137623. declare module BABYLON {
  137624. /**
  137625. * DisplayPassPostProcess which produces an output the same as it's input
  137626. */
  137627. export class DisplayPassPostProcess extends PostProcess {
  137628. /**
  137629. * Creates the DisplayPassPostProcess
  137630. * @param name The name of the effect.
  137631. * @param options The required width/height ratio to downsize to before computing the render pass.
  137632. * @param camera The camera to apply the render pass to.
  137633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137634. * @param engine The engine which the post process will be applied. (default: current engine)
  137635. * @param reusable If the post process can be reused on the same frame. (default: false)
  137636. */
  137637. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137638. }
  137639. }
  137640. declare module BABYLON {
  137641. /** @hidden */
  137642. export var filterPixelShader: {
  137643. name: string;
  137644. shader: string;
  137645. };
  137646. }
  137647. declare module BABYLON {
  137648. /**
  137649. * Applies a kernel filter to the image
  137650. */
  137651. export class FilterPostProcess extends PostProcess {
  137652. /** The matrix to be applied to the image */
  137653. kernelMatrix: Matrix;
  137654. /**
  137655. *
  137656. * @param name The name of the effect.
  137657. * @param kernelMatrix The matrix to be applied to the image
  137658. * @param options The required width/height ratio to downsize to before computing the render pass.
  137659. * @param camera The camera to apply the render pass to.
  137660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137661. * @param engine The engine which the post process will be applied. (default: current engine)
  137662. * @param reusable If the post process can be reused on the same frame. (default: false)
  137663. */
  137664. constructor(name: string,
  137665. /** The matrix to be applied to the image */
  137666. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137667. }
  137668. }
  137669. declare module BABYLON {
  137670. /** @hidden */
  137671. export var fxaaPixelShader: {
  137672. name: string;
  137673. shader: string;
  137674. };
  137675. }
  137676. declare module BABYLON {
  137677. /** @hidden */
  137678. export var fxaaVertexShader: {
  137679. name: string;
  137680. shader: string;
  137681. };
  137682. }
  137683. declare module BABYLON {
  137684. /**
  137685. * Fxaa post process
  137686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137687. */
  137688. export class FxaaPostProcess extends PostProcess {
  137689. /** @hidden */
  137690. texelWidth: number;
  137691. /** @hidden */
  137692. texelHeight: number;
  137693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137694. private _getDefines;
  137695. }
  137696. }
  137697. declare module BABYLON {
  137698. /** @hidden */
  137699. export var grainPixelShader: {
  137700. name: string;
  137701. shader: string;
  137702. };
  137703. }
  137704. declare module BABYLON {
  137705. /**
  137706. * The GrainPostProcess adds noise to the image at mid luminance levels
  137707. */
  137708. export class GrainPostProcess extends PostProcess {
  137709. /**
  137710. * The intensity of the grain added (default: 30)
  137711. */
  137712. intensity: number;
  137713. /**
  137714. * If the grain should be randomized on every frame
  137715. */
  137716. animated: boolean;
  137717. /**
  137718. * Creates a new instance of @see GrainPostProcess
  137719. * @param name The name of the effect.
  137720. * @param options The required width/height ratio to downsize to before computing the render pass.
  137721. * @param camera The camera to apply the render pass to.
  137722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137723. * @param engine The engine which the post process will be applied. (default: current engine)
  137724. * @param reusable If the post process can be reused on the same frame. (default: false)
  137725. * @param textureType Type of textures used when performing the post process. (default: 0)
  137726. * @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)
  137727. */
  137728. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137729. }
  137730. }
  137731. declare module BABYLON {
  137732. /** @hidden */
  137733. export var highlightsPixelShader: {
  137734. name: string;
  137735. shader: string;
  137736. };
  137737. }
  137738. declare module BABYLON {
  137739. /**
  137740. * Extracts highlights from the image
  137741. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137742. */
  137743. export class HighlightsPostProcess extends PostProcess {
  137744. /**
  137745. * Extracts highlights from the image
  137746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137747. * @param name The name of the effect.
  137748. * @param options The required width/height ratio to downsize to before computing the render pass.
  137749. * @param camera The camera to apply the render pass to.
  137750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137751. * @param engine The engine which the post process will be applied. (default: current engine)
  137752. * @param reusable If the post process can be reused on the same frame. (default: false)
  137753. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137754. */
  137755. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137756. }
  137757. }
  137758. declare module BABYLON {
  137759. /** @hidden */
  137760. export var mrtFragmentDeclaration: {
  137761. name: string;
  137762. shader: string;
  137763. };
  137764. }
  137765. declare module BABYLON {
  137766. /** @hidden */
  137767. export var geometryPixelShader: {
  137768. name: string;
  137769. shader: string;
  137770. };
  137771. }
  137772. declare module BABYLON {
  137773. /** @hidden */
  137774. export var geometryVertexShader: {
  137775. name: string;
  137776. shader: string;
  137777. };
  137778. }
  137779. declare module BABYLON {
  137780. /** @hidden */
  137781. interface ISavedTransformationMatrix {
  137782. world: Matrix;
  137783. viewProjection: Matrix;
  137784. }
  137785. /**
  137786. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137787. */
  137788. export class GeometryBufferRenderer {
  137789. /**
  137790. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137791. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137792. */
  137793. static readonly POSITION_TEXTURE_TYPE: number;
  137794. /**
  137795. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137796. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137797. */
  137798. static readonly VELOCITY_TEXTURE_TYPE: number;
  137799. /**
  137800. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137801. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137802. */
  137803. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137804. /**
  137805. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137806. * in order to compute objects velocities when enableVelocity is set to "true"
  137807. * @hidden
  137808. */
  137809. _previousTransformationMatrices: {
  137810. [index: number]: ISavedTransformationMatrix;
  137811. };
  137812. /**
  137813. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137814. * in order to compute objects velocities when enableVelocity is set to "true"
  137815. * @hidden
  137816. */
  137817. _previousBonesTransformationMatrices: {
  137818. [index: number]: Float32Array;
  137819. };
  137820. /**
  137821. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137822. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137823. */
  137824. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137825. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137826. renderTransparentMeshes: boolean;
  137827. private _scene;
  137828. private _multiRenderTarget;
  137829. private _ratio;
  137830. private _enablePosition;
  137831. private _enableVelocity;
  137832. private _enableReflectivity;
  137833. private _positionIndex;
  137834. private _velocityIndex;
  137835. private _reflectivityIndex;
  137836. protected _effect: Effect;
  137837. protected _cachedDefines: string;
  137838. /**
  137839. * Set the render list (meshes to be rendered) used in the G buffer.
  137840. */
  137841. set renderList(meshes: Mesh[]);
  137842. /**
  137843. * Gets wether or not G buffer are supported by the running hardware.
  137844. * This requires draw buffer supports
  137845. */
  137846. get isSupported(): boolean;
  137847. /**
  137848. * Returns the index of the given texture type in the G-Buffer textures array
  137849. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137850. * @returns the index of the given texture type in the G-Buffer textures array
  137851. */
  137852. getTextureIndex(textureType: number): number;
  137853. /**
  137854. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137855. */
  137856. get enablePosition(): boolean;
  137857. /**
  137858. * Sets whether or not objects positions are enabled for the G buffer.
  137859. */
  137860. set enablePosition(enable: boolean);
  137861. /**
  137862. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137863. */
  137864. get enableVelocity(): boolean;
  137865. /**
  137866. * Sets wether or not objects velocities are enabled for the G buffer.
  137867. */
  137868. set enableVelocity(enable: boolean);
  137869. /**
  137870. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137871. */
  137872. get enableReflectivity(): boolean;
  137873. /**
  137874. * Sets wether or not objects roughness are enabled for the G buffer.
  137875. */
  137876. set enableReflectivity(enable: boolean);
  137877. /**
  137878. * Gets the scene associated with the buffer.
  137879. */
  137880. get scene(): Scene;
  137881. /**
  137882. * Gets the ratio used by the buffer during its creation.
  137883. * How big is the buffer related to the main canvas.
  137884. */
  137885. get ratio(): number;
  137886. /** @hidden */
  137887. static _SceneComponentInitialization: (scene: Scene) => void;
  137888. /**
  137889. * Creates a new G Buffer for the scene
  137890. * @param scene The scene the buffer belongs to
  137891. * @param ratio How big is the buffer related to the main canvas.
  137892. */
  137893. constructor(scene: Scene, ratio?: number);
  137894. /**
  137895. * Checks wether everything is ready to render a submesh to the G buffer.
  137896. * @param subMesh the submesh to check readiness for
  137897. * @param useInstances is the mesh drawn using instance or not
  137898. * @returns true if ready otherwise false
  137899. */
  137900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137901. /**
  137902. * Gets the current underlying G Buffer.
  137903. * @returns the buffer
  137904. */
  137905. getGBuffer(): MultiRenderTarget;
  137906. /**
  137907. * Gets the number of samples used to render the buffer (anti aliasing).
  137908. */
  137909. get samples(): number;
  137910. /**
  137911. * Sets the number of samples used to render the buffer (anti aliasing).
  137912. */
  137913. set samples(value: number);
  137914. /**
  137915. * Disposes the renderer and frees up associated resources.
  137916. */
  137917. dispose(): void;
  137918. protected _createRenderTargets(): void;
  137919. private _copyBonesTransformationMatrices;
  137920. }
  137921. }
  137922. declare module BABYLON {
  137923. interface Scene {
  137924. /** @hidden (Backing field) */
  137925. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137926. /**
  137927. * Gets or Sets the current geometry buffer associated to the scene.
  137928. */
  137929. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137930. /**
  137931. * Enables a GeometryBufferRender and associates it with the scene
  137932. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137933. * @returns the GeometryBufferRenderer
  137934. */
  137935. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137936. /**
  137937. * Disables the GeometryBufferRender associated with the scene
  137938. */
  137939. disableGeometryBufferRenderer(): void;
  137940. }
  137941. /**
  137942. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137943. * in several rendering techniques.
  137944. */
  137945. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137946. /**
  137947. * The component name helpful to identify the component in the list of scene components.
  137948. */
  137949. readonly name: string;
  137950. /**
  137951. * The scene the component belongs to.
  137952. */
  137953. scene: Scene;
  137954. /**
  137955. * Creates a new instance of the component for the given scene
  137956. * @param scene Defines the scene to register the component in
  137957. */
  137958. constructor(scene: Scene);
  137959. /**
  137960. * Registers the component in a given scene
  137961. */
  137962. register(): void;
  137963. /**
  137964. * Rebuilds the elements related to this component in case of
  137965. * context lost for instance.
  137966. */
  137967. rebuild(): void;
  137968. /**
  137969. * Disposes the component and the associated ressources
  137970. */
  137971. dispose(): void;
  137972. private _gatherRenderTargets;
  137973. }
  137974. }
  137975. declare module BABYLON {
  137976. /** @hidden */
  137977. export var motionBlurPixelShader: {
  137978. name: string;
  137979. shader: string;
  137980. };
  137981. }
  137982. declare module BABYLON {
  137983. /**
  137984. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137985. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137986. * As an example, all you have to do is to create the post-process:
  137987. * var mb = new BABYLON.MotionBlurPostProcess(
  137988. * 'mb', // The name of the effect.
  137989. * scene, // The scene containing the objects to blur according to their velocity.
  137990. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137991. * camera // The camera to apply the render pass to.
  137992. * );
  137993. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137994. */
  137995. export class MotionBlurPostProcess extends PostProcess {
  137996. /**
  137997. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137998. */
  137999. motionStrength: number;
  138000. /**
  138001. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138002. */
  138003. get motionBlurSamples(): number;
  138004. /**
  138005. * Sets the number of iterations to be used for motion blur quality
  138006. */
  138007. set motionBlurSamples(samples: number);
  138008. private _motionBlurSamples;
  138009. private _geometryBufferRenderer;
  138010. /**
  138011. * Creates a new instance MotionBlurPostProcess
  138012. * @param name The name of the effect.
  138013. * @param scene The scene containing the objects to blur according to their velocity.
  138014. * @param options The required width/height ratio to downsize to before computing the render pass.
  138015. * @param camera The camera to apply the render pass to.
  138016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138017. * @param engine The engine which the post process will be applied. (default: current engine)
  138018. * @param reusable If the post process can be reused on the same frame. (default: false)
  138019. * @param textureType Type of textures used when performing the post process. (default: 0)
  138020. * @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)
  138021. */
  138022. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138023. /**
  138024. * Excludes the given skinned mesh from computing bones velocities.
  138025. * 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.
  138026. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138027. */
  138028. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138029. /**
  138030. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138031. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138032. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138033. */
  138034. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138035. /**
  138036. * Disposes the post process.
  138037. * @param camera The camera to dispose the post process on.
  138038. */
  138039. dispose(camera?: Camera): void;
  138040. }
  138041. }
  138042. declare module BABYLON {
  138043. /** @hidden */
  138044. export var refractionPixelShader: {
  138045. name: string;
  138046. shader: string;
  138047. };
  138048. }
  138049. declare module BABYLON {
  138050. /**
  138051. * Post process which applies a refractin texture
  138052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138053. */
  138054. export class RefractionPostProcess extends PostProcess {
  138055. /** the base color of the refraction (used to taint the rendering) */
  138056. color: Color3;
  138057. /** simulated refraction depth */
  138058. depth: number;
  138059. /** the coefficient of the base color (0 to remove base color tainting) */
  138060. colorLevel: number;
  138061. private _refTexture;
  138062. private _ownRefractionTexture;
  138063. /**
  138064. * Gets or sets the refraction texture
  138065. * Please note that you are responsible for disposing the texture if you set it manually
  138066. */
  138067. get refractionTexture(): Texture;
  138068. set refractionTexture(value: Texture);
  138069. /**
  138070. * Initializes the RefractionPostProcess
  138071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138072. * @param name The name of the effect.
  138073. * @param refractionTextureUrl Url of the refraction texture to use
  138074. * @param color the base color of the refraction (used to taint the rendering)
  138075. * @param depth simulated refraction depth
  138076. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138077. * @param camera The camera to apply the render pass to.
  138078. * @param options The required width/height ratio to downsize to before computing the render pass.
  138079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138080. * @param engine The engine which the post process will be applied. (default: current engine)
  138081. * @param reusable If the post process can be reused on the same frame. (default: false)
  138082. */
  138083. constructor(name: string, refractionTextureUrl: string,
  138084. /** the base color of the refraction (used to taint the rendering) */
  138085. color: Color3,
  138086. /** simulated refraction depth */
  138087. depth: number,
  138088. /** the coefficient of the base color (0 to remove base color tainting) */
  138089. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138090. /**
  138091. * Disposes of the post process
  138092. * @param camera Camera to dispose post process on
  138093. */
  138094. dispose(camera: Camera): void;
  138095. }
  138096. }
  138097. declare module BABYLON {
  138098. /** @hidden */
  138099. export var sharpenPixelShader: {
  138100. name: string;
  138101. shader: string;
  138102. };
  138103. }
  138104. declare module BABYLON {
  138105. /**
  138106. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138107. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138108. */
  138109. export class SharpenPostProcess extends PostProcess {
  138110. /**
  138111. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138112. */
  138113. colorAmount: number;
  138114. /**
  138115. * How much sharpness should be applied (default: 0.3)
  138116. */
  138117. edgeAmount: number;
  138118. /**
  138119. * Creates a new instance ConvolutionPostProcess
  138120. * @param name The name of the effect.
  138121. * @param options The required width/height ratio to downsize to before computing the render pass.
  138122. * @param camera The camera to apply the render pass to.
  138123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138124. * @param engine The engine which the post process will be applied. (default: current engine)
  138125. * @param reusable If the post process can be reused on the same frame. (default: false)
  138126. * @param textureType Type of textures used when performing the post process. (default: 0)
  138127. * @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)
  138128. */
  138129. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138130. }
  138131. }
  138132. declare module BABYLON {
  138133. /**
  138134. * PostProcessRenderPipeline
  138135. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138136. */
  138137. export class PostProcessRenderPipeline {
  138138. private engine;
  138139. private _renderEffects;
  138140. private _renderEffectsForIsolatedPass;
  138141. /**
  138142. * List of inspectable custom properties (used by the Inspector)
  138143. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138144. */
  138145. inspectableCustomProperties: IInspectable[];
  138146. /**
  138147. * @hidden
  138148. */
  138149. protected _cameras: Camera[];
  138150. /** @hidden */
  138151. _name: string;
  138152. /**
  138153. * Gets pipeline name
  138154. */
  138155. get name(): string;
  138156. /** Gets the list of attached cameras */
  138157. get cameras(): Camera[];
  138158. /**
  138159. * Initializes a PostProcessRenderPipeline
  138160. * @param engine engine to add the pipeline to
  138161. * @param name name of the pipeline
  138162. */
  138163. constructor(engine: Engine, name: string);
  138164. /**
  138165. * Gets the class name
  138166. * @returns "PostProcessRenderPipeline"
  138167. */
  138168. getClassName(): string;
  138169. /**
  138170. * If all the render effects in the pipeline are supported
  138171. */
  138172. get isSupported(): boolean;
  138173. /**
  138174. * Adds an effect to the pipeline
  138175. * @param renderEffect the effect to add
  138176. */
  138177. addEffect(renderEffect: PostProcessRenderEffect): void;
  138178. /** @hidden */
  138179. _rebuild(): void;
  138180. /** @hidden */
  138181. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138182. /** @hidden */
  138183. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138184. /** @hidden */
  138185. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138186. /** @hidden */
  138187. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138188. /** @hidden */
  138189. _attachCameras(cameras: Camera, unique: boolean): void;
  138190. /** @hidden */
  138191. _attachCameras(cameras: Camera[], unique: boolean): void;
  138192. /** @hidden */
  138193. _detachCameras(cameras: Camera): void;
  138194. /** @hidden */
  138195. _detachCameras(cameras: Nullable<Camera[]>): void;
  138196. /** @hidden */
  138197. _update(): void;
  138198. /** @hidden */
  138199. _reset(): void;
  138200. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138201. /**
  138202. * Disposes of the pipeline
  138203. */
  138204. dispose(): void;
  138205. }
  138206. }
  138207. declare module BABYLON {
  138208. /**
  138209. * PostProcessRenderPipelineManager class
  138210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138211. */
  138212. export class PostProcessRenderPipelineManager {
  138213. private _renderPipelines;
  138214. /**
  138215. * Initializes a PostProcessRenderPipelineManager
  138216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138217. */
  138218. constructor();
  138219. /**
  138220. * Gets the list of supported render pipelines
  138221. */
  138222. get supportedPipelines(): PostProcessRenderPipeline[];
  138223. /**
  138224. * Adds a pipeline to the manager
  138225. * @param renderPipeline The pipeline to add
  138226. */
  138227. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138228. /**
  138229. * Attaches a camera to the pipeline
  138230. * @param renderPipelineName The name of the pipeline to attach to
  138231. * @param cameras the camera to attach
  138232. * @param unique if the camera can be attached multiple times to the pipeline
  138233. */
  138234. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138235. /**
  138236. * Detaches a camera from the pipeline
  138237. * @param renderPipelineName The name of the pipeline to detach from
  138238. * @param cameras the camera to detach
  138239. */
  138240. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138241. /**
  138242. * Enables an effect by name on a pipeline
  138243. * @param renderPipelineName the name of the pipeline to enable the effect in
  138244. * @param renderEffectName the name of the effect to enable
  138245. * @param cameras the cameras that the effect should be enabled on
  138246. */
  138247. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138248. /**
  138249. * Disables an effect by name on a pipeline
  138250. * @param renderPipelineName the name of the pipeline to disable the effect in
  138251. * @param renderEffectName the name of the effect to disable
  138252. * @param cameras the cameras that the effect should be disabled on
  138253. */
  138254. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138255. /**
  138256. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138257. */
  138258. update(): void;
  138259. /** @hidden */
  138260. _rebuild(): void;
  138261. /**
  138262. * Disposes of the manager and pipelines
  138263. */
  138264. dispose(): void;
  138265. }
  138266. }
  138267. declare module BABYLON {
  138268. interface Scene {
  138269. /** @hidden (Backing field) */
  138270. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138271. /**
  138272. * Gets the postprocess render pipeline manager
  138273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138274. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138275. */
  138276. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138277. }
  138278. /**
  138279. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138280. */
  138281. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138282. /**
  138283. * The component name helpfull to identify the component in the list of scene components.
  138284. */
  138285. readonly name: string;
  138286. /**
  138287. * The scene the component belongs to.
  138288. */
  138289. scene: Scene;
  138290. /**
  138291. * Creates a new instance of the component for the given scene
  138292. * @param scene Defines the scene to register the component in
  138293. */
  138294. constructor(scene: Scene);
  138295. /**
  138296. * Registers the component in a given scene
  138297. */
  138298. register(): void;
  138299. /**
  138300. * Rebuilds the elements related to this component in case of
  138301. * context lost for instance.
  138302. */
  138303. rebuild(): void;
  138304. /**
  138305. * Disposes the component and the associated ressources
  138306. */
  138307. dispose(): void;
  138308. private _gatherRenderTargets;
  138309. }
  138310. }
  138311. declare module BABYLON {
  138312. /**
  138313. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138314. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138315. */
  138316. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138317. private _scene;
  138318. private _camerasToBeAttached;
  138319. /**
  138320. * ID of the sharpen post process,
  138321. */
  138322. private readonly SharpenPostProcessId;
  138323. /**
  138324. * @ignore
  138325. * ID of the image processing post process;
  138326. */
  138327. readonly ImageProcessingPostProcessId: string;
  138328. /**
  138329. * @ignore
  138330. * ID of the Fast Approximate Anti-Aliasing post process;
  138331. */
  138332. readonly FxaaPostProcessId: string;
  138333. /**
  138334. * ID of the chromatic aberration post process,
  138335. */
  138336. private readonly ChromaticAberrationPostProcessId;
  138337. /**
  138338. * ID of the grain post process
  138339. */
  138340. private readonly GrainPostProcessId;
  138341. /**
  138342. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138343. */
  138344. sharpen: SharpenPostProcess;
  138345. private _sharpenEffect;
  138346. private bloom;
  138347. /**
  138348. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138349. */
  138350. depthOfField: DepthOfFieldEffect;
  138351. /**
  138352. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138353. */
  138354. fxaa: FxaaPostProcess;
  138355. /**
  138356. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138357. */
  138358. imageProcessing: ImageProcessingPostProcess;
  138359. /**
  138360. * Chromatic aberration post process which will shift rgb colors in the image
  138361. */
  138362. chromaticAberration: ChromaticAberrationPostProcess;
  138363. private _chromaticAberrationEffect;
  138364. /**
  138365. * Grain post process which add noise to the image
  138366. */
  138367. grain: GrainPostProcess;
  138368. private _grainEffect;
  138369. /**
  138370. * Glow post process which adds a glow to emissive areas of the image
  138371. */
  138372. private _glowLayer;
  138373. /**
  138374. * Animations which can be used to tweak settings over a period of time
  138375. */
  138376. animations: Animation[];
  138377. private _imageProcessingConfigurationObserver;
  138378. private _sharpenEnabled;
  138379. private _bloomEnabled;
  138380. private _depthOfFieldEnabled;
  138381. private _depthOfFieldBlurLevel;
  138382. private _fxaaEnabled;
  138383. private _imageProcessingEnabled;
  138384. private _defaultPipelineTextureType;
  138385. private _bloomScale;
  138386. private _chromaticAberrationEnabled;
  138387. private _grainEnabled;
  138388. private _buildAllowed;
  138389. /**
  138390. * Gets active scene
  138391. */
  138392. get scene(): Scene;
  138393. /**
  138394. * Enable or disable the sharpen process from the pipeline
  138395. */
  138396. set sharpenEnabled(enabled: boolean);
  138397. get sharpenEnabled(): boolean;
  138398. private _resizeObserver;
  138399. private _hardwareScaleLevel;
  138400. private _bloomKernel;
  138401. /**
  138402. * Specifies the size of the bloom blur kernel, relative to the final output size
  138403. */
  138404. get bloomKernel(): number;
  138405. set bloomKernel(value: number);
  138406. /**
  138407. * Specifies the weight of the bloom in the final rendering
  138408. */
  138409. private _bloomWeight;
  138410. /**
  138411. * Specifies the luma threshold for the area that will be blurred by the bloom
  138412. */
  138413. private _bloomThreshold;
  138414. private _hdr;
  138415. /**
  138416. * The strength of the bloom.
  138417. */
  138418. set bloomWeight(value: number);
  138419. get bloomWeight(): number;
  138420. /**
  138421. * The strength of the bloom.
  138422. */
  138423. set bloomThreshold(value: number);
  138424. get bloomThreshold(): number;
  138425. /**
  138426. * The scale of the bloom, lower value will provide better performance.
  138427. */
  138428. set bloomScale(value: number);
  138429. get bloomScale(): number;
  138430. /**
  138431. * Enable or disable the bloom from the pipeline
  138432. */
  138433. set bloomEnabled(enabled: boolean);
  138434. get bloomEnabled(): boolean;
  138435. private _rebuildBloom;
  138436. /**
  138437. * If the depth of field is enabled.
  138438. */
  138439. get depthOfFieldEnabled(): boolean;
  138440. set depthOfFieldEnabled(enabled: boolean);
  138441. /**
  138442. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138443. */
  138444. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138445. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138446. /**
  138447. * If the anti aliasing is enabled.
  138448. */
  138449. set fxaaEnabled(enabled: boolean);
  138450. get fxaaEnabled(): boolean;
  138451. private _samples;
  138452. /**
  138453. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138454. */
  138455. set samples(sampleCount: number);
  138456. get samples(): number;
  138457. /**
  138458. * If image processing is enabled.
  138459. */
  138460. set imageProcessingEnabled(enabled: boolean);
  138461. get imageProcessingEnabled(): boolean;
  138462. /**
  138463. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138464. */
  138465. set glowLayerEnabled(enabled: boolean);
  138466. get glowLayerEnabled(): boolean;
  138467. /**
  138468. * Gets the glow layer (or null if not defined)
  138469. */
  138470. get glowLayer(): Nullable<GlowLayer>;
  138471. /**
  138472. * Enable or disable the chromaticAberration process from the pipeline
  138473. */
  138474. set chromaticAberrationEnabled(enabled: boolean);
  138475. get chromaticAberrationEnabled(): boolean;
  138476. /**
  138477. * Enable or disable the grain process from the pipeline
  138478. */
  138479. set grainEnabled(enabled: boolean);
  138480. get grainEnabled(): boolean;
  138481. /**
  138482. * @constructor
  138483. * @param name - The rendering pipeline name (default: "")
  138484. * @param hdr - If high dynamic range textures should be used (default: true)
  138485. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138486. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138487. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138488. */
  138489. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138490. /**
  138491. * Get the class name
  138492. * @returns "DefaultRenderingPipeline"
  138493. */
  138494. getClassName(): string;
  138495. /**
  138496. * Force the compilation of the entire pipeline.
  138497. */
  138498. prepare(): void;
  138499. private _hasCleared;
  138500. private _prevPostProcess;
  138501. private _prevPrevPostProcess;
  138502. private _setAutoClearAndTextureSharing;
  138503. private _depthOfFieldSceneObserver;
  138504. private _buildPipeline;
  138505. private _disposePostProcesses;
  138506. /**
  138507. * Adds a camera to the pipeline
  138508. * @param camera the camera to be added
  138509. */
  138510. addCamera(camera: Camera): void;
  138511. /**
  138512. * Removes a camera from the pipeline
  138513. * @param camera the camera to remove
  138514. */
  138515. removeCamera(camera: Camera): void;
  138516. /**
  138517. * Dispose of the pipeline and stop all post processes
  138518. */
  138519. dispose(): void;
  138520. /**
  138521. * Serialize the rendering pipeline (Used when exporting)
  138522. * @returns the serialized object
  138523. */
  138524. serialize(): any;
  138525. /**
  138526. * Parse the serialized pipeline
  138527. * @param source Source pipeline.
  138528. * @param scene The scene to load the pipeline to.
  138529. * @param rootUrl The URL of the serialized pipeline.
  138530. * @returns An instantiated pipeline from the serialized object.
  138531. */
  138532. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138533. }
  138534. }
  138535. declare module BABYLON {
  138536. /** @hidden */
  138537. export var lensHighlightsPixelShader: {
  138538. name: string;
  138539. shader: string;
  138540. };
  138541. }
  138542. declare module BABYLON {
  138543. /** @hidden */
  138544. export var depthOfFieldPixelShader: {
  138545. name: string;
  138546. shader: string;
  138547. };
  138548. }
  138549. declare module BABYLON {
  138550. /**
  138551. * BABYLON.JS Chromatic Aberration GLSL Shader
  138552. * Author: Olivier Guyot
  138553. * Separates very slightly R, G and B colors on the edges of the screen
  138554. * Inspired by Francois Tarlier & Martins Upitis
  138555. */
  138556. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138557. /**
  138558. * @ignore
  138559. * The chromatic aberration PostProcess id in the pipeline
  138560. */
  138561. LensChromaticAberrationEffect: string;
  138562. /**
  138563. * @ignore
  138564. * The highlights enhancing PostProcess id in the pipeline
  138565. */
  138566. HighlightsEnhancingEffect: string;
  138567. /**
  138568. * @ignore
  138569. * The depth-of-field PostProcess id in the pipeline
  138570. */
  138571. LensDepthOfFieldEffect: string;
  138572. private _scene;
  138573. private _depthTexture;
  138574. private _grainTexture;
  138575. private _chromaticAberrationPostProcess;
  138576. private _highlightsPostProcess;
  138577. private _depthOfFieldPostProcess;
  138578. private _edgeBlur;
  138579. private _grainAmount;
  138580. private _chromaticAberration;
  138581. private _distortion;
  138582. private _highlightsGain;
  138583. private _highlightsThreshold;
  138584. private _dofDistance;
  138585. private _dofAperture;
  138586. private _dofDarken;
  138587. private _dofPentagon;
  138588. private _blurNoise;
  138589. /**
  138590. * @constructor
  138591. *
  138592. * Effect parameters are as follow:
  138593. * {
  138594. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138595. * edge_blur: number; // from 0 to x (1 for realism)
  138596. * distortion: number; // from 0 to x (1 for realism)
  138597. * grain_amount: number; // from 0 to 1
  138598. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138599. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138600. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138601. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138602. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138603. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138604. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138605. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138606. * }
  138607. * Note: if an effect parameter is unset, effect is disabled
  138608. *
  138609. * @param name The rendering pipeline name
  138610. * @param parameters - An object containing all parameters (see above)
  138611. * @param scene The scene linked to this pipeline
  138612. * @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)
  138613. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138614. */
  138615. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138616. /**
  138617. * Get the class name
  138618. * @returns "LensRenderingPipeline"
  138619. */
  138620. getClassName(): string;
  138621. /**
  138622. * Gets associated scene
  138623. */
  138624. get scene(): Scene;
  138625. /**
  138626. * Gets or sets the edge blur
  138627. */
  138628. get edgeBlur(): number;
  138629. set edgeBlur(value: number);
  138630. /**
  138631. * Gets or sets the grain amount
  138632. */
  138633. get grainAmount(): number;
  138634. set grainAmount(value: number);
  138635. /**
  138636. * Gets or sets the chromatic aberration amount
  138637. */
  138638. get chromaticAberration(): number;
  138639. set chromaticAberration(value: number);
  138640. /**
  138641. * Gets or sets the depth of field aperture
  138642. */
  138643. get dofAperture(): number;
  138644. set dofAperture(value: number);
  138645. /**
  138646. * Gets or sets the edge distortion
  138647. */
  138648. get edgeDistortion(): number;
  138649. set edgeDistortion(value: number);
  138650. /**
  138651. * Gets or sets the depth of field distortion
  138652. */
  138653. get dofDistortion(): number;
  138654. set dofDistortion(value: number);
  138655. /**
  138656. * Gets or sets the darken out of focus amount
  138657. */
  138658. get darkenOutOfFocus(): number;
  138659. set darkenOutOfFocus(value: number);
  138660. /**
  138661. * Gets or sets a boolean indicating if blur noise is enabled
  138662. */
  138663. get blurNoise(): boolean;
  138664. set blurNoise(value: boolean);
  138665. /**
  138666. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138667. */
  138668. get pentagonBokeh(): boolean;
  138669. set pentagonBokeh(value: boolean);
  138670. /**
  138671. * Gets or sets the highlight grain amount
  138672. */
  138673. get highlightsGain(): number;
  138674. set highlightsGain(value: number);
  138675. /**
  138676. * Gets or sets the highlight threshold
  138677. */
  138678. get highlightsThreshold(): number;
  138679. set highlightsThreshold(value: number);
  138680. /**
  138681. * Sets the amount of blur at the edges
  138682. * @param amount blur amount
  138683. */
  138684. setEdgeBlur(amount: number): void;
  138685. /**
  138686. * Sets edge blur to 0
  138687. */
  138688. disableEdgeBlur(): void;
  138689. /**
  138690. * Sets the amout of grain
  138691. * @param amount Amount of grain
  138692. */
  138693. setGrainAmount(amount: number): void;
  138694. /**
  138695. * Set grain amount to 0
  138696. */
  138697. disableGrain(): void;
  138698. /**
  138699. * Sets the chromatic aberration amount
  138700. * @param amount amount of chromatic aberration
  138701. */
  138702. setChromaticAberration(amount: number): void;
  138703. /**
  138704. * Sets chromatic aberration amount to 0
  138705. */
  138706. disableChromaticAberration(): void;
  138707. /**
  138708. * Sets the EdgeDistortion amount
  138709. * @param amount amount of EdgeDistortion
  138710. */
  138711. setEdgeDistortion(amount: number): void;
  138712. /**
  138713. * Sets edge distortion to 0
  138714. */
  138715. disableEdgeDistortion(): void;
  138716. /**
  138717. * Sets the FocusDistance amount
  138718. * @param amount amount of FocusDistance
  138719. */
  138720. setFocusDistance(amount: number): void;
  138721. /**
  138722. * Disables depth of field
  138723. */
  138724. disableDepthOfField(): void;
  138725. /**
  138726. * Sets the Aperture amount
  138727. * @param amount amount of Aperture
  138728. */
  138729. setAperture(amount: number): void;
  138730. /**
  138731. * Sets the DarkenOutOfFocus amount
  138732. * @param amount amount of DarkenOutOfFocus
  138733. */
  138734. setDarkenOutOfFocus(amount: number): void;
  138735. private _pentagonBokehIsEnabled;
  138736. /**
  138737. * Creates a pentagon bokeh effect
  138738. */
  138739. enablePentagonBokeh(): void;
  138740. /**
  138741. * Disables the pentagon bokeh effect
  138742. */
  138743. disablePentagonBokeh(): void;
  138744. /**
  138745. * Enables noise blur
  138746. */
  138747. enableNoiseBlur(): void;
  138748. /**
  138749. * Disables noise blur
  138750. */
  138751. disableNoiseBlur(): void;
  138752. /**
  138753. * Sets the HighlightsGain amount
  138754. * @param amount amount of HighlightsGain
  138755. */
  138756. setHighlightsGain(amount: number): void;
  138757. /**
  138758. * Sets the HighlightsThreshold amount
  138759. * @param amount amount of HighlightsThreshold
  138760. */
  138761. setHighlightsThreshold(amount: number): void;
  138762. /**
  138763. * Disables highlights
  138764. */
  138765. disableHighlights(): void;
  138766. /**
  138767. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138768. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138769. */
  138770. dispose(disableDepthRender?: boolean): void;
  138771. private _createChromaticAberrationPostProcess;
  138772. private _createHighlightsPostProcess;
  138773. private _createDepthOfFieldPostProcess;
  138774. private _createGrainTexture;
  138775. }
  138776. }
  138777. declare module BABYLON {
  138778. /** @hidden */
  138779. export var ssao2PixelShader: {
  138780. name: string;
  138781. shader: string;
  138782. };
  138783. }
  138784. declare module BABYLON {
  138785. /** @hidden */
  138786. export var ssaoCombinePixelShader: {
  138787. name: string;
  138788. shader: string;
  138789. };
  138790. }
  138791. declare module BABYLON {
  138792. /**
  138793. * Render pipeline to produce ssao effect
  138794. */
  138795. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138796. /**
  138797. * @ignore
  138798. * The PassPostProcess id in the pipeline that contains the original scene color
  138799. */
  138800. SSAOOriginalSceneColorEffect: string;
  138801. /**
  138802. * @ignore
  138803. * The SSAO PostProcess id in the pipeline
  138804. */
  138805. SSAORenderEffect: string;
  138806. /**
  138807. * @ignore
  138808. * The horizontal blur PostProcess id in the pipeline
  138809. */
  138810. SSAOBlurHRenderEffect: string;
  138811. /**
  138812. * @ignore
  138813. * The vertical blur PostProcess id in the pipeline
  138814. */
  138815. SSAOBlurVRenderEffect: string;
  138816. /**
  138817. * @ignore
  138818. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138819. */
  138820. SSAOCombineRenderEffect: string;
  138821. /**
  138822. * The output strength of the SSAO post-process. Default value is 1.0.
  138823. */
  138824. totalStrength: number;
  138825. /**
  138826. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138827. */
  138828. maxZ: number;
  138829. /**
  138830. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138831. */
  138832. minZAspect: number;
  138833. private _samples;
  138834. /**
  138835. * Number of samples used for the SSAO calculations. Default value is 8
  138836. */
  138837. set samples(n: number);
  138838. get samples(): number;
  138839. private _textureSamples;
  138840. /**
  138841. * Number of samples to use for antialiasing
  138842. */
  138843. set textureSamples(n: number);
  138844. get textureSamples(): number;
  138845. /**
  138846. * Ratio object used for SSAO ratio and blur ratio
  138847. */
  138848. private _ratio;
  138849. /**
  138850. * Dynamically generated sphere sampler.
  138851. */
  138852. private _sampleSphere;
  138853. /**
  138854. * Blur filter offsets
  138855. */
  138856. private _samplerOffsets;
  138857. private _expensiveBlur;
  138858. /**
  138859. * If bilateral blur should be used
  138860. */
  138861. set expensiveBlur(b: boolean);
  138862. get expensiveBlur(): boolean;
  138863. /**
  138864. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138865. */
  138866. radius: number;
  138867. /**
  138868. * The base color of the SSAO post-process
  138869. * The final result is "base + ssao" between [0, 1]
  138870. */
  138871. base: number;
  138872. /**
  138873. * Support test.
  138874. */
  138875. static get IsSupported(): boolean;
  138876. private _scene;
  138877. private _depthTexture;
  138878. private _normalTexture;
  138879. private _randomTexture;
  138880. private _originalColorPostProcess;
  138881. private _ssaoPostProcess;
  138882. private _blurHPostProcess;
  138883. private _blurVPostProcess;
  138884. private _ssaoCombinePostProcess;
  138885. /**
  138886. * Gets active scene
  138887. */
  138888. get scene(): Scene;
  138889. /**
  138890. * @constructor
  138891. * @param name The rendering pipeline name
  138892. * @param scene The scene linked to this pipeline
  138893. * @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 }
  138894. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138895. */
  138896. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138897. /**
  138898. * Get the class name
  138899. * @returns "SSAO2RenderingPipeline"
  138900. */
  138901. getClassName(): string;
  138902. /**
  138903. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138904. */
  138905. dispose(disableGeometryBufferRenderer?: boolean): void;
  138906. private _createBlurPostProcess;
  138907. /** @hidden */
  138908. _rebuild(): void;
  138909. private _bits;
  138910. private _radicalInverse_VdC;
  138911. private _hammersley;
  138912. private _hemisphereSample_uniform;
  138913. private _generateHemisphere;
  138914. private _createSSAOPostProcess;
  138915. private _createSSAOCombinePostProcess;
  138916. private _createRandomTexture;
  138917. /**
  138918. * Serialize the rendering pipeline (Used when exporting)
  138919. * @returns the serialized object
  138920. */
  138921. serialize(): any;
  138922. /**
  138923. * Parse the serialized pipeline
  138924. * @param source Source pipeline.
  138925. * @param scene The scene to load the pipeline to.
  138926. * @param rootUrl The URL of the serialized pipeline.
  138927. * @returns An instantiated pipeline from the serialized object.
  138928. */
  138929. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138930. }
  138931. }
  138932. declare module BABYLON {
  138933. /** @hidden */
  138934. export var ssaoPixelShader: {
  138935. name: string;
  138936. shader: string;
  138937. };
  138938. }
  138939. declare module BABYLON {
  138940. /**
  138941. * Render pipeline to produce ssao effect
  138942. */
  138943. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138944. /**
  138945. * @ignore
  138946. * The PassPostProcess id in the pipeline that contains the original scene color
  138947. */
  138948. SSAOOriginalSceneColorEffect: string;
  138949. /**
  138950. * @ignore
  138951. * The SSAO PostProcess id in the pipeline
  138952. */
  138953. SSAORenderEffect: string;
  138954. /**
  138955. * @ignore
  138956. * The horizontal blur PostProcess id in the pipeline
  138957. */
  138958. SSAOBlurHRenderEffect: string;
  138959. /**
  138960. * @ignore
  138961. * The vertical blur PostProcess id in the pipeline
  138962. */
  138963. SSAOBlurVRenderEffect: string;
  138964. /**
  138965. * @ignore
  138966. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138967. */
  138968. SSAOCombineRenderEffect: string;
  138969. /**
  138970. * The output strength of the SSAO post-process. Default value is 1.0.
  138971. */
  138972. totalStrength: number;
  138973. /**
  138974. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138975. */
  138976. radius: number;
  138977. /**
  138978. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138979. * Must not be equal to fallOff and superior to fallOff.
  138980. * Default value is 0.0075
  138981. */
  138982. area: number;
  138983. /**
  138984. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138985. * Must not be equal to area and inferior to area.
  138986. * Default value is 0.000001
  138987. */
  138988. fallOff: number;
  138989. /**
  138990. * The base color of the SSAO post-process
  138991. * The final result is "base + ssao" between [0, 1]
  138992. */
  138993. base: number;
  138994. private _scene;
  138995. private _depthTexture;
  138996. private _randomTexture;
  138997. private _originalColorPostProcess;
  138998. private _ssaoPostProcess;
  138999. private _blurHPostProcess;
  139000. private _blurVPostProcess;
  139001. private _ssaoCombinePostProcess;
  139002. private _firstUpdate;
  139003. /**
  139004. * Gets active scene
  139005. */
  139006. get scene(): Scene;
  139007. /**
  139008. * @constructor
  139009. * @param name - The rendering pipeline name
  139010. * @param scene - The scene linked to this pipeline
  139011. * @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 }
  139012. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139013. */
  139014. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139015. /**
  139016. * Get the class name
  139017. * @returns "SSAORenderingPipeline"
  139018. */
  139019. getClassName(): string;
  139020. /**
  139021. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139022. */
  139023. dispose(disableDepthRender?: boolean): void;
  139024. private _createBlurPostProcess;
  139025. /** @hidden */
  139026. _rebuild(): void;
  139027. private _createSSAOPostProcess;
  139028. private _createSSAOCombinePostProcess;
  139029. private _createRandomTexture;
  139030. }
  139031. }
  139032. declare module BABYLON {
  139033. /** @hidden */
  139034. export var screenSpaceReflectionPixelShader: {
  139035. name: string;
  139036. shader: string;
  139037. };
  139038. }
  139039. declare module BABYLON {
  139040. /**
  139041. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139042. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139043. */
  139044. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139045. /**
  139046. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139047. */
  139048. threshold: number;
  139049. /**
  139050. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139051. */
  139052. strength: number;
  139053. /**
  139054. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139055. */
  139056. reflectionSpecularFalloffExponent: number;
  139057. /**
  139058. * 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]
  139059. */
  139060. step: number;
  139061. /**
  139062. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139063. */
  139064. roughnessFactor: number;
  139065. private _geometryBufferRenderer;
  139066. private _enableSmoothReflections;
  139067. private _reflectionSamples;
  139068. private _smoothSteps;
  139069. /**
  139070. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139071. * @param name The name of the effect.
  139072. * @param scene The scene containing the objects to calculate reflections.
  139073. * @param options The required width/height ratio to downsize to before computing the render pass.
  139074. * @param camera The camera to apply the render pass to.
  139075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139076. * @param engine The engine which the post process will be applied. (default: current engine)
  139077. * @param reusable If the post process can be reused on the same frame. (default: false)
  139078. * @param textureType Type of textures used when performing the post process. (default: 0)
  139079. * @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)
  139080. */
  139081. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139082. /**
  139083. * Gets wether or not smoothing reflections is enabled.
  139084. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139085. */
  139086. get enableSmoothReflections(): boolean;
  139087. /**
  139088. * Sets wether or not smoothing reflections is enabled.
  139089. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139090. */
  139091. set enableSmoothReflections(enabled: boolean);
  139092. /**
  139093. * Gets the number of samples taken while computing reflections. More samples count is high,
  139094. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139095. */
  139096. get reflectionSamples(): number;
  139097. /**
  139098. * Sets the number of samples taken while computing reflections. More samples count is high,
  139099. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139100. */
  139101. set reflectionSamples(samples: number);
  139102. /**
  139103. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139104. * more the post-process will require GPU power and can generate a drop in FPS.
  139105. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139106. */
  139107. get smoothSteps(): number;
  139108. set smoothSteps(steps: number);
  139109. private _updateEffectDefines;
  139110. }
  139111. }
  139112. declare module BABYLON {
  139113. /** @hidden */
  139114. export var standardPixelShader: {
  139115. name: string;
  139116. shader: string;
  139117. };
  139118. }
  139119. declare module BABYLON {
  139120. /**
  139121. * Standard rendering pipeline
  139122. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139123. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139124. */
  139125. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139126. /**
  139127. * Public members
  139128. */
  139129. /**
  139130. * Post-process which contains the original scene color before the pipeline applies all the effects
  139131. */
  139132. originalPostProcess: Nullable<PostProcess>;
  139133. /**
  139134. * Post-process used to down scale an image x4
  139135. */
  139136. downSampleX4PostProcess: Nullable<PostProcess>;
  139137. /**
  139138. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139139. */
  139140. brightPassPostProcess: Nullable<PostProcess>;
  139141. /**
  139142. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139143. */
  139144. blurHPostProcesses: PostProcess[];
  139145. /**
  139146. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139147. */
  139148. blurVPostProcesses: PostProcess[];
  139149. /**
  139150. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139151. */
  139152. textureAdderPostProcess: Nullable<PostProcess>;
  139153. /**
  139154. * Post-process used to create volumetric lighting effect
  139155. */
  139156. volumetricLightPostProcess: Nullable<PostProcess>;
  139157. /**
  139158. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139159. */
  139160. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139161. /**
  139162. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139163. */
  139164. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139165. /**
  139166. * Post-process used to merge the volumetric light effect and the real scene color
  139167. */
  139168. volumetricLightMergePostProces: Nullable<PostProcess>;
  139169. /**
  139170. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139171. */
  139172. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139173. /**
  139174. * Base post-process used to calculate the average luminance of the final image for HDR
  139175. */
  139176. luminancePostProcess: Nullable<PostProcess>;
  139177. /**
  139178. * Post-processes used to create down sample post-processes in order to get
  139179. * the average luminance of the final image for HDR
  139180. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139181. */
  139182. luminanceDownSamplePostProcesses: PostProcess[];
  139183. /**
  139184. * Post-process used to create a HDR effect (light adaptation)
  139185. */
  139186. hdrPostProcess: Nullable<PostProcess>;
  139187. /**
  139188. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139189. */
  139190. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139191. /**
  139192. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139193. */
  139194. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139195. /**
  139196. * Post-process used to merge the final HDR post-process and the real scene color
  139197. */
  139198. hdrFinalPostProcess: Nullable<PostProcess>;
  139199. /**
  139200. * Post-process used to create a lens flare effect
  139201. */
  139202. lensFlarePostProcess: Nullable<PostProcess>;
  139203. /**
  139204. * Post-process that merges the result of the lens flare post-process and the real scene color
  139205. */
  139206. lensFlareComposePostProcess: Nullable<PostProcess>;
  139207. /**
  139208. * Post-process used to create a motion blur effect
  139209. */
  139210. motionBlurPostProcess: Nullable<PostProcess>;
  139211. /**
  139212. * Post-process used to create a depth of field effect
  139213. */
  139214. depthOfFieldPostProcess: Nullable<PostProcess>;
  139215. /**
  139216. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139217. */
  139218. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139219. /**
  139220. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139221. */
  139222. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139223. /**
  139224. * Represents the brightness threshold in order to configure the illuminated surfaces
  139225. */
  139226. brightThreshold: number;
  139227. /**
  139228. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139229. */
  139230. blurWidth: number;
  139231. /**
  139232. * Sets if the blur for highlighted surfaces must be only horizontal
  139233. */
  139234. horizontalBlur: boolean;
  139235. /**
  139236. * Gets the overall exposure used by the pipeline
  139237. */
  139238. get exposure(): number;
  139239. /**
  139240. * Sets the overall exposure used by the pipeline
  139241. */
  139242. set exposure(value: number);
  139243. /**
  139244. * Texture used typically to simulate "dirty" on camera lens
  139245. */
  139246. lensTexture: Nullable<Texture>;
  139247. /**
  139248. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139249. */
  139250. volumetricLightCoefficient: number;
  139251. /**
  139252. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139253. */
  139254. volumetricLightPower: number;
  139255. /**
  139256. * Used the set the blur intensity to smooth the volumetric lights
  139257. */
  139258. volumetricLightBlurScale: number;
  139259. /**
  139260. * Light (spot or directional) used to generate the volumetric lights rays
  139261. * The source light must have a shadow generate so the pipeline can get its
  139262. * depth map
  139263. */
  139264. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139265. /**
  139266. * For eye adaptation, represents the minimum luminance the eye can see
  139267. */
  139268. hdrMinimumLuminance: number;
  139269. /**
  139270. * For eye adaptation, represents the decrease luminance speed
  139271. */
  139272. hdrDecreaseRate: number;
  139273. /**
  139274. * For eye adaptation, represents the increase luminance speed
  139275. */
  139276. hdrIncreaseRate: number;
  139277. /**
  139278. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139279. */
  139280. get hdrAutoExposure(): boolean;
  139281. /**
  139282. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139283. */
  139284. set hdrAutoExposure(value: boolean);
  139285. /**
  139286. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139287. */
  139288. lensColorTexture: Nullable<Texture>;
  139289. /**
  139290. * The overall strengh for the lens flare effect
  139291. */
  139292. lensFlareStrength: number;
  139293. /**
  139294. * Dispersion coefficient for lens flare ghosts
  139295. */
  139296. lensFlareGhostDispersal: number;
  139297. /**
  139298. * Main lens flare halo width
  139299. */
  139300. lensFlareHaloWidth: number;
  139301. /**
  139302. * Based on the lens distortion effect, defines how much the lens flare result
  139303. * is distorted
  139304. */
  139305. lensFlareDistortionStrength: number;
  139306. /**
  139307. * Configures the blur intensity used for for lens flare (halo)
  139308. */
  139309. lensFlareBlurWidth: number;
  139310. /**
  139311. * Lens star texture must be used to simulate rays on the flares and is available
  139312. * in the documentation
  139313. */
  139314. lensStarTexture: Nullable<Texture>;
  139315. /**
  139316. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139317. * flare effect by taking account of the dirt texture
  139318. */
  139319. lensFlareDirtTexture: Nullable<Texture>;
  139320. /**
  139321. * Represents the focal length for the depth of field effect
  139322. */
  139323. depthOfFieldDistance: number;
  139324. /**
  139325. * Represents the blur intensity for the blurred part of the depth of field effect
  139326. */
  139327. depthOfFieldBlurWidth: number;
  139328. /**
  139329. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139330. */
  139331. get motionStrength(): number;
  139332. /**
  139333. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139334. */
  139335. set motionStrength(strength: number);
  139336. /**
  139337. * Gets wether or not the motion blur post-process is object based or screen based.
  139338. */
  139339. get objectBasedMotionBlur(): boolean;
  139340. /**
  139341. * Sets wether or not the motion blur post-process should be object based or screen based
  139342. */
  139343. set objectBasedMotionBlur(value: boolean);
  139344. /**
  139345. * List of animations for the pipeline (IAnimatable implementation)
  139346. */
  139347. animations: Animation[];
  139348. /**
  139349. * Private members
  139350. */
  139351. private _scene;
  139352. private _currentDepthOfFieldSource;
  139353. private _basePostProcess;
  139354. private _fixedExposure;
  139355. private _currentExposure;
  139356. private _hdrAutoExposure;
  139357. private _hdrCurrentLuminance;
  139358. private _motionStrength;
  139359. private _isObjectBasedMotionBlur;
  139360. private _floatTextureType;
  139361. private _camerasToBeAttached;
  139362. private _ratio;
  139363. private _bloomEnabled;
  139364. private _depthOfFieldEnabled;
  139365. private _vlsEnabled;
  139366. private _lensFlareEnabled;
  139367. private _hdrEnabled;
  139368. private _motionBlurEnabled;
  139369. private _fxaaEnabled;
  139370. private _screenSpaceReflectionsEnabled;
  139371. private _motionBlurSamples;
  139372. private _volumetricLightStepsCount;
  139373. private _samples;
  139374. /**
  139375. * @ignore
  139376. * Specifies if the bloom pipeline is enabled
  139377. */
  139378. get BloomEnabled(): boolean;
  139379. set BloomEnabled(enabled: boolean);
  139380. /**
  139381. * @ignore
  139382. * Specifies if the depth of field pipeline is enabed
  139383. */
  139384. get DepthOfFieldEnabled(): boolean;
  139385. set DepthOfFieldEnabled(enabled: boolean);
  139386. /**
  139387. * @ignore
  139388. * Specifies if the lens flare pipeline is enabed
  139389. */
  139390. get LensFlareEnabled(): boolean;
  139391. set LensFlareEnabled(enabled: boolean);
  139392. /**
  139393. * @ignore
  139394. * Specifies if the HDR pipeline is enabled
  139395. */
  139396. get HDREnabled(): boolean;
  139397. set HDREnabled(enabled: boolean);
  139398. /**
  139399. * @ignore
  139400. * Specifies if the volumetric lights scattering effect is enabled
  139401. */
  139402. get VLSEnabled(): boolean;
  139403. set VLSEnabled(enabled: boolean);
  139404. /**
  139405. * @ignore
  139406. * Specifies if the motion blur effect is enabled
  139407. */
  139408. get MotionBlurEnabled(): boolean;
  139409. set MotionBlurEnabled(enabled: boolean);
  139410. /**
  139411. * Specifies if anti-aliasing is enabled
  139412. */
  139413. get fxaaEnabled(): boolean;
  139414. set fxaaEnabled(enabled: boolean);
  139415. /**
  139416. * Specifies if screen space reflections are enabled.
  139417. */
  139418. get screenSpaceReflectionsEnabled(): boolean;
  139419. set screenSpaceReflectionsEnabled(enabled: boolean);
  139420. /**
  139421. * Specifies the number of steps used to calculate the volumetric lights
  139422. * Typically in interval [50, 200]
  139423. */
  139424. get volumetricLightStepsCount(): number;
  139425. set volumetricLightStepsCount(count: number);
  139426. /**
  139427. * Specifies the number of samples used for the motion blur effect
  139428. * Typically in interval [16, 64]
  139429. */
  139430. get motionBlurSamples(): number;
  139431. set motionBlurSamples(samples: number);
  139432. /**
  139433. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139434. */
  139435. get samples(): number;
  139436. set samples(sampleCount: number);
  139437. /**
  139438. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139439. * @constructor
  139440. * @param name The rendering pipeline name
  139441. * @param scene The scene linked to this pipeline
  139442. * @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)
  139443. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139444. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139445. */
  139446. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139447. private _buildPipeline;
  139448. private _createDownSampleX4PostProcess;
  139449. private _createBrightPassPostProcess;
  139450. private _createBlurPostProcesses;
  139451. private _createTextureAdderPostProcess;
  139452. private _createVolumetricLightPostProcess;
  139453. private _createLuminancePostProcesses;
  139454. private _createHdrPostProcess;
  139455. private _createLensFlarePostProcess;
  139456. private _createDepthOfFieldPostProcess;
  139457. private _createMotionBlurPostProcess;
  139458. private _getDepthTexture;
  139459. private _disposePostProcesses;
  139460. /**
  139461. * Dispose of the pipeline and stop all post processes
  139462. */
  139463. dispose(): void;
  139464. /**
  139465. * Serialize the rendering pipeline (Used when exporting)
  139466. * @returns the serialized object
  139467. */
  139468. serialize(): any;
  139469. /**
  139470. * Parse the serialized pipeline
  139471. * @param source Source pipeline.
  139472. * @param scene The scene to load the pipeline to.
  139473. * @param rootUrl The URL of the serialized pipeline.
  139474. * @returns An instantiated pipeline from the serialized object.
  139475. */
  139476. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139477. /**
  139478. * Luminance steps
  139479. */
  139480. static LuminanceSteps: number;
  139481. }
  139482. }
  139483. declare module BABYLON {
  139484. /** @hidden */
  139485. export var tonemapPixelShader: {
  139486. name: string;
  139487. shader: string;
  139488. };
  139489. }
  139490. declare module BABYLON {
  139491. /** Defines operator used for tonemapping */
  139492. export enum TonemappingOperator {
  139493. /** Hable */
  139494. Hable = 0,
  139495. /** Reinhard */
  139496. Reinhard = 1,
  139497. /** HejiDawson */
  139498. HejiDawson = 2,
  139499. /** Photographic */
  139500. Photographic = 3
  139501. }
  139502. /**
  139503. * Defines a post process to apply tone mapping
  139504. */
  139505. export class TonemapPostProcess extends PostProcess {
  139506. private _operator;
  139507. /** Defines the required exposure adjustement */
  139508. exposureAdjustment: number;
  139509. /**
  139510. * Creates a new TonemapPostProcess
  139511. * @param name defines the name of the postprocess
  139512. * @param _operator defines the operator to use
  139513. * @param exposureAdjustment defines the required exposure adjustement
  139514. * @param camera defines the camera to use (can be null)
  139515. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139516. * @param engine defines the hosting engine (can be ignore if camera is set)
  139517. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139518. */
  139519. constructor(name: string, _operator: TonemappingOperator,
  139520. /** Defines the required exposure adjustement */
  139521. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139522. }
  139523. }
  139524. declare module BABYLON {
  139525. /** @hidden */
  139526. export var volumetricLightScatteringPixelShader: {
  139527. name: string;
  139528. shader: string;
  139529. };
  139530. }
  139531. declare module BABYLON {
  139532. /** @hidden */
  139533. export var volumetricLightScatteringPassVertexShader: {
  139534. name: string;
  139535. shader: string;
  139536. };
  139537. }
  139538. declare module BABYLON {
  139539. /** @hidden */
  139540. export var volumetricLightScatteringPassPixelShader: {
  139541. name: string;
  139542. shader: string;
  139543. };
  139544. }
  139545. declare module BABYLON {
  139546. /**
  139547. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139548. */
  139549. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139550. private _volumetricLightScatteringPass;
  139551. private _volumetricLightScatteringRTT;
  139552. private _viewPort;
  139553. private _screenCoordinates;
  139554. private _cachedDefines;
  139555. /**
  139556. * If not undefined, the mesh position is computed from the attached node position
  139557. */
  139558. attachedNode: {
  139559. position: Vector3;
  139560. };
  139561. /**
  139562. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139563. */
  139564. customMeshPosition: Vector3;
  139565. /**
  139566. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139567. */
  139568. useCustomMeshPosition: boolean;
  139569. /**
  139570. * If the post-process should inverse the light scattering direction
  139571. */
  139572. invert: boolean;
  139573. /**
  139574. * The internal mesh used by the post-process
  139575. */
  139576. mesh: Mesh;
  139577. /**
  139578. * @hidden
  139579. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139580. */
  139581. get useDiffuseColor(): boolean;
  139582. set useDiffuseColor(useDiffuseColor: boolean);
  139583. /**
  139584. * Array containing the excluded meshes not rendered in the internal pass
  139585. */
  139586. excludedMeshes: AbstractMesh[];
  139587. /**
  139588. * Controls the overall intensity of the post-process
  139589. */
  139590. exposure: number;
  139591. /**
  139592. * Dissipates each sample's contribution in range [0, 1]
  139593. */
  139594. decay: number;
  139595. /**
  139596. * Controls the overall intensity of each sample
  139597. */
  139598. weight: number;
  139599. /**
  139600. * Controls the density of each sample
  139601. */
  139602. density: number;
  139603. /**
  139604. * @constructor
  139605. * @param name The post-process name
  139606. * @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)
  139607. * @param camera The camera that the post-process will be attached to
  139608. * @param mesh The mesh used to create the light scattering
  139609. * @param samples The post-process quality, default 100
  139610. * @param samplingModeThe post-process filtering mode
  139611. * @param engine The babylon engine
  139612. * @param reusable If the post-process is reusable
  139613. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139614. */
  139615. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139616. /**
  139617. * Returns the string "VolumetricLightScatteringPostProcess"
  139618. * @returns "VolumetricLightScatteringPostProcess"
  139619. */
  139620. getClassName(): string;
  139621. private _isReady;
  139622. /**
  139623. * Sets the new light position for light scattering effect
  139624. * @param position The new custom light position
  139625. */
  139626. setCustomMeshPosition(position: Vector3): void;
  139627. /**
  139628. * Returns the light position for light scattering effect
  139629. * @return Vector3 The custom light position
  139630. */
  139631. getCustomMeshPosition(): Vector3;
  139632. /**
  139633. * Disposes the internal assets and detaches the post-process from the camera
  139634. */
  139635. dispose(camera: Camera): void;
  139636. /**
  139637. * Returns the render target texture used by the post-process
  139638. * @return the render target texture used by the post-process
  139639. */
  139640. getPass(): RenderTargetTexture;
  139641. private _meshExcluded;
  139642. private _createPass;
  139643. private _updateMeshScreenCoordinates;
  139644. /**
  139645. * Creates a default mesh for the Volumeric Light Scattering post-process
  139646. * @param name The mesh name
  139647. * @param scene The scene where to create the mesh
  139648. * @return the default mesh
  139649. */
  139650. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139651. }
  139652. }
  139653. declare module BABYLON {
  139654. interface Scene {
  139655. /** @hidden (Backing field) */
  139656. _boundingBoxRenderer: BoundingBoxRenderer;
  139657. /** @hidden (Backing field) */
  139658. _forceShowBoundingBoxes: boolean;
  139659. /**
  139660. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139661. */
  139662. forceShowBoundingBoxes: boolean;
  139663. /**
  139664. * Gets the bounding box renderer associated with the scene
  139665. * @returns a BoundingBoxRenderer
  139666. */
  139667. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139668. }
  139669. interface AbstractMesh {
  139670. /** @hidden (Backing field) */
  139671. _showBoundingBox: boolean;
  139672. /**
  139673. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139674. */
  139675. showBoundingBox: boolean;
  139676. }
  139677. /**
  139678. * Component responsible of rendering the bounding box of the meshes in a scene.
  139679. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139680. */
  139681. export class BoundingBoxRenderer implements ISceneComponent {
  139682. /**
  139683. * The component name helpfull to identify the component in the list of scene components.
  139684. */
  139685. readonly name: string;
  139686. /**
  139687. * The scene the component belongs to.
  139688. */
  139689. scene: Scene;
  139690. /**
  139691. * Color of the bounding box lines placed in front of an object
  139692. */
  139693. frontColor: Color3;
  139694. /**
  139695. * Color of the bounding box lines placed behind an object
  139696. */
  139697. backColor: Color3;
  139698. /**
  139699. * Defines if the renderer should show the back lines or not
  139700. */
  139701. showBackLines: boolean;
  139702. /**
  139703. * @hidden
  139704. */
  139705. renderList: SmartArray<BoundingBox>;
  139706. private _colorShader;
  139707. private _vertexBuffers;
  139708. private _indexBuffer;
  139709. private _fillIndexBuffer;
  139710. private _fillIndexData;
  139711. /**
  139712. * Instantiates a new bounding box renderer in a scene.
  139713. * @param scene the scene the renderer renders in
  139714. */
  139715. constructor(scene: Scene);
  139716. /**
  139717. * Registers the component in a given scene
  139718. */
  139719. register(): void;
  139720. private _evaluateSubMesh;
  139721. private _activeMesh;
  139722. private _prepareRessources;
  139723. private _createIndexBuffer;
  139724. /**
  139725. * Rebuilds the elements related to this component in case of
  139726. * context lost for instance.
  139727. */
  139728. rebuild(): void;
  139729. /**
  139730. * @hidden
  139731. */
  139732. reset(): void;
  139733. /**
  139734. * Render the bounding boxes of a specific rendering group
  139735. * @param renderingGroupId defines the rendering group to render
  139736. */
  139737. render(renderingGroupId: number): void;
  139738. /**
  139739. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139740. * @param mesh Define the mesh to render the occlusion bounding box for
  139741. */
  139742. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139743. /**
  139744. * Dispose and release the resources attached to this renderer.
  139745. */
  139746. dispose(): void;
  139747. }
  139748. }
  139749. declare module BABYLON {
  139750. interface Scene {
  139751. /** @hidden (Backing field) */
  139752. _depthRenderer: {
  139753. [id: string]: DepthRenderer;
  139754. };
  139755. /**
  139756. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139757. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139758. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139759. * @returns the created depth renderer
  139760. */
  139761. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139762. /**
  139763. * Disables a depth renderer for a given camera
  139764. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139765. */
  139766. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139767. }
  139768. /**
  139769. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139770. * in several rendering techniques.
  139771. */
  139772. export class DepthRendererSceneComponent implements ISceneComponent {
  139773. /**
  139774. * The component name helpfull to identify the component in the list of scene components.
  139775. */
  139776. readonly name: string;
  139777. /**
  139778. * The scene the component belongs to.
  139779. */
  139780. scene: Scene;
  139781. /**
  139782. * Creates a new instance of the component for the given scene
  139783. * @param scene Defines the scene to register the component in
  139784. */
  139785. constructor(scene: Scene);
  139786. /**
  139787. * Registers the component in a given scene
  139788. */
  139789. register(): void;
  139790. /**
  139791. * Rebuilds the elements related to this component in case of
  139792. * context lost for instance.
  139793. */
  139794. rebuild(): void;
  139795. /**
  139796. * Disposes the component and the associated ressources
  139797. */
  139798. dispose(): void;
  139799. private _gatherRenderTargets;
  139800. private _gatherActiveCameraRenderTargets;
  139801. }
  139802. }
  139803. declare module BABYLON {
  139804. /** @hidden */
  139805. export var outlinePixelShader: {
  139806. name: string;
  139807. shader: string;
  139808. };
  139809. }
  139810. declare module BABYLON {
  139811. /** @hidden */
  139812. export var outlineVertexShader: {
  139813. name: string;
  139814. shader: string;
  139815. };
  139816. }
  139817. declare module BABYLON {
  139818. interface Scene {
  139819. /** @hidden */
  139820. _outlineRenderer: OutlineRenderer;
  139821. /**
  139822. * Gets the outline renderer associated with the scene
  139823. * @returns a OutlineRenderer
  139824. */
  139825. getOutlineRenderer(): OutlineRenderer;
  139826. }
  139827. interface AbstractMesh {
  139828. /** @hidden (Backing field) */
  139829. _renderOutline: boolean;
  139830. /**
  139831. * Gets or sets a boolean indicating if the outline must be rendered as well
  139832. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139833. */
  139834. renderOutline: boolean;
  139835. /** @hidden (Backing field) */
  139836. _renderOverlay: boolean;
  139837. /**
  139838. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139839. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139840. */
  139841. renderOverlay: boolean;
  139842. }
  139843. /**
  139844. * This class is responsible to draw bothe outline/overlay of meshes.
  139845. * It should not be used directly but through the available method on mesh.
  139846. */
  139847. export class OutlineRenderer implements ISceneComponent {
  139848. /**
  139849. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139850. */
  139851. private static _StencilReference;
  139852. /**
  139853. * The name of the component. Each component must have a unique name.
  139854. */
  139855. name: string;
  139856. /**
  139857. * The scene the component belongs to.
  139858. */
  139859. scene: Scene;
  139860. /**
  139861. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139862. */
  139863. zOffset: number;
  139864. private _engine;
  139865. private _effect;
  139866. private _cachedDefines;
  139867. private _savedDepthWrite;
  139868. /**
  139869. * Instantiates a new outline renderer. (There could be only one per scene).
  139870. * @param scene Defines the scene it belongs to
  139871. */
  139872. constructor(scene: Scene);
  139873. /**
  139874. * Register the component to one instance of a scene.
  139875. */
  139876. register(): void;
  139877. /**
  139878. * Rebuilds the elements related to this component in case of
  139879. * context lost for instance.
  139880. */
  139881. rebuild(): void;
  139882. /**
  139883. * Disposes the component and the associated ressources.
  139884. */
  139885. dispose(): void;
  139886. /**
  139887. * Renders the outline in the canvas.
  139888. * @param subMesh Defines the sumesh to render
  139889. * @param batch Defines the batch of meshes in case of instances
  139890. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139891. */
  139892. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139893. /**
  139894. * Returns whether or not the outline renderer is ready for a given submesh.
  139895. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139896. * @param subMesh Defines the submesh to check readyness for
  139897. * @param useInstances Defines wheter wee are trying to render instances or not
  139898. * @returns true if ready otherwise false
  139899. */
  139900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139901. private _beforeRenderingMesh;
  139902. private _afterRenderingMesh;
  139903. }
  139904. }
  139905. declare module BABYLON {
  139906. /**
  139907. * Defines the basic options interface of a Sprite Frame Source Size.
  139908. */
  139909. export interface ISpriteJSONSpriteSourceSize {
  139910. /**
  139911. * number of the original width of the Frame
  139912. */
  139913. w: number;
  139914. /**
  139915. * number of the original height of the Frame
  139916. */
  139917. h: number;
  139918. }
  139919. /**
  139920. * Defines the basic options interface of a Sprite Frame Data.
  139921. */
  139922. export interface ISpriteJSONSpriteFrameData {
  139923. /**
  139924. * number of the x offset of the Frame
  139925. */
  139926. x: number;
  139927. /**
  139928. * number of the y offset of the Frame
  139929. */
  139930. y: number;
  139931. /**
  139932. * number of the width of the Frame
  139933. */
  139934. w: number;
  139935. /**
  139936. * number of the height of the Frame
  139937. */
  139938. h: number;
  139939. }
  139940. /**
  139941. * Defines the basic options interface of a JSON Sprite.
  139942. */
  139943. export interface ISpriteJSONSprite {
  139944. /**
  139945. * string name of the Frame
  139946. */
  139947. filename: string;
  139948. /**
  139949. * ISpriteJSONSpriteFrame basic object of the frame data
  139950. */
  139951. frame: ISpriteJSONSpriteFrameData;
  139952. /**
  139953. * boolean to flag is the frame was rotated.
  139954. */
  139955. rotated: boolean;
  139956. /**
  139957. * boolean to flag is the frame was trimmed.
  139958. */
  139959. trimmed: boolean;
  139960. /**
  139961. * ISpriteJSONSpriteFrame basic object of the source data
  139962. */
  139963. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139964. /**
  139965. * ISpriteJSONSpriteFrame basic object of the source data
  139966. */
  139967. sourceSize: ISpriteJSONSpriteSourceSize;
  139968. }
  139969. /**
  139970. * Defines the basic options interface of a JSON atlas.
  139971. */
  139972. export interface ISpriteJSONAtlas {
  139973. /**
  139974. * Array of objects that contain the frame data.
  139975. */
  139976. frames: Array<ISpriteJSONSprite>;
  139977. /**
  139978. * object basic object containing the sprite meta data.
  139979. */
  139980. meta?: object;
  139981. }
  139982. }
  139983. declare module BABYLON {
  139984. /** @hidden */
  139985. export var spriteMapPixelShader: {
  139986. name: string;
  139987. shader: string;
  139988. };
  139989. }
  139990. declare module BABYLON {
  139991. /** @hidden */
  139992. export var spriteMapVertexShader: {
  139993. name: string;
  139994. shader: string;
  139995. };
  139996. }
  139997. declare module BABYLON {
  139998. /**
  139999. * Defines the basic options interface of a SpriteMap
  140000. */
  140001. export interface ISpriteMapOptions {
  140002. /**
  140003. * Vector2 of the number of cells in the grid.
  140004. */
  140005. stageSize?: Vector2;
  140006. /**
  140007. * Vector2 of the size of the output plane in World Units.
  140008. */
  140009. outputSize?: Vector2;
  140010. /**
  140011. * Vector3 of the position of the output plane in World Units.
  140012. */
  140013. outputPosition?: Vector3;
  140014. /**
  140015. * Vector3 of the rotation of the output plane.
  140016. */
  140017. outputRotation?: Vector3;
  140018. /**
  140019. * number of layers that the system will reserve in resources.
  140020. */
  140021. layerCount?: number;
  140022. /**
  140023. * number of max animation frames a single cell will reserve in resources.
  140024. */
  140025. maxAnimationFrames?: number;
  140026. /**
  140027. * number cell index of the base tile when the system compiles.
  140028. */
  140029. baseTile?: number;
  140030. /**
  140031. * boolean flip the sprite after its been repositioned by the framing data.
  140032. */
  140033. flipU?: boolean;
  140034. /**
  140035. * Vector3 scalar of the global RGB values of the SpriteMap.
  140036. */
  140037. colorMultiply?: Vector3;
  140038. }
  140039. /**
  140040. * Defines the IDisposable interface in order to be cleanable from resources.
  140041. */
  140042. export interface ISpriteMap extends IDisposable {
  140043. /**
  140044. * String name of the SpriteMap.
  140045. */
  140046. name: string;
  140047. /**
  140048. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140049. */
  140050. atlasJSON: ISpriteJSONAtlas;
  140051. /**
  140052. * Texture of the SpriteMap.
  140053. */
  140054. spriteSheet: Texture;
  140055. /**
  140056. * The parameters to initialize the SpriteMap with.
  140057. */
  140058. options: ISpriteMapOptions;
  140059. }
  140060. /**
  140061. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140062. */
  140063. export class SpriteMap implements ISpriteMap {
  140064. /** The Name of the spriteMap */
  140065. name: string;
  140066. /** The JSON file with the frame and meta data */
  140067. atlasJSON: ISpriteJSONAtlas;
  140068. /** The systems Sprite Sheet Texture */
  140069. spriteSheet: Texture;
  140070. /** Arguments passed with the Constructor */
  140071. options: ISpriteMapOptions;
  140072. /** Public Sprite Storage array, parsed from atlasJSON */
  140073. sprites: Array<ISpriteJSONSprite>;
  140074. /** Returns the Number of Sprites in the System */
  140075. get spriteCount(): number;
  140076. /** Returns the Position of Output Plane*/
  140077. get position(): Vector3;
  140078. /** Returns the Position of Output Plane*/
  140079. set position(v: Vector3);
  140080. /** Returns the Rotation of Output Plane*/
  140081. get rotation(): Vector3;
  140082. /** Returns the Rotation of Output Plane*/
  140083. set rotation(v: Vector3);
  140084. /** Sets the AnimationMap*/
  140085. get animationMap(): RawTexture;
  140086. /** Sets the AnimationMap*/
  140087. set animationMap(v: RawTexture);
  140088. /** Scene that the SpriteMap was created in */
  140089. private _scene;
  140090. /** Texture Buffer of Float32 that holds tile frame data*/
  140091. private _frameMap;
  140092. /** Texture Buffers of Float32 that holds tileMap data*/
  140093. private _tileMaps;
  140094. /** Texture Buffer of Float32 that holds Animation Data*/
  140095. private _animationMap;
  140096. /** Custom ShaderMaterial Central to the System*/
  140097. private _material;
  140098. /** Custom ShaderMaterial Central to the System*/
  140099. private _output;
  140100. /** Systems Time Ticker*/
  140101. private _time;
  140102. /**
  140103. * Creates a new SpriteMap
  140104. * @param name defines the SpriteMaps Name
  140105. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140106. * @param spriteSheet is the Texture that the Sprites are on.
  140107. * @param options a basic deployment configuration
  140108. * @param scene The Scene that the map is deployed on
  140109. */
  140110. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140111. /**
  140112. * Returns tileID location
  140113. * @returns Vector2 the cell position ID
  140114. */
  140115. getTileID(): Vector2;
  140116. /**
  140117. * Gets the UV location of the mouse over the SpriteMap.
  140118. * @returns Vector2 the UV position of the mouse interaction
  140119. */
  140120. getMousePosition(): Vector2;
  140121. /**
  140122. * Creates the "frame" texture Buffer
  140123. * -------------------------------------
  140124. * Structure of frames
  140125. * "filename": "Falling-Water-2.png",
  140126. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140127. * "rotated": true,
  140128. * "trimmed": true,
  140129. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140130. * "sourceSize": {"w":32,"h":32}
  140131. * @returns RawTexture of the frameMap
  140132. */
  140133. private _createFrameBuffer;
  140134. /**
  140135. * Creates the tileMap texture Buffer
  140136. * @param buffer normally and array of numbers, or a false to generate from scratch
  140137. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140138. * @returns RawTexture of the tileMap
  140139. */
  140140. private _createTileBuffer;
  140141. /**
  140142. * Modifies the data of the tileMaps
  140143. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140144. * @param pos is the iVector2 Coordinates of the Tile
  140145. * @param tile The SpriteIndex of the new Tile
  140146. */
  140147. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140148. /**
  140149. * Creates the animationMap texture Buffer
  140150. * @param buffer normally and array of numbers, or a false to generate from scratch
  140151. * @returns RawTexture of the animationMap
  140152. */
  140153. private _createTileAnimationBuffer;
  140154. /**
  140155. * Modifies the data of the animationMap
  140156. * @param cellID is the Index of the Sprite
  140157. * @param _frame is the target Animation frame
  140158. * @param toCell is the Target Index of the next frame of the animation
  140159. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140160. * @param speed is a global scalar of the time variable on the map.
  140161. */
  140162. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140163. /**
  140164. * Exports the .tilemaps file
  140165. */
  140166. saveTileMaps(): void;
  140167. /**
  140168. * Imports the .tilemaps file
  140169. * @param url of the .tilemaps file
  140170. */
  140171. loadTileMaps(url: string): void;
  140172. /**
  140173. * Release associated resources
  140174. */
  140175. dispose(): void;
  140176. }
  140177. }
  140178. declare module BABYLON {
  140179. /**
  140180. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140181. * @see http://doc.babylonjs.com/babylon101/sprites
  140182. */
  140183. export class SpritePackedManager extends SpriteManager {
  140184. /** defines the packed manager's name */
  140185. name: string;
  140186. /**
  140187. * Creates a new sprite manager from a packed sprite sheet
  140188. * @param name defines the manager's name
  140189. * @param imgUrl defines the sprite sheet url
  140190. * @param capacity defines the maximum allowed number of sprites
  140191. * @param scene defines the hosting scene
  140192. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140193. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140194. * @param samplingMode defines the smapling mode to use with spritesheet
  140195. * @param fromPacked set to true; do not alter
  140196. */
  140197. constructor(
  140198. /** defines the packed manager's name */
  140199. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140200. }
  140201. }
  140202. declare module BABYLON {
  140203. /**
  140204. * Defines the list of states available for a task inside a AssetsManager
  140205. */
  140206. export enum AssetTaskState {
  140207. /**
  140208. * Initialization
  140209. */
  140210. INIT = 0,
  140211. /**
  140212. * Running
  140213. */
  140214. RUNNING = 1,
  140215. /**
  140216. * Done
  140217. */
  140218. DONE = 2,
  140219. /**
  140220. * Error
  140221. */
  140222. ERROR = 3
  140223. }
  140224. /**
  140225. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140226. */
  140227. export abstract class AbstractAssetTask {
  140228. /**
  140229. * Task name
  140230. */ name: string;
  140231. /**
  140232. * Callback called when the task is successful
  140233. */
  140234. onSuccess: (task: any) => void;
  140235. /**
  140236. * Callback called when the task is not successful
  140237. */
  140238. onError: (task: any, message?: string, exception?: any) => void;
  140239. /**
  140240. * Creates a new AssetsManager
  140241. * @param name defines the name of the task
  140242. */
  140243. constructor(
  140244. /**
  140245. * Task name
  140246. */ name: string);
  140247. private _isCompleted;
  140248. private _taskState;
  140249. private _errorObject;
  140250. /**
  140251. * Get if the task is completed
  140252. */
  140253. get isCompleted(): boolean;
  140254. /**
  140255. * Gets the current state of the task
  140256. */
  140257. get taskState(): AssetTaskState;
  140258. /**
  140259. * Gets the current error object (if task is in error)
  140260. */
  140261. get errorObject(): {
  140262. message?: string;
  140263. exception?: any;
  140264. };
  140265. /**
  140266. * Internal only
  140267. * @hidden
  140268. */
  140269. _setErrorObject(message?: string, exception?: any): void;
  140270. /**
  140271. * Execute the current task
  140272. * @param scene defines the scene where you want your assets to be loaded
  140273. * @param onSuccess is a callback called when the task is successfully executed
  140274. * @param onError is a callback called if an error occurs
  140275. */
  140276. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140277. /**
  140278. * Execute the current task
  140279. * @param scene defines the scene where you want your assets to be loaded
  140280. * @param onSuccess is a callback called when the task is successfully executed
  140281. * @param onError is a callback called if an error occurs
  140282. */
  140283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140284. /**
  140285. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140286. * This can be used with failed tasks that have the reason for failure fixed.
  140287. */
  140288. reset(): void;
  140289. private onErrorCallback;
  140290. private onDoneCallback;
  140291. }
  140292. /**
  140293. * Define the interface used by progress events raised during assets loading
  140294. */
  140295. export interface IAssetsProgressEvent {
  140296. /**
  140297. * Defines the number of remaining tasks to process
  140298. */
  140299. remainingCount: number;
  140300. /**
  140301. * Defines the total number of tasks
  140302. */
  140303. totalCount: number;
  140304. /**
  140305. * Defines the task that was just processed
  140306. */
  140307. task: AbstractAssetTask;
  140308. }
  140309. /**
  140310. * Class used to share progress information about assets loading
  140311. */
  140312. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140313. /**
  140314. * Defines the number of remaining tasks to process
  140315. */
  140316. remainingCount: number;
  140317. /**
  140318. * Defines the total number of tasks
  140319. */
  140320. totalCount: number;
  140321. /**
  140322. * Defines the task that was just processed
  140323. */
  140324. task: AbstractAssetTask;
  140325. /**
  140326. * Creates a AssetsProgressEvent
  140327. * @param remainingCount defines the number of remaining tasks to process
  140328. * @param totalCount defines the total number of tasks
  140329. * @param task defines the task that was just processed
  140330. */
  140331. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140332. }
  140333. /**
  140334. * Define a task used by AssetsManager to load meshes
  140335. */
  140336. export class MeshAssetTask extends AbstractAssetTask {
  140337. /**
  140338. * Defines the name of the task
  140339. */
  140340. name: string;
  140341. /**
  140342. * Defines the list of mesh's names you want to load
  140343. */
  140344. meshesNames: any;
  140345. /**
  140346. * Defines the root url to use as a base to load your meshes and associated resources
  140347. */
  140348. rootUrl: string;
  140349. /**
  140350. * Defines the filename of the scene to load from
  140351. */
  140352. sceneFilename: string;
  140353. /**
  140354. * Gets the list of loaded meshes
  140355. */
  140356. loadedMeshes: Array<AbstractMesh>;
  140357. /**
  140358. * Gets the list of loaded particle systems
  140359. */
  140360. loadedParticleSystems: Array<IParticleSystem>;
  140361. /**
  140362. * Gets the list of loaded skeletons
  140363. */
  140364. loadedSkeletons: Array<Skeleton>;
  140365. /**
  140366. * Gets the list of loaded animation groups
  140367. */
  140368. loadedAnimationGroups: Array<AnimationGroup>;
  140369. /**
  140370. * Callback called when the task is successful
  140371. */
  140372. onSuccess: (task: MeshAssetTask) => void;
  140373. /**
  140374. * Callback called when the task is successful
  140375. */
  140376. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140377. /**
  140378. * Creates a new MeshAssetTask
  140379. * @param name defines the name of the task
  140380. * @param meshesNames defines the list of mesh's names you want to load
  140381. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140382. * @param sceneFilename defines the filename of the scene to load from
  140383. */
  140384. constructor(
  140385. /**
  140386. * Defines the name of the task
  140387. */
  140388. name: string,
  140389. /**
  140390. * Defines the list of mesh's names you want to load
  140391. */
  140392. meshesNames: any,
  140393. /**
  140394. * Defines the root url to use as a base to load your meshes and associated resources
  140395. */
  140396. rootUrl: string,
  140397. /**
  140398. * Defines the filename of the scene to load from
  140399. */
  140400. sceneFilename: string);
  140401. /**
  140402. * Execute the current task
  140403. * @param scene defines the scene where you want your assets to be loaded
  140404. * @param onSuccess is a callback called when the task is successfully executed
  140405. * @param onError is a callback called if an error occurs
  140406. */
  140407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140408. }
  140409. /**
  140410. * Define a task used by AssetsManager to load text content
  140411. */
  140412. export class TextFileAssetTask extends AbstractAssetTask {
  140413. /**
  140414. * Defines the name of the task
  140415. */
  140416. name: string;
  140417. /**
  140418. * Defines the location of the file to load
  140419. */
  140420. url: string;
  140421. /**
  140422. * Gets the loaded text string
  140423. */
  140424. text: string;
  140425. /**
  140426. * Callback called when the task is successful
  140427. */
  140428. onSuccess: (task: TextFileAssetTask) => void;
  140429. /**
  140430. * Callback called when the task is successful
  140431. */
  140432. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140433. /**
  140434. * Creates a new TextFileAssetTask object
  140435. * @param name defines the name of the task
  140436. * @param url defines the location of the file to load
  140437. */
  140438. constructor(
  140439. /**
  140440. * Defines the name of the task
  140441. */
  140442. name: string,
  140443. /**
  140444. * Defines the location of the file to load
  140445. */
  140446. url: string);
  140447. /**
  140448. * Execute the current task
  140449. * @param scene defines the scene where you want your assets to be loaded
  140450. * @param onSuccess is a callback called when the task is successfully executed
  140451. * @param onError is a callback called if an error occurs
  140452. */
  140453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140454. }
  140455. /**
  140456. * Define a task used by AssetsManager to load binary data
  140457. */
  140458. export class BinaryFileAssetTask extends AbstractAssetTask {
  140459. /**
  140460. * Defines the name of the task
  140461. */
  140462. name: string;
  140463. /**
  140464. * Defines the location of the file to load
  140465. */
  140466. url: string;
  140467. /**
  140468. * Gets the lodaded data (as an array buffer)
  140469. */
  140470. data: ArrayBuffer;
  140471. /**
  140472. * Callback called when the task is successful
  140473. */
  140474. onSuccess: (task: BinaryFileAssetTask) => void;
  140475. /**
  140476. * Callback called when the task is successful
  140477. */
  140478. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140479. /**
  140480. * Creates a new BinaryFileAssetTask object
  140481. * @param name defines the name of the new task
  140482. * @param url defines the location of the file to load
  140483. */
  140484. constructor(
  140485. /**
  140486. * Defines the name of the task
  140487. */
  140488. name: string,
  140489. /**
  140490. * Defines the location of the file to load
  140491. */
  140492. url: string);
  140493. /**
  140494. * Execute the current task
  140495. * @param scene defines the scene where you want your assets to be loaded
  140496. * @param onSuccess is a callback called when the task is successfully executed
  140497. * @param onError is a callback called if an error occurs
  140498. */
  140499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140500. }
  140501. /**
  140502. * Define a task used by AssetsManager to load images
  140503. */
  140504. export class ImageAssetTask extends AbstractAssetTask {
  140505. /**
  140506. * Defines the name of the task
  140507. */
  140508. name: string;
  140509. /**
  140510. * Defines the location of the image to load
  140511. */
  140512. url: string;
  140513. /**
  140514. * Gets the loaded images
  140515. */
  140516. image: HTMLImageElement;
  140517. /**
  140518. * Callback called when the task is successful
  140519. */
  140520. onSuccess: (task: ImageAssetTask) => void;
  140521. /**
  140522. * Callback called when the task is successful
  140523. */
  140524. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140525. /**
  140526. * Creates a new ImageAssetTask
  140527. * @param name defines the name of the task
  140528. * @param url defines the location of the image to load
  140529. */
  140530. constructor(
  140531. /**
  140532. * Defines the name of the task
  140533. */
  140534. name: string,
  140535. /**
  140536. * Defines the location of the image to load
  140537. */
  140538. url: string);
  140539. /**
  140540. * Execute the current task
  140541. * @param scene defines the scene where you want your assets to be loaded
  140542. * @param onSuccess is a callback called when the task is successfully executed
  140543. * @param onError is a callback called if an error occurs
  140544. */
  140545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140546. }
  140547. /**
  140548. * Defines the interface used by texture loading tasks
  140549. */
  140550. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140551. /**
  140552. * Gets the loaded texture
  140553. */
  140554. texture: TEX;
  140555. }
  140556. /**
  140557. * Define a task used by AssetsManager to load 2D textures
  140558. */
  140559. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140560. /**
  140561. * Defines the name of the task
  140562. */
  140563. name: string;
  140564. /**
  140565. * Defines the location of the file to load
  140566. */
  140567. url: string;
  140568. /**
  140569. * Defines if mipmap should not be generated (default is false)
  140570. */
  140571. noMipmap?: boolean | undefined;
  140572. /**
  140573. * Defines if texture must be inverted on Y axis (default is false)
  140574. */
  140575. invertY?: boolean | undefined;
  140576. /**
  140577. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140578. */
  140579. samplingMode: number;
  140580. /**
  140581. * Gets the loaded texture
  140582. */
  140583. texture: Texture;
  140584. /**
  140585. * Callback called when the task is successful
  140586. */
  140587. onSuccess: (task: TextureAssetTask) => void;
  140588. /**
  140589. * Callback called when the task is successful
  140590. */
  140591. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140592. /**
  140593. * Creates a new TextureAssetTask object
  140594. * @param name defines the name of the task
  140595. * @param url defines the location of the file to load
  140596. * @param noMipmap defines if mipmap should not be generated (default is false)
  140597. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140598. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140599. */
  140600. constructor(
  140601. /**
  140602. * Defines the name of the task
  140603. */
  140604. name: string,
  140605. /**
  140606. * Defines the location of the file to load
  140607. */
  140608. url: string,
  140609. /**
  140610. * Defines if mipmap should not be generated (default is false)
  140611. */
  140612. noMipmap?: boolean | undefined,
  140613. /**
  140614. * Defines if texture must be inverted on Y axis (default is false)
  140615. */
  140616. invertY?: boolean | undefined,
  140617. /**
  140618. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140619. */
  140620. samplingMode?: number);
  140621. /**
  140622. * Execute the current task
  140623. * @param scene defines the scene where you want your assets to be loaded
  140624. * @param onSuccess is a callback called when the task is successfully executed
  140625. * @param onError is a callback called if an error occurs
  140626. */
  140627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140628. }
  140629. /**
  140630. * Define a task used by AssetsManager to load cube textures
  140631. */
  140632. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140633. /**
  140634. * Defines the name of the task
  140635. */
  140636. name: string;
  140637. /**
  140638. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140639. */
  140640. url: string;
  140641. /**
  140642. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140643. */
  140644. extensions?: string[] | undefined;
  140645. /**
  140646. * Defines if mipmaps should not be generated (default is false)
  140647. */
  140648. noMipmap?: boolean | undefined;
  140649. /**
  140650. * Defines the explicit list of files (undefined by default)
  140651. */
  140652. files?: string[] | undefined;
  140653. /**
  140654. * Gets the loaded texture
  140655. */
  140656. texture: CubeTexture;
  140657. /**
  140658. * Callback called when the task is successful
  140659. */
  140660. onSuccess: (task: CubeTextureAssetTask) => void;
  140661. /**
  140662. * Callback called when the task is successful
  140663. */
  140664. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140665. /**
  140666. * Creates a new CubeTextureAssetTask
  140667. * @param name defines the name of the task
  140668. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140669. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140670. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140671. * @param files defines the explicit list of files (undefined by default)
  140672. */
  140673. constructor(
  140674. /**
  140675. * Defines the name of the task
  140676. */
  140677. name: string,
  140678. /**
  140679. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140680. */
  140681. url: string,
  140682. /**
  140683. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140684. */
  140685. extensions?: string[] | undefined,
  140686. /**
  140687. * Defines if mipmaps should not be generated (default is false)
  140688. */
  140689. noMipmap?: boolean | undefined,
  140690. /**
  140691. * Defines the explicit list of files (undefined by default)
  140692. */
  140693. files?: string[] | undefined);
  140694. /**
  140695. * Execute the current task
  140696. * @param scene defines the scene where you want your assets to be loaded
  140697. * @param onSuccess is a callback called when the task is successfully executed
  140698. * @param onError is a callback called if an error occurs
  140699. */
  140700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140701. }
  140702. /**
  140703. * Define a task used by AssetsManager to load HDR cube textures
  140704. */
  140705. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140706. /**
  140707. * Defines the name of the task
  140708. */
  140709. name: string;
  140710. /**
  140711. * Defines the location of the file to load
  140712. */
  140713. url: string;
  140714. /**
  140715. * Defines the desired size (the more it increases the longer the generation will be)
  140716. */
  140717. size: number;
  140718. /**
  140719. * Defines if mipmaps should not be generated (default is false)
  140720. */
  140721. noMipmap: boolean;
  140722. /**
  140723. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140724. */
  140725. generateHarmonics: boolean;
  140726. /**
  140727. * 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)
  140728. */
  140729. gammaSpace: boolean;
  140730. /**
  140731. * Internal Use Only
  140732. */
  140733. reserved: boolean;
  140734. /**
  140735. * Gets the loaded texture
  140736. */
  140737. texture: HDRCubeTexture;
  140738. /**
  140739. * Callback called when the task is successful
  140740. */
  140741. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140742. /**
  140743. * Callback called when the task is successful
  140744. */
  140745. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140746. /**
  140747. * Creates a new HDRCubeTextureAssetTask object
  140748. * @param name defines the name of the task
  140749. * @param url defines the location of the file to load
  140750. * @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.
  140751. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140752. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140753. * @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)
  140754. * @param reserved Internal use only
  140755. */
  140756. constructor(
  140757. /**
  140758. * Defines the name of the task
  140759. */
  140760. name: string,
  140761. /**
  140762. * Defines the location of the file to load
  140763. */
  140764. url: string,
  140765. /**
  140766. * Defines the desired size (the more it increases the longer the generation will be)
  140767. */
  140768. size: number,
  140769. /**
  140770. * Defines if mipmaps should not be generated (default is false)
  140771. */
  140772. noMipmap?: boolean,
  140773. /**
  140774. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140775. */
  140776. generateHarmonics?: boolean,
  140777. /**
  140778. * 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)
  140779. */
  140780. gammaSpace?: boolean,
  140781. /**
  140782. * Internal Use Only
  140783. */
  140784. reserved?: boolean);
  140785. /**
  140786. * Execute the current task
  140787. * @param scene defines the scene where you want your assets to be loaded
  140788. * @param onSuccess is a callback called when the task is successfully executed
  140789. * @param onError is a callback called if an error occurs
  140790. */
  140791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140792. }
  140793. /**
  140794. * Define a task used by AssetsManager to load Equirectangular cube textures
  140795. */
  140796. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140797. /**
  140798. * Defines the name of the task
  140799. */
  140800. name: string;
  140801. /**
  140802. * Defines the location of the file to load
  140803. */
  140804. url: string;
  140805. /**
  140806. * Defines the desired size (the more it increases the longer the generation will be)
  140807. */
  140808. size: number;
  140809. /**
  140810. * Defines if mipmaps should not be generated (default is false)
  140811. */
  140812. noMipmap: boolean;
  140813. /**
  140814. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140815. * but the standard material would require them in Gamma space) (default is true)
  140816. */
  140817. gammaSpace: boolean;
  140818. /**
  140819. * Gets the loaded texture
  140820. */
  140821. texture: EquiRectangularCubeTexture;
  140822. /**
  140823. * Callback called when the task is successful
  140824. */
  140825. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140826. /**
  140827. * Callback called when the task is successful
  140828. */
  140829. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140830. /**
  140831. * Creates a new EquiRectangularCubeTextureAssetTask object
  140832. * @param name defines the name of the task
  140833. * @param url defines the location of the file to load
  140834. * @param size defines the desired size (the more it increases the longer the generation will be)
  140835. * If the size is omitted this implies you are using a preprocessed cubemap.
  140836. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140837. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140838. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140839. * (default is true)
  140840. */
  140841. constructor(
  140842. /**
  140843. * Defines the name of the task
  140844. */
  140845. name: string,
  140846. /**
  140847. * Defines the location of the file to load
  140848. */
  140849. url: string,
  140850. /**
  140851. * Defines the desired size (the more it increases the longer the generation will be)
  140852. */
  140853. size: number,
  140854. /**
  140855. * Defines if mipmaps should not be generated (default is false)
  140856. */
  140857. noMipmap?: boolean,
  140858. /**
  140859. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140860. * but the standard material would require them in Gamma space) (default is true)
  140861. */
  140862. gammaSpace?: boolean);
  140863. /**
  140864. * Execute the current task
  140865. * @param scene defines the scene where you want your assets to be loaded
  140866. * @param onSuccess is a callback called when the task is successfully executed
  140867. * @param onError is a callback called if an error occurs
  140868. */
  140869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140870. }
  140871. /**
  140872. * This class can be used to easily import assets into a scene
  140873. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140874. */
  140875. export class AssetsManager {
  140876. private _scene;
  140877. private _isLoading;
  140878. protected _tasks: AbstractAssetTask[];
  140879. protected _waitingTasksCount: number;
  140880. protected _totalTasksCount: number;
  140881. /**
  140882. * Callback called when all tasks are processed
  140883. */
  140884. onFinish: (tasks: AbstractAssetTask[]) => void;
  140885. /**
  140886. * Callback called when a task is successful
  140887. */
  140888. onTaskSuccess: (task: AbstractAssetTask) => void;
  140889. /**
  140890. * Callback called when a task had an error
  140891. */
  140892. onTaskError: (task: AbstractAssetTask) => void;
  140893. /**
  140894. * Callback called when a task is done (whatever the result is)
  140895. */
  140896. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140897. /**
  140898. * Observable called when all tasks are processed
  140899. */
  140900. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140901. /**
  140902. * Observable called when a task had an error
  140903. */
  140904. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140905. /**
  140906. * Observable called when all tasks were executed
  140907. */
  140908. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140909. /**
  140910. * Observable called when a task is done (whatever the result is)
  140911. */
  140912. onProgressObservable: Observable<IAssetsProgressEvent>;
  140913. /**
  140914. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140915. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140916. */
  140917. useDefaultLoadingScreen: boolean;
  140918. /**
  140919. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140920. * when all assets have been downloaded.
  140921. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140922. */
  140923. autoHideLoadingUI: boolean;
  140924. /**
  140925. * Creates a new AssetsManager
  140926. * @param scene defines the scene to work on
  140927. */
  140928. constructor(scene: Scene);
  140929. /**
  140930. * Add a MeshAssetTask to the list of active tasks
  140931. * @param taskName defines the name of the new task
  140932. * @param meshesNames defines the name of meshes to load
  140933. * @param rootUrl defines the root url to use to locate files
  140934. * @param sceneFilename defines the filename of the scene file
  140935. * @returns a new MeshAssetTask object
  140936. */
  140937. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140938. /**
  140939. * Add a TextFileAssetTask to the list of active tasks
  140940. * @param taskName defines the name of the new task
  140941. * @param url defines the url of the file to load
  140942. * @returns a new TextFileAssetTask object
  140943. */
  140944. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140945. /**
  140946. * Add a BinaryFileAssetTask to the list of active tasks
  140947. * @param taskName defines the name of the new task
  140948. * @param url defines the url of the file to load
  140949. * @returns a new BinaryFileAssetTask object
  140950. */
  140951. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140952. /**
  140953. * Add a ImageAssetTask to the list of active tasks
  140954. * @param taskName defines the name of the new task
  140955. * @param url defines the url of the file to load
  140956. * @returns a new ImageAssetTask object
  140957. */
  140958. addImageTask(taskName: string, url: string): ImageAssetTask;
  140959. /**
  140960. * Add a TextureAssetTask to the list of active tasks
  140961. * @param taskName defines the name of the new task
  140962. * @param url defines the url of the file to load
  140963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140964. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140965. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140966. * @returns a new TextureAssetTask object
  140967. */
  140968. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140969. /**
  140970. * Add a CubeTextureAssetTask to the list of active tasks
  140971. * @param taskName defines the name of the new task
  140972. * @param url defines the url of the file to load
  140973. * @param extensions defines the extension to use to load the cube map (can be null)
  140974. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140975. * @param files defines the list of files to load (can be null)
  140976. * @returns a new CubeTextureAssetTask object
  140977. */
  140978. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140979. /**
  140980. *
  140981. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140982. * @param taskName defines the name of the new task
  140983. * @param url defines the url of the file to load
  140984. * @param size defines the size you want for the cubemap (can be null)
  140985. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140986. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140987. * @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)
  140988. * @param reserved Internal use only
  140989. * @returns a new HDRCubeTextureAssetTask object
  140990. */
  140991. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140992. /**
  140993. *
  140994. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140995. * @param taskName defines the name of the new task
  140996. * @param url defines the url of the file to load
  140997. * @param size defines the size you want for the cubemap (can be null)
  140998. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140999. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141000. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141001. * @returns a new EquiRectangularCubeTextureAssetTask object
  141002. */
  141003. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141004. /**
  141005. * Remove a task from the assets manager.
  141006. * @param task the task to remove
  141007. */
  141008. removeTask(task: AbstractAssetTask): void;
  141009. private _decreaseWaitingTasksCount;
  141010. private _runTask;
  141011. /**
  141012. * Reset the AssetsManager and remove all tasks
  141013. * @return the current instance of the AssetsManager
  141014. */
  141015. reset(): AssetsManager;
  141016. /**
  141017. * Start the loading process
  141018. * @return the current instance of the AssetsManager
  141019. */
  141020. load(): AssetsManager;
  141021. /**
  141022. * Start the loading process as an async operation
  141023. * @return a promise returning the list of failed tasks
  141024. */
  141025. loadAsync(): Promise<void>;
  141026. }
  141027. }
  141028. declare module BABYLON {
  141029. /**
  141030. * Wrapper class for promise with external resolve and reject.
  141031. */
  141032. export class Deferred<T> {
  141033. /**
  141034. * The promise associated with this deferred object.
  141035. */
  141036. readonly promise: Promise<T>;
  141037. private _resolve;
  141038. private _reject;
  141039. /**
  141040. * The resolve method of the promise associated with this deferred object.
  141041. */
  141042. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141043. /**
  141044. * The reject method of the promise associated with this deferred object.
  141045. */
  141046. get reject(): (reason?: any) => void;
  141047. /**
  141048. * Constructor for this deferred object.
  141049. */
  141050. constructor();
  141051. }
  141052. }
  141053. declare module BABYLON {
  141054. /**
  141055. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141056. */
  141057. export class MeshExploder {
  141058. private _centerMesh;
  141059. private _meshes;
  141060. private _meshesOrigins;
  141061. private _toCenterVectors;
  141062. private _scaledDirection;
  141063. private _newPosition;
  141064. private _centerPosition;
  141065. /**
  141066. * Explodes meshes from a center mesh.
  141067. * @param meshes The meshes to explode.
  141068. * @param centerMesh The mesh to be center of explosion.
  141069. */
  141070. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141071. private _setCenterMesh;
  141072. /**
  141073. * Get class name
  141074. * @returns "MeshExploder"
  141075. */
  141076. getClassName(): string;
  141077. /**
  141078. * "Exploded meshes"
  141079. * @returns Array of meshes with the centerMesh at index 0.
  141080. */
  141081. getMeshes(): Array<Mesh>;
  141082. /**
  141083. * Explodes meshes giving a specific direction
  141084. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141085. */
  141086. explode(direction?: number): void;
  141087. }
  141088. }
  141089. declare module BABYLON {
  141090. /**
  141091. * Class used to help managing file picking and drag'n'drop
  141092. */
  141093. export class FilesInput {
  141094. /**
  141095. * List of files ready to be loaded
  141096. */
  141097. static get FilesToLoad(): {
  141098. [key: string]: File;
  141099. };
  141100. /**
  141101. * Callback called when a file is processed
  141102. */
  141103. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141104. private _engine;
  141105. private _currentScene;
  141106. private _sceneLoadedCallback;
  141107. private _progressCallback;
  141108. private _additionalRenderLoopLogicCallback;
  141109. private _textureLoadingCallback;
  141110. private _startingProcessingFilesCallback;
  141111. private _onReloadCallback;
  141112. private _errorCallback;
  141113. private _elementToMonitor;
  141114. private _sceneFileToLoad;
  141115. private _filesToLoad;
  141116. /**
  141117. * Creates a new FilesInput
  141118. * @param engine defines the rendering engine
  141119. * @param scene defines the hosting scene
  141120. * @param sceneLoadedCallback callback called when scene is loaded
  141121. * @param progressCallback callback called to track progress
  141122. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141123. * @param textureLoadingCallback callback called when a texture is loading
  141124. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141125. * @param onReloadCallback callback called when a reload is requested
  141126. * @param errorCallback callback call if an error occurs
  141127. */
  141128. 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);
  141129. private _dragEnterHandler;
  141130. private _dragOverHandler;
  141131. private _dropHandler;
  141132. /**
  141133. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141134. * @param elementToMonitor defines the DOM element to track
  141135. */
  141136. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141137. /**
  141138. * Release all associated resources
  141139. */
  141140. dispose(): void;
  141141. private renderFunction;
  141142. private drag;
  141143. private drop;
  141144. private _traverseFolder;
  141145. private _processFiles;
  141146. /**
  141147. * Load files from a drop event
  141148. * @param event defines the drop event to use as source
  141149. */
  141150. loadFiles(event: any): void;
  141151. private _processReload;
  141152. /**
  141153. * Reload the current scene from the loaded files
  141154. */
  141155. reload(): void;
  141156. }
  141157. }
  141158. declare module BABYLON {
  141159. /**
  141160. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141162. */
  141163. export class SceneOptimization {
  141164. /**
  141165. * Defines the priority of this optimization (0 by default which means first in the list)
  141166. */
  141167. priority: number;
  141168. /**
  141169. * Gets a string describing the action executed by the current optimization
  141170. * @returns description string
  141171. */
  141172. getDescription(): string;
  141173. /**
  141174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141175. * @param scene defines the current scene where to apply this optimization
  141176. * @param optimizer defines the current optimizer
  141177. * @returns true if everything that can be done was applied
  141178. */
  141179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141180. /**
  141181. * Creates the SceneOptimization object
  141182. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141183. * @param desc defines the description associated with the optimization
  141184. */
  141185. constructor(
  141186. /**
  141187. * Defines the priority of this optimization (0 by default which means first in the list)
  141188. */
  141189. priority?: number);
  141190. }
  141191. /**
  141192. * Defines an optimization used to reduce the size of render target textures
  141193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141194. */
  141195. export class TextureOptimization extends SceneOptimization {
  141196. /**
  141197. * Defines the priority of this optimization (0 by default which means first in the list)
  141198. */
  141199. priority: number;
  141200. /**
  141201. * 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
  141202. */
  141203. maximumSize: number;
  141204. /**
  141205. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141206. */
  141207. step: number;
  141208. /**
  141209. * Gets a string describing the action executed by the current optimization
  141210. * @returns description string
  141211. */
  141212. getDescription(): string;
  141213. /**
  141214. * Creates the TextureOptimization object
  141215. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141216. * @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
  141217. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141218. */
  141219. constructor(
  141220. /**
  141221. * Defines the priority of this optimization (0 by default which means first in the list)
  141222. */
  141223. priority?: number,
  141224. /**
  141225. * 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
  141226. */
  141227. maximumSize?: number,
  141228. /**
  141229. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141230. */
  141231. step?: number);
  141232. /**
  141233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141234. * @param scene defines the current scene where to apply this optimization
  141235. * @param optimizer defines the current optimizer
  141236. * @returns true if everything that can be done was applied
  141237. */
  141238. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141239. }
  141240. /**
  141241. * Defines an optimization used to increase or decrease the rendering resolution
  141242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141243. */
  141244. export class HardwareScalingOptimization extends SceneOptimization {
  141245. /**
  141246. * Defines the priority of this optimization (0 by default which means first in the list)
  141247. */
  141248. priority: number;
  141249. /**
  141250. * Defines the maximum scale to use (2 by default)
  141251. */
  141252. maximumScale: number;
  141253. /**
  141254. * Defines the step to use between two passes (0.5 by default)
  141255. */
  141256. step: number;
  141257. private _currentScale;
  141258. private _directionOffset;
  141259. /**
  141260. * Gets a string describing the action executed by the current optimization
  141261. * @return description string
  141262. */
  141263. getDescription(): string;
  141264. /**
  141265. * Creates the HardwareScalingOptimization object
  141266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141267. * @param maximumScale defines the maximum scale to use (2 by default)
  141268. * @param step defines the step to use between two passes (0.5 by default)
  141269. */
  141270. constructor(
  141271. /**
  141272. * Defines the priority of this optimization (0 by default which means first in the list)
  141273. */
  141274. priority?: number,
  141275. /**
  141276. * Defines the maximum scale to use (2 by default)
  141277. */
  141278. maximumScale?: number,
  141279. /**
  141280. * Defines the step to use between two passes (0.5 by default)
  141281. */
  141282. step?: number);
  141283. /**
  141284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141285. * @param scene defines the current scene where to apply this optimization
  141286. * @param optimizer defines the current optimizer
  141287. * @returns true if everything that can be done was applied
  141288. */
  141289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141290. }
  141291. /**
  141292. * Defines an optimization used to remove shadows
  141293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141294. */
  141295. export class ShadowsOptimization extends SceneOptimization {
  141296. /**
  141297. * Gets a string describing the action executed by the current optimization
  141298. * @return description string
  141299. */
  141300. getDescription(): string;
  141301. /**
  141302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141303. * @param scene defines the current scene where to apply this optimization
  141304. * @param optimizer defines the current optimizer
  141305. * @returns true if everything that can be done was applied
  141306. */
  141307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141308. }
  141309. /**
  141310. * Defines an optimization used to turn post-processes off
  141311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141312. */
  141313. export class PostProcessesOptimization extends SceneOptimization {
  141314. /**
  141315. * Gets a string describing the action executed by the current optimization
  141316. * @return description string
  141317. */
  141318. getDescription(): string;
  141319. /**
  141320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141321. * @param scene defines the current scene where to apply this optimization
  141322. * @param optimizer defines the current optimizer
  141323. * @returns true if everything that can be done was applied
  141324. */
  141325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141326. }
  141327. /**
  141328. * Defines an optimization used to turn lens flares off
  141329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141330. */
  141331. export class LensFlaresOptimization extends SceneOptimization {
  141332. /**
  141333. * Gets a string describing the action executed by the current optimization
  141334. * @return description string
  141335. */
  141336. getDescription(): string;
  141337. /**
  141338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141339. * @param scene defines the current scene where to apply this optimization
  141340. * @param optimizer defines the current optimizer
  141341. * @returns true if everything that can be done was applied
  141342. */
  141343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141344. }
  141345. /**
  141346. * Defines an optimization based on user defined callback.
  141347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141348. */
  141349. export class CustomOptimization extends SceneOptimization {
  141350. /**
  141351. * Callback called to apply the custom optimization.
  141352. */
  141353. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141354. /**
  141355. * Callback called to get custom description
  141356. */
  141357. onGetDescription: () => string;
  141358. /**
  141359. * Gets a string describing the action executed by the current optimization
  141360. * @returns description string
  141361. */
  141362. getDescription(): string;
  141363. /**
  141364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141365. * @param scene defines the current scene where to apply this optimization
  141366. * @param optimizer defines the current optimizer
  141367. * @returns true if everything that can be done was applied
  141368. */
  141369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141370. }
  141371. /**
  141372. * Defines an optimization used to turn particles off
  141373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141374. */
  141375. export class ParticlesOptimization extends SceneOptimization {
  141376. /**
  141377. * Gets a string describing the action executed by the current optimization
  141378. * @return description string
  141379. */
  141380. getDescription(): string;
  141381. /**
  141382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141383. * @param scene defines the current scene where to apply this optimization
  141384. * @param optimizer defines the current optimizer
  141385. * @returns true if everything that can be done was applied
  141386. */
  141387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141388. }
  141389. /**
  141390. * Defines an optimization used to turn render targets off
  141391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141392. */
  141393. export class RenderTargetsOptimization extends SceneOptimization {
  141394. /**
  141395. * Gets a string describing the action executed by the current optimization
  141396. * @return description string
  141397. */
  141398. getDescription(): string;
  141399. /**
  141400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141401. * @param scene defines the current scene where to apply this optimization
  141402. * @param optimizer defines the current optimizer
  141403. * @returns true if everything that can be done was applied
  141404. */
  141405. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141406. }
  141407. /**
  141408. * Defines an optimization used to merge meshes with compatible materials
  141409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141410. */
  141411. export class MergeMeshesOptimization extends SceneOptimization {
  141412. private static _UpdateSelectionTree;
  141413. /**
  141414. * Gets or sets a boolean which defines if optimization octree has to be updated
  141415. */
  141416. static get UpdateSelectionTree(): boolean;
  141417. /**
  141418. * Gets or sets a boolean which defines if optimization octree has to be updated
  141419. */
  141420. static set UpdateSelectionTree(value: boolean);
  141421. /**
  141422. * Gets a string describing the action executed by the current optimization
  141423. * @return description string
  141424. */
  141425. getDescription(): string;
  141426. private _canBeMerged;
  141427. /**
  141428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141429. * @param scene defines the current scene where to apply this optimization
  141430. * @param optimizer defines the current optimizer
  141431. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141432. * @returns true if everything that can be done was applied
  141433. */
  141434. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141435. }
  141436. /**
  141437. * Defines a list of options used by SceneOptimizer
  141438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141439. */
  141440. export class SceneOptimizerOptions {
  141441. /**
  141442. * Defines the target frame rate to reach (60 by default)
  141443. */
  141444. targetFrameRate: number;
  141445. /**
  141446. * Defines the interval between two checkes (2000ms by default)
  141447. */
  141448. trackerDuration: number;
  141449. /**
  141450. * Gets the list of optimizations to apply
  141451. */
  141452. optimizations: SceneOptimization[];
  141453. /**
  141454. * Creates a new list of options used by SceneOptimizer
  141455. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141456. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141457. */
  141458. constructor(
  141459. /**
  141460. * Defines the target frame rate to reach (60 by default)
  141461. */
  141462. targetFrameRate?: number,
  141463. /**
  141464. * Defines the interval between two checkes (2000ms by default)
  141465. */
  141466. trackerDuration?: number);
  141467. /**
  141468. * Add a new optimization
  141469. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141470. * @returns the current SceneOptimizerOptions
  141471. */
  141472. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141473. /**
  141474. * Add a new custom optimization
  141475. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141476. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141477. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141478. * @returns the current SceneOptimizerOptions
  141479. */
  141480. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141481. /**
  141482. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141483. * @param targetFrameRate defines the target frame rate (60 by default)
  141484. * @returns a SceneOptimizerOptions object
  141485. */
  141486. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141487. /**
  141488. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141489. * @param targetFrameRate defines the target frame rate (60 by default)
  141490. * @returns a SceneOptimizerOptions object
  141491. */
  141492. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141493. /**
  141494. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141495. * @param targetFrameRate defines the target frame rate (60 by default)
  141496. * @returns a SceneOptimizerOptions object
  141497. */
  141498. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141499. }
  141500. /**
  141501. * Class used to run optimizations in order to reach a target frame rate
  141502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141503. */
  141504. export class SceneOptimizer implements IDisposable {
  141505. private _isRunning;
  141506. private _options;
  141507. private _scene;
  141508. private _currentPriorityLevel;
  141509. private _targetFrameRate;
  141510. private _trackerDuration;
  141511. private _currentFrameRate;
  141512. private _sceneDisposeObserver;
  141513. private _improvementMode;
  141514. /**
  141515. * Defines an observable called when the optimizer reaches the target frame rate
  141516. */
  141517. onSuccessObservable: Observable<SceneOptimizer>;
  141518. /**
  141519. * Defines an observable called when the optimizer enables an optimization
  141520. */
  141521. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141522. /**
  141523. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141524. */
  141525. onFailureObservable: Observable<SceneOptimizer>;
  141526. /**
  141527. * Gets a boolean indicating if the optimizer is in improvement mode
  141528. */
  141529. get isInImprovementMode(): boolean;
  141530. /**
  141531. * Gets the current priority level (0 at start)
  141532. */
  141533. get currentPriorityLevel(): number;
  141534. /**
  141535. * Gets the current frame rate checked by the SceneOptimizer
  141536. */
  141537. get currentFrameRate(): number;
  141538. /**
  141539. * Gets or sets the current target frame rate (60 by default)
  141540. */
  141541. get targetFrameRate(): number;
  141542. /**
  141543. * Gets or sets the current target frame rate (60 by default)
  141544. */
  141545. set targetFrameRate(value: number);
  141546. /**
  141547. * Gets or sets the current interval between two checks (every 2000ms by default)
  141548. */
  141549. get trackerDuration(): number;
  141550. /**
  141551. * Gets or sets the current interval between two checks (every 2000ms by default)
  141552. */
  141553. set trackerDuration(value: number);
  141554. /**
  141555. * Gets the list of active optimizations
  141556. */
  141557. get optimizations(): SceneOptimization[];
  141558. /**
  141559. * Creates a new SceneOptimizer
  141560. * @param scene defines the scene to work on
  141561. * @param options defines the options to use with the SceneOptimizer
  141562. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141563. * @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)
  141564. */
  141565. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141566. /**
  141567. * Stops the current optimizer
  141568. */
  141569. stop(): void;
  141570. /**
  141571. * Reset the optimizer to initial step (current priority level = 0)
  141572. */
  141573. reset(): void;
  141574. /**
  141575. * Start the optimizer. By default it will try to reach a specific framerate
  141576. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141577. */
  141578. start(): void;
  141579. private _checkCurrentState;
  141580. /**
  141581. * Release all resources
  141582. */
  141583. dispose(): void;
  141584. /**
  141585. * Helper function to create a SceneOptimizer with one single line of code
  141586. * @param scene defines the scene to work on
  141587. * @param options defines the options to use with the SceneOptimizer
  141588. * @param onSuccess defines a callback to call on success
  141589. * @param onFailure defines a callback to call on failure
  141590. * @returns the new SceneOptimizer object
  141591. */
  141592. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141593. }
  141594. }
  141595. declare module BABYLON {
  141596. /**
  141597. * Class used to serialize a scene into a string
  141598. */
  141599. export class SceneSerializer {
  141600. /**
  141601. * Clear cache used by a previous serialization
  141602. */
  141603. static ClearCache(): void;
  141604. /**
  141605. * Serialize a scene into a JSON compatible object
  141606. * @param scene defines the scene to serialize
  141607. * @returns a JSON compatible object
  141608. */
  141609. static Serialize(scene: Scene): any;
  141610. /**
  141611. * Serialize a mesh into a JSON compatible object
  141612. * @param toSerialize defines the mesh to serialize
  141613. * @param withParents defines if parents must be serialized as well
  141614. * @param withChildren defines if children must be serialized as well
  141615. * @returns a JSON compatible object
  141616. */
  141617. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141618. }
  141619. }
  141620. declare module BABYLON {
  141621. /**
  141622. * Class used to host texture specific utilities
  141623. */
  141624. export class TextureTools {
  141625. /**
  141626. * Uses the GPU to create a copy texture rescaled at a given size
  141627. * @param texture Texture to copy from
  141628. * @param width defines the desired width
  141629. * @param height defines the desired height
  141630. * @param useBilinearMode defines if bilinear mode has to be used
  141631. * @return the generated texture
  141632. */
  141633. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141634. }
  141635. }
  141636. declare module BABYLON {
  141637. /**
  141638. * This represents the different options available for the video capture.
  141639. */
  141640. export interface VideoRecorderOptions {
  141641. /** Defines the mime type of the video. */
  141642. mimeType: string;
  141643. /** Defines the FPS the video should be recorded at. */
  141644. fps: number;
  141645. /** Defines the chunk size for the recording data. */
  141646. recordChunckSize: number;
  141647. /** The audio tracks to attach to the recording. */
  141648. audioTracks?: MediaStreamTrack[];
  141649. }
  141650. /**
  141651. * This can help with recording videos from BabylonJS.
  141652. * This is based on the available WebRTC functionalities of the browser.
  141653. *
  141654. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141655. */
  141656. export class VideoRecorder {
  141657. private static readonly _defaultOptions;
  141658. /**
  141659. * Returns whether or not the VideoRecorder is available in your browser.
  141660. * @param engine Defines the Babylon Engine.
  141661. * @returns true if supported otherwise false.
  141662. */
  141663. static IsSupported(engine: Engine): boolean;
  141664. private readonly _options;
  141665. private _canvas;
  141666. private _mediaRecorder;
  141667. private _recordedChunks;
  141668. private _fileName;
  141669. private _resolve;
  141670. private _reject;
  141671. /**
  141672. * True when a recording is already in progress.
  141673. */
  141674. get isRecording(): boolean;
  141675. /**
  141676. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141677. * @param engine Defines the BabylonJS Engine you wish to record.
  141678. * @param options Defines options that can be used to customize the capture.
  141679. */
  141680. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141681. /**
  141682. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141683. */
  141684. stopRecording(): void;
  141685. /**
  141686. * Starts recording the canvas for a max duration specified in parameters.
  141687. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141688. * If null no automatic download will start and you can rely on the promise to get the data back.
  141689. * @param maxDuration Defines the maximum recording time in seconds.
  141690. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141691. * @return A promise callback at the end of the recording with the video data in Blob.
  141692. */
  141693. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141694. /**
  141695. * Releases internal resources used during the recording.
  141696. */
  141697. dispose(): void;
  141698. private _handleDataAvailable;
  141699. private _handleError;
  141700. private _handleStop;
  141701. }
  141702. }
  141703. declare module BABYLON {
  141704. /**
  141705. * Class containing a set of static utilities functions for screenshots
  141706. */
  141707. export class ScreenshotTools {
  141708. /**
  141709. * Captures a screenshot of the current rendering
  141710. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141711. * @param engine defines the rendering engine
  141712. * @param camera defines the source camera
  141713. * @param size This parameter can be set to a single number or to an object with the
  141714. * following (optional) properties: precision, width, height. If a single number is passed,
  141715. * it will be used for both width and height. If an object is passed, the screenshot size
  141716. * will be derived from the parameters. The precision property is a multiplier allowing
  141717. * rendering at a higher or lower resolution
  141718. * @param successCallback defines the callback receives a single parameter which contains the
  141719. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141720. * src parameter of an <img> to display it
  141721. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141722. * Check your browser for supported MIME types
  141723. */
  141724. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141725. /**
  141726. * Captures a screenshot of the current rendering
  141727. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141728. * @param engine defines the rendering engine
  141729. * @param camera defines the source camera
  141730. * @param size This parameter can be set to a single number or to an object with the
  141731. * following (optional) properties: precision, width, height. If a single number is passed,
  141732. * it will be used for both width and height. If an object is passed, the screenshot size
  141733. * will be derived from the parameters. The precision property is a multiplier allowing
  141734. * rendering at a higher or lower resolution
  141735. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141736. * Check your browser for supported MIME types
  141737. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141738. * to the src parameter of an <img> to display it
  141739. */
  141740. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141741. /**
  141742. * Generates an image screenshot from the specified camera.
  141743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141744. * @param engine The engine to use for rendering
  141745. * @param camera The camera to use for rendering
  141746. * @param size This parameter can be set to a single number or to an object with the
  141747. * following (optional) properties: precision, width, height. If a single number is passed,
  141748. * it will be used for both width and height. If an object is passed, the screenshot size
  141749. * will be derived from the parameters. The precision property is a multiplier allowing
  141750. * rendering at a higher or lower resolution
  141751. * @param successCallback The callback receives a single parameter which contains the
  141752. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141753. * src parameter of an <img> to display it
  141754. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141755. * Check your browser for supported MIME types
  141756. * @param samples Texture samples (default: 1)
  141757. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141758. * @param fileName A name for for the downloaded file.
  141759. */
  141760. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141761. /**
  141762. * Generates an image screenshot from the specified camera.
  141763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141764. * @param engine The engine to use for rendering
  141765. * @param camera The camera to use for rendering
  141766. * @param size This parameter can be set to a single number or to an object with the
  141767. * following (optional) properties: precision, width, height. If a single number is passed,
  141768. * it will be used for both width and height. If an object is passed, the screenshot size
  141769. * will be derived from the parameters. The precision property is a multiplier allowing
  141770. * rendering at a higher or lower resolution
  141771. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141772. * Check your browser for supported MIME types
  141773. * @param samples Texture samples (default: 1)
  141774. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141775. * @param fileName A name for for the downloaded file.
  141776. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141777. * to the src parameter of an <img> to display it
  141778. */
  141779. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141780. /**
  141781. * Gets height and width for screenshot size
  141782. * @private
  141783. */
  141784. private static _getScreenshotSize;
  141785. }
  141786. }
  141787. declare module BABYLON {
  141788. /**
  141789. * Interface for a data buffer
  141790. */
  141791. export interface IDataBuffer {
  141792. /**
  141793. * Reads bytes from the data buffer.
  141794. * @param byteOffset The byte offset to read
  141795. * @param byteLength The byte length to read
  141796. * @returns A promise that resolves when the bytes are read
  141797. */
  141798. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141799. /**
  141800. * The byte length of the buffer.
  141801. */
  141802. readonly byteLength: number;
  141803. }
  141804. /**
  141805. * Utility class for reading from a data buffer
  141806. */
  141807. export class DataReader {
  141808. /**
  141809. * The data buffer associated with this data reader.
  141810. */
  141811. readonly buffer: IDataBuffer;
  141812. /**
  141813. * The current byte offset from the beginning of the data buffer.
  141814. */
  141815. byteOffset: number;
  141816. private _dataView;
  141817. private _dataByteOffset;
  141818. /**
  141819. * Constructor
  141820. * @param buffer The buffer to read
  141821. */
  141822. constructor(buffer: IDataBuffer);
  141823. /**
  141824. * Loads the given byte length.
  141825. * @param byteLength The byte length to load
  141826. * @returns A promise that resolves when the load is complete
  141827. */
  141828. loadAsync(byteLength: number): Promise<void>;
  141829. /**
  141830. * Read a unsigned 32-bit integer from the currently loaded data range.
  141831. * @returns The 32-bit integer read
  141832. */
  141833. readUint32(): number;
  141834. /**
  141835. * Read a byte array from the currently loaded data range.
  141836. * @param byteLength The byte length to read
  141837. * @returns The byte array read
  141838. */
  141839. readUint8Array(byteLength: number): Uint8Array;
  141840. /**
  141841. * Read a string from the currently loaded data range.
  141842. * @param byteLength The byte length to read
  141843. * @returns The string read
  141844. */
  141845. readString(byteLength: number): string;
  141846. /**
  141847. * Skips the given byte length the currently loaded data range.
  141848. * @param byteLength The byte length to skip
  141849. */
  141850. skipBytes(byteLength: number): void;
  141851. }
  141852. }
  141853. declare module BABYLON {
  141854. /**
  141855. * Options used for hit testing
  141856. */
  141857. export interface IWebXRHitTestOptions {
  141858. /**
  141859. * Only test when user interacted with the scene. Default - hit test every frame
  141860. */
  141861. testOnPointerDownOnly?: boolean;
  141862. /**
  141863. * The node to use to transform the local results to world coordinates
  141864. */
  141865. worldParentNode?: TransformNode;
  141866. }
  141867. /**
  141868. * Interface defining the babylon result of raycasting/hit-test
  141869. */
  141870. export interface IWebXRHitResult {
  141871. /**
  141872. * The native hit test result
  141873. */
  141874. xrHitResult: XRHitResult;
  141875. /**
  141876. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141877. */
  141878. transformationMatrix: Matrix;
  141879. }
  141880. /**
  141881. * The currently-working hit-test module.
  141882. * Hit test (or raycasting) is used to interact with the real world.
  141883. * For further information read here - https://github.com/immersive-web/hit-test
  141884. */
  141885. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141886. /**
  141887. * options to use when constructing this feature
  141888. */
  141889. readonly options: IWebXRHitTestOptions;
  141890. /**
  141891. * The module's name
  141892. */
  141893. static readonly Name: string;
  141894. /**
  141895. * The (Babylon) version of this module.
  141896. * This is an integer representing the implementation version.
  141897. * This number does not correspond to the webxr specs version
  141898. */
  141899. static readonly Version: number;
  141900. /**
  141901. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141902. * @param event the (select) event to use to select with
  141903. * @param referenceSpace the reference space to use for this hit test
  141904. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141905. */
  141906. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141907. /**
  141908. * execute a hit test with an XR Ray
  141909. *
  141910. * @param xrSession a native xrSession that will execute this hit test
  141911. * @param xrRay the ray (position and direction) to use for raycasting
  141912. * @param referenceSpace native XR reference space to use for the hit-test
  141913. * @param filter filter function that will filter the results
  141914. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141915. */
  141916. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141917. /**
  141918. * Triggered when new babylon (transformed) hit test results are available
  141919. */
  141920. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141921. private _onSelectEnabled;
  141922. /**
  141923. * Creates a new instance of the (legacy version) hit test feature
  141924. * @param _xrSessionManager an instance of WebXRSessionManager
  141925. * @param options options to use when constructing this feature
  141926. */
  141927. constructor(_xrSessionManager: WebXRSessionManager,
  141928. /**
  141929. * options to use when constructing this feature
  141930. */
  141931. options?: IWebXRHitTestOptions);
  141932. /**
  141933. * Populated with the last native XR Hit Results
  141934. */
  141935. lastNativeXRHitResults: XRHitResult[];
  141936. /**
  141937. * attach this feature
  141938. * Will usually be called by the features manager
  141939. *
  141940. * @returns true if successful.
  141941. */
  141942. attach(): boolean;
  141943. /**
  141944. * detach this feature.
  141945. * Will usually be called by the features manager
  141946. *
  141947. * @returns true if successful.
  141948. */
  141949. detach(): boolean;
  141950. private _onHitTestResults;
  141951. private _origin;
  141952. private _direction;
  141953. private _mat;
  141954. protected _onXRFrame(frame: XRFrame): void;
  141955. private _onSelect;
  141956. /**
  141957. * Dispose this feature and all of the resources attached
  141958. */
  141959. dispose(): void;
  141960. }
  141961. }
  141962. declare module BABYLON {
  141963. /**
  141964. * Options used in the plane detector module
  141965. */
  141966. export interface IWebXRPlaneDetectorOptions {
  141967. /**
  141968. * The node to use to transform the local results to world coordinates
  141969. */
  141970. worldParentNode?: TransformNode;
  141971. }
  141972. /**
  141973. * A babylon interface for a webxr plane.
  141974. * A Plane is actually a polygon, built from N points in space
  141975. *
  141976. * Supported in chrome 79, not supported in canary 81 ATM
  141977. */
  141978. export interface IWebXRPlane {
  141979. /**
  141980. * a babylon-assigned ID for this polygon
  141981. */
  141982. id: number;
  141983. /**
  141984. * the native xr-plane object
  141985. */
  141986. xrPlane: XRPlane;
  141987. /**
  141988. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141989. */
  141990. polygonDefinition: Array<Vector3>;
  141991. /**
  141992. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141993. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141994. */
  141995. transformationMatrix: Matrix;
  141996. }
  141997. /**
  141998. * The plane detector is used to detect planes in the real world when in AR
  141999. * For more information see https://github.com/immersive-web/real-world-geometry/
  142000. */
  142001. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142002. private _options;
  142003. /**
  142004. * The module's name
  142005. */
  142006. static readonly Name: string;
  142007. /**
  142008. * The (Babylon) version of this module.
  142009. * This is an integer representing the implementation version.
  142010. * This number does not correspond to the webxr specs version
  142011. */
  142012. static readonly Version: number;
  142013. /**
  142014. * Observers registered here will be executed when a new plane was added to the session
  142015. */
  142016. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142017. /**
  142018. * Observers registered here will be executed when a plane is no longer detected in the session
  142019. */
  142020. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142021. /**
  142022. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142023. * This can execute N times every frame
  142024. */
  142025. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142026. private _enabled;
  142027. private _detectedPlanes;
  142028. private _lastFrameDetected;
  142029. /**
  142030. * construct a new Plane Detector
  142031. * @param _xrSessionManager an instance of xr Session manager
  142032. * @param _options configuration to use when constructing this feature
  142033. */
  142034. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142035. private _init;
  142036. protected _onXRFrame(frame: XRFrame): void;
  142037. /**
  142038. * Dispose this feature and all of the resources attached
  142039. */
  142040. dispose(): void;
  142041. private _updatePlaneWithXRPlane;
  142042. /**
  142043. * avoiding using Array.find for global support.
  142044. * @param xrPlane the plane to find in the array
  142045. */
  142046. private findIndexInPlaneArray;
  142047. }
  142048. }
  142049. declare module BABYLON {
  142050. /**
  142051. * Configuration options of the anchor system
  142052. */
  142053. export interface IWebXRAnchorSystemOptions {
  142054. /**
  142055. * a node that will be used to convert local to world coordinates
  142056. */
  142057. worldParentNode?: TransformNode;
  142058. /**
  142059. * should the anchor system use plane detection.
  142060. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142061. */
  142062. usePlaneDetection?: boolean;
  142063. /**
  142064. * Should a new anchor be added every time a select event is triggered
  142065. */
  142066. addAnchorOnSelect?: boolean;
  142067. }
  142068. /**
  142069. * A babylon container for an XR Anchor
  142070. */
  142071. export interface IWebXRAnchor {
  142072. /**
  142073. * A babylon-assigned ID for this anchor
  142074. */
  142075. id: number;
  142076. /**
  142077. * The native anchor object
  142078. */
  142079. xrAnchor: XRAnchor;
  142080. /**
  142081. * Transformation matrix to apply to an object attached to this anchor
  142082. */
  142083. transformationMatrix: Matrix;
  142084. }
  142085. /**
  142086. * An implementation of the anchor system of WebXR.
  142087. * Note that the current documented implementation is not available in any browser. Future implementations
  142088. * will use the frame to create an anchor and not the session or a detected plane
  142089. * For further information see https://github.com/immersive-web/anchors/
  142090. */
  142091. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142092. private _options;
  142093. /**
  142094. * The module's name
  142095. */
  142096. static readonly Name: string;
  142097. /**
  142098. * The (Babylon) version of this module.
  142099. * This is an integer representing the implementation version.
  142100. * This number does not correspond to the webxr specs version
  142101. */
  142102. static readonly Version: number;
  142103. /**
  142104. * Observers registered here will be executed when a new anchor was added to the session
  142105. */
  142106. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142107. /**
  142108. * Observers registered here will be executed when an existing anchor updates
  142109. * This can execute N times every frame
  142110. */
  142111. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142112. /**
  142113. * Observers registered here will be executed when an anchor was removed from the session
  142114. */
  142115. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142116. private _planeDetector;
  142117. private _hitTestModule;
  142118. private _enabled;
  142119. private _trackedAnchors;
  142120. private _lastFrameDetected;
  142121. /**
  142122. * constructs a new anchor system
  142123. * @param _xrSessionManager an instance of WebXRSessionManager
  142124. * @param _options configuration object for this feature
  142125. */
  142126. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142127. /**
  142128. * set the plane detector to use in order to create anchors from frames
  142129. * @param planeDetector the plane-detector module to use
  142130. * @param enable enable plane-anchors. default is true
  142131. */
  142132. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142133. /**
  142134. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142135. * @param hitTestModule the hit-test module to use.
  142136. */
  142137. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142138. /**
  142139. * attach this feature
  142140. * Will usually be called by the features manager
  142141. *
  142142. * @returns true if successful.
  142143. */
  142144. attach(): boolean;
  142145. /**
  142146. * detach this feature.
  142147. * Will usually be called by the features manager
  142148. *
  142149. * @returns true if successful.
  142150. */
  142151. detach(): boolean;
  142152. /**
  142153. * Dispose this feature and all of the resources attached
  142154. */
  142155. dispose(): void;
  142156. protected _onXRFrame(frame: XRFrame): void;
  142157. private _onSelect;
  142158. /**
  142159. * Add anchor at a specific XR point.
  142160. *
  142161. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142162. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142163. * @returns a promise the fulfills when the anchor was created
  142164. */
  142165. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142166. private _updateAnchorWithXRFrame;
  142167. /**
  142168. * avoiding using Array.find for global support.
  142169. * @param xrAnchor the plane to find in the array
  142170. */
  142171. private _findIndexInAnchorArray;
  142172. }
  142173. }
  142174. declare module BABYLON {
  142175. /**
  142176. * Options interface for the background remover plugin
  142177. */
  142178. export interface IWebXRBackgroundRemoverOptions {
  142179. /**
  142180. * don't disable the environment helper
  142181. */
  142182. ignoreEnvironmentHelper?: boolean;
  142183. /**
  142184. * flags to configure the removal of the environment helper.
  142185. * If not set, the entire background will be removed. If set, flags should be set as well.
  142186. */
  142187. environmentHelperRemovalFlags?: {
  142188. /**
  142189. * Should the skybox be removed (default false)
  142190. */
  142191. skyBox?: boolean;
  142192. /**
  142193. * Should the ground be removed (default false)
  142194. */
  142195. ground?: boolean;
  142196. };
  142197. /**
  142198. * Further background meshes to disable when entering AR
  142199. */
  142200. backgroundMeshes?: AbstractMesh[];
  142201. }
  142202. /**
  142203. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142204. */
  142205. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142206. /**
  142207. * read-only options to be used in this module
  142208. */
  142209. readonly options: IWebXRBackgroundRemoverOptions;
  142210. /**
  142211. * The module's name
  142212. */
  142213. static readonly Name: string;
  142214. /**
  142215. * The (Babylon) version of this module.
  142216. * This is an integer representing the implementation version.
  142217. * This number does not correspond to the webxr specs version
  142218. */
  142219. static readonly Version: number;
  142220. /**
  142221. * registered observers will be triggered when the background state changes
  142222. */
  142223. onBackgroundStateChangedObservable: Observable<boolean>;
  142224. /**
  142225. * constructs a new background remover module
  142226. * @param _xrSessionManager the session manager for this module
  142227. * @param options read-only options to be used in this module
  142228. */
  142229. constructor(_xrSessionManager: WebXRSessionManager,
  142230. /**
  142231. * read-only options to be used in this module
  142232. */
  142233. options?: IWebXRBackgroundRemoverOptions);
  142234. /**
  142235. * attach this feature
  142236. * Will usually be called by the features manager
  142237. *
  142238. * @returns true if successful.
  142239. */
  142240. attach(): boolean;
  142241. /**
  142242. * detach this feature.
  142243. * Will usually be called by the features manager
  142244. *
  142245. * @returns true if successful.
  142246. */
  142247. detach(): boolean;
  142248. private _setBackgroundState;
  142249. /**
  142250. * Dispose this feature and all of the resources attached
  142251. */
  142252. dispose(): void;
  142253. protected _onXRFrame(_xrFrame: XRFrame): void;
  142254. }
  142255. }
  142256. declare module BABYLON {
  142257. /**
  142258. * Options for the controller physics feature
  142259. */
  142260. export class IWebXRControllerPhysicsOptions {
  142261. /**
  142262. * the xr input to use with this pointer selection
  142263. */
  142264. xrInput: WebXRInput;
  142265. /**
  142266. * The physics properties of the future impostors
  142267. */
  142268. physicsProperties?: {
  142269. /**
  142270. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142271. * Note that this requires a physics engine that supports mesh impostors!
  142272. */
  142273. useControllerMesh?: boolean;
  142274. /**
  142275. * The type of impostor to create. Default is sphere
  142276. */
  142277. impostorType?: number;
  142278. /**
  142279. * the size of the impostor. Defaults to 10cm
  142280. */
  142281. impostorSize?: number | {
  142282. width: number;
  142283. height: number;
  142284. depth: number;
  142285. };
  142286. /**
  142287. * Friction definitions
  142288. */
  142289. friction?: number;
  142290. /**
  142291. * Restitution
  142292. */
  142293. restitution?: number;
  142294. };
  142295. }
  142296. /**
  142297. * Add physics impostor to your webxr controllers,
  142298. * including naive calculation of their linear and angular velocity
  142299. */
  142300. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142301. private readonly _options;
  142302. /**
  142303. * The module's name
  142304. */
  142305. static readonly Name: string;
  142306. /**
  142307. * The (Babylon) version of this module.
  142308. * This is an integer representing the implementation version.
  142309. * This number does not correspond to the webxr specs version
  142310. */
  142311. static readonly Version: number;
  142312. private _lastTimestamp;
  142313. private _delta;
  142314. private _controllers;
  142315. private _tmpVector;
  142316. private _tmpQuaternion;
  142317. /**
  142318. * Construct a new Controller Physics Feature
  142319. * @param _xrSessionManager the corresponding xr session manager
  142320. * @param _options options to create this feature with
  142321. */
  142322. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142323. /**
  142324. * Update the physics properties provided in the constructor
  142325. * @param newProperties the new properties object
  142326. */
  142327. setPhysicsProperties(newProperties: {
  142328. impostorType?: number;
  142329. impostorSize?: number | {
  142330. width: number;
  142331. height: number;
  142332. depth: number;
  142333. };
  142334. friction?: number;
  142335. restitution?: number;
  142336. }): void;
  142337. /**
  142338. * attach this feature
  142339. * Will usually be called by the features manager
  142340. *
  142341. * @returns true if successful.
  142342. */
  142343. attach(): boolean;
  142344. /**
  142345. * detach this feature.
  142346. * Will usually be called by the features manager
  142347. *
  142348. * @returns true if successful.
  142349. */
  142350. detach(): boolean;
  142351. /**
  142352. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142353. * @param xrController the controller to add
  142354. */
  142355. addController(xrController: WebXRInputSource): void;
  142356. private _debugMode;
  142357. /**
  142358. * @hidden
  142359. * enable debugging - will show console outputs and the impostor mesh
  142360. */
  142361. _enablePhysicsDebug(): void;
  142362. private _attachController;
  142363. private _detachController;
  142364. protected _onXRFrame(_xrFrame: any): void;
  142365. }
  142366. }
  142367. declare module BABYLON {
  142368. /**
  142369. * The motion controller class for all microsoft mixed reality controllers
  142370. */
  142371. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142372. /**
  142373. * The base url used to load the left and right controller models
  142374. */
  142375. static MODEL_BASE_URL: string;
  142376. /**
  142377. * The name of the left controller model file
  142378. */
  142379. static MODEL_LEFT_FILENAME: string;
  142380. /**
  142381. * The name of the right controller model file
  142382. */
  142383. static MODEL_RIGHT_FILENAME: string;
  142384. profileId: string;
  142385. protected readonly _mapping: {
  142386. defaultButton: {
  142387. "valueNodeName": string;
  142388. "unpressedNodeName": string;
  142389. "pressedNodeName": string;
  142390. };
  142391. defaultAxis: {
  142392. "valueNodeName": string;
  142393. "minNodeName": string;
  142394. "maxNodeName": string;
  142395. };
  142396. buttons: {
  142397. "xr-standard-trigger": {
  142398. "rootNodeName": string;
  142399. "componentProperty": string;
  142400. "states": string[];
  142401. };
  142402. "xr-standard-squeeze": {
  142403. "rootNodeName": string;
  142404. "componentProperty": string;
  142405. "states": string[];
  142406. };
  142407. "xr-standard-touchpad": {
  142408. "rootNodeName": string;
  142409. "labelAnchorNodeName": string;
  142410. "touchPointNodeName": string;
  142411. };
  142412. "xr-standard-thumbstick": {
  142413. "rootNodeName": string;
  142414. "componentProperty": string;
  142415. "states": string[];
  142416. };
  142417. };
  142418. axes: {
  142419. "xr-standard-touchpad": {
  142420. "x-axis": {
  142421. "rootNodeName": string;
  142422. };
  142423. "y-axis": {
  142424. "rootNodeName": string;
  142425. };
  142426. };
  142427. "xr-standard-thumbstick": {
  142428. "x-axis": {
  142429. "rootNodeName": string;
  142430. };
  142431. "y-axis": {
  142432. "rootNodeName": string;
  142433. };
  142434. };
  142435. };
  142436. };
  142437. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142439. protected _getFilenameAndPath(): {
  142440. filename: string;
  142441. path: string;
  142442. };
  142443. protected _updateModel(): void;
  142444. protected _getModelLoadingConstraints(): boolean;
  142445. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142446. }
  142447. }
  142448. declare module BABYLON {
  142449. /**
  142450. * The motion controller class for oculus touch (quest, rift).
  142451. * This class supports legacy mapping as well the standard xr mapping
  142452. */
  142453. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142454. private _forceLegacyControllers;
  142455. /**
  142456. * The base url used to load the left and right controller models
  142457. */
  142458. static MODEL_BASE_URL: string;
  142459. /**
  142460. * The name of the left controller model file
  142461. */
  142462. static MODEL_LEFT_FILENAME: string;
  142463. /**
  142464. * The name of the right controller model file
  142465. */
  142466. static MODEL_RIGHT_FILENAME: string;
  142467. /**
  142468. * Base Url for the Quest controller model.
  142469. */
  142470. static QUEST_MODEL_BASE_URL: string;
  142471. profileId: string;
  142472. private _modelRootNode;
  142473. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142474. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142475. protected _getFilenameAndPath(): {
  142476. filename: string;
  142477. path: string;
  142478. };
  142479. /**
  142480. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142481. * between the touch and touch 2.
  142482. */
  142483. private _isQuest;
  142484. protected _updateModel(): void;
  142485. protected _getModelLoadingConstraints(): boolean;
  142486. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142487. }
  142488. }
  142489. declare module BABYLON {
  142490. /**
  142491. * The motion controller class for the standard HTC-Vive controllers
  142492. */
  142493. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142494. /**
  142495. * The base url used to load the left and right controller models
  142496. */
  142497. static MODEL_BASE_URL: string;
  142498. /**
  142499. * File name for the controller model.
  142500. */
  142501. static MODEL_FILENAME: string;
  142502. profileId: string;
  142503. private _modelRootNode;
  142504. /**
  142505. * Create a new Vive motion controller object
  142506. * @param scene the scene to use to create this controller
  142507. * @param gamepadObject the corresponding gamepad object
  142508. * @param handness the handness of the controller
  142509. */
  142510. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142511. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142512. protected _getFilenameAndPath(): {
  142513. filename: string;
  142514. path: string;
  142515. };
  142516. protected _updateModel(): void;
  142517. protected _getModelLoadingConstraints(): boolean;
  142518. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142519. }
  142520. }
  142521. declare module BABYLON {
  142522. /**
  142523. * A cursor which tracks a point on a path
  142524. */
  142525. export class PathCursor {
  142526. private path;
  142527. /**
  142528. * Stores path cursor callbacks for when an onchange event is triggered
  142529. */
  142530. private _onchange;
  142531. /**
  142532. * The value of the path cursor
  142533. */
  142534. value: number;
  142535. /**
  142536. * The animation array of the path cursor
  142537. */
  142538. animations: Animation[];
  142539. /**
  142540. * Initializes the path cursor
  142541. * @param path The path to track
  142542. */
  142543. constructor(path: Path2);
  142544. /**
  142545. * Gets the cursor point on the path
  142546. * @returns A point on the path cursor at the cursor location
  142547. */
  142548. getPoint(): Vector3;
  142549. /**
  142550. * Moves the cursor ahead by the step amount
  142551. * @param step The amount to move the cursor forward
  142552. * @returns This path cursor
  142553. */
  142554. moveAhead(step?: number): PathCursor;
  142555. /**
  142556. * Moves the cursor behind by the step amount
  142557. * @param step The amount to move the cursor back
  142558. * @returns This path cursor
  142559. */
  142560. moveBack(step?: number): PathCursor;
  142561. /**
  142562. * Moves the cursor by the step amount
  142563. * If the step amount is greater than one, an exception is thrown
  142564. * @param step The amount to move the cursor
  142565. * @returns This path cursor
  142566. */
  142567. move(step: number): PathCursor;
  142568. /**
  142569. * Ensures that the value is limited between zero and one
  142570. * @returns This path cursor
  142571. */
  142572. private ensureLimits;
  142573. /**
  142574. * Runs onchange callbacks on change (used by the animation engine)
  142575. * @returns This path cursor
  142576. */
  142577. private raiseOnChange;
  142578. /**
  142579. * Executes a function on change
  142580. * @param f A path cursor onchange callback
  142581. * @returns This path cursor
  142582. */
  142583. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142584. }
  142585. }
  142586. declare module BABYLON {
  142587. /** @hidden */
  142588. export var blurPixelShader: {
  142589. name: string;
  142590. shader: string;
  142591. };
  142592. }
  142593. declare module BABYLON {
  142594. /** @hidden */
  142595. export var pointCloudVertexDeclaration: {
  142596. name: string;
  142597. shader: string;
  142598. };
  142599. }
  142600. // Mixins
  142601. interface Window {
  142602. mozIndexedDB: IDBFactory;
  142603. webkitIndexedDB: IDBFactory;
  142604. msIndexedDB: IDBFactory;
  142605. webkitURL: typeof URL;
  142606. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142607. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142608. WebGLRenderingContext: WebGLRenderingContext;
  142609. MSGesture: MSGesture;
  142610. CANNON: any;
  142611. AudioContext: AudioContext;
  142612. webkitAudioContext: AudioContext;
  142613. PointerEvent: any;
  142614. Math: Math;
  142615. Uint8Array: Uint8ArrayConstructor;
  142616. Float32Array: Float32ArrayConstructor;
  142617. mozURL: typeof URL;
  142618. msURL: typeof URL;
  142619. VRFrameData: any; // WebVR, from specs 1.1
  142620. DracoDecoderModule: any;
  142621. setImmediate(handler: (...args: any[]) => void): number;
  142622. }
  142623. interface HTMLCanvasElement {
  142624. requestPointerLock(): void;
  142625. msRequestPointerLock?(): void;
  142626. mozRequestPointerLock?(): void;
  142627. webkitRequestPointerLock?(): void;
  142628. /** Track wether a record is in progress */
  142629. isRecording: boolean;
  142630. /** Capture Stream method defined by some browsers */
  142631. captureStream(fps?: number): MediaStream;
  142632. }
  142633. interface CanvasRenderingContext2D {
  142634. msImageSmoothingEnabled: boolean;
  142635. }
  142636. interface MouseEvent {
  142637. mozMovementX: number;
  142638. mozMovementY: number;
  142639. webkitMovementX: number;
  142640. webkitMovementY: number;
  142641. msMovementX: number;
  142642. msMovementY: number;
  142643. }
  142644. interface Navigator {
  142645. mozGetVRDevices: (any: any) => any;
  142646. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142647. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142648. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142649. webkitGetGamepads(): Gamepad[];
  142650. msGetGamepads(): Gamepad[];
  142651. webkitGamepads(): Gamepad[];
  142652. }
  142653. interface HTMLVideoElement {
  142654. mozSrcObject: any;
  142655. }
  142656. interface Math {
  142657. fround(x: number): number;
  142658. imul(a: number, b: number): number;
  142659. }
  142660. interface WebGLRenderingContext {
  142661. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142662. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142663. vertexAttribDivisor(index: number, divisor: number): void;
  142664. createVertexArray(): any;
  142665. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142666. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142667. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142668. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142669. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142670. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142671. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142672. // Queries
  142673. createQuery(): WebGLQuery;
  142674. deleteQuery(query: WebGLQuery): void;
  142675. beginQuery(target: number, query: WebGLQuery): void;
  142676. endQuery(target: number): void;
  142677. getQueryParameter(query: WebGLQuery, pname: number): any;
  142678. getQuery(target: number, pname: number): any;
  142679. MAX_SAMPLES: number;
  142680. RGBA8: number;
  142681. READ_FRAMEBUFFER: number;
  142682. DRAW_FRAMEBUFFER: number;
  142683. UNIFORM_BUFFER: number;
  142684. HALF_FLOAT_OES: number;
  142685. RGBA16F: number;
  142686. RGBA32F: number;
  142687. R32F: number;
  142688. RG32F: number;
  142689. RGB32F: number;
  142690. R16F: number;
  142691. RG16F: number;
  142692. RGB16F: number;
  142693. RED: number;
  142694. RG: number;
  142695. R8: number;
  142696. RG8: number;
  142697. UNSIGNED_INT_24_8: number;
  142698. DEPTH24_STENCIL8: number;
  142699. MIN: number;
  142700. MAX: number;
  142701. /* Multiple Render Targets */
  142702. drawBuffers(buffers: number[]): void;
  142703. readBuffer(src: number): void;
  142704. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142705. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142706. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142707. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142708. // Occlusion Query
  142709. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142710. ANY_SAMPLES_PASSED: number;
  142711. QUERY_RESULT_AVAILABLE: number;
  142712. QUERY_RESULT: number;
  142713. }
  142714. interface WebGLProgram {
  142715. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142716. }
  142717. interface EXT_disjoint_timer_query {
  142718. QUERY_COUNTER_BITS_EXT: number;
  142719. TIME_ELAPSED_EXT: number;
  142720. TIMESTAMP_EXT: number;
  142721. GPU_DISJOINT_EXT: number;
  142722. QUERY_RESULT_EXT: number;
  142723. QUERY_RESULT_AVAILABLE_EXT: number;
  142724. queryCounterEXT(query: WebGLQuery, target: number): void;
  142725. createQueryEXT(): WebGLQuery;
  142726. beginQueryEXT(target: number, query: WebGLQuery): void;
  142727. endQueryEXT(target: number): void;
  142728. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142729. deleteQueryEXT(query: WebGLQuery): void;
  142730. }
  142731. interface WebGLUniformLocation {
  142732. _currentState: any;
  142733. }
  142734. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142735. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142736. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142737. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142738. interface WebGLRenderingContext {
  142739. readonly RASTERIZER_DISCARD: number;
  142740. readonly DEPTH_COMPONENT24: number;
  142741. readonly TEXTURE_3D: number;
  142742. readonly TEXTURE_2D_ARRAY: number;
  142743. readonly TEXTURE_COMPARE_FUNC: number;
  142744. readonly TEXTURE_COMPARE_MODE: number;
  142745. readonly COMPARE_REF_TO_TEXTURE: number;
  142746. readonly TEXTURE_WRAP_R: number;
  142747. readonly HALF_FLOAT: number;
  142748. readonly RGB8: number;
  142749. readonly RED_INTEGER: number;
  142750. readonly RG_INTEGER: number;
  142751. readonly RGB_INTEGER: number;
  142752. readonly RGBA_INTEGER: number;
  142753. readonly R8_SNORM: number;
  142754. readonly RG8_SNORM: number;
  142755. readonly RGB8_SNORM: number;
  142756. readonly RGBA8_SNORM: number;
  142757. readonly R8I: number;
  142758. readonly RG8I: number;
  142759. readonly RGB8I: number;
  142760. readonly RGBA8I: number;
  142761. readonly R8UI: number;
  142762. readonly RG8UI: number;
  142763. readonly RGB8UI: number;
  142764. readonly RGBA8UI: number;
  142765. readonly R16I: number;
  142766. readonly RG16I: number;
  142767. readonly RGB16I: number;
  142768. readonly RGBA16I: number;
  142769. readonly R16UI: number;
  142770. readonly RG16UI: number;
  142771. readonly RGB16UI: number;
  142772. readonly RGBA16UI: number;
  142773. readonly R32I: number;
  142774. readonly RG32I: number;
  142775. readonly RGB32I: number;
  142776. readonly RGBA32I: number;
  142777. readonly R32UI: number;
  142778. readonly RG32UI: number;
  142779. readonly RGB32UI: number;
  142780. readonly RGBA32UI: number;
  142781. readonly RGB10_A2UI: number;
  142782. readonly R11F_G11F_B10F: number;
  142783. readonly RGB9_E5: number;
  142784. readonly RGB10_A2: number;
  142785. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142786. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142787. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142788. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142789. readonly DEPTH_COMPONENT32F: number;
  142790. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142791. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142792. 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;
  142793. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142794. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142795. readonly TRANSFORM_FEEDBACK: number;
  142796. readonly INTERLEAVED_ATTRIBS: number;
  142797. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142798. createTransformFeedback(): WebGLTransformFeedback;
  142799. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142800. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142801. beginTransformFeedback(primitiveMode: number): void;
  142802. endTransformFeedback(): void;
  142803. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142804. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142805. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142806. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142807. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142808. }
  142809. interface ImageBitmap {
  142810. readonly width: number;
  142811. readonly height: number;
  142812. close(): void;
  142813. }
  142814. interface WebGLQuery extends WebGLObject {
  142815. }
  142816. declare var WebGLQuery: {
  142817. prototype: WebGLQuery;
  142818. new(): WebGLQuery;
  142819. };
  142820. interface WebGLSampler extends WebGLObject {
  142821. }
  142822. declare var WebGLSampler: {
  142823. prototype: WebGLSampler;
  142824. new(): WebGLSampler;
  142825. };
  142826. interface WebGLSync extends WebGLObject {
  142827. }
  142828. declare var WebGLSync: {
  142829. prototype: WebGLSync;
  142830. new(): WebGLSync;
  142831. };
  142832. interface WebGLTransformFeedback extends WebGLObject {
  142833. }
  142834. declare var WebGLTransformFeedback: {
  142835. prototype: WebGLTransformFeedback;
  142836. new(): WebGLTransformFeedback;
  142837. };
  142838. interface WebGLVertexArrayObject extends WebGLObject {
  142839. }
  142840. declare var WebGLVertexArrayObject: {
  142841. prototype: WebGLVertexArrayObject;
  142842. new(): WebGLVertexArrayObject;
  142843. };
  142844. // Type definitions for WebVR API
  142845. // Project: https://w3c.github.io/webvr/
  142846. // Definitions by: six a <https://github.com/lostfictions>
  142847. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142848. interface VRDisplay extends EventTarget {
  142849. /**
  142850. * Dictionary of capabilities describing the VRDisplay.
  142851. */
  142852. readonly capabilities: VRDisplayCapabilities;
  142853. /**
  142854. * z-depth defining the far plane of the eye view frustum
  142855. * enables mapping of values in the render target depth
  142856. * attachment to scene coordinates. Initially set to 10000.0.
  142857. */
  142858. depthFar: number;
  142859. /**
  142860. * z-depth defining the near plane of the eye view frustum
  142861. * enables mapping of values in the render target depth
  142862. * attachment to scene coordinates. Initially set to 0.01.
  142863. */
  142864. depthNear: number;
  142865. /**
  142866. * An identifier for this distinct VRDisplay. Used as an
  142867. * association point in the Gamepad API.
  142868. */
  142869. readonly displayId: number;
  142870. /**
  142871. * A display name, a user-readable name identifying it.
  142872. */
  142873. readonly displayName: string;
  142874. readonly isConnected: boolean;
  142875. readonly isPresenting: boolean;
  142876. /**
  142877. * If this VRDisplay supports room-scale experiences, the optional
  142878. * stage attribute contains details on the room-scale parameters.
  142879. */
  142880. readonly stageParameters: VRStageParameters | null;
  142881. /**
  142882. * Passing the value returned by `requestAnimationFrame` to
  142883. * `cancelAnimationFrame` will unregister the callback.
  142884. * @param handle Define the hanle of the request to cancel
  142885. */
  142886. cancelAnimationFrame(handle: number): void;
  142887. /**
  142888. * Stops presenting to the VRDisplay.
  142889. * @returns a promise to know when it stopped
  142890. */
  142891. exitPresent(): Promise<void>;
  142892. /**
  142893. * Return the current VREyeParameters for the given eye.
  142894. * @param whichEye Define the eye we want the parameter for
  142895. * @returns the eye parameters
  142896. */
  142897. getEyeParameters(whichEye: string): VREyeParameters;
  142898. /**
  142899. * Populates the passed VRFrameData with the information required to render
  142900. * the current frame.
  142901. * @param frameData Define the data structure to populate
  142902. * @returns true if ok otherwise false
  142903. */
  142904. getFrameData(frameData: VRFrameData): boolean;
  142905. /**
  142906. * Get the layers currently being presented.
  142907. * @returns the list of VR layers
  142908. */
  142909. getLayers(): VRLayer[];
  142910. /**
  142911. * Return a VRPose containing the future predicted pose of the VRDisplay
  142912. * when the current frame will be presented. The value returned will not
  142913. * change until JavaScript has returned control to the browser.
  142914. *
  142915. * The VRPose will contain the position, orientation, velocity,
  142916. * and acceleration of each of these properties.
  142917. * @returns the pose object
  142918. */
  142919. getPose(): VRPose;
  142920. /**
  142921. * Return the current instantaneous pose of the VRDisplay, with no
  142922. * prediction applied.
  142923. * @returns the current instantaneous pose
  142924. */
  142925. getImmediatePose(): VRPose;
  142926. /**
  142927. * The callback passed to `requestAnimationFrame` will be called
  142928. * any time a new frame should be rendered. When the VRDisplay is
  142929. * presenting the callback will be called at the native refresh
  142930. * rate of the HMD. When not presenting this function acts
  142931. * identically to how window.requestAnimationFrame acts. Content should
  142932. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142933. * asynchronously from other displays and at differing refresh rates.
  142934. * @param callback Define the eaction to run next frame
  142935. * @returns the request handle it
  142936. */
  142937. requestAnimationFrame(callback: FrameRequestCallback): number;
  142938. /**
  142939. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142940. * Repeat calls while already presenting will update the VRLayers being displayed.
  142941. * @param layers Define the list of layer to present
  142942. * @returns a promise to know when the request has been fulfilled
  142943. */
  142944. requestPresent(layers: VRLayer[]): Promise<void>;
  142945. /**
  142946. * Reset the pose for this display, treating its current position and
  142947. * orientation as the "origin/zero" values. VRPose.position,
  142948. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142949. * updated when calling resetPose(). This should be called in only
  142950. * sitting-space experiences.
  142951. */
  142952. resetPose(): void;
  142953. /**
  142954. * The VRLayer provided to the VRDisplay will be captured and presented
  142955. * in the HMD. Calling this function has the same effect on the source
  142956. * canvas as any other operation that uses its source image, and canvases
  142957. * created without preserveDrawingBuffer set to true will be cleared.
  142958. * @param pose Define the pose to submit
  142959. */
  142960. submitFrame(pose?: VRPose): void;
  142961. }
  142962. declare var VRDisplay: {
  142963. prototype: VRDisplay;
  142964. new(): VRDisplay;
  142965. };
  142966. interface VRLayer {
  142967. leftBounds?: number[] | Float32Array | null;
  142968. rightBounds?: number[] | Float32Array | null;
  142969. source?: HTMLCanvasElement | null;
  142970. }
  142971. interface VRDisplayCapabilities {
  142972. readonly canPresent: boolean;
  142973. readonly hasExternalDisplay: boolean;
  142974. readonly hasOrientation: boolean;
  142975. readonly hasPosition: boolean;
  142976. readonly maxLayers: number;
  142977. }
  142978. interface VREyeParameters {
  142979. /** @deprecated */
  142980. readonly fieldOfView: VRFieldOfView;
  142981. readonly offset: Float32Array;
  142982. readonly renderHeight: number;
  142983. readonly renderWidth: number;
  142984. }
  142985. interface VRFieldOfView {
  142986. readonly downDegrees: number;
  142987. readonly leftDegrees: number;
  142988. readonly rightDegrees: number;
  142989. readonly upDegrees: number;
  142990. }
  142991. interface VRFrameData {
  142992. readonly leftProjectionMatrix: Float32Array;
  142993. readonly leftViewMatrix: Float32Array;
  142994. readonly pose: VRPose;
  142995. readonly rightProjectionMatrix: Float32Array;
  142996. readonly rightViewMatrix: Float32Array;
  142997. readonly timestamp: number;
  142998. }
  142999. interface VRPose {
  143000. readonly angularAcceleration: Float32Array | null;
  143001. readonly angularVelocity: Float32Array | null;
  143002. readonly linearAcceleration: Float32Array | null;
  143003. readonly linearVelocity: Float32Array | null;
  143004. readonly orientation: Float32Array | null;
  143005. readonly position: Float32Array | null;
  143006. readonly timestamp: number;
  143007. }
  143008. interface VRStageParameters {
  143009. sittingToStandingTransform?: Float32Array;
  143010. sizeX?: number;
  143011. sizeY?: number;
  143012. }
  143013. interface Navigator {
  143014. getVRDisplays(): Promise<VRDisplay[]>;
  143015. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143016. }
  143017. interface Window {
  143018. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143019. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143020. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143021. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143022. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143023. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143024. }
  143025. interface Gamepad {
  143026. readonly displayId: number;
  143027. }
  143028. type XRSessionMode =
  143029. | "inline"
  143030. | "immersive-vr"
  143031. | "immersive-ar";
  143032. type XRReferenceSpaceType =
  143033. | "viewer"
  143034. | "local"
  143035. | "local-floor"
  143036. | "bounded-floor"
  143037. | "unbounded";
  143038. type XREnvironmentBlendMode =
  143039. | "opaque"
  143040. | "additive"
  143041. | "alpha-blend";
  143042. type XRVisibilityState =
  143043. | "visible"
  143044. | "visible-blurred"
  143045. | "hidden";
  143046. type XRHandedness =
  143047. | "none"
  143048. | "left"
  143049. | "right";
  143050. type XRTargetRayMode =
  143051. | "gaze"
  143052. | "tracked-pointer"
  143053. | "screen";
  143054. type XREye =
  143055. | "none"
  143056. | "left"
  143057. | "right";
  143058. interface XRSpace extends EventTarget {
  143059. }
  143060. interface XRRenderState {
  143061. depthNear?: number;
  143062. depthFar?: number;
  143063. inlineVerticalFieldOfView?: number;
  143064. baseLayer?: XRWebGLLayer;
  143065. }
  143066. interface XRInputSource {
  143067. handedness: XRHandedness;
  143068. targetRayMode: XRTargetRayMode;
  143069. targetRaySpace: XRSpace;
  143070. gripSpace: XRSpace | undefined;
  143071. gamepad: Gamepad | undefined;
  143072. profiles: Array<string>;
  143073. }
  143074. interface XRSessionInit {
  143075. optionalFeatures?: XRReferenceSpaceType[];
  143076. requiredFeatures?: XRReferenceSpaceType[];
  143077. }
  143078. interface XRSession extends XRAnchorCreator {
  143079. addEventListener: Function;
  143080. removeEventListener: Function;
  143081. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143082. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143083. requestAnimationFrame: Function;
  143084. end(): Promise<void>;
  143085. renderState: XRRenderState;
  143086. inputSources: Array<XRInputSource>;
  143087. // AR hit test
  143088. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143089. updateWorldTrackingState(options: {
  143090. planeDetectionState?: { enabled: boolean; }
  143091. }): void;
  143092. }
  143093. interface XRReferenceSpace extends XRSpace {
  143094. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143095. onreset: any;
  143096. }
  143097. type XRPlaneSet = Set<XRPlane>;
  143098. type XRAnchorSet = Set<XRAnchor>;
  143099. interface XRFrame {
  143100. session: XRSession;
  143101. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143102. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143103. // Anchors
  143104. trackedAnchors?: XRAnchorSet;
  143105. // Planes
  143106. worldInformation: {
  143107. detectedPlanes?: XRPlaneSet;
  143108. };
  143109. }
  143110. interface XRViewerPose extends XRPose {
  143111. views: Array<XRView>;
  143112. }
  143113. interface XRPose {
  143114. transform: XRRigidTransform;
  143115. emulatedPosition: boolean;
  143116. }
  143117. interface XRWebGLLayerOptions {
  143118. antialias?: boolean;
  143119. depth?: boolean;
  143120. stencil?: boolean;
  143121. alpha?: boolean;
  143122. multiview?: boolean;
  143123. framebufferScaleFactor?: number;
  143124. }
  143125. declare var XRWebGLLayer: {
  143126. prototype: XRWebGLLayer;
  143127. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143128. };
  143129. interface XRWebGLLayer {
  143130. framebuffer: WebGLFramebuffer;
  143131. framebufferWidth: number;
  143132. framebufferHeight: number;
  143133. getViewport: Function;
  143134. }
  143135. declare class XRRigidTransform {
  143136. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143137. position: DOMPointReadOnly;
  143138. orientation: DOMPointReadOnly;
  143139. matrix: Float32Array;
  143140. inverse: XRRigidTransform;
  143141. }
  143142. interface XRView {
  143143. eye: XREye;
  143144. projectionMatrix: Float32Array;
  143145. transform: XRRigidTransform;
  143146. }
  143147. interface XRInputSourceChangeEvent {
  143148. session: XRSession;
  143149. removed: Array<XRInputSource>;
  143150. added: Array<XRInputSource>;
  143151. }
  143152. interface XRInputSourceEvent extends Event {
  143153. readonly frame: XRFrame;
  143154. readonly inputSource: XRInputSource;
  143155. }
  143156. // Experimental(er) features
  143157. declare class XRRay {
  143158. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143159. origin: DOMPointReadOnly;
  143160. direction: DOMPointReadOnly;
  143161. matrix: Float32Array;
  143162. }
  143163. interface XRHitResult {
  143164. hitMatrix: Float32Array;
  143165. }
  143166. interface XRAnchor {
  143167. // remove?
  143168. id?: string;
  143169. anchorSpace: XRSpace;
  143170. lastChangedTime: number;
  143171. detach(): void;
  143172. }
  143173. interface XRPlane extends XRAnchorCreator {
  143174. orientation: "Horizontal" | "Vertical";
  143175. planeSpace: XRSpace;
  143176. polygon: Array<DOMPointReadOnly>;
  143177. lastChangedTime: number;
  143178. }
  143179. interface XRAnchorCreator {
  143180. // AR Anchors
  143181. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143182. }